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