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