]>
Commit | Line | Data |
---|---|---|
1ef5468a | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | ||
49e110ec | 18 | #include "AliMpDCSNamer.h" |
1ef5468a | 19 | |
20 | #include "AliCodeTimer.h" | |
21 | #include "AliLog.h" | |
22 | #include "AliMpArea.h" | |
23 | #include "AliMpDEIterator.h" | |
24 | #include "AliMpDEManager.h" | |
25 | #include "AliMpHelper.h" | |
26 | #include "AliMpMotifMap.h" | |
27 | #include "AliMpMotifPosition.h" | |
28 | #include "AliMpSector.h" | |
1ef5468a | 29 | #include "AliMpSegmentation.h" |
30 | #include "AliMpSlat.h" | |
49e110ec | 31 | #include "AliMpConstants.h" |
1ef5468a | 32 | #include <Riostream.h> |
33 | #include <TMap.h> | |
34 | #include <TObjArray.h> | |
35 | #include <TObjString.h> | |
36 | #include <TString.h> | |
37 | #include <TSystem.h> | |
38 | ||
39 | //----------------------------------------------------------------------------- | |
49e110ec | 40 | /// \class AliMpDCSNamer |
1ef5468a | 41 | /// |
49e110ec | 42 | /// A utility class to manage DCS aliases names, in particular the |
1ef5468a | 43 | /// two conventions used to number the detection elements within a detector. |
44 | /// | |
49e110ec | 45 | /// \author: Laurent Aphecetche and Diego Stocco, Subatech |
1ef5468a | 46 | //----------------------------------------------------------------------------- |
47 | ||
48 | /// \cond CLASSIMP | |
49e110ec | 49 | ClassImp(AliMpDCSNamer) |
1ef5468a | 50 | /// \endcond |
51 | ||
49e110ec | 52 | const char* AliMpDCSNamer::fgkDCSChannelSt345Pattern[] = |
1ef5468a | 53 | { "MchHvLvLeft/Chamber%02dLeft/Slat%02d.actual.vMon", |
54 | "MchHvLvRight/Chamber%02dRight/Slat%02d.actual.vMon" | |
55 | }; | |
56 | ||
49e110ec | 57 | const char* AliMpDCSNamer::fgkDCSChannelSt12Pattern[] = |
1ef5468a | 58 | { |
59 | "MchHvLvLeft/Chamber%02dLeft/Quad%dSect%d.actual.vMon", | |
60 | "MchHvLvRight/Chamber%02dRight/Quad%dSect%d.actual.vMon", | |
61 | }; | |
62 | ||
49e110ec | 63 | const char* AliMpDCSNamer::fgkDCSSideTrackerName[] = { "Left", "Right" }; |
64 | ||
65 | ||
66 | const char* AliMpDCSNamer::fgkDCSSwitchSt345Pattern = "MchDE%04dsw%d.inValue"; | |
67 | ||
8980e5a2 | 68 | const char* AliMpDCSNamer::fgkDCSChannelTriggerPatternRead[] = {"MTR_%3sSIDE_MT%2i_RPC%i_HV.%14s", "MTR_%2sSIDE_MT%2i_RPC%i_HV.%14s"}; |
9b1e069f | 69 | const char* AliMpDCSNamer::fgkDCSChannelTriggerPattern[] = {"MTR_%3sSIDE_MT%2i_RPC%i_HV.%s", "MTR_%2sSIDE_MT%2i_RPC%i_HV.%s"}; |
49e110ec | 70 | const char* AliMpDCSNamer::fgkDCSSideTriggerName[] = { "OUT", "IN" }; |
7946a6bf | 71 | const char* AliMpDCSNamer::fgkDCSMeasureName[] = { "vEff", "actual.iMon" }; |
49e110ec | 72 | |
73 | const char* AliMpDCSNamer::fgkDetectorName[] = { "TRACKER", "TRIGGER" }; | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliMpDCSNamer::AliMpDCSNamer(): | |
77 | fDetector(-1) | |
78 | { | |
79 | SetDetector("TRACKER"); | |
80 | /// default ctor | |
81 | } | |
1ef5468a | 82 | |
83 | //_____________________________________________________________________________ | |
49e110ec | 84 | AliMpDCSNamer::AliMpDCSNamer(const char* detName): |
85 | fDetector(-1) | |
1ef5468a | 86 | { |
49e110ec | 87 | /// ctor taking the detector name as argument (either trigger or tracker) |
88 | SetDetector(detName); | |
1ef5468a | 89 | } |
90 | ||
91 | //_____________________________________________________________________________ | |
49e110ec | 92 | AliMpDCSNamer::~AliMpDCSNamer() |
1ef5468a | 93 | { |
94 | /// dtor | |
95 | } | |
96 | ||
49e110ec | 97 | //_____________________________________________________________________________ |
98 | Bool_t AliMpDCSNamer::SetDetector(const char* detName) | |
99 | { | |
100 | /// Set the detector type | |
101 | /// \param detName = tracker, trigger | |
102 | ||
103 | TString sDetName(detName); | |
104 | Bool_t isOk(kTRUE); | |
105 | sDetName.ToUpper(); | |
106 | if(sDetName.Contains(fgkDetectorName[kTrackerDet])) | |
107 | fDetector = kTrackerDet; | |
108 | else if(sDetName.Contains(fgkDetectorName[kTriggerDet])) | |
109 | fDetector = kTriggerDet; | |
110 | else { | |
111 | AliWarning("Detector name must be either tracker or trigger. Default tracker selected"); | |
112 | isOk = kFALSE; | |
113 | } | |
114 | return isOk; | |
115 | } | |
116 | ||
117 | ||
1ef5468a | 118 | //_____________________________________________________________________________ |
119 | void | |
49e110ec | 120 | AliMpDCSNamer::AliasesAsLdif(const char* ldiffile) const |
1ef5468a | 121 | { |
122 | /// Export the aliases in LDIF format | |
123 | ||
124 | ofstream out(ldiffile); | |
125 | ||
126 | TObjArray* a = CompactAliases(); | |
127 | ||
128 | TIter next(a); | |
129 | TObjString* s; | |
130 | ||
131 | // Some header. host name and port probably not up to date. | |
49e110ec | 132 | TString detName = (fDetector == kTriggerDet) ? "MTR" : "MCH"; |
133 | ||
134 | out << "#" << detName.Data() << " config" << endl | |
135 | << "dn: det=" << detName.Data() <<",o=alice,dc=cern,dc=ch" << endl | |
136 | << "objectClass: AliShuttleDetector" << endl | |
137 | << "det: " << detName.Data() << endl | |
138 | << "StrictRunOrder: 1" << endl | |
139 | << "responsible: aphecetc@in2p3.fr" << endl | |
140 | << "DCSHost: aldcs053.cern.ch" << endl | |
141 | << "DCSPort: 4242" <<endl; | |
1ef5468a | 142 | |
143 | while ( ( s = (TObjString*)(next()) ) ) | |
144 | { | |
145 | out << "DCSalias: " << s->String().Data() << endl; | |
146 | } | |
147 | ||
148 | out.close(); | |
149 | ||
150 | delete a; | |
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
154 | TObjArray* | |
49e110ec | 155 | AliMpDCSNamer::CompactAliases() const |
1ef5468a | 156 | { |
157 | /// Generate a compact list of aliases, for Shuttle test | |
158 | /// This one is completely hand-made, in contrast with GenerateAliases() | |
159 | /// method | |
160 | ||
161 | TObjArray* a = new TObjArray; | |
162 | a->SetOwner(kTRUE); | |
49e110ec | 163 | |
164 | switch(fDetector){ | |
165 | case kTrackerDet: | |
166 | // St 12 (DCS Channels) | |
167 | a->Add(new TObjString("MchHvLvRight/Chamber[00..03]Right/Quad0Sect[0..2].actual.vMon")); | |
168 | a->Add(new TObjString("MchHvLvLeft/Chamber[00..03]Left/Quad1Sect[0..2].actual.vMon")); | |
169 | a->Add(new TObjString("MchHvLvLeft/Chamber[00..03]Left/Quad2Sect[0..2].actual.vMon")); | |
170 | a->Add(new TObjString("MchHvLvRight/Chamber[00..03]Right/Quad3Sect[0..2].actual.vMon")); | |
1ef5468a | 171 | |
49e110ec | 172 | // St345 (DCS Channels) |
1ef5468a | 173 | |
49e110ec | 174 | a->Add(new TObjString("MchHvLvRight/Chamber[04..09]Right/Slat[00..08].actual.vMon")); |
175 | a->Add(new TObjString("MchHvLvLeft/Chamber[04..09]Left/Slat[00..08].actual.vMon")); | |
1ef5468a | 176 | |
49e110ec | 177 | a->Add(new TObjString("MchHvLvRight/Chamber[06..09]Right/Slat[09..12].actual.vMon")); |
178 | a->Add(new TObjString("MchHvLvLeft/Chamber[06..09]Left/Slat[09..12].actual.vMon")); | |
179 | break; | |
180 | ||
181 | case kTriggerDet: | |
182 | a->Add(new TObjString("MTR_OUTSIDE_MT[11..12]Right/RPC[1..9]_HV.imon")); | |
183 | a->Add(new TObjString("MTR_OUTSIDE_MT[21..22]Right/RPC[1..9]_HV.imon")); | |
184 | a->Add(new TObjString("MTR_INSIDE_MT[11..12]Right/RPC[1..9]_HV.imon")); | |
185 | a->Add(new TObjString("MTR_INSIDE_MT[21..22]Right/RPC[1..9]_HV.imon")); | |
186 | ||
187 | a->Add(new TObjString("MTR_OUTSIDE_MT[11..12]Right/RPC[1..9]_HV.vmon")); | |
188 | a->Add(new TObjString("MTR_OUTSIDE_MT[21..22]Right/RPC[1..9]_HV.vmon")); | |
189 | a->Add(new TObjString("MTR_INSIDE_MT[11..12]Right/RPC[1..9]_HV.vmon")); | |
190 | a->Add(new TObjString("MTR_INSIDE_MT[21..22]Right/RPC[1..9]_HV.vmon")); | |
191 | } | |
192 | ||
1ef5468a | 193 | |
49e110ec | 194 | if(fDetector == kTrackerDet){ |
195 | // St345 (DCS Switches) | |
196 | AliMpDEIterator it; | |
1ef5468a | 197 | |
49e110ec | 198 | it.First(); |
1ef5468a | 199 | |
49e110ec | 200 | while (!it.IsDone()) |
1ef5468a | 201 | { |
49e110ec | 202 | Int_t detElemId = it.CurrentDEId(); |
203 | if ( AliMpDEManager::GetStationType(detElemId) == AliMp::kStation345 ) | |
204 | { | |
205 | a->Add(new TObjString(Form("MchDE%04dsw[0..%d].inValue",detElemId,NumberOfPCBs(detElemId)-1))); | |
206 | } | |
207 | it.Next(); | |
208 | } | |
1ef5468a | 209 | } |
49e110ec | 210 | |
1ef5468a | 211 | return a; |
212 | } | |
213 | ||
214 | //_____________________________________________________________________________ | |
215 | Int_t | |
49e110ec | 216 | AliMpDCSNamer::DCS2DE(Int_t chId, Int_t side, Int_t dcsNumber) const |
1ef5468a | 217 | { |
49e110ec | 218 | /// Convert DCS Tracker "slat number" (old convention) to DE (new) convention. |
1ef5468a | 219 | /// |
220 | /// \param chamberId : chamber number (starting at 0) | |
221 | /// \param side : 0 for Left, 1 for Right | |
49e110ec | 222 | /// \param dcsNumber : slat number in DCS convention |
1ef5468a | 223 | /// |
224 | /// note that dcsNumber should be >=0 and < number of DEs/2 in chamber | |
225 | ||
49e110ec | 226 | Int_t de(-1); |
227 | Int_t chamberId = chId; | |
228 | ||
229 | if(fDetector == kTrackerDet){ // Tracker | |
230 | ||
231 | Int_t nofDE = AliMpDEManager::GetNofDEInChamber(chamberId); | |
1ef5468a | 232 | |
49e110ec | 233 | Int_t half = nofDE/2; |
1ef5468a | 234 | |
49e110ec | 235 | dcsNumber = half - dcsNumber; |
1ef5468a | 236 | |
49e110ec | 237 | Int_t quarter = nofDE/4; |
238 | Int_t threeQuarter = half + quarter; | |
1ef5468a | 239 | |
49e110ec | 240 | if ( side == 0 ) // left |
241 | { | |
242 | de = threeQuarter + 1 - dcsNumber; | |
243 | } | |
244 | else if ( side == 1 ) // right | |
245 | { | |
246 | if ( dcsNumber <= quarter ) | |
247 | { | |
248 | de = dcsNumber + threeQuarter; | |
249 | } | |
250 | else | |
251 | { | |
252 | de = dcsNumber - quarter - 1; | |
253 | } | |
254 | } | |
1ef5468a | 255 | } |
49e110ec | 256 | else { // Trigger |
257 | ||
258 | if ( chId < 19 ) chamberId = chId - 1; | |
259 | else chamberId = chId - 9; | |
260 | ||
261 | Int_t nofDE = AliMpDEManager::GetNofDEInChamber(chamberId); | |
262 | ||
263 | if ( side == 0 ) // left -> Outside | |
1ef5468a | 264 | { |
49e110ec | 265 | de = 14 - dcsNumber; |
1ef5468a | 266 | } |
49e110ec | 267 | else if ( side == 1 ) // right -> Inside |
1ef5468a | 268 | { |
49e110ec | 269 | de = (13 + dcsNumber) % nofDE; |
1ef5468a | 270 | } |
271 | } | |
272 | ||
82c70ae8 | 273 | return (chamberId+1)*100 + de; |
1ef5468a | 274 | } |
275 | ||
49e110ec | 276 | |
1ef5468a | 277 | //_____________________________________________________________________________ |
278 | Int_t | |
49e110ec | 279 | AliMpDCSNamer::DetElemId2DCS(Int_t detElemId, Int_t& side, Int_t &chId) const |
1ef5468a | 280 | { |
281 | /// Convert DE to DCS "slat number" | |
282 | /// @see DCS2DE | |
49e110ec | 283 | |
284 | CheckConsistency(detElemId); | |
1ef5468a | 285 | |
286 | Int_t chamberId = AliMpDEManager::GetChamberId(detElemId); | |
287 | if ( chamberId < 0 ) | |
288 | { | |
289 | AliDebug(1,Form("DetElemId %d invalid",detElemId)); | |
290 | return -1; | |
291 | } | |
292 | Int_t dcsNumber = (detElemId-(chamberId+1)*100); | |
293 | ||
294 | switch ( AliMpDEManager::GetStationType(detElemId) ) | |
295 | { | |
4e51cfd2 | 296 | case AliMp::kStation12: |
1ef5468a | 297 | { |
298 | switch (dcsNumber) | |
299 | { | |
300 | case 0: | |
301 | case 3: | |
302 | side = 1; // right | |
303 | break; | |
304 | case 1: | |
305 | case 2: | |
306 | side = 0; // left | |
307 | default: | |
308 | break; | |
309 | } | |
310 | } | |
311 | break; | |
312 | case AliMp::kStation345: | |
313 | { | |
314 | Int_t nofDE = AliMpDEManager::GetNofDEInChamber(chamberId); | |
315 | ||
316 | Int_t quarter = nofDE/4; | |
317 | ||
318 | Int_t half = nofDE/2; | |
319 | ||
320 | Int_t threeQuarter = half + quarter; | |
321 | ||
322 | side = -1; | |
323 | ||
324 | if ( dcsNumber <= quarter ) | |
325 | { | |
326 | dcsNumber += quarter + 1 ; | |
327 | side = 1; // right | |
328 | } | |
329 | else if ( dcsNumber <= threeQuarter ) | |
330 | { | |
331 | dcsNumber = ( threeQuarter - dcsNumber + 1 ); | |
332 | side = 0; // left | |
333 | } | |
334 | else if ( dcsNumber > threeQuarter ) | |
335 | { | |
336 | dcsNumber = dcsNumber - threeQuarter; | |
337 | side = 1; // right | |
338 | } | |
339 | else | |
340 | { | |
341 | AliFatal("oups"); | |
342 | } | |
343 | // dcs convention change : numbering from top, not from bottom | |
344 | dcsNumber = half-dcsNumber; | |
345 | } | |
346 | break; | |
49e110ec | 347 | case AliMp::kStationTrigger: |
348 | { | |
349 | if (chamberId < AliMpConstants::NofChambers()-2) | |
350 | chId = chamberId + 1; | |
351 | else chId = 23 + chamberId - AliMpConstants::NofChambers(); | |
352 | ||
353 | Int_t nofDE = AliMpDEManager::GetNofDEInChamber(chamberId); | |
354 | ||
355 | if ( dcsNumber >=5 && dcsNumber <= 13 ) { | |
356 | side = 0; | |
357 | dcsNumber = 14 - dcsNumber; | |
358 | } | |
359 | else { | |
360 | side = 1; | |
361 | dcsNumber = (5 + dcsNumber) % nofDE; | |
362 | } | |
363 | AliDebug(10, Form("detElemId %i -> MT%i_side%i_L%i", detElemId, chId, side, dcsNumber)); | |
364 | } | |
365 | break; | |
1ef5468a | 366 | default: |
367 | break; | |
368 | } | |
49e110ec | 369 | |
1ef5468a | 370 | return dcsNumber; |
371 | } | |
372 | ||
49e110ec | 373 | |
1ef5468a | 374 | //_____________________________________________________________________________ |
375 | const char* | |
49e110ec | 376 | AliMpDCSNamer::DCSChannelName(Int_t detElemId, Int_t sector, Int_t dcsMeasure) const |
1ef5468a | 377 | { |
49e110ec | 378 | /// Return the alias name of the DCS Channel for a given DCS area |
1ef5468a | 379 | /// \param detElemId |
49e110ec | 380 | /// \param sector = 0,1 or 2 for St12, and is unused for st345 and trigger |
381 | /// \param dcsMeasure = kDCSHV, kDCSI and is unused for tracker | |
1ef5468a | 382 | |
383 | Int_t chamberId = AliMpDEManager::GetChamberId(detElemId); | |
384 | if ( chamberId < 0 ) return 0x0; | |
385 | ||
49e110ec | 386 | Int_t side(-1), chId(-1); |
387 | Int_t dcsNumber = DetElemId2DCS(detElemId,side,chId); | |
388 | ||
1ef5468a | 389 | switch (AliMpDEManager::GetStationType(detElemId)) |
390 | { | |
4e51cfd2 | 391 | case AliMp::kStation12: |
49e110ec | 392 | return Form(fgkDCSChannelSt12Pattern[side],chamberId,dcsNumber,sector); |
1ef5468a | 393 | break; |
394 | case AliMp::kStation345: | |
49e110ec | 395 | return Form(fgkDCSChannelSt345Pattern[side],chamberId,dcsNumber); |
396 | break; | |
397 | case AliMp::kStationTrigger: | |
398 | return Form(fgkDCSChannelTriggerPattern[side],fgkDCSSideTriggerName[side],chId,dcsNumber,fgkDCSMeasureName[dcsMeasure]); | |
1ef5468a | 399 | break; |
400 | default: | |
401 | return 0x0; | |
402 | break; | |
403 | } | |
404 | } | |
405 | ||
406 | //_____________________________________________________________________________ | |
407 | const char* | |
49e110ec | 408 | AliMpDCSNamer::DCSSwitchName(Int_t detElemId, Int_t pcbNumber) const |
1ef5468a | 409 | { |
49e110ec | 410 | /// Return the alias name of the DCS Switch for a given PCB |
1ef5468a | 411 | /// within a slat of St345 |
412 | ||
413 | if (AliMpDEManager::GetStationType(detElemId) == AliMp::kStation345) | |
414 | { | |
49e110ec | 415 | return Form(fgkDCSSwitchSt345Pattern,detElemId,pcbNumber); |
1ef5468a | 416 | } |
417 | return 0x0; | |
418 | } | |
419 | ||
82c70ae8 | 420 | //_____________________________________________________________________________ |
421 | Int_t | |
49e110ec | 422 | AliMpDCSNamer::DCSIndexFromDCSAlias(const char* dcsAlias) const |
82c70ae8 | 423 | { |
424 | /// Converts the dcs alias to a hv index | |
425 | /// | |
426 | /// dcsAlias has one of the following 3 forms : | |
427 | /// | |
428 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Slat##.actual.vMon | |
429 | /// | |
430 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Quad#Sect#.actual.vMon | |
431 | /// | |
432 | /// MchDE####dsw#.inValue | |
433 | ||
434 | TString sDcsAlias(dcsAlias); | |
435 | Int_t de(-1); | |
436 | Int_t sw(-1); | |
437 | ||
438 | int side(-1); | |
439 | ||
440 | if ( sDcsAlias.Contains("Left") ) | |
441 | { | |
442 | side = 0; | |
443 | } | |
444 | else if ( sDcsAlias.Contains("Right") ) | |
445 | { | |
446 | side = 1; | |
447 | } | |
448 | else | |
449 | { | |
450 | /// it's a switch | |
49e110ec | 451 | sscanf(sDcsAlias.Data(),fgkDCSSwitchSt345Pattern,&de,&sw); |
82c70ae8 | 452 | return sw; |
453 | } | |
454 | ||
455 | int n1(-1); | |
456 | int n3(-1); | |
457 | int n4(-1); | |
458 | ||
459 | if ( sDcsAlias.Contains("Quad") ) | |
460 | { | |
49e110ec | 461 | sscanf(sDcsAlias.Data(),fgkDCSChannelSt12Pattern[side],&n1,&n3,&n4); |
82c70ae8 | 462 | return n4; |
463 | } | |
464 | ||
465 | return -2; | |
466 | } | |
467 | ||
1ef5468a | 468 | //_____________________________________________________________________________ |
469 | Int_t | |
49e110ec | 470 | AliMpDCSNamer::DetElemIdFromDCSAlias(const char* dcsAlias) const |
1ef5468a | 471 | { |
472 | /// Converts the dcs alias to a detection element identifier | |
473 | /// | |
49e110ec | 474 | /// dcsAlias has one of the following forms : |
1ef5468a | 475 | /// |
476 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Slat##.actual.vMon | |
477 | /// | |
478 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Quad#Sect#.actual.vMon | |
49e110ec | 479 | /// |
9b1e069f | 480 | /// MTR_Side[OUTSIDE|INSIDE]_MTChamber##_RPC#_HV.Type[actual.iMon|vEff] |
1ef5468a | 481 | |
82c70ae8 | 482 | AliDebug(1,Form("dcsAlias=%s",dcsAlias)); |
483 | ||
1ef5468a | 484 | TString sDcsAlias(dcsAlias); |
485 | ||
486 | int side(-1); | |
49e110ec | 487 | |
488 | const char** sideName = (fDetector == kTriggerDet) ? fgkDCSSideTriggerName : fgkDCSSideTrackerName; | |
489 | ||
490 | for(Int_t iside=0; iside<2; iside++){ | |
491 | if ( sDcsAlias.Contains(sideName[iside]) ) { | |
492 | side = iside; | |
493 | break; | |
494 | } | |
1ef5468a | 495 | } |
49e110ec | 496 | if(side<0) return -2; |
1ef5468a | 497 | |
498 | int n1(-1); | |
499 | int n3(-1); | |
500 | int n4(-1); | |
9b1e069f | 501 | char type[15]; |
49e110ec | 502 | char cside[4]; |
1ef5468a | 503 | int detElemId(-1); |
504 | ||
505 | if ( sDcsAlias.Contains("Slat") ) | |
506 | { | |
49e110ec | 507 | sscanf(sDcsAlias.Data(),fgkDCSChannelSt345Pattern[side],&n1,&n3); |
1ef5468a | 508 | detElemId = DCS2DE(n1,side,n3); |
82c70ae8 | 509 | AliDebug(1,Form("Slat side=%d n1=%d n3=%d de=%d",side,n1,n3,detElemId)); |
1ef5468a | 510 | } |
511 | else if ( sDcsAlias.Contains("Quad") ) | |
512 | { | |
49e110ec | 513 | sscanf(sDcsAlias.Data(),fgkDCSChannelSt12Pattern[side],&n1,&n3,&n4); |
82c70ae8 | 514 | detElemId = 100*(n1+1) + n3; |
515 | AliDebug(1,Form("Quad side=%d n1=%d n3=%d n4=%d de=%d",side,n1,n3,n4,detElemId)); | |
1ef5468a | 516 | } |
49e110ec | 517 | else if ( sDcsAlias.Contains("MT") ) |
518 | { | |
8980e5a2 | 519 | sscanf(sDcsAlias.Data(),fgkDCSChannelTriggerPatternRead[side],cside,&n1,&n3,type); |
49e110ec | 520 | detElemId = DCS2DE(n1,side,n3); |
521 | AliDebug(1,Form("Slat side=%d n1=%d n3=%d de=%d",side,n1,n3,detElemId)); | |
522 | } | |
1ef5468a | 523 | else |
524 | { | |
525 | return -3; | |
526 | } | |
527 | ||
528 | if ( !AliMpDEManager::IsValidDetElemId(detElemId) ) | |
529 | { | |
530 | AliError(Form("Invalid aliasName %s",dcsAlias)); | |
531 | return -1; | |
532 | } | |
533 | ||
534 | return detElemId; | |
535 | } | |
536 | ||
49e110ec | 537 | //_____________________________________________________________________________ |
538 | Int_t AliMpDCSNamer::DCSvariableFromDCSAlias(const char* dcsAlias) const | |
539 | { | |
540 | /// Get DCS variable from an alias (trigger) | |
541 | ||
542 | TString sDcsAlias(dcsAlias); | |
543 | ||
544 | Int_t dcsMeasurement = -1; | |
545 | ||
546 | for(Int_t iMeas=0; iMeas<kNDCSMeas; iMeas++){ | |
547 | if ( sDcsAlias.Contains(fgkDCSMeasureName[iMeas]) ) { | |
548 | dcsMeasurement = iMeas; | |
549 | break; | |
550 | } | |
551 | } | |
552 | ||
553 | return dcsMeasurement; | |
554 | } | |
555 | ||
556 | ||
1ef5468a | 557 | //_____________________________________________________________________________ |
558 | TObjArray* | |
49e110ec | 559 | AliMpDCSNamer::GenerateAliases() const |
1ef5468a | 560 | { |
561 | /// Generate DCS alias names, for MUON Tracker High Voltage system. | |
49e110ec | 562 | /// or for MUON Trigger HV and current system. |
1ef5468a | 563 | /// |
49e110ec | 564 | /// We first generate aliases of DCS channels : |
1ef5468a | 565 | /// |
566 | /// St 1 ch 1 : 12 channels | |
567 | /// ch 2 : 12 channels | |
568 | /// St 2 ch 3 : 12 channels | |
569 | /// ch 4 : 12 channels | |
570 | /// St 3 ch 5 : 18 channels | |
571 | /// ch 6 : 18 channels | |
572 | /// St 4 ch 7 : 26 channels | |
573 | /// ch 8 : 26 channels | |
574 | /// St 5 ch 9 : 26 channels | |
575 | /// ch 10 : 26 channels | |
576 | /// | |
49e110ec | 577 | /// then aliases of DCS switches (only for St345) : 1 switch per PCB. |
1ef5468a | 578 | /// |
579 | /// Returns a TObjArray of TObjString(=alias name) | |
580 | ||
581 | TObjArray* aliases = new TObjArray; | |
582 | aliases->SetOwner(kTRUE); | |
49e110ec | 583 | |
584 | Int_t nMeasures = (fDetector == kTriggerDet) ? kNDCSMeas : 1; | |
1ef5468a | 585 | |
49e110ec | 586 | for(Int_t iMeas=0; iMeas<nMeasures; iMeas++){ |
587 | ||
588 | AliMpDEIterator it; | |
1ef5468a | 589 | |
49e110ec | 590 | it.First(); |
1ef5468a | 591 | |
49e110ec | 592 | while (!it.IsDone()) |
1ef5468a | 593 | { |
49e110ec | 594 | Int_t detElemId = it.CurrentDEId(); |
595 | switch (fDetector){ | |
596 | case kTrackerDet: | |
597 | { | |
598 | switch ( AliMpDEManager::GetStationType(detElemId) ) | |
599 | { | |
4e51cfd2 | 600 | case AliMp::kStation12: |
49e110ec | 601 | for ( int sector = 0; sector < 3; ++sector) |
602 | { | |
603 | aliases->Add(new TObjString(DCSChannelName(detElemId,sector))); | |
604 | } | |
605 | break; | |
606 | case AliMp::kStation345: | |
607 | aliases->Add(new TObjString(DCSChannelName(detElemId))); | |
608 | for ( Int_t i = 0; i < NumberOfPCBs(detElemId); ++i ) | |
609 | { | |
610 | aliases->Add(new TObjString(DCSSwitchName(detElemId,i))); | |
611 | } | |
612 | break; | |
613 | default: | |
614 | break; | |
615 | } | |
616 | } | |
617 | break; | |
618 | case kTriggerDet: | |
619 | { | |
620 | switch ( AliMpDEManager::GetStationType(detElemId) ) | |
621 | { | |
622 | case AliMp::kStationTrigger: | |
623 | AliDebug(10,Form("Current DetElemId %i",detElemId)); | |
624 | aliases->Add(new TObjString(DCSChannelName(detElemId,0,iMeas))); | |
625 | break; | |
626 | default: | |
627 | break; | |
628 | } | |
629 | } | |
630 | break; | |
631 | } | |
632 | it.Next(); | |
633 | } // loop on detElemId | |
634 | } // Loop on measurement type | |
635 | ||
1ef5468a | 636 | return aliases; |
637 | } | |
638 | ||
639 | //_____________________________________________________________________________ | |
640 | Int_t | |
49e110ec | 641 | AliMpDCSNamer::ManuId2Index(Int_t detElemId, Int_t manuId) const |
1ef5468a | 642 | { |
643 | /// Convert (de,manu) to hv index, depending on the station | |
644 | ||
645 | AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); | |
646 | if ( stationType == AliMp::kStation345 ) | |
647 | { | |
648 | return ManuId2PCBIndex(detElemId,manuId); | |
649 | } | |
4e51cfd2 | 650 | else if ( stationType == AliMp::kStation12 ) |
1ef5468a | 651 | { |
652 | return ManuId2Sector(detElemId,manuId); | |
653 | } | |
654 | return -1; | |
655 | } | |
656 | ||
657 | //_____________________________________________________________________________ | |
658 | Int_t | |
49e110ec | 659 | AliMpDCSNamer::ManuId2PCBIndex(Int_t detElemId, Int_t manuId) const |
1ef5468a | 660 | { |
661 | /// Returns the index of PCB (within a St345 slat) for a given manu number. | |
662 | /// Returns -1 if (detElemId,manuId) is incorrect | |
663 | ||
99c136e1 | 664 | AliCodeTimerAuto("",0) |
1ef5468a | 665 | |
f3ed9a44 | 666 | const AliMpSlat* slat |
667 | = AliMpSegmentation::Instance()->GetSlatByElectronics(detElemId, manuId); | |
668 | if ( ! slat ) return -1; | |
1ef5468a | 669 | |
670 | return slat->FindPCBIndexByMotifPositionID(manuId); | |
671 | } | |
672 | ||
673 | //_____________________________________________________________________________ | |
674 | Int_t | |
49e110ec | 675 | AliMpDCSNamer::ManuId2Sector(Int_t detElemId, Int_t manuId) const |
1ef5468a | 676 | { |
49e110ec | 677 | /// Return the DCS-sector number (within a St12 quadrant) for a given manu number. |
1ef5468a | 678 | |
99c136e1 | 679 | AliCodeTimerAuto("",0) |
1ef5468a | 680 | |
f3ed9a44 | 681 | const AliMpSector* sector |
682 | = AliMpSegmentation::Instance()->GetSectorByElectronics(detElemId, manuId); | |
683 | if ( ! sector ) return -1; | |
684 | ||
1ef5468a | 685 | const AliMpMotifMap* motifMap = sector->GetMotifMap(); |
686 | const AliMpMotifPosition* motifPos = motifMap->FindMotifPosition(manuId); | |
687 | ||
6e97fbb8 | 688 | Double_t lowerLeftX |
689 | = motifPos->GetPositionX()-motifPos->GetDimensionX(); | |
1ef5468a | 690 | |
6e97fbb8 | 691 | Double_t x = lowerLeftX*10.0; // cm -> mm |
1ef5468a | 692 | Int_t isector(-1); |
693 | ||
4e51cfd2 | 694 | AliMq::Station12Type stationType = AliMpDEManager::GetStation12Type(detElemId); |
1ef5468a | 695 | |
4e51cfd2 | 696 | if ( stationType == AliMq::kStation1 ) |
1ef5468a | 697 | { |
82c70ae8 | 698 | if ( x < -10 ) AliFatal(""); |
1ef5468a | 699 | |
700 | if ( x < 291.65 ) isector = 0; | |
701 | else if ( x < 585.65 ) isector = 1; | |
702 | else if ( x < 879.65 ) isector = 2; | |
703 | } | |
704 | else | |
705 | { | |
82c70ae8 | 706 | if ( x < -140 ) AliFatal(""); |
1ef5468a | 707 | |
708 | if ( x < 283.75 ) isector = 0; | |
0365cd91 | 709 | else if ( x < 606.25 ) isector = 1; |
1ef5468a | 710 | else if ( x < 1158.75 ) isector = 2; |
711 | } | |
712 | ||
713 | return isector; | |
714 | } | |
715 | ||
716 | //_____________________________________________________________________________ | |
717 | Int_t | |
49e110ec | 718 | AliMpDCSNamer::NumberOfPCBs(Int_t detElemId) const |
1ef5468a | 719 | { |
720 | /// Returns the number of PCB in a given detection element | |
721 | /// Only works for St345 | |
722 | ||
723 | AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); | |
724 | if ( stationType != AliMp::kStation345 ) | |
725 | { | |
726 | return 0; | |
727 | } | |
728 | else | |
729 | { | |
f3ed9a44 | 730 | const AliMpSlat* slat |
731 | = AliMpSegmentation::Instance()->GetSlat(detElemId, AliMp::kCath0); | |
1ef5468a | 732 | return slat->GetSize(); |
733 | } | |
734 | } | |
49e110ec | 735 | |
736 | //_____________________________________________________________________________ | |
737 | Bool_t AliMpDCSNamer::CheckConsistency(Int_t detElemId) const | |
738 | { | |
739 | // | |
740 | /// Check that the required detElemId either belongs to tracker or trigger | |
741 | /// consistently with the initial definition of the namer | |
742 | // | |
743 | ||
744 | Bool_t isConsistent(kFALSE); | |
745 | TString requestInfo; | |
746 | switch(AliMpDEManager::GetStationType(detElemId)) | |
747 | { | |
4e51cfd2 | 748 | case AliMp::kStation12: |
49e110ec | 749 | case AliMp::kStation345: |
750 | if (fDetector == kTrackerDet) isConsistent = kTRUE; | |
751 | requestInfo = "TRACKER"; | |
752 | break; | |
753 | case AliMp::kStationTrigger: | |
754 | if (fDetector == kTriggerDet) isConsistent = kTRUE; | |
755 | requestInfo = "TRIGGER"; | |
756 | break; | |
757 | default: | |
758 | break; | |
759 | } | |
760 | ||
761 | if(!isConsistent) AliWarning(Form("Requesting information for %s station but class initialized for %s",requestInfo.Data(), fgkDetectorName[fDetector])); | |
762 | ||
763 | return isConsistent; | |
764 | } |