]>
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 | { |
eaf6dbb0 | 269 | if (nofDE>0) |
270 | de = (13 + dcsNumber) % nofDE; | |
1ef5468a | 271 | } |
272 | } | |
273 | ||
82c70ae8 | 274 | return (chamberId+1)*100 + de; |
1ef5468a | 275 | } |
276 | ||
49e110ec | 277 | |
1ef5468a | 278 | //_____________________________________________________________________________ |
279 | Int_t | |
49e110ec | 280 | AliMpDCSNamer::DetElemId2DCS(Int_t detElemId, Int_t& side, Int_t &chId) const |
1ef5468a | 281 | { |
282 | /// Convert DE to DCS "slat number" | |
283 | /// @see DCS2DE | |
49e110ec | 284 | |
285 | CheckConsistency(detElemId); | |
1ef5468a | 286 | |
287 | Int_t chamberId = AliMpDEManager::GetChamberId(detElemId); | |
288 | if ( chamberId < 0 ) | |
289 | { | |
290 | AliDebug(1,Form("DetElemId %d invalid",detElemId)); | |
291 | return -1; | |
292 | } | |
293 | Int_t dcsNumber = (detElemId-(chamberId+1)*100); | |
294 | ||
295 | switch ( AliMpDEManager::GetStationType(detElemId) ) | |
296 | { | |
4e51cfd2 | 297 | case AliMp::kStation12: |
1ef5468a | 298 | { |
299 | switch (dcsNumber) | |
300 | { | |
301 | case 0: | |
302 | case 3: | |
303 | side = 1; // right | |
304 | break; | |
305 | case 1: | |
306 | case 2: | |
307 | side = 0; // left | |
308 | default: | |
309 | break; | |
310 | } | |
311 | } | |
312 | break; | |
313 | case AliMp::kStation345: | |
314 | { | |
315 | Int_t nofDE = AliMpDEManager::GetNofDEInChamber(chamberId); | |
316 | ||
317 | Int_t quarter = nofDE/4; | |
318 | ||
319 | Int_t half = nofDE/2; | |
320 | ||
321 | Int_t threeQuarter = half + quarter; | |
322 | ||
323 | side = -1; | |
324 | ||
325 | if ( dcsNumber <= quarter ) | |
326 | { | |
327 | dcsNumber += quarter + 1 ; | |
328 | side = 1; // right | |
329 | } | |
330 | else if ( dcsNumber <= threeQuarter ) | |
331 | { | |
332 | dcsNumber = ( threeQuarter - dcsNumber + 1 ); | |
333 | side = 0; // left | |
334 | } | |
335 | else if ( dcsNumber > threeQuarter ) | |
336 | { | |
337 | dcsNumber = dcsNumber - threeQuarter; | |
338 | side = 1; // right | |
339 | } | |
340 | else | |
341 | { | |
342 | AliFatal("oups"); | |
343 | } | |
344 | // dcs convention change : numbering from top, not from bottom | |
345 | dcsNumber = half-dcsNumber; | |
346 | } | |
347 | break; | |
49e110ec | 348 | case AliMp::kStationTrigger: |
349 | { | |
350 | if (chamberId < AliMpConstants::NofChambers()-2) | |
351 | chId = chamberId + 1; | |
352 | else chId = 23 + chamberId - AliMpConstants::NofChambers(); | |
353 | ||
354 | Int_t nofDE = AliMpDEManager::GetNofDEInChamber(chamberId); | |
355 | ||
356 | if ( dcsNumber >=5 && dcsNumber <= 13 ) { | |
357 | side = 0; | |
358 | dcsNumber = 14 - dcsNumber; | |
359 | } | |
360 | else { | |
361 | side = 1; | |
eaf6dbb0 | 362 | if (nofDE>0) |
363 | dcsNumber = (5 + dcsNumber) % nofDE; | |
49e110ec | 364 | } |
365 | AliDebug(10, Form("detElemId %i -> MT%i_side%i_L%i", detElemId, chId, side, dcsNumber)); | |
366 | } | |
367 | break; | |
1ef5468a | 368 | default: |
369 | break; | |
370 | } | |
49e110ec | 371 | |
1ef5468a | 372 | return dcsNumber; |
373 | } | |
374 | ||
49e110ec | 375 | |
1ef5468a | 376 | //_____________________________________________________________________________ |
377 | const char* | |
49e110ec | 378 | AliMpDCSNamer::DCSChannelName(Int_t detElemId, Int_t sector, Int_t dcsMeasure) const |
1ef5468a | 379 | { |
49e110ec | 380 | /// Return the alias name of the DCS Channel for a given DCS area |
1ef5468a | 381 | /// \param detElemId |
49e110ec | 382 | /// \param sector = 0,1 or 2 for St12, and is unused for st345 and trigger |
383 | /// \param dcsMeasure = kDCSHV, kDCSI and is unused for tracker | |
1ef5468a | 384 | |
385 | Int_t chamberId = AliMpDEManager::GetChamberId(detElemId); | |
386 | if ( chamberId < 0 ) return 0x0; | |
387 | ||
49e110ec | 388 | Int_t side(-1), chId(-1); |
389 | Int_t dcsNumber = DetElemId2DCS(detElemId,side,chId); | |
390 | ||
1ef5468a | 391 | switch (AliMpDEManager::GetStationType(detElemId)) |
392 | { | |
4e51cfd2 | 393 | case AliMp::kStation12: |
49e110ec | 394 | return Form(fgkDCSChannelSt12Pattern[side],chamberId,dcsNumber,sector); |
1ef5468a | 395 | break; |
396 | case AliMp::kStation345: | |
49e110ec | 397 | return Form(fgkDCSChannelSt345Pattern[side],chamberId,dcsNumber); |
398 | break; | |
399 | case AliMp::kStationTrigger: | |
400 | return Form(fgkDCSChannelTriggerPattern[side],fgkDCSSideTriggerName[side],chId,dcsNumber,fgkDCSMeasureName[dcsMeasure]); | |
1ef5468a | 401 | break; |
402 | default: | |
403 | return 0x0; | |
404 | break; | |
405 | } | |
406 | } | |
407 | ||
408 | //_____________________________________________________________________________ | |
409 | const char* | |
49e110ec | 410 | AliMpDCSNamer::DCSSwitchName(Int_t detElemId, Int_t pcbNumber) const |
1ef5468a | 411 | { |
49e110ec | 412 | /// Return the alias name of the DCS Switch for a given PCB |
1ef5468a | 413 | /// within a slat of St345 |
414 | ||
415 | if (AliMpDEManager::GetStationType(detElemId) == AliMp::kStation345) | |
416 | { | |
49e110ec | 417 | return Form(fgkDCSSwitchSt345Pattern,detElemId,pcbNumber); |
1ef5468a | 418 | } |
419 | return 0x0; | |
420 | } | |
421 | ||
82c70ae8 | 422 | //_____________________________________________________________________________ |
423 | Int_t | |
49e110ec | 424 | AliMpDCSNamer::DCSIndexFromDCSAlias(const char* dcsAlias) const |
82c70ae8 | 425 | { |
426 | /// Converts the dcs alias to a hv index | |
427 | /// | |
428 | /// dcsAlias has one of the following 3 forms : | |
429 | /// | |
430 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Slat##.actual.vMon | |
431 | /// | |
432 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Quad#Sect#.actual.vMon | |
433 | /// | |
434 | /// MchDE####dsw#.inValue | |
435 | ||
436 | TString sDcsAlias(dcsAlias); | |
437 | Int_t de(-1); | |
438 | Int_t sw(-1); | |
439 | ||
440 | int side(-1); | |
441 | ||
442 | if ( sDcsAlias.Contains("Left") ) | |
443 | { | |
444 | side = 0; | |
445 | } | |
446 | else if ( sDcsAlias.Contains("Right") ) | |
447 | { | |
448 | side = 1; | |
449 | } | |
450 | else | |
451 | { | |
452 | /// it's a switch | |
49e110ec | 453 | sscanf(sDcsAlias.Data(),fgkDCSSwitchSt345Pattern,&de,&sw); |
82c70ae8 | 454 | return sw; |
455 | } | |
456 | ||
457 | int n1(-1); | |
458 | int n3(-1); | |
459 | int n4(-1); | |
460 | ||
461 | if ( sDcsAlias.Contains("Quad") ) | |
462 | { | |
49e110ec | 463 | sscanf(sDcsAlias.Data(),fgkDCSChannelSt12Pattern[side],&n1,&n3,&n4); |
82c70ae8 | 464 | return n4; |
465 | } | |
466 | ||
467 | return -2; | |
468 | } | |
469 | ||
1ef5468a | 470 | //_____________________________________________________________________________ |
471 | Int_t | |
49e110ec | 472 | AliMpDCSNamer::DetElemIdFromDCSAlias(const char* dcsAlias) const |
1ef5468a | 473 | { |
474 | /// Converts the dcs alias to a detection element identifier | |
475 | /// | |
49e110ec | 476 | /// dcsAlias has one of the following forms : |
1ef5468a | 477 | /// |
478 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Slat##.actual.vMon | |
479 | /// | |
480 | /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Quad#Sect#.actual.vMon | |
49e110ec | 481 | /// |
9b1e069f | 482 | /// MTR_Side[OUTSIDE|INSIDE]_MTChamber##_RPC#_HV.Type[actual.iMon|vEff] |
1ef5468a | 483 | |
82c70ae8 | 484 | AliDebug(1,Form("dcsAlias=%s",dcsAlias)); |
485 | ||
1ef5468a | 486 | TString sDcsAlias(dcsAlias); |
487 | ||
488 | int side(-1); | |
49e110ec | 489 | |
490 | const char** sideName = (fDetector == kTriggerDet) ? fgkDCSSideTriggerName : fgkDCSSideTrackerName; | |
491 | ||
492 | for(Int_t iside=0; iside<2; iside++){ | |
493 | if ( sDcsAlias.Contains(sideName[iside]) ) { | |
494 | side = iside; | |
495 | break; | |
496 | } | |
1ef5468a | 497 | } |
49e110ec | 498 | if(side<0) return -2; |
1ef5468a | 499 | |
500 | int n1(-1); | |
501 | int n3(-1); | |
502 | int n4(-1); | |
9b1e069f | 503 | char type[15]; |
49e110ec | 504 | char cside[4]; |
1ef5468a | 505 | int detElemId(-1); |
506 | ||
507 | if ( sDcsAlias.Contains("Slat") ) | |
508 | { | |
49e110ec | 509 | sscanf(sDcsAlias.Data(),fgkDCSChannelSt345Pattern[side],&n1,&n3); |
1ef5468a | 510 | detElemId = DCS2DE(n1,side,n3); |
82c70ae8 | 511 | AliDebug(1,Form("Slat side=%d n1=%d n3=%d de=%d",side,n1,n3,detElemId)); |
1ef5468a | 512 | } |
513 | else if ( sDcsAlias.Contains("Quad") ) | |
514 | { | |
49e110ec | 515 | sscanf(sDcsAlias.Data(),fgkDCSChannelSt12Pattern[side],&n1,&n3,&n4); |
82c70ae8 | 516 | detElemId = 100*(n1+1) + n3; |
517 | AliDebug(1,Form("Quad side=%d n1=%d n3=%d n4=%d de=%d",side,n1,n3,n4,detElemId)); | |
1ef5468a | 518 | } |
49e110ec | 519 | else if ( sDcsAlias.Contains("MT") ) |
520 | { | |
8980e5a2 | 521 | sscanf(sDcsAlias.Data(),fgkDCSChannelTriggerPatternRead[side],cside,&n1,&n3,type); |
49e110ec | 522 | detElemId = DCS2DE(n1,side,n3); |
523 | AliDebug(1,Form("Slat side=%d n1=%d n3=%d de=%d",side,n1,n3,detElemId)); | |
524 | } | |
1ef5468a | 525 | else |
526 | { | |
527 | return -3; | |
528 | } | |
529 | ||
530 | if ( !AliMpDEManager::IsValidDetElemId(detElemId) ) | |
531 | { | |
532 | AliError(Form("Invalid aliasName %s",dcsAlias)); | |
533 | return -1; | |
534 | } | |
535 | ||
536 | return detElemId; | |
537 | } | |
538 | ||
49e110ec | 539 | //_____________________________________________________________________________ |
540 | Int_t AliMpDCSNamer::DCSvariableFromDCSAlias(const char* dcsAlias) const | |
541 | { | |
542 | /// Get DCS variable from an alias (trigger) | |
543 | ||
544 | TString sDcsAlias(dcsAlias); | |
545 | ||
546 | Int_t dcsMeasurement = -1; | |
547 | ||
548 | for(Int_t iMeas=0; iMeas<kNDCSMeas; iMeas++){ | |
549 | if ( sDcsAlias.Contains(fgkDCSMeasureName[iMeas]) ) { | |
550 | dcsMeasurement = iMeas; | |
551 | break; | |
552 | } | |
553 | } | |
554 | ||
555 | return dcsMeasurement; | |
556 | } | |
557 | ||
558 | ||
1ef5468a | 559 | //_____________________________________________________________________________ |
560 | TObjArray* | |
49e110ec | 561 | AliMpDCSNamer::GenerateAliases() const |
1ef5468a | 562 | { |
563 | /// Generate DCS alias names, for MUON Tracker High Voltage system. | |
49e110ec | 564 | /// or for MUON Trigger HV and current system. |
1ef5468a | 565 | /// |
49e110ec | 566 | /// We first generate aliases of DCS channels : |
1ef5468a | 567 | /// |
568 | /// St 1 ch 1 : 12 channels | |
569 | /// ch 2 : 12 channels | |
570 | /// St 2 ch 3 : 12 channels | |
571 | /// ch 4 : 12 channels | |
572 | /// St 3 ch 5 : 18 channels | |
573 | /// ch 6 : 18 channels | |
574 | /// St 4 ch 7 : 26 channels | |
575 | /// ch 8 : 26 channels | |
576 | /// St 5 ch 9 : 26 channels | |
577 | /// ch 10 : 26 channels | |
578 | /// | |
49e110ec | 579 | /// then aliases of DCS switches (only for St345) : 1 switch per PCB. |
1ef5468a | 580 | /// |
581 | /// Returns a TObjArray of TObjString(=alias name) | |
582 | ||
583 | TObjArray* aliases = new TObjArray; | |
584 | aliases->SetOwner(kTRUE); | |
49e110ec | 585 | |
586 | Int_t nMeasures = (fDetector == kTriggerDet) ? kNDCSMeas : 1; | |
1ef5468a | 587 | |
49e110ec | 588 | for(Int_t iMeas=0; iMeas<nMeasures; iMeas++){ |
589 | ||
590 | AliMpDEIterator it; | |
1ef5468a | 591 | |
49e110ec | 592 | it.First(); |
1ef5468a | 593 | |
49e110ec | 594 | while (!it.IsDone()) |
1ef5468a | 595 | { |
49e110ec | 596 | Int_t detElemId = it.CurrentDEId(); |
597 | switch (fDetector){ | |
598 | case kTrackerDet: | |
599 | { | |
600 | switch ( AliMpDEManager::GetStationType(detElemId) ) | |
601 | { | |
4e51cfd2 | 602 | case AliMp::kStation12: |
49e110ec | 603 | for ( int sector = 0; sector < 3; ++sector) |
604 | { | |
605 | aliases->Add(new TObjString(DCSChannelName(detElemId,sector))); | |
606 | } | |
607 | break; | |
608 | case AliMp::kStation345: | |
609 | aliases->Add(new TObjString(DCSChannelName(detElemId))); | |
610 | for ( Int_t i = 0; i < NumberOfPCBs(detElemId); ++i ) | |
611 | { | |
612 | aliases->Add(new TObjString(DCSSwitchName(detElemId,i))); | |
613 | } | |
614 | break; | |
615 | default: | |
616 | break; | |
617 | } | |
618 | } | |
619 | break; | |
620 | case kTriggerDet: | |
621 | { | |
622 | switch ( AliMpDEManager::GetStationType(detElemId) ) | |
623 | { | |
624 | case AliMp::kStationTrigger: | |
625 | AliDebug(10,Form("Current DetElemId %i",detElemId)); | |
626 | aliases->Add(new TObjString(DCSChannelName(detElemId,0,iMeas))); | |
627 | break; | |
628 | default: | |
629 | break; | |
630 | } | |
631 | } | |
632 | break; | |
633 | } | |
634 | it.Next(); | |
635 | } // loop on detElemId | |
636 | } // Loop on measurement type | |
637 | ||
1ef5468a | 638 | return aliases; |
639 | } | |
640 | ||
641 | //_____________________________________________________________________________ | |
642 | Int_t | |
49e110ec | 643 | AliMpDCSNamer::ManuId2Index(Int_t detElemId, Int_t manuId) const |
1ef5468a | 644 | { |
645 | /// Convert (de,manu) to hv index, depending on the station | |
646 | ||
647 | AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); | |
648 | if ( stationType == AliMp::kStation345 ) | |
649 | { | |
650 | return ManuId2PCBIndex(detElemId,manuId); | |
651 | } | |
4e51cfd2 | 652 | else if ( stationType == AliMp::kStation12 ) |
1ef5468a | 653 | { |
654 | return ManuId2Sector(detElemId,manuId); | |
655 | } | |
656 | return -1; | |
657 | } | |
658 | ||
659 | //_____________________________________________________________________________ | |
660 | Int_t | |
49e110ec | 661 | AliMpDCSNamer::ManuId2PCBIndex(Int_t detElemId, Int_t manuId) const |
1ef5468a | 662 | { |
663 | /// Returns the index of PCB (within a St345 slat) for a given manu number. | |
664 | /// Returns -1 if (detElemId,manuId) is incorrect | |
665 | ||
99c136e1 | 666 | AliCodeTimerAuto("",0) |
1ef5468a | 667 | |
f3ed9a44 | 668 | const AliMpSlat* slat |
669 | = AliMpSegmentation::Instance()->GetSlatByElectronics(detElemId, manuId); | |
670 | if ( ! slat ) return -1; | |
1ef5468a | 671 | |
672 | return slat->FindPCBIndexByMotifPositionID(manuId); | |
673 | } | |
674 | ||
675 | //_____________________________________________________________________________ | |
676 | Int_t | |
49e110ec | 677 | AliMpDCSNamer::ManuId2Sector(Int_t detElemId, Int_t manuId) const |
1ef5468a | 678 | { |
49e110ec | 679 | /// Return the DCS-sector number (within a St12 quadrant) for a given manu number. |
1ef5468a | 680 | |
99c136e1 | 681 | AliCodeTimerAuto("",0) |
1ef5468a | 682 | |
f3ed9a44 | 683 | const AliMpSector* sector |
684 | = AliMpSegmentation::Instance()->GetSectorByElectronics(detElemId, manuId); | |
685 | if ( ! sector ) return -1; | |
686 | ||
1ef5468a | 687 | const AliMpMotifMap* motifMap = sector->GetMotifMap(); |
688 | const AliMpMotifPosition* motifPos = motifMap->FindMotifPosition(manuId); | |
689 | ||
6e97fbb8 | 690 | Double_t lowerLeftX |
691 | = motifPos->GetPositionX()-motifPos->GetDimensionX(); | |
1ef5468a | 692 | |
6e97fbb8 | 693 | Double_t x = lowerLeftX*10.0; // cm -> mm |
1ef5468a | 694 | Int_t isector(-1); |
695 | ||
4e51cfd2 | 696 | AliMq::Station12Type stationType = AliMpDEManager::GetStation12Type(detElemId); |
1ef5468a | 697 | |
4e51cfd2 | 698 | if ( stationType == AliMq::kStation1 ) |
1ef5468a | 699 | { |
82c70ae8 | 700 | if ( x < -10 ) AliFatal(""); |
1ef5468a | 701 | |
702 | if ( x < 291.65 ) isector = 0; | |
703 | else if ( x < 585.65 ) isector = 1; | |
704 | else if ( x < 879.65 ) isector = 2; | |
705 | } | |
706 | else | |
707 | { | |
82c70ae8 | 708 | if ( x < -140 ) AliFatal(""); |
1ef5468a | 709 | |
710 | if ( x < 283.75 ) isector = 0; | |
0365cd91 | 711 | else if ( x < 606.25 ) isector = 1; |
1ef5468a | 712 | else if ( x < 1158.75 ) isector = 2; |
713 | } | |
714 | ||
715 | return isector; | |
716 | } | |
717 | ||
718 | //_____________________________________________________________________________ | |
719 | Int_t | |
49e110ec | 720 | AliMpDCSNamer::NumberOfPCBs(Int_t detElemId) const |
1ef5468a | 721 | { |
722 | /// Returns the number of PCB in a given detection element | |
723 | /// Only works for St345 | |
724 | ||
725 | AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); | |
726 | if ( stationType != AliMp::kStation345 ) | |
727 | { | |
728 | return 0; | |
729 | } | |
730 | else | |
731 | { | |
f3ed9a44 | 732 | const AliMpSlat* slat |
733 | = AliMpSegmentation::Instance()->GetSlat(detElemId, AliMp::kCath0); | |
1ef5468a | 734 | return slat->GetSize(); |
735 | } | |
736 | } | |
49e110ec | 737 | |
738 | //_____________________________________________________________________________ | |
739 | Bool_t AliMpDCSNamer::CheckConsistency(Int_t detElemId) const | |
740 | { | |
741 | // | |
742 | /// Check that the required detElemId either belongs to tracker or trigger | |
743 | /// consistently with the initial definition of the namer | |
744 | // | |
745 | ||
746 | Bool_t isConsistent(kFALSE); | |
747 | TString requestInfo; | |
748 | switch(AliMpDEManager::GetStationType(detElemId)) | |
749 | { | |
4e51cfd2 | 750 | case AliMp::kStation12: |
49e110ec | 751 | case AliMp::kStation345: |
752 | if (fDetector == kTrackerDet) isConsistent = kTRUE; | |
753 | requestInfo = "TRACKER"; | |
754 | break; | |
755 | case AliMp::kStationTrigger: | |
756 | if (fDetector == kTriggerDet) isConsistent = kTRUE; | |
757 | requestInfo = "TRIGGER"; | |
758 | break; | |
759 | default: | |
760 | break; | |
761 | } | |
762 | ||
763 | if(!isConsistent) AliWarning(Form("Requesting information for %s station but class initialized for %s",requestInfo.Data(), fgkDetectorName[fDetector])); | |
764 | ||
765 | return isConsistent; | |
766 | } |