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)
50 //______________________________________________________________
51 AliTPCmapper::AliTPCmapper() :
68 //______________________________________________________________
69 AliTPCmapper::~AliTPCmapper()
75 for ( Int_t i = 0; i < fNrcu; i++ ) {
82 //_____________________________________________________________________________
83 AliTPCmapper::AliTPCmapper(const AliTPCmapper& mapper) :
85 fNside(mapper.fNside),
86 fNsector(mapper.fNsector),
88 fNbranch(mapper.fNbranch),
89 fNaltro(mapper.fNaltro),
90 fNchannel(mapper.fNchannel),
91 fNpadrow(mapper.fNpadrow),
92 fNpadrowIROC(mapper.fNpadrowIROC),
93 fNpadrowOROC(mapper.fNpadrowOROC),
94 fTpcDdlOffset(mapper.fTpcDdlOffset),
98 for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
101 //_____________________________________________________________________________
102 AliTPCmapper& AliTPCmapper::operator = (const AliTPCmapper& mapper)
104 // Assignment operator
106 if(&mapper == this) return *this;
107 ((TObject *)this)->operator=(mapper);
109 for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
112 fNside = mapper.fNside;
113 fNsector = mapper.fNsector;
114 fNrcu = mapper.fNrcu;
115 fNbranch = mapper.fNbranch;
116 fNaltro = mapper.fNaltro;
117 fNchannel = mapper.fNchannel;
118 fNpadrow = mapper.fNpadrow;
119 fNpadrowIROC = mapper.fNpadrowIROC;
120 fNpadrowOROC = mapper.fNpadrowOROC;
121 fTpcDdlOffset = mapper.fTpcDdlOffset;
126 //______________________________________________________________
127 void AliTPCmapper::Init()
137 // Load and read mapping files. AliTPCAltroMapping contains the mapping for
139 TString path = gSystem->Getenv("ALICE_ROOT");
140 path += "/TPC/mapping/Patch";
142 for(Int_t i = 0; i < fNrcu; i++) {
146 fMapping[i] = new AliTPCAltroMapping(path2.Data());
149 // Create instance of AliTPCROC object
150 fROC = AliTPCROC::Instance();
152 fNpadrowIROC = fROC->GetNRows(0);
153 fNpadrowOROC = fROC->GetNRows(36);
154 fNpadrow = fNpadrowIROC+fNpadrowOROC;
157 fTpcDdlOffset = daq.DdlIDOffset("TPC");
162 //_____________________________________________________________________________
163 Int_t AliTPCmapper::GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
165 // Get the hardware address from pad coordinates for a given ROC
166 Int_t patch = GetPatch(roc, padrow, pad);
167 if ( (patch >= fNrcu) || (patch < 0) ) return -1;
168 return fMapping[patch]->GetHWAddress(padrow, pad, roc);
172 //_____________________________________________________________________________
173 Int_t AliTPCmapper::GetHWAddressSector(Int_t globalpadrow, Int_t pad) const
175 // Get the hardware address from pad coordinates
177 if ( globalpadrow < fNpadrowIROC ) {
178 patch = GetPatch(0, globalpadrow, pad);
179 return fMapping[patch]->GetHWAddress(globalpadrow, pad, 0);
180 } else if ( globalpadrow < fNpadrow ) {
181 patch = GetPatch(36, globalpadrow - fNpadrowIROC, pad);
182 return fMapping[patch]->GetHWAddress(globalpadrow - fNpadrowIROC,
185 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
191 //_____________________________________________________________________________
192 Int_t AliTPCmapper::GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
194 // Get the patch (rcu) index from the pad coordinates. The Roc index is
195 // needed as well to determine if it is IROC or OROC.
196 return GetPatch(roc, padrow, pad);
200 //_____________________________________________________________________________
201 Int_t AliTPCmapper::GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
203 // Get the patch (rcu) index from the pad coordinates. The Roc index is
204 // needed as well to determine if it is IROC or OROC.
206 if ( (padrow < 0) || (pad < 0) || (roc < 0) ) {
207 AliWarning(Form("Pad coordinates outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
213 Int_t padsInRow = GetNpads(padrow);
214 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
215 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
218 if ( padrow < 30 ) { return 0;
219 } else if ( padrow == 30 ) { // padrow 30 is shared between rcus 0 and 1
220 if ( (pad < 37) || (pad > 48) ) return 1;
222 } else if ( padrow < fNpadrowIROC ) { return 1;
224 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
227 } else if ( roc < 72 ) {
229 Int_t padsInRow = GetNpads(fNpadrowIROC+padrow);
230 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
231 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
234 if ( padrow < 27 ) { return 2;
235 } else if ( padrow == 27 ) { // padrow 27 is shared between rcus 2 and 3
236 if ( (pad >= 43) && (pad <= 46) ) return 3;
238 } else if ( padrow < 54 ) { return 3;
239 } else if ( padrow < 76 ) { return 4;
240 } else if ( padrow == 76) { // padrow 76 is shared between rcus 4 and 5
241 if ( (pad >= 33) && (pad <= 88) ) return 5;
243 } else if ( padrow < fNpadrowOROC ) { return 5;
245 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
253 //_____________________________________________________________________________
254 Int_t AliTPCmapper::GetRcuSector(Int_t globalpadrow, Int_t pad) const
256 // Get the patch (rcu) index from the pad coordinates for a sector
257 return GetPatchSector(globalpadrow, pad);
261 //_____________________________________________________________________________
262 Int_t AliTPCmapper::GetPatchSector(Int_t globalpadrow, Int_t pad) const
264 // Get the patch (rcu) index from the pad coordinates for a sector
265 if ( globalpadrow >= fNpadrow ) {
266 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
269 if ( globalpadrow < fNpadrowIROC ) return GetPatch(0, globalpadrow, pad);
270 else return GetPatch(36, globalpadrow-fNpadrowIROC, pad);
274 //_____________________________________________________________________________
275 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t hwAddress) const
277 // Get Pad Row (for a ROC) from the hardware address
278 if ( (patch >= fNrcu) || (patch < 0) ) {
279 AliWarning(Form("Patch index outside range (patch %d) !", patch));
282 return fMapping[patch]->GetPadRow(hwAddress);
286 //_____________________________________________________________________________
287 Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
289 // Get Pad Row (for full sector) from the hardware address
290 if ( patch < 2 ) return GetPadRow(patch, hwAddress);
291 else return GetPadRow(patch, hwAddress) + fNpadrowIROC;
295 //_____________________________________________________________________________
296 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t hwAddress) const
298 // Get Pad index from the hardware address
299 if ( (patch >= fNrcu) || (patch < 0) ) {
300 AliWarning(Form("Patch index outside range (patch %d) !", patch));
303 return fMapping[patch]->GetPad(hwAddress);
307 //_____________________________________________________________________________
308 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
311 // Get pad row (for a ROC) from hardware coordinates
312 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
313 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
314 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
315 patch, branch, fec, chip, channel));
318 return GetPadRow(patch, CodeHWAddress(branch, fec, chip, channel));
322 //_____________________________________________________________________________
323 Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
326 // Get Pad Row (for full sector) from the hardware address
327 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
328 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
329 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
330 patch, branch, fec, chip, channel));
333 if ( patch < 2 ) return GetPadRow(patch, branch, fec, chip, channel);
334 else return GetPadRow(patch, branch, fec, chip, channel) + fNpadrowIROC;
338 //_____________________________________________________________________________
339 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
341 // Get pad from hardware coordinates
342 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
343 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
344 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
345 patch, branch, fec, chip, channel));
348 return GetPad(patch, CodeHWAddress(branch, fec, chip, channel));
352 //_____________________________________________________________________________
353 Int_t AliTPCmapper::GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
355 // Get the branch to which this pad is connected. The FECs connected to
356 // one RCU are divided into two branches: A(=0) and B(=1). This information
357 // can be extracted from the hardware address.
358 return DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
362 //_____________________________________________________________________________
363 Int_t AliTPCmapper::GetBranchSector(Int_t globalpadrow, Int_t pad) const
365 // Get Branch from pad coordinates, where globalpadrow is counted
366 // for a full sector (0 ... 158)
367 return DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
371 //_____________________________________________________________________________
372 Int_t AliTPCmapper::GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
374 // Get the FEC number in hardware numbering. The FECs are numbered from 0 (in the
375 // center of the partition) to 8 (partition 3, 4, 5), 9 (partition 0, 2), 11
376 // (partition 1, branch A) or 12 (partition 1, branch B). This information
377 // can be extracted from the hardware address.
378 return DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
382 //_____________________________________________________________________________
383 Int_t AliTPCmapper::GetFEChwSector(Int_t globalpadrow, Int_t pad) const
385 // Get the FEC number in hardware numbering from pad coordinates, where
386 // globalpadrow is counted for a full sector (0 ... 158)
387 return DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
391 //_____________________________________________________________________________
392 Int_t AliTPCmapper::GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
394 // Get the FEC number in offline-oriented numbering. The FECs are numbered from 0
395 // 17 (partition 3, 4, 5), 19 (partition 0, 2) or 24 (partition 1).
396 Int_t patch = GetPatch(roc, padrow, pad);
397 Int_t fec = DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
398 Int_t branch = DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
399 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
400 return HwToOffline(patch, branch, fec);
404 //_____________________________________________________________________________
405 Int_t AliTPCmapper::GetFECSector(Int_t globalpadrow, Int_t pad) const
407 // Get the FEC number in offline-oriented numbering. globalpadrow is
408 // counted for a full sector (0 ... 158)
409 Int_t patch = GetPatchSector(globalpadrow, pad);
410 Int_t fec = DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
411 Int_t branch = DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
412 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
413 return HwToOffline(patch, branch, fec);
417 //_____________________________________________________________________________
418 Int_t AliTPCmapper::GetChip(Int_t roc, Int_t padrow, Int_t pad) const
420 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates
421 return DecodedHWAddressChipaddr(GetHWAddress(roc, padrow, pad));
425 //_____________________________________________________________________________
426 Int_t AliTPCmapper::GetChipSector(Int_t globalpadrow, Int_t pad) const
428 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates, where
429 // globalpadrow is counted for a full sector (0 ... 158)
430 return DecodedHWAddressChipaddr(GetHWAddressSector(globalpadrow, pad));
434 //_____________________________________________________________________________
435 Int_t AliTPCmapper::GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
437 // Get Channel index (0 ... 15) from pad coordinates
438 return DecodedHWAddressChanneladdr(GetHWAddress(roc, padrow, pad));
442 //_____________________________________________________________________________
443 Int_t AliTPCmapper::GetChannelSector(Int_t globalpadrow, Int_t pad) const
445 // Get Channel index (0 ... 15) from pad coordinates, where
446 // globalpadrow is counted for a full sector (0 ... 158)
447 return DecodedHWAddressChanneladdr(GetHWAddressSector(globalpadrow, pad));
451 //_____________________________________________________________________________
452 Int_t AliTPCmapper::CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
454 // Get Hardware address from channel, altro, fec and branch coordinates
455 return ((branch&1)<<11) + ((fec&0xf)<<7) + ((chip&0x7)<<4) + (channel&0xf);
459 //_____________________________________________________________________________
460 Int_t AliTPCmapper::DecodedHWAddressBranch(Int_t hwAddress) const
462 // Get branch index (0, 1) from hardware address
463 if ( hwAddress < 0 ) return -1;
464 return ((hwAddress>>11)&1);
468 //_____________________________________________________________________________
469 Int_t AliTPCmapper::DecodedHWAddressFECaddr(Int_t hwAddress) const
471 // Get FEC index (0 ... 12) from hardware address
472 if ( hwAddress < 0 ) return -1;
473 return ((hwAddress>>7)&0xf);
477 //_____________________________________________________________________________
478 Int_t AliTPCmapper::DecodedHWAddressChipaddr(Int_t hwAddress) const
480 // Get ALTRO index (0 ... 7) from hardware address
481 if ( hwAddress < 0 ) return -1;
482 return ((hwAddress>>4)&0x7);
486 //_____________________________________________________________________________
487 Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
489 // Get channel index (0 ... 15) from hardware address
490 if ( hwAddress < 0 ) return -1;
491 return ((hwAddress&0xf));
495 //______________________________________________________________
496 Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
497 // Get number of pads in padrow for this ROC.
498 return fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
502 //______________________________________________________________
503 Int_t AliTPCmapper::GetNpads(Int_t globalpadrow) const{
504 // Get number of pads in padrow, where globalpadrow is counted for a full sector (0 ... 158)
506 if ( globalpadrow >= fNpadrow ) {
507 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
510 if ( globalpadrow < fNpadrowIROC ) return GetNpads(0, globalpadrow); // IROC
511 else return GetNpads(36, globalpadrow - fNpadrowIROC); // OROC
517 //______________________________________________________________
518 Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
520 // Get number of padrows
521 return fROC->GetNRows(roc);
525 //______________________________________________________________
527 Double_t AliTPCmapper::GetPadXlocal(Int_t globalpadrow) const
529 // Get local x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
531 if ( globalpadrow >= fNpadrow ) {
532 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
537 if ( globalpadrow < fNpadrowIROC )
538 return (852.25 + 7.5*(Double_t)globalpadrow)/10.; //divide by 10 to get cm
540 globalpadrow -= fNpadrowIROC;
542 if ( globalpadrow < 64 ) //OROC inner part
543 return (10.* globalpadrow + 1351.)/10.; //divide by 10 to get cm
546 return (15.*(globalpadrow - 64) + 1993.5)/10.; //divide by 10 to get cm
550 //______________________________________________________________
552 Double_t AliTPCmapper::GetPadYlocal(Int_t globalpadrow, Int_t pad) const
554 // Get local y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
556 if ( globalpadrow >= fNpadrow ) {
557 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
561 Int_t padsInRow = GetNpads(globalpadrow);
562 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
563 AliWarning(Form("Pad index outside range (pad %d) !", pad));
568 if ( globalpadrow < fNpadrowIROC )
569 return (2.* padsInRow - 4.*pad - 2.)*1.e-1; //divide by 10 to get cm
572 return (3.* padsInRow -6.*pad - 3.)*1.e-1; //divide by 10 to get cm
576 //______________________________________________________________
578 Double_t AliTPCmapper::GetPadXglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const
580 // Get global x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
582 if ( globalpadrow >= fNpadrow ) {
583 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
587 Int_t padsInRow = GetNpads(globalpadrow);
588 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
589 AliWarning(Form("Pad index outside range (pad %d) !", pad));
593 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
594 return GetPadXlocal(globalpadrow) * TMath::Cos(angle) -
595 GetPadYlocal(globalpadrow, pad) * TMath::Sin(angle);
599 //______________________________________________________________
601 Double_t AliTPCmapper::GetPadYglobal(Int_t globalpadrow, Int_t pad,Int_t sector) const
603 // Get global y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
605 if ( globalpadrow >= fNpadrow ) {
606 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
610 Int_t padsInRow = GetNpads(globalpadrow);
611 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
612 AliWarning(Form("Pad index outside range (pad %d) !", pad));
616 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
617 return GetPadXlocal(globalpadrow) * TMath::Sin(angle) +
618 GetPadYlocal(globalpadrow, pad) * TMath::Cos(angle);
622 //______________________________________________________________
624 Double_t AliTPCmapper::GetPadWidth(Int_t globalpadrow) const
626 // Get pad width, where globalpadrow is counted for a full sector (0 ... 158)
628 if ( globalpadrow >= fNpadrow ) {
629 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
633 if (globalpadrow < fNpadrowIROC ) // IROC
639 //______________________________________________________________
641 Double_t AliTPCmapper::GetPadLength(Int_t globalpadrow) const
643 // Get pad length, where globalpadrow is counted for a full sector (0 ... 158)
645 if ( globalpadrow >= fNpadrow ) {
646 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
650 if ( globalpadrow < fNpadrowIROC ) return 0.75;
651 if ( globalpadrow < 127 ) return 1.0;
656 //_____________________________________________________________________________
657 Int_t AliTPCmapper::GetNfec(Int_t patch) const
659 // Get size of readout partition (number of FECs) for this rcu (patch) index (0 ... 5)
685 //_____________________________________________________________________________
686 Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
688 // Get size of readout partition (number of FECs) for this branch
711 if( (branch == 1) && (patch == 1) ){
718 //_____________________________________________________________________________
719 Int_t AliTPCmapper::OfflineToHwFec(Int_t patch, Int_t fec) const
721 // Convert FEC position in offline-like numbering to hardware numbering (fec).
723 if ( (patch < 0) || (fec < 0) ) {
724 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
727 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
728 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
732 Int_t fecsInBranchA = GetNfec(patch, 0);
733 if ( fec < fecsInBranchA ) // branch A
734 return (fecsInBranchA - 1 - fec);
736 return (fec - fecsInBranchA);
742 //_____________________________________________________________________________
743 Int_t AliTPCmapper::OfflineToHwBranch(Int_t patch, Int_t fec) const
745 // Convert fec position in offline-like numbering to hardware numbering (branch).
747 if ( (patch < 0) || (fec < 0) ) {
748 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
751 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
752 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
755 if ( fec < GetNfec(patch, 0) ) return 0; // branch A
756 else return 1; // branch B
762 //_____________________________________________________________________________
763 Int_t AliTPCmapper::HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
765 // Convert hardware FEC position (branch, fec) to the offline-oriented numbering
767 if ( (patch < 0) || (fec < 0) || (branch < 0) ) {
768 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
771 if ( (patch > 5) || (branch > 1) || (fec >= GetNfec(patch, branch)) ) {
772 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
775 Int_t fecsInBranchA = GetNfec(patch, 0);
776 if ( branch == 0 ) // branch A
777 return (fecsInBranchA - 1 - fec);
779 return (fec + fecsInBranchA);
785 //_____________________________________________________________________________
786 Int_t AliTPCmapper::GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
788 // Get EqID from pad coordinate. The Roc index is
789 // needed as well to determine if it is IROC or OROC.
791 Int_t side = GetSideFromRoc(roc);
792 if ( side < 0 ) return -1;
793 Int_t sector = GetSectorFromRoc(roc);
794 if ( sector < 0 ) return -1;
795 Int_t patch = GetPatch(roc, padrow, pad);
796 if ( patch < 0 ) return -1;
797 return GetEquipmentIDfromPatch(side, sector, patch);
801 //_____________________________________________________________________________
802 Int_t AliTPCmapper::GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
804 // Get EqID from pad coordinate, where padrow is counted for a full sector (0 ... 158)
805 Int_t patch = GetPatchSector(globalpadrow, pad);
806 if ( patch < 0 ) return -1;
807 Int_t roc = GetRocFromPatch(side, sector, patch);
808 if ( roc < 0 ) return -1;
810 if ( globalpadrow < fNpadrowIROC )
811 return GetEquipmentID(roc, globalpadrow, pad);
813 return GetEquipmentID(roc, globalpadrow-fNpadrowIROC, pad);
817 //_____________________________________________________________________________
818 Int_t AliTPCmapper::GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
820 // Get EqID from patch (rcu).
822 Int_t roc = GetRocFromPatch(side, sector, patch);
824 if (patch < 2) // IROC
827 ddl = (roc-36)*4 + 36*2 + (patch-2);
828 // Add offset. TPC has detectorID = 3
829 return ddl+fTpcDdlOffset;
833 //_____________________________________________________________________________
834 Int_t AliTPCmapper::GetPatchFromEquipmentID(Int_t equipmentID) const
836 // Get rcu (patch) index (0 ... 5) from equipment ID
839 if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
840 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
843 if ( ( (int)equipmentID - 840 ) < 0) retval = (equipmentID-768)%2;
844 else retval = (equipmentID-840)%4 + 2;
849 //_____________________________________________________________________________
850 Int_t AliTPCmapper::GetSideFromEquipmentID(Int_t equipmentID) const
852 // Get side from Eq ID
853 if ( equipmentID < fTpcDdlOffset ) {
854 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
857 if ( equipmentID < 804 ) return 0;
858 else if ( equipmentID < 840 ) return 1;
859 else if ( equipmentID < 912 ) return 0;
860 else if ( equipmentID < 984 ) return 1;
862 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
868 //_____________________________________________________________________________
869 Int_t AliTPCmapper::GetSectorFromEquipmentID(Int_t equipmentID) const
871 // Get sector index (0 ... 17) from equipment ID
874 if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
875 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
878 if ( (equipmentID - 840) < 0 ) retval = (equipmentID-768)/2;
879 else retval = (equipmentID-840)/4;
884 //_____________________________________________________________________________
885 Int_t AliTPCmapper::GetRocFromEquipmentID(Int_t equipmentID) const
887 // Get ROC index (0 ... 71) from equipment ID
888 Int_t side = GetSideFromEquipmentID(equipmentID);
889 if ( side < 0 ) return -1;
890 Int_t sector = GetSectorFromEquipmentID(equipmentID);
891 if ( sector < 0 ) return -1;
892 Int_t patch = GetPatchFromEquipmentID(equipmentID);
893 if ( patch < 0 ) return -1;
895 return GetRocFromPatch(side, sector, patch);
899 //_____________________________________________________________________________
900 Int_t AliTPCmapper::GetSectorFromRoc(Int_t roc) const
902 // get the sector number (0 ... 17) from the roc number (0 ... 71)
905 AliWarning(Form("Roc outside range (roc %d) !", roc));
907 } else if ( roc < 18 ) { // inner sector, A side
909 } else if ( roc < 36 ) { // inner sector, C side
911 } else if ( roc < 54 ) { // outer sector, A side
913 } else if ( roc < 72 ) { // outer sector, C side
916 AliWarning(Form("Roc outside range (roc %d) !", roc));
922 //_____________________________________________________________________________
923 Int_t AliTPCmapper::GetSideFromRoc(Int_t roc) const
925 // get the side (0, 1) from the roc number (0 ... 71)
928 AliWarning(Form("Roc outside range (roc %d) !", roc));
930 } else if ( roc < 18 ) { // inner sector, A side
932 } else if ( roc < 36 ) { // inner sector, C side
934 } else if ( roc < 54 ) { // outer sector, A side
936 } else if ( roc < 72 ) { // outer sector, C side
939 AliWarning(Form("Roc outside range (roc %d) !", roc));
945 //_____________________________________________________________________________
946 Int_t AliTPCmapper::GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
948 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and patch (0 ... 5)
950 if ( (side < 0) || (side >= fNside) ) {
951 AliWarning(Form("Side outside range (side %d) !", side));
954 if ( (sector < 0) || (sector >= fNsector) ) {
955 AliWarning(Form("Sector outside range (sector %d) !", sector));
958 if ( (patch < 0) || (patch >= fNrcu) ) {
959 AliWarning(Form("Patch (rcu) outside range (patch %d) !", patch));
963 if ( side == 0 ) { // A side
964 if ( patch < 2 ) return sector; // IROC
965 else return 36+sector; // OROC
967 if ( patch < 2 ) return 18+(17-sector); // IROC
968 else return 54+(17-sector); // OROC
973 //_____________________________________________________________________________
974 Int_t AliTPCmapper::GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
976 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and pad coordinates
978 Int_t patch = GetPatchSector(globalpadrow, pad);
979 if ( patch < 0 ) return -1;
980 return GetRocFromPatch(side, sector, patch);
984 //_____________________________________________________________________________
985 Bool_t AliTPCmapper::IsIROC(Int_t roc) const
987 // Is this ROC an IROC?
989 AliWarning(Form("Roc outside range (roc %d) !", roc));
991 } else if ( roc < 36 ) { // inner sector
993 } else if ( roc < 72 ) { // outer sector, C side
996 AliWarning(Form("Roc outside range (roc %d) !", roc));
1002 //_____________________________________________________________________________
1003 Bool_t AliTPCmapper::IsOROC(Int_t roc) const
1005 // Is this ROC an OROC?
1007 AliWarning(Form("Roc outside range (roc %d) !", roc));
1009 } else if ( roc < 36 ) { // inner sector
1011 } else if ( roc < 72 ) { // outer sector, C side
1014 AliWarning(Form("Roc outside range (roc %d) !", roc));