]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpDCSNamer.cxx
Raw2SDigits() restored and improved.
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDCSNamer.cxx
CommitLineData
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 49ClassImp(AliMpDCSNamer)
1ef5468a 50/// \endcond
51
49e110ec 52const char* AliMpDCSNamer::fgkDCSChannelSt345Pattern[] =
1ef5468a 53{ "MchHvLvLeft/Chamber%02dLeft/Slat%02d.actual.vMon",
54 "MchHvLvRight/Chamber%02dRight/Slat%02d.actual.vMon"
55};
56
49e110ec 57const 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 63const char* AliMpDCSNamer::fgkDCSSideTrackerName[] = { "Left", "Right" };
64
65
66const char* AliMpDCSNamer::fgkDCSSwitchSt345Pattern = "MchDE%04dsw%d.inValue";
67
68const char* AliMpDCSNamer::fgkDCSChannelTriggerPattern[] = {"MTR_%3sSIDE_MT%2i_RPC%i_HV.%4s", "MTR_%2sSIDE_MT%2i_RPC%i_HV.%4s"};
69const char* AliMpDCSNamer::fgkDCSSideTriggerName[] = { "OUT", "IN" };
70const char* AliMpDCSNamer::fgkDCSMeasureName[] = { "imon", "vmon" };
71
72const char* AliMpDCSNamer::fgkDetectorName[] = { "TRACKER", "TRIGGER" };
73
74//_____________________________________________________________________________
75AliMpDCSNamer::AliMpDCSNamer():
76fDetector(-1)
77{
78 SetDetector("TRACKER");
79 /// default ctor
80}
1ef5468a 81
82//_____________________________________________________________________________
49e110ec 83AliMpDCSNamer::AliMpDCSNamer(const char* detName):
84fDetector(-1)
1ef5468a 85{
49e110ec 86 /// ctor taking the detector name as argument (either trigger or tracker)
87 SetDetector(detName);
1ef5468a 88}
89
90//_____________________________________________________________________________
49e110ec 91AliMpDCSNamer::~AliMpDCSNamer()
1ef5468a 92{
93 /// dtor
94}
95
49e110ec 96//_____________________________________________________________________________
97Bool_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//_____________________________________________________________________________
118void
49e110ec 119AliMpDCSNamer::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//_____________________________________________________________________________
153TObjArray*
49e110ec 154AliMpDCSNamer::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//_____________________________________________________________________________
214Int_t
49e110ec 215AliMpDCSNamer::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//_____________________________________________________________________________
277Int_t
49e110ec 278AliMpDCSNamer::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 {
295 case AliMp::kStation1:
296 case AliMp::kStation2:
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//_____________________________________________________________________________
375const 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 {
391 case AliMp::kStation1:
392 case AliMp::kStation2:
49e110ec 393 return Form(fgkDCSChannelSt12Pattern[side],chamberId,dcsNumber,sector);
1ef5468a 394 break;
395 case AliMp::kStation345:
49e110ec 396 return Form(fgkDCSChannelSt345Pattern[side],chamberId,dcsNumber);
397 break;
398 case AliMp::kStationTrigger:
399 return Form(fgkDCSChannelTriggerPattern[side],fgkDCSSideTriggerName[side],chId,dcsNumber,fgkDCSMeasureName[dcsMeasure]);
1ef5468a 400 break;
401 default:
402 return 0x0;
403 break;
404 }
405}
406
407//_____________________________________________________________________________
408const char*
49e110ec 409AliMpDCSNamer::DCSSwitchName(Int_t detElemId, Int_t pcbNumber) const
1ef5468a 410{
49e110ec 411 /// Return the alias name of the DCS Switch for a given PCB
1ef5468a 412 /// within a slat of St345
413
414 if (AliMpDEManager::GetStationType(detElemId) == AliMp::kStation345)
415 {
49e110ec 416 return Form(fgkDCSSwitchSt345Pattern,detElemId,pcbNumber);
1ef5468a 417 }
418 return 0x0;
419}
420
82c70ae8 421//_____________________________________________________________________________
422Int_t
49e110ec 423AliMpDCSNamer::DCSIndexFromDCSAlias(const char* dcsAlias) const
82c70ae8 424{
425 /// Converts the dcs alias to a hv index
426 ///
427 /// dcsAlias has one of the following 3 forms :
428 ///
429 /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Slat##.actual.vMon
430 ///
431 /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Quad#Sect#.actual.vMon
432 ///
433 /// MchDE####dsw#.inValue
434
435 TString sDcsAlias(dcsAlias);
436 Int_t de(-1);
437 Int_t sw(-1);
438
439 int side(-1);
440
441 if ( sDcsAlias.Contains("Left") )
442 {
443 side = 0;
444 }
445 else if ( sDcsAlias.Contains("Right") )
446 {
447 side = 1;
448 }
449 else
450 {
451 /// it's a switch
49e110ec 452 sscanf(sDcsAlias.Data(),fgkDCSSwitchSt345Pattern,&de,&sw);
82c70ae8 453 return sw;
454 }
455
456 int n1(-1);
457 int n3(-1);
458 int n4(-1);
459
460 if ( sDcsAlias.Contains("Quad") )
461 {
49e110ec 462 sscanf(sDcsAlias.Data(),fgkDCSChannelSt12Pattern[side],&n1,&n3,&n4);
82c70ae8 463 return n4;
464 }
465
466 return -2;
467}
468
1ef5468a 469//_____________________________________________________________________________
470Int_t
49e110ec 471AliMpDCSNamer::DetElemIdFromDCSAlias(const char* dcsAlias) const
1ef5468a 472{
473 /// Converts the dcs alias to a detection element identifier
474 ///
49e110ec 475 /// dcsAlias has one of the following forms :
1ef5468a 476 ///
477 /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Slat##.actual.vMon
478 ///
479 /// MchHvLv[Left|Right]/Chamber##[Left|Right]/Chamber##[Left|Right]Quad#Sect#.actual.vMon
49e110ec 480 ///
481 /// MTR_Side[OUTSIDE|INSIDE]_MTChamber##_RPC#_HV_Type[imon|vmon]
1ef5468a 482
82c70ae8 483 AliDebug(1,Form("dcsAlias=%s",dcsAlias));
484
1ef5468a 485 TString sDcsAlias(dcsAlias);
486
487 int side(-1);
49e110ec 488
489 const char** sideName = (fDetector == kTriggerDet) ? fgkDCSSideTriggerName : fgkDCSSideTrackerName;
490
491 for(Int_t iside=0; iside<2; iside++){
492 if ( sDcsAlias.Contains(sideName[iside]) ) {
493 side = iside;
494 break;
495 }
1ef5468a 496 }
49e110ec 497 if(side<0) return -2;
1ef5468a 498
499 int n1(-1);
500 int n3(-1);
501 int n4(-1);
49e110ec 502 char type[10];
503 char cside[4];
1ef5468a 504 int detElemId(-1);
505
506 if ( sDcsAlias.Contains("Slat") )
507 {
49e110ec 508 sscanf(sDcsAlias.Data(),fgkDCSChannelSt345Pattern[side],&n1,&n3);
1ef5468a 509 detElemId = DCS2DE(n1,side,n3);
82c70ae8 510 AliDebug(1,Form("Slat side=%d n1=%d n3=%d de=%d",side,n1,n3,detElemId));
1ef5468a 511 }
512 else if ( sDcsAlias.Contains("Quad") )
513 {
49e110ec 514 sscanf(sDcsAlias.Data(),fgkDCSChannelSt12Pattern[side],&n1,&n3,&n4);
82c70ae8 515 detElemId = 100*(n1+1) + n3;
516 AliDebug(1,Form("Quad side=%d n1=%d n3=%d n4=%d de=%d",side,n1,n3,n4,detElemId));
1ef5468a 517 }
49e110ec 518 else if ( sDcsAlias.Contains("MT") )
519 {
520 sscanf(sDcsAlias.Data(),fgkDCSChannelTriggerPattern[side],cside,&n1,&n3,type);
521 detElemId = DCS2DE(n1,side,n3);
522 AliDebug(1,Form("Slat side=%d n1=%d n3=%d de=%d",side,n1,n3,detElemId));
523 }
1ef5468a 524 else
525 {
526 return -3;
527 }
528
529 if ( !AliMpDEManager::IsValidDetElemId(detElemId) )
530 {
531 AliError(Form("Invalid aliasName %s",dcsAlias));
532 return -1;
533 }
534
535 return detElemId;
536}
537
49e110ec 538//_____________________________________________________________________________
539Int_t AliMpDCSNamer::DCSvariableFromDCSAlias(const char* dcsAlias) const
540{
541 /// Get DCS variable from an alias (trigger)
542
543 TString sDcsAlias(dcsAlias);
544
545 Int_t dcsMeasurement = -1;
546
547 for(Int_t iMeas=0; iMeas<kNDCSMeas; iMeas++){
548 if ( sDcsAlias.Contains(fgkDCSMeasureName[iMeas]) ) {
549 dcsMeasurement = iMeas;
550 break;
551 }
552 }
553
554 return dcsMeasurement;
555}
556
557
1ef5468a 558//_____________________________________________________________________________
559TObjArray*
49e110ec 560AliMpDCSNamer::GenerateAliases() const
1ef5468a 561{
562 /// Generate DCS alias names, for MUON Tracker High Voltage system.
49e110ec 563 /// or for MUON Trigger HV and current system.
1ef5468a 564 ///
49e110ec 565 /// We first generate aliases of DCS channels :
1ef5468a 566 ///
567 /// St 1 ch 1 : 12 channels
568 /// ch 2 : 12 channels
569 /// St 2 ch 3 : 12 channels
570 /// ch 4 : 12 channels
571 /// St 3 ch 5 : 18 channels
572 /// ch 6 : 18 channels
573 /// St 4 ch 7 : 26 channels
574 /// ch 8 : 26 channels
575 /// St 5 ch 9 : 26 channels
576 /// ch 10 : 26 channels
577 ///
49e110ec 578 /// then aliases of DCS switches (only for St345) : 1 switch per PCB.
1ef5468a 579 ///
580 /// Returns a TObjArray of TObjString(=alias name)
581
582 TObjArray* aliases = new TObjArray;
583 aliases->SetOwner(kTRUE);
49e110ec 584
585 Int_t nMeasures = (fDetector == kTriggerDet) ? kNDCSMeas : 1;
1ef5468a 586
49e110ec 587 for(Int_t iMeas=0; iMeas<nMeasures; iMeas++){
588
589 AliMpDEIterator it;
1ef5468a 590
49e110ec 591 it.First();
1ef5468a 592
49e110ec 593 while (!it.IsDone())
1ef5468a 594 {
49e110ec 595 Int_t detElemId = it.CurrentDEId();
596 switch (fDetector){
597 case kTrackerDet:
598 {
599 switch ( AliMpDEManager::GetStationType(detElemId) )
600 {
601 case AliMp::kStation1:
602 case AliMp::kStation2:
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//_____________________________________________________________________________
642Int_t
49e110ec 643AliMpDCSNamer::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 }
652 else if ( stationType == AliMp::kStation1 || stationType == AliMp::kStation2 )
653 {
654 return ManuId2Sector(detElemId,manuId);
655 }
656 return -1;
657}
658
659//_____________________________________________________________________________
660Int_t
49e110ec 661AliMpDCSNamer::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
666 AliCodeTimerAuto("")
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//_____________________________________________________________________________
676Int_t
49e110ec 677AliMpDCSNamer::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
681 AliCodeTimerAuto("")
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
690 TVector2 lowerLeft(motifPos->Position()-motifPos->Dimensions());
691
82c70ae8 692 Double_t x = lowerLeft.X()*10.0; // cm -> mm
1ef5468a 693 Int_t isector(-1);
694
695 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
696
697 if ( stationType == AliMp::kStation1 )
698 {
82c70ae8 699 if ( x < -10 ) AliFatal("");
1ef5468a 700
701 if ( x < 291.65 ) isector = 0;
702 else if ( x < 585.65 ) isector = 1;
703 else if ( x < 879.65 ) isector = 2;
704 }
705 else
706 {
82c70ae8 707 if ( x < -140 ) AliFatal("");
1ef5468a 708
709 if ( x < 283.75 ) isector = 0;
710 else if ( x < 603.75 ) isector = 1;
711 else if ( x < 1158.75 ) isector = 2;
712 }
713
714 return isector;
715}
716
717//_____________________________________________________________________________
718Int_t
49e110ec 719AliMpDCSNamer::NumberOfPCBs(Int_t detElemId) const
1ef5468a 720{
721 /// Returns the number of PCB in a given detection element
722 /// Only works for St345
723
724 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
725 if ( stationType != AliMp::kStation345 )
726 {
727 return 0;
728 }
729 else
730 {
f3ed9a44 731 const AliMpSlat* slat
732 = AliMpSegmentation::Instance()->GetSlat(detElemId, AliMp::kCath0);
1ef5468a 733 return slat->GetSize();
734 }
735}
49e110ec 736
737//_____________________________________________________________________________
738Bool_t AliMpDCSNamer::CheckConsistency(Int_t detElemId) const
739{
740 //
741 /// Check that the required detElemId either belongs to tracker or trigger
742 /// consistently with the initial definition of the namer
743 //
744
745 Bool_t isConsistent(kFALSE);
746 TString requestInfo;
747 switch(AliMpDEManager::GetStationType(detElemId))
748 {
749 case AliMp::kStation1:
750 case AliMp::kStation2:
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}