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(const char * dirname) :
66 // dirname - specify the directory with the ascii Altro mapping files
71 //______________________________________________________________
72 AliTPCmapper::~AliTPCmapper()
76 for ( Int_t i = 0; i < fNrcu; i++ ) {
83 //_____________________________________________________________________________
84 AliTPCmapper::AliTPCmapper(const AliTPCmapper& mapper) :
86 fNside(mapper.fNside),
87 fNsector(mapper.fNsector),
89 fNbranch(mapper.fNbranch),
90 fNaltro(mapper.fNaltro),
91 fNchannel(mapper.fNchannel),
92 fNpadrow(mapper.fNpadrow),
93 fNpadrowIROC(mapper.fNpadrowIROC),
94 fNpadrowOROC(mapper.fNpadrowOROC),
95 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];
111 fNside = mapper.fNside;
112 fNsector = mapper.fNsector;
113 fNrcu = mapper.fNrcu;
114 fNbranch = mapper.fNbranch;
115 fNaltro = mapper.fNaltro;
116 fNchannel = mapper.fNchannel;
117 fNpadrow = mapper.fNpadrow;
118 fNpadrowIROC = mapper.fNpadrowIROC;
119 fNpadrowOROC = mapper.fNpadrowOROC;
120 fTpcDdlOffset = mapper.fTpcDdlOffset;
125 //______________________________________________________________
126 void AliTPCmapper::Init(const char *dirname)
136 // Load and read mapping files. AliTPCAltroMapping contains the mapping for
140 path =gSystem->Getenv("ALICE_ROOT");
141 path += "/TPC/mapping/Patch";
148 for(Int_t i = 0; i < fNrcu; i++) {
152 fMapping[i] = new AliTPCAltroMapping(path2.Data());
155 // Create instance of AliTPCROC object
156 AliTPCROC *fROC = AliTPCROC::Instance();
157 fNpadrowIROC = fROC->GetNRows(0);
158 fNpadrowOROC = fROC->GetNRows(36);
159 fNpadrow = fNpadrowIROC+fNpadrowOROC;
162 fTpcDdlOffset = daq.DdlIDOffset("TPC");
167 //_____________________________________________________________________________
168 Int_t AliTPCmapper::GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
170 // Get the hardware address from pad coordinates for a given ROC
171 Int_t patch = GetPatch(roc, padrow, pad);
172 if ( (patch >= fNrcu) || (patch < 0) ) return -1;
173 return fMapping[patch]->GetHWAddress(padrow, pad, roc);
177 //_____________________________________________________________________________
178 Int_t AliTPCmapper::GetHWAddressSector(Int_t globalpadrow, Int_t pad) const
180 // Get the hardware address from pad coordinates
182 if ( globalpadrow < fNpadrowIROC ) {
183 patch = GetPatch(0, globalpadrow, pad);
184 return fMapping[patch]->GetHWAddress(globalpadrow, pad, 0);
185 } else if ( globalpadrow < fNpadrow ) {
186 patch = GetPatch(36, globalpadrow - fNpadrowIROC, pad);
187 return fMapping[patch]->GetHWAddress(globalpadrow - fNpadrowIROC,
190 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
196 //_____________________________________________________________________________
197 Int_t AliTPCmapper::GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
199 // Get the patch (rcu) index from the pad coordinates. The Roc index is
200 // needed as well to determine if it is IROC or OROC.
201 return GetPatch(roc, padrow, pad);
205 //_____________________________________________________________________________
206 Int_t AliTPCmapper::GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
208 // Get the patch (rcu) index from the pad coordinates. The Roc index is
209 // needed as well to determine if it is IROC or OROC.
211 if ( (padrow < 0) || (pad < 0) || (roc < 0) ) {
212 AliWarning(Form("Pad coordinates outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
218 Int_t padsInRow = GetNpads(padrow);
219 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
220 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
223 if ( padrow < 30 ) { return 0;
224 } else if ( padrow == 30 ) { // padrow 30 is shared between rcus 0 and 1
225 if ( (pad < 37) || (pad > 48) ) return 1;
227 } else if ( padrow < fNpadrowIROC ) { return 1;
229 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
232 } else if ( roc < 72 ) {
234 Int_t padsInRow = GetNpads(fNpadrowIROC+padrow);
235 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
236 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
239 if ( padrow < 27 ) { return 2;
240 } else if ( padrow == 27 ) { // padrow 27 is shared between rcus 2 and 3
241 if ( (pad >= 43) && (pad <= 46) ) return 3;
243 } else if ( padrow < 54 ) { return 3;
244 } else if ( padrow < 76 ) { return 4;
245 } else if ( padrow == 76) { // padrow 76 is shared between rcus 4 and 5
246 if ( (pad >= 33) && (pad <= 88) ) return 5;
248 } else if ( padrow < fNpadrowOROC ) { return 5;
250 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
258 //_____________________________________________________________________________
259 Int_t AliTPCmapper::GetRcuSector(Int_t globalpadrow, Int_t pad) const
261 // Get the patch (rcu) index from the pad coordinates for a sector
262 return GetPatchSector(globalpadrow, pad);
266 //_____________________________________________________________________________
267 Int_t AliTPCmapper::GetPatchSector(Int_t globalpadrow, Int_t pad) const
269 // Get the patch (rcu) index from the pad coordinates for a sector
270 if ( globalpadrow >= fNpadrow ) {
271 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
274 if ( globalpadrow < fNpadrowIROC ) return GetPatch(0, globalpadrow, pad);
275 else return GetPatch(36, globalpadrow-fNpadrowIROC, pad);
279 //_____________________________________________________________________________
280 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t hwAddress) const
282 // Get Pad Row (for a ROC) from the hardware address
283 if ( (patch >= fNrcu) || (patch < 0) ) {
284 AliWarning(Form("Patch index outside range (patch %d) !", patch));
287 return fMapping[patch]->GetPadRow(hwAddress);
291 //_____________________________________________________________________________
292 Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
294 // Get Pad Row (for full sector) from the hardware address
295 if ( patch < 2 ) return GetPadRow(patch, hwAddress);
296 else return GetPadRow(patch, hwAddress) + fNpadrowIROC;
300 //_____________________________________________________________________________
301 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t hwAddress) const
303 // Get Pad index from the hardware address
304 if ( (patch >= fNrcu) || (patch < 0) ) {
305 AliWarning(Form("Patch index outside range (patch %d) !", patch));
308 return fMapping[patch]->GetPad(hwAddress);
312 //_____________________________________________________________________________
313 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
316 // Get pad row (for a ROC) from hardware coordinates
317 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
318 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
319 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
320 patch, branch, fec, chip, channel));
323 return GetPadRow(patch, CodeHWAddress(branch, fec, chip, channel));
327 //_____________________________________________________________________________
328 Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
331 // Get Pad Row (for full sector) from the hardware address
332 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
333 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
334 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
335 patch, branch, fec, chip, channel));
338 if ( patch < 2 ) return GetPadRow(patch, branch, fec, chip, channel);
339 else return GetPadRow(patch, branch, fec, chip, channel) + fNpadrowIROC;
343 //_____________________________________________________________________________
344 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
346 // Get pad from hardware coordinates
347 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
348 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
349 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
350 patch, branch, fec, chip, channel));
353 return GetPad(patch, CodeHWAddress(branch, fec, chip, channel));
357 //_____________________________________________________________________________
358 Int_t AliTPCmapper::GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
360 // Get the branch to which this pad is connected. The FECs connected to
361 // one RCU are divided into two branches: A(=0) and B(=1). This information
362 // can be extracted from the hardware address.
363 return DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
367 //_____________________________________________________________________________
368 Int_t AliTPCmapper::GetBranchSector(Int_t globalpadrow, Int_t pad) const
370 // Get Branch from pad coordinates, where globalpadrow is counted
371 // for a full sector (0 ... 158)
372 return DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
376 //_____________________________________________________________________________
377 Int_t AliTPCmapper::GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
379 // Get the FEC number in hardware numbering. The FECs are numbered from 0 (in the
380 // center of the partition) to 8 (partition 3, 4, 5), 9 (partition 0, 2), 11
381 // (partition 1, branch A) or 12 (partition 1, branch B). This information
382 // can be extracted from the hardware address.
383 return DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
387 //_____________________________________________________________________________
388 Int_t AliTPCmapper::GetFEChwSector(Int_t globalpadrow, Int_t pad) const
390 // Get the FEC number in hardware numbering from pad coordinates, where
391 // globalpadrow is counted for a full sector (0 ... 158)
392 return DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
396 //_____________________________________________________________________________
397 Int_t AliTPCmapper::GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
399 // Get the FEC number in offline-oriented numbering. The FECs are numbered from 0
400 // 17 (partition 3, 4, 5), 19 (partition 0, 2) or 24 (partition 1).
401 Int_t patch = GetPatch(roc, padrow, pad);
402 Int_t fec = DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
403 Int_t branch = DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
404 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
405 return HwToOffline(patch, branch, fec);
409 //_____________________________________________________________________________
410 Int_t AliTPCmapper::GetFECSector(Int_t globalpadrow, Int_t pad) const
412 // Get the FEC number in offline-oriented numbering. globalpadrow is
413 // counted for a full sector (0 ... 158)
414 Int_t patch = GetPatchSector(globalpadrow, pad);
415 Int_t fec = DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
416 Int_t branch = DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
417 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
418 return HwToOffline(patch, branch, fec);
422 //_____________________________________________________________________________
423 Int_t AliTPCmapper::GetChip(Int_t roc, Int_t padrow, Int_t pad) const
425 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates
426 return DecodedHWAddressChipaddr(GetHWAddress(roc, padrow, pad));
430 //_____________________________________________________________________________
431 Int_t AliTPCmapper::GetChipSector(Int_t globalpadrow, Int_t pad) const
433 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates, where
434 // globalpadrow is counted for a full sector (0 ... 158)
435 return DecodedHWAddressChipaddr(GetHWAddressSector(globalpadrow, pad));
439 //_____________________________________________________________________________
440 Int_t AliTPCmapper::GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
442 // Get Channel index (0 ... 15) from pad coordinates
443 return DecodedHWAddressChanneladdr(GetHWAddress(roc, padrow, pad));
447 //_____________________________________________________________________________
448 Int_t AliTPCmapper::GetChannelSector(Int_t globalpadrow, Int_t pad) const
450 // Get Channel index (0 ... 15) from pad coordinates, where
451 // globalpadrow is counted for a full sector (0 ... 158)
452 return DecodedHWAddressChanneladdr(GetHWAddressSector(globalpadrow, pad));
456 //_____________________________________________________________________________
457 Int_t AliTPCmapper::CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
459 // Get Hardware address from channel, altro, fec and branch coordinates
460 return ((branch&1)<<11) + ((fec&0xf)<<7) + ((chip&0x7)<<4) + (channel&0xf);
464 //_____________________________________________________________________________
465 Int_t AliTPCmapper::DecodedHWAddressBranch(Int_t hwAddress) const
467 // Get branch index (0, 1) from hardware address
468 if ( hwAddress < 0 ) return -1;
469 return ((hwAddress>>11)&1);
473 //_____________________________________________________________________________
474 Int_t AliTPCmapper::DecodedHWAddressFECaddr(Int_t hwAddress) const
476 // Get FEC index (0 ... 12) from hardware address
477 if ( hwAddress < 0 ) return -1;
478 return ((hwAddress>>7)&0xf);
482 //_____________________________________________________________________________
483 Int_t AliTPCmapper::DecodedHWAddressChipaddr(Int_t hwAddress) const
485 // Get ALTRO index (0 ... 7) from hardware address
486 if ( hwAddress < 0 ) return -1;
487 return ((hwAddress>>4)&0x7);
491 //_____________________________________________________________________________
492 Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
494 // Get channel index (0 ... 15) from hardware address
495 if ( hwAddress < 0 ) return -1;
496 return ((hwAddress&0xf));
500 //______________________________________________________________
501 Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
502 // Get number of pads in padrow for this ROC.
503 AliTPCROC *fROC = AliTPCROC::Instance();
504 Int_t retval = fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
509 //______________________________________________________________
510 Int_t AliTPCmapper::GetNpads(Int_t globalpadrow) const{
511 // Get number of pads in padrow, where globalpadrow is counted for a full sector (0 ... 158)
513 if ( globalpadrow >= fNpadrow ) {
514 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
517 if ( globalpadrow < fNpadrowIROC ) return GetNpads(0, globalpadrow); // IROC
518 else return GetNpads(36, globalpadrow - fNpadrowIROC); // OROC
524 //______________________________________________________________
525 Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
527 // Get number of padrows
528 if (roc < 36) return fNpadrowIROC;
529 else if (roc < 72) return fNpadrowOROC;
534 //______________________________________________________________
536 Double_t AliTPCmapper::GetPadXlocal(Int_t globalpadrow) const
538 // Get local x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
540 if ( globalpadrow >= fNpadrow ) {
541 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
546 if ( globalpadrow < fNpadrowIROC )
547 return (852.25 + 7.5*(Double_t)globalpadrow)/10.; //divide by 10 to get cm
549 globalpadrow -= fNpadrowIROC;
551 if ( globalpadrow < 64 ) //OROC inner part
552 return (10.* globalpadrow + 1351.)/10.; //divide by 10 to get cm
555 return (15.*(globalpadrow - 64) + 1993.5)/10.; //divide by 10 to get cm
559 //______________________________________________________________
561 Double_t AliTPCmapper::GetPadYlocal(Int_t globalpadrow, Int_t pad) const
563 // Get local y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
565 if ( globalpadrow >= fNpadrow ) {
566 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
570 Int_t padsInRow = GetNpads(globalpadrow);
571 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
572 AliWarning(Form("Pad index outside range (pad %d) !", pad));
577 if ( globalpadrow < fNpadrowIROC )
578 return (2.* padsInRow - 4.*pad - 2.)*1.e-1; //divide by 10 to get cm
581 return (3.* padsInRow -6.*pad - 3.)*1.e-1; //divide by 10 to get cm
585 //______________________________________________________________
587 Double_t AliTPCmapper::GetPadXglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const
589 // Get global x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
591 if ( globalpadrow >= fNpadrow ) {
592 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
596 Int_t padsInRow = GetNpads(globalpadrow);
597 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
598 AliWarning(Form("Pad index outside range (pad %d) !", pad));
602 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
603 return GetPadXlocal(globalpadrow) * TMath::Cos(angle) -
604 GetPadYlocal(globalpadrow, pad) * TMath::Sin(angle);
608 //______________________________________________________________
610 Double_t AliTPCmapper::GetPadYglobal(Int_t globalpadrow, Int_t pad,Int_t sector) const
612 // Get global y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
614 if ( globalpadrow >= fNpadrow ) {
615 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
619 Int_t padsInRow = GetNpads(globalpadrow);
620 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
621 AliWarning(Form("Pad index outside range (pad %d) !", pad));
625 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
626 return GetPadXlocal(globalpadrow) * TMath::Sin(angle) +
627 GetPadYlocal(globalpadrow, pad) * TMath::Cos(angle);
631 //______________________________________________________________
633 Double_t AliTPCmapper::GetPadWidth(Int_t globalpadrow) const
635 // Get pad width, where globalpadrow is counted for a full sector (0 ... 158)
637 if ( globalpadrow >= fNpadrow ) {
638 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
642 if (globalpadrow < fNpadrowIROC ) // IROC
648 //______________________________________________________________
650 Double_t AliTPCmapper::GetPadLength(Int_t globalpadrow) const
652 // Get pad length, where globalpadrow is counted for a full sector (0 ... 158)
654 if ( globalpadrow >= fNpadrow ) {
655 AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
659 if ( globalpadrow < fNpadrowIROC ) return 0.75;
660 if ( globalpadrow < 127 ) return 1.0;
665 //_____________________________________________________________________________
666 Int_t AliTPCmapper::GetNfec(Int_t patch) const
668 // Get size of readout partition (number of FECs) for this rcu (patch) index (0 ... 5)
694 //_____________________________________________________________________________
695 Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
697 // Get size of readout partition (number of FECs) for this branch
720 if( (branch == 1) && (patch == 1) ){
728 //_____________________________________________________________________________
729 Int_t AliTPCmapper::OfflineToHwFec(Int_t patch, Int_t fec) const
731 // Convert FEC position in offline-like numbering to hardware numbering (fec).
733 if ( (patch < 0) || (fec < 0) ) {
734 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
737 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
738 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
742 Int_t fecsInBranchA = GetNfec(patch, 0);
743 if ( fec < fecsInBranchA ) // branch A
744 return (fecsInBranchA - 1 - fec);
746 return (fec - fecsInBranchA);
752 //_____________________________________________________________________________
753 Int_t AliTPCmapper::OfflineToHwBranch(Int_t patch, Int_t fec) const
755 // Convert fec position in offline-like numbering to hardware numbering (branch).
757 if ( (patch < 0) || (fec < 0) ) {
758 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
761 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
762 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
765 if ( fec < GetNfec(patch, 0) ) return 0; // branch A
766 else return 1; // branch B
772 //_____________________________________________________________________________
773 Int_t AliTPCmapper::HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
775 // Convert hardware FEC position (branch, fec) to the offline-oriented numbering
777 if ( (patch < 0) || (fec < 0) || (branch < 0) ) {
778 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
781 if ( (patch > 5) || (branch > 1) || (fec >= GetNfec(patch, branch)) ) {
782 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
785 Int_t fecsInBranchA = GetNfec(patch, 0);
786 if ( branch == 0 ) // branch A
787 return (fecsInBranchA - 1 - fec);
789 return (fec + fecsInBranchA);
795 //_____________________________________________________________________________
796 Int_t AliTPCmapper::GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
798 // Get EqID from pad coordinate. The Roc index is
799 // needed as well to determine if it is IROC or OROC.
801 Int_t side = GetSideFromRoc(roc);
802 if ( side < 0 ) return -1;
803 Int_t sector = GetSectorFromRoc(roc);
804 if ( sector < 0 ) return -1;
805 Int_t patch = GetPatch(roc, padrow, pad);
806 if ( patch < 0 ) return -1;
807 return GetEquipmentIDfromPatch(side, sector, patch);
811 //_____________________________________________________________________________
812 Int_t AliTPCmapper::GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
814 // Get EqID from pad coordinate, where padrow is counted for a full sector (0 ... 158)
815 Int_t patch = GetPatchSector(globalpadrow, pad);
816 if ( patch < 0 ) return -1;
817 Int_t roc = GetRocFromPatch(side, sector, patch);
818 if ( roc < 0 ) return -1;
820 if ( globalpadrow < fNpadrowIROC )
821 return GetEquipmentID(roc, globalpadrow, pad);
823 return GetEquipmentID(roc, globalpadrow-fNpadrowIROC, pad);
827 //_____________________________________________________________________________
828 Int_t AliTPCmapper::GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
830 // Get EqID from patch (rcu).
832 Int_t roc = GetRocFromPatch(side, sector, patch);
834 if (patch < 2) // IROC
837 ddl = (roc-36)*4 + 36*2 + (patch-2);
838 // Add offset. TPC has detectorID = 3
839 return ddl+fTpcDdlOffset;
843 //_____________________________________________________________________________
844 Int_t AliTPCmapper::GetPatchFromEquipmentID(Int_t equipmentID) const
846 // Get rcu (patch) index (0 ... 5) from equipment ID
849 if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
850 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
853 if ( ( (int)equipmentID - 840 ) < 0) retval = (equipmentID-768)%2;
854 else retval = (equipmentID-840)%4 + 2;
859 //_____________________________________________________________________________
860 Int_t AliTPCmapper::GetSideFromEquipmentID(Int_t equipmentID) const
862 // Get side from Eq ID
863 if ( equipmentID < fTpcDdlOffset ) {
864 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
867 if ( equipmentID < 804 ) return 0;
868 else if ( equipmentID < 840 ) return 1;
869 else if ( equipmentID < 912 ) return 0;
870 else if ( equipmentID < 984 ) return 1;
872 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
878 //_____________________________________________________________________________
879 Int_t AliTPCmapper::GetSectorFromEquipmentID(Int_t equipmentID) const
881 // Get sector index (0 ... 17) from equipment ID
884 if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
885 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
888 if ( (equipmentID - 840) < 0 ) retval = (equipmentID-768)/2;
889 else retval = (equipmentID-840)/4;
894 //_____________________________________________________________________________
895 Int_t AliTPCmapper::GetRocFromEquipmentID(Int_t equipmentID) const
897 // Get ROC index (0 ... 71) from equipment ID
898 Int_t side = GetSideFromEquipmentID(equipmentID);
899 if ( side < 0 ) return -1;
900 Int_t sector = GetSectorFromEquipmentID(equipmentID);
901 if ( sector < 0 ) return -1;
902 Int_t patch = GetPatchFromEquipmentID(equipmentID);
903 if ( patch < 0 ) return -1;
905 return GetRocFromPatch(side, sector, patch);
909 //_____________________________________________________________________________
910 Int_t AliTPCmapper::GetSectorFromRoc(Int_t roc) const
912 // get the sector number (0 ... 17) from the roc number (0 ... 71)
915 AliWarning(Form("Roc outside range (roc %d) !", roc));
917 } else if ( roc < 18 ) { // inner sector, A side
919 } else if ( roc < 36 ) { // inner sector, C side
921 } else if ( roc < 54 ) { // outer sector, A side
923 } else if ( roc < 72 ) { // outer sector, C side
926 AliWarning(Form("Roc outside range (roc %d) !", roc));
932 //_____________________________________________________________________________
933 Int_t AliTPCmapper::GetSideFromRoc(Int_t roc) const
935 // get the side (0, 1) from the roc number (0 ... 71)
938 AliWarning(Form("Roc outside range (roc %d) !", roc));
940 } else if ( roc < 18 ) { // inner sector, A side
942 } else if ( roc < 36 ) { // inner sector, C side
944 } else if ( roc < 54 ) { // outer sector, A side
946 } else if ( roc < 72 ) { // outer sector, C side
949 AliWarning(Form("Roc outside range (roc %d) !", roc));
955 //_____________________________________________________________________________
956 Int_t AliTPCmapper::GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
958 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and patch (0 ... 5)
960 if ( (side < 0) || (side >= fNside) ) {
961 AliWarning(Form("Side outside range (side %d) !", side));
964 if ( (sector < 0) || (sector >= fNsector) ) {
965 AliWarning(Form("Sector outside range (sector %d) !", sector));
968 if ( (patch < 0) || (patch >= fNrcu) ) {
969 AliWarning(Form("Patch (rcu) outside range (patch %d) !", patch));
973 if ( side == 0 ) { // A side
974 if ( patch < 2 ) return sector; // IROC
975 else return 36+sector; // OROC
977 if ( patch < 2 ) return 18+(17-sector); // IROC
978 else return 54+(17-sector); // OROC
983 //_____________________________________________________________________________
984 Int_t AliTPCmapper::GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
986 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and pad coordinates
988 Int_t patch = GetPatchSector(globalpadrow, pad);
989 if ( patch < 0 ) return -1;
990 return GetRocFromPatch(side, sector, patch);
994 //_____________________________________________________________________________
995 Bool_t AliTPCmapper::IsIROC(Int_t roc) const
997 // Is this ROC an IROC?
999 AliWarning(Form("Roc outside range (roc %d) !", roc));
1001 } else if ( roc < 36 ) { // inner sector
1003 } else if ( roc < 72 ) { // outer sector, C side
1006 AliWarning(Form("Roc outside range (roc %d) !", roc));
1012 //_____________________________________________________________________________
1013 Bool_t AliTPCmapper::IsOROC(Int_t roc) const
1015 // Is this ROC an OROC?
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));