1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-------------------------------------------------------------------------
19 // Authors: Christian.Lippmann@cern.ch, J.Wiechula@gsi.de
20 // Class to map detector coordinates (row, pad, sector, ...) to
21 // hardware coordinates (RCU, Branch, FEC, Altro, channel, Equipment ID, ...)
23 // There are two different ways to number padrows:
24 // 1) local padrow: for each ROC, 0 ... 62 for an IROC, 0 ... 95 for an OROC,
25 // 2) global padrow: for each sector, from 0 ... 158.
26 // If the global numbering is used, it is denoted by the variable name
27 // globalpadrow in this class.
29 // There are two different ways to number sectors:
30 // 1) Sectors contain one IROC and one OROC and are counted from 0 to 17 on
31 // each of the two sides (A=0 and C=1),
32 // 2) ROCs are numbered from 0 to 71 where the ROCs 0 ... 35 are IROCS and
33 // ROCs 36 ... 71 are OROCs. A ROC is often named "sector" in aliroot,
34 // which can be very confusing!
36 //-------------------------------------------------------------------------
42 #include "AliTPCmapper.h"
43 #include "AliTPCAltroMapping.h"
44 #include "AliTPCROC.h"
48 ClassImp(AliTPCmapper)
49 //______________________________________________________________
50 AliTPCmapper::AliTPCmapper() :
65 for ( Int_t i = 0; i < 6; i++ ) fMapping[i]=0;
68 //______________________________________________________________
69 AliTPCmapper::AliTPCmapper(const char * dirname) :
84 // dirname - specify the directory with the ascii Altro mapping files
89 //______________________________________________________________
90 AliTPCmapper::~AliTPCmapper()
94 for ( Int_t i = 0; i < fNrcu; i++ ) {
101 //_____________________________________________________________________________
102 AliTPCmapper::AliTPCmapper(const AliTPCmapper& mapper) :
104 fNside(mapper.fNside),
105 fNsector(mapper.fNsector),
107 fNbranch(mapper.fNbranch),
108 fNaltro(mapper.fNaltro),
109 fNchannel(mapper.fNchannel),
110 fNpadrow(mapper.fNpadrow),
111 fNpadrowIROC(mapper.fNpadrowIROC),
112 fNpadrowOROC(mapper.fNpadrowOROC),
113 fTpcDdlOffset(mapper.fTpcDdlOffset)
116 for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
119 //_____________________________________________________________________________
120 AliTPCmapper& AliTPCmapper::operator = (const AliTPCmapper& mapper)
122 // Assignment operator
124 if(&mapper == this) return *this;
125 ((TObject *)this)->operator=(mapper);
127 for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
129 fNside = mapper.fNside;
130 fNsector = mapper.fNsector;
131 fNrcu = mapper.fNrcu;
132 fNbranch = mapper.fNbranch;
133 fNaltro = mapper.fNaltro;
134 fNchannel = mapper.fNchannel;
135 fNpadrow = mapper.fNpadrow;
136 fNpadrowIROC = mapper.fNpadrowIROC;
137 fNpadrowOROC = mapper.fNpadrowOROC;
138 fTpcDdlOffset = mapper.fTpcDdlOffset;
143 //______________________________________________________________
144 void AliTPCmapper::Init(const char *dirname)
154 // Load and read mapping files. AliTPCAltroMapping contains the mapping for
158 path =gSystem->Getenv("ALICE_ROOT");
159 path += "/TPC/mapping/Patch";
166 for(Int_t i = 0; i < fNrcu; i++) {
170 fMapping[i] = new AliTPCAltroMapping(path2.Data());
173 // Create instance of AliTPCROC object
174 AliTPCROC *fROC = AliTPCROC::Instance();
175 fNpadrowIROC = fROC->GetNRows(0);
176 fNpadrowOROC = fROC->GetNRows(36);
177 fNpadrow = fNpadrowIROC+fNpadrowOROC;
180 fTpcDdlOffset = daq.DdlIDOffset("TPC");
185 //_____________________________________________________________________________
186 Int_t AliTPCmapper::GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
188 // Get the hardware address from pad coordinates for a given ROC
189 Int_t patch = GetPatch(roc, padrow, pad);
190 if ( (patch >= fNrcu) || (patch < 0) ) return -1;
191 return fMapping[patch]->GetHWAddress(padrow, pad, roc);
195 //_____________________________________________________________________________
196 Int_t AliTPCmapper::GetHWAddressSector(Int_t globalpadrow, Int_t pad) const
198 // Get the hardware address from pad coordinates
200 if ( globalpadrow < fNpadrowIROC ) {
201 patch = GetPatch(0, globalpadrow, pad);
202 return fMapping[patch]->GetHWAddress(globalpadrow, pad, 0);
203 } else if ( globalpadrow < fNpadrow ) {
204 patch = GetPatch(36, globalpadrow - fNpadrowIROC, pad);
205 return fMapping[patch]->GetHWAddress(globalpadrow - fNpadrowIROC,
208 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
214 //_____________________________________________________________________________
215 Int_t AliTPCmapper::GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
217 // Get the patch (rcu) index from the pad coordinates. The Roc index is
218 // needed as well to determine if it is IROC or OROC.
219 return GetPatch(roc, padrow, pad);
223 //_____________________________________________________________________________
224 Int_t AliTPCmapper::GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
226 // Get the patch (rcu) index from the pad coordinates. The Roc index is
227 // needed as well to determine if it is IROC or OROC.
229 if ( (padrow < 0) || (pad < 0) || (roc < 0) ) {
230 AliWarning(Form("Pad coordinates outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
236 Int_t padsInRow = GetNpads(padrow);
237 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
238 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
241 if ( padrow < 30 ) { return 0;
242 } else if ( padrow == 30 ) { // padrow 30 is shared between rcus 0 and 1
243 if ( (pad < 37) || (pad > 48) ) return 1;
245 } else if ( padrow < fNpadrowIROC ) { return 1;
247 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
250 } else if ( roc < 72 ) {
252 Int_t padsInRow = GetNpads(fNpadrowIROC+padrow);
253 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
254 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
257 if ( padrow < 27 ) { return 2;
258 } else if ( padrow == 27 ) { // padrow 27 is shared between rcus 2 and 3
259 if ( (pad >= 43) && (pad <= 46) ) return 3;
261 } else if ( padrow < 54 ) { return 3;
262 } else if ( padrow < 76 ) { return 4;
263 } else if ( padrow == 76) { // padrow 76 is shared between rcus 4 and 5
264 if ( (pad >= 33) && (pad <= 88) ) return 5;
266 } else if ( padrow < fNpadrowOROC ) { return 5;
268 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
276 //_____________________________________________________________________________
277 Int_t AliTPCmapper::GetRcuSector(Int_t globalpadrow, Int_t pad) const
279 // Get the patch (rcu) index from the pad coordinates for a sector
280 return GetPatchSector(globalpadrow, pad);
284 //_____________________________________________________________________________
285 Int_t AliTPCmapper::GetPatchSector(Int_t globalpadrow, Int_t pad) const
287 // Get the patch (rcu) index from the pad coordinates for a sector
288 if ( globalpadrow >= fNpadrow ) {
289 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
292 if ( globalpadrow < fNpadrowIROC ) return GetPatch(0, globalpadrow, pad);
293 else return GetPatch(36, globalpadrow-fNpadrowIROC, pad);
297 //_____________________________________________________________________________
298 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t hwAddress) const
300 // Get Pad Row (for a ROC) from the hardware address
301 if ( (patch >= fNrcu) || (patch < 0) ) {
302 AliWarning(Form("Patch index outside range (patch %d) !", patch));
305 return fMapping[patch]->GetPadRow(hwAddress);
309 //_____________________________________________________________________________
310 Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
312 // Get Pad Row (for full sector) from the hardware address
313 if ( patch < 2 ) return GetPadRow(patch, hwAddress);
314 else return GetPadRow(patch, hwAddress) + fNpadrowIROC;
318 //_____________________________________________________________________________
319 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t hwAddress) const
321 // Get Pad index from the hardware address
322 if ( (patch >= fNrcu) || (patch < 0) ) {
323 AliWarning(Form("Patch index outside range (patch %d) !", patch));
326 return fMapping[patch]->GetPad(hwAddress);
330 //_____________________________________________________________________________
331 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
334 // Get pad row (for a ROC) from hardware coordinates
335 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
336 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
337 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
338 patch, branch, fec, chip, channel));
341 return GetPadRow(patch, CodeHWAddress(branch, fec, chip, channel));
345 //_____________________________________________________________________________
346 Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
349 // Get Pad Row (for full sector) from the hardware address
350 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
351 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
352 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
353 patch, branch, fec, chip, channel));
356 if ( patch < 2 ) return GetPadRow(patch, branch, fec, chip, channel);
357 else return GetPadRow(patch, branch, fec, chip, channel) + fNpadrowIROC;
361 //_____________________________________________________________________________
362 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
364 // Get pad from hardware coordinates
365 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
366 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
367 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
368 patch, branch, fec, chip, channel));
371 return GetPad(patch, CodeHWAddress(branch, fec, chip, channel));
375 //_____________________________________________________________________________
376 Int_t AliTPCmapper::GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
378 // Get the branch to which this pad is connected. The FECs connected to
379 // one RCU are divided into two branches: A(=0) and B(=1). This information
380 // can be extracted from the hardware address.
381 return DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
385 //_____________________________________________________________________________
386 Int_t AliTPCmapper::GetBranchSector(Int_t globalpadrow, Int_t pad) const
388 // Get Branch from pad coordinates, where globalpadrow is counted
389 // for a full sector (0 ... 158)
390 return DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
394 //_____________________________________________________________________________
395 Int_t AliTPCmapper::GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
397 // Get the FEC number in hardware numbering. The FECs are numbered from 0 (in the
398 // center of the partition) to 8 (partition 3, 4, 5), 9 (partition 0, 2), 11
399 // (partition 1, branch A) or 12 (partition 1, branch B). This information
400 // can be extracted from the hardware address.
401 return DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
405 //_____________________________________________________________________________
406 Int_t AliTPCmapper::GetFEChwSector(Int_t globalpadrow, Int_t pad) const
408 // Get the FEC number in hardware numbering from pad coordinates, where
409 // globalpadrow is counted for a full sector (0 ... 158)
410 return DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
414 //_____________________________________________________________________________
415 Int_t AliTPCmapper::GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
417 // Get the FEC number in offline-oriented numbering. The FECs are numbered from 0
418 // 17 (partition 3, 4, 5), 19 (partition 0, 2) or 24 (partition 1).
419 Int_t patch = GetPatch(roc, padrow, pad);
420 Int_t fec = DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
421 Int_t branch = DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
422 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
423 return HwToOffline(patch, branch, fec);
427 //_____________________________________________________________________________
428 Int_t AliTPCmapper::GetFECSector(Int_t globalpadrow, Int_t pad) const
430 // Get the FEC number in offline-oriented numbering. globalpadrow is
431 // counted for a full sector (0 ... 158)
432 Int_t patch = GetPatchSector(globalpadrow, pad);
433 Int_t fec = DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
434 Int_t branch = DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
435 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
436 return HwToOffline(patch, branch, fec);
440 //_____________________________________________________________________________
441 Int_t AliTPCmapper::GetChip(Int_t roc, Int_t padrow, Int_t pad) const
443 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates
444 return DecodedHWAddressChipaddr(GetHWAddress(roc, padrow, pad));
448 //_____________________________________________________________________________
449 Int_t AliTPCmapper::GetChipSector(Int_t globalpadrow, Int_t pad) const
451 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates, where
452 // globalpadrow is counted for a full sector (0 ... 158)
453 return DecodedHWAddressChipaddr(GetHWAddressSector(globalpadrow, pad));
457 //_____________________________________________________________________________
458 Int_t AliTPCmapper::GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
460 // Get Channel index (0 ... 15) from pad coordinates
461 return DecodedHWAddressChanneladdr(GetHWAddress(roc, padrow, pad));
465 //_____________________________________________________________________________
466 Int_t AliTPCmapper::GetChannelSector(Int_t globalpadrow, Int_t pad) const
468 // Get Channel index (0 ... 15) from pad coordinates, where
469 // globalpadrow is counted for a full sector (0 ... 158)
470 return DecodedHWAddressChanneladdr(GetHWAddressSector(globalpadrow, pad));
474 //_____________________________________________________________________________
475 Int_t AliTPCmapper::CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
477 // Get Hardware address from channel, altro, fec and branch coordinates
478 return ((branch&1)<<11) + ((fec&0xf)<<7) + ((chip&0x7)<<4) + (channel&0xf);
482 //_____________________________________________________________________________
483 Int_t AliTPCmapper::DecodedHWAddressBranch(Int_t hwAddress) const
485 // Get branch index (0, 1) from hardware address
486 if ( hwAddress < 0 ) return -1;
487 return ((hwAddress>>11)&1);
491 //_____________________________________________________________________________
492 Int_t AliTPCmapper::DecodedHWAddressFECaddr(Int_t hwAddress) const
494 // Get FEC index (0 ... 12) from hardware address
495 if ( hwAddress < 0 ) return -1;
496 return ((hwAddress>>7)&0xf);
500 //_____________________________________________________________________________
501 Int_t AliTPCmapper::DecodedHWAddressChipaddr(Int_t hwAddress) const
503 // Get ALTRO index (0 ... 7) from hardware address
504 if ( hwAddress < 0 ) return -1;
505 return ((hwAddress>>4)&0x7);
509 //_____________________________________________________________________________
510 Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
512 // Get channel index (0 ... 15) from hardware address
513 if ( hwAddress < 0 ) return -1;
514 return ((hwAddress&0xf));
518 //______________________________________________________________
519 Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
520 // Get number of pads in padrow for this ROC.
521 AliTPCROC *fROC = AliTPCROC::Instance();
522 Int_t retval = fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
527 //______________________________________________________________
528 Int_t AliTPCmapper::GetNpads(Int_t globalpadrow) const{
529 // Get number of pads in padrow, where globalpadrow is counted for a full sector (0 ... 158)
531 if ( globalpadrow >= fNpadrow ) {
532 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
535 if ( globalpadrow < fNpadrowIROC ) return GetNpads(0, globalpadrow); // IROC
536 else return GetNpads(36, globalpadrow - fNpadrowIROC); // OROC
542 //______________________________________________________________
543 Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
545 // Get number of padrows
546 if (roc < 36) return fNpadrowIROC;
547 else if (roc < 72) return fNpadrowOROC;
552 //______________________________________________________________
554 Double_t AliTPCmapper::GetPadXlocal(Int_t globalpadrow) const
556 // Get local x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
558 if ( globalpadrow >= fNpadrow ) {
559 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
564 if ( globalpadrow < fNpadrowIROC )
565 return (852.25 + 7.5*(Double_t)globalpadrow)/10.; //divide by 10 to get cm
567 globalpadrow -= fNpadrowIROC;
569 if ( globalpadrow < 64 ) //OROC inner part
570 return (10.* globalpadrow + 1351.)/10.; //divide by 10 to get cm
573 return (15.*(globalpadrow - 64) + 1993.5)/10.; //divide by 10 to get cm
577 //______________________________________________________________
579 Double_t AliTPCmapper::GetPadYlocal(Int_t globalpadrow, Int_t pad) const
581 // Get local y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
583 if ( globalpadrow >= fNpadrow ) {
584 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
588 Int_t padsInRow = GetNpads(globalpadrow);
589 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
590 AliWarning(Form("Pad index outside range (pad %d) !", pad));
595 if ( globalpadrow < fNpadrowIROC )
596 return (2.* padsInRow - 4.*pad - 2.)*1.e-1; //divide by 10 to get cm
599 return (3.* padsInRow -6.*pad - 3.)*1.e-1; //divide by 10 to get cm
603 //______________________________________________________________
605 Double_t AliTPCmapper::GetPadXglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const
607 // Get global x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
609 if ( globalpadrow >= fNpadrow ) {
610 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
614 Int_t padsInRow = GetNpads(globalpadrow);
615 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
616 AliWarning(Form("Pad index outside range (pad %d) !", pad));
620 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
621 return GetPadXlocal(globalpadrow) * TMath::Cos(angle) -
622 GetPadYlocal(globalpadrow, pad) * TMath::Sin(angle);
626 //______________________________________________________________
628 Double_t AliTPCmapper::GetPadYglobal(Int_t globalpadrow, Int_t pad,Int_t sector) const
630 // Get global y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
632 if ( globalpadrow >= fNpadrow ) {
633 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
637 Int_t padsInRow = GetNpads(globalpadrow);
638 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
639 AliWarning(Form("Pad index outside range (pad %d) !", pad));
643 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
644 return GetPadXlocal(globalpadrow) * TMath::Sin(angle) +
645 GetPadYlocal(globalpadrow, pad) * TMath::Cos(angle);
649 //______________________________________________________________
651 Double_t AliTPCmapper::GetPadWidth(Int_t globalpadrow) const
653 // Get pad width, where globalpadrow is counted for a full sector (0 ... 158)
655 if ( globalpadrow >= fNpadrow ) {
656 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
660 if (globalpadrow < fNpadrowIROC ) // IROC
666 //______________________________________________________________
668 Double_t AliTPCmapper::GetPadLength(Int_t globalpadrow) const
670 // Get pad length, where globalpadrow is counted for a full sector (0 ... 158)
672 if ( globalpadrow >= fNpadrow ) {
673 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
677 if ( globalpadrow < fNpadrowIROC ) return 0.75;
678 if ( globalpadrow < 127 ) return 1.0;
683 //_____________________________________________________________________________
684 Int_t AliTPCmapper::GetNfec(Int_t patch) const
686 // Get size of readout partition (number of FECs) for this rcu (patch) index (0 ... 5)
712 //_____________________________________________________________________________
713 Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
715 // Get size of readout partition (number of FECs) for this branch
738 if( (branch == 1) && (patch == 1) ){
746 //_____________________________________________________________________________
747 Int_t AliTPCmapper::OfflineToHwFec(Int_t patch, Int_t fec) const
749 // Convert FEC position in offline-like numbering to hardware numbering (fec).
751 if ( (patch < 0) || (fec < 0) ) {
752 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
755 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
756 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
760 Int_t fecsInBranchA = GetNfec(patch, 0);
761 if ( fec < fecsInBranchA ) // branch A
762 return (fecsInBranchA - 1 - fec);
764 return (fec - fecsInBranchA);
770 //_____________________________________________________________________________
771 Int_t AliTPCmapper::OfflineToHwBranch(Int_t patch, Int_t fec) const
773 // Convert fec position in offline-like numbering to hardware numbering (branch).
775 if ( (patch < 0) || (fec < 0) ) {
776 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
779 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
780 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
783 if ( fec < GetNfec(patch, 0) ) return 0; // branch A
784 else return 1; // branch B
790 //_____________________________________________________________________________
791 Int_t AliTPCmapper::HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
793 // Convert hardware FEC position (branch, fec) to the offline-oriented numbering
795 if ( (patch < 0) || (fec < 0) || (branch < 0) ) {
796 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
799 if ( (patch > 5) || (branch > 1) || (fec >= GetNfec(patch, branch)) ) {
800 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
803 Int_t fecsInBranchA = GetNfec(patch, 0);
804 if ( branch == 0 ) // branch A
805 return (fecsInBranchA - 1 - fec);
807 return (fec + fecsInBranchA);
813 //_____________________________________________________________________________
814 Int_t AliTPCmapper::GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
816 // Get EqID from pad coordinate. The Roc index is
817 // needed as well to determine if it is IROC or OROC.
819 Int_t side = GetSideFromRoc(roc);
820 if ( side < 0 ) return -1;
821 Int_t sector = GetSectorFromRoc(roc);
822 if ( sector < 0 ) return -1;
823 Int_t patch = GetPatch(roc, padrow, pad);
824 if ( patch < 0 ) return -1;
825 return GetEquipmentIDfromPatch(side, sector, patch);
829 //_____________________________________________________________________________
830 Int_t AliTPCmapper::GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
832 // Get EqID from pad coordinate, where padrow is counted for a full sector (0 ... 158)
833 Int_t patch = GetPatchSector(globalpadrow, pad);
834 if ( patch < 0 ) return -1;
835 Int_t roc = GetRocFromPatch(side, sector, patch);
836 if ( roc < 0 ) return -1;
838 if ( globalpadrow < fNpadrowIROC )
839 return GetEquipmentID(roc, globalpadrow, pad);
841 return GetEquipmentID(roc, globalpadrow-fNpadrowIROC, pad);
845 //_____________________________________________________________________________
846 Int_t AliTPCmapper::GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
848 // Get EqID from patch (rcu).
850 Int_t roc = GetRocFromPatch(side, sector, patch);
852 if (patch < 2) // IROC
855 ddl = (roc-36)*4 + 36*2 + (patch-2);
856 // Add offset. TPC has detectorID = 3
857 return ddl+fTpcDdlOffset;
861 //_____________________________________________________________________________
862 Int_t AliTPCmapper::GetPatchFromEquipmentID(Int_t equipmentID) const
864 // Get rcu (patch) index (0 ... 5) from equipment ID
867 if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
868 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
871 if ( ( (int)equipmentID - 840 ) < 0) retval = (equipmentID-768)%2;
872 else retval = (equipmentID-840)%4 + 2;
877 //_____________________________________________________________________________
878 Int_t AliTPCmapper::GetSideFromEquipmentID(Int_t equipmentID) const
880 // Get side from Eq ID
881 if ( equipmentID < fTpcDdlOffset ) {
882 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
885 if ( equipmentID < 804 ) return 0;
886 else if ( equipmentID < 840 ) return 1;
887 else if ( equipmentID < 912 ) return 0;
888 else if ( equipmentID < 984 ) return 1;
890 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
896 //_____________________________________________________________________________
897 Int_t AliTPCmapper::GetSectorFromEquipmentID(Int_t equipmentID) const
899 // Get sector index (0 ... 17) from equipment ID
902 if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
903 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
906 if ( (equipmentID - 840) < 0 ) retval = (equipmentID-768)/2;
907 else retval = (equipmentID-840)/4;
912 //_____________________________________________________________________________
913 Int_t AliTPCmapper::GetRocFromEquipmentID(Int_t equipmentID) const
915 // Get ROC index (0 ... 71) from equipment ID
916 Int_t side = GetSideFromEquipmentID(equipmentID);
917 if ( side < 0 ) return -1;
918 Int_t sector = GetSectorFromEquipmentID(equipmentID);
919 if ( sector < 0 ) return -1;
920 Int_t patch = GetPatchFromEquipmentID(equipmentID);
921 if ( patch < 0 ) return -1;
923 return GetRocFromPatch(side, sector, patch);
927 //_____________________________________________________________________________
928 Int_t AliTPCmapper::GetSectorFromRoc(Int_t roc) const
930 // get the sector number (0 ... 17) from the roc number (0 ... 71)
933 AliWarning(Form("Roc outside range (roc %d) !", roc));
935 } else if ( roc < 18 ) { // inner sector, A side
937 } else if ( roc < 36 ) { // inner sector, C side
939 } else if ( roc < 54 ) { // outer sector, A side
941 } else if ( roc < 72 ) { // outer sector, C side
944 AliWarning(Form("Roc outside range (roc %d) !", roc));
950 //_____________________________________________________________________________
951 Int_t AliTPCmapper::GetSideFromRoc(Int_t roc) const
953 // get the side (0, 1) from the roc number (0 ... 71)
956 AliWarning(Form("Roc outside range (roc %d) !", roc));
958 } else if ( roc < 18 ) { // inner sector, A side
960 } else if ( roc < 36 ) { // inner sector, C side
962 } else if ( roc < 54 ) { // outer sector, A side
964 } else if ( roc < 72 ) { // outer sector, C side
967 AliWarning(Form("Roc outside range (roc %d) !", roc));
973 //_____________________________________________________________________________
974 Int_t AliTPCmapper::GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
976 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and patch (0 ... 5)
978 if ( (side < 0) || (side >= fNside) ) {
979 AliWarning(Form("Side outside range (side %d) !", side));
982 if ( (sector < 0) || (sector >= fNsector) ) {
983 AliWarning(Form("Sector outside range (sector %d) !", sector));
986 if ( (patch < 0) || (patch >= fNrcu) ) {
987 AliWarning(Form("Patch (rcu) outside range (patch %d) !", patch));
991 if ( side == 0 ) { // A side
992 if ( patch < 2 ) return sector; // IROC
993 else return 36+sector; // OROC
995 if ( patch < 2 ) return 18+(17-sector); // IROC
996 else return 54+(17-sector); // OROC
1001 //_____________________________________________________________________________
1002 Int_t AliTPCmapper::GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
1004 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and pad coordinates
1006 Int_t patch = GetPatchSector(globalpadrow, pad);
1007 if ( patch < 0 ) return -1;
1008 return GetRocFromPatch(side, sector, patch);
1012 //_____________________________________________________________________________
1013 Bool_t AliTPCmapper::IsIROC(Int_t roc) const
1015 // Is this ROC an IROC?
1017 AliWarning(Form("Roc outside range (roc %d) !", roc));
1019 } else if ( roc < 36 ) { // inner sector
1021 } else if ( roc < 72 ) { // outer sector, C side
1024 AliWarning(Form("Roc outside range (roc %d) !", roc));
1030 //_____________________________________________________________________________
1031 Bool_t AliTPCmapper::IsOROC(Int_t roc) const
1033 // Is this ROC an OROC?
1035 AliWarning(Form("Roc outside range (roc %d) !", roc));
1037 } else if ( roc < 36 ) { // inner sector
1039 } else if ( roc < 72 ) { // outer sector, C side
1042 AliWarning(Form("Roc outside range (roc %d) !", roc));