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 //-------------------------------------------------------------------------
18 // Origin: Christian.Lippmann@cern.ch
20 // Class to map detector coordinates (row, pad, sector, ...) to
21 // hardware coordinates (RCU, Branch, FEC, Altro, channel, Equipment ID, ...)
23 // Note: There are two different ways to number padrows:
24 // 1) for each ROC, like 0 ... 62 for an IROC and 0 ... 95 for an OROC,
25 // 2) for each sector, from 0 ... 158.
26 // If the second numbering is used, it is denoted by the variable name
27 // sectorpadrow in this class.
29 // Note: 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!
35 //-------------------------------------------------------------------------
42 #include "AliTPCmapper.h"
43 #include "AliTPCAltroMapping.h"
44 #include "AliTPCROC.h"
47 ClassImp(AliTPCmapper)
49 //______________________________________________________________
50 AliTPCmapper::AliTPCmapper() :
66 //______________________________________________________________
67 AliTPCmapper::~AliTPCmapper()
73 for ( Int_t i = 0; i < fNrcu; i++ ) {
80 //_____________________________________________________________________________
81 AliTPCmapper::AliTPCmapper(const AliTPCmapper& mapper) :
83 fNside(mapper.fNside),
84 fNsector(mapper.fNsector),
86 fNbranch(mapper.fNbranch),
87 fNaltro(mapper.fNaltro),
88 fNchannel(mapper.fNchannel),
89 fNpadrow(mapper.fNpadrow),
90 fNpadrowIROC(mapper.fNpadrowIROC),
91 fNpadrowOROC(mapper.fNpadrowOROC),
95 for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
98 //_____________________________________________________________________________
99 AliTPCmapper& AliTPCmapper::operator = (const AliTPCmapper& mapper)
101 // Assignment operator
103 if(&mapper == this) return *this;
104 ((TObject *)this)->operator=(mapper);
106 for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
109 fNside = mapper.fNside;
110 fNsector = mapper.fNsector;
111 fNrcu = mapper.fNrcu;
112 fNbranch = mapper.fNbranch;
113 fNaltro = mapper.fNaltro;
114 fNchannel = mapper.fNchannel;
115 fNpadrow = mapper.fNpadrow;
116 fNpadrowIROC = mapper.fNpadrowIROC;
117 fNpadrowOROC = mapper.fNpadrowOROC;
122 //______________________________________________________________
123 void AliTPCmapper::Init()
133 // Load and read mapping files. AliTPCAltroMapping contains the mapping for
135 TString path = gSystem->Getenv("ALICE_ROOT");
136 path += "/TPC/mapping/Patch";
138 for(Int_t i = 0; i < fNrcu; i++) {
142 fMapping[i] = new AliTPCAltroMapping(path2.Data());
145 // Create instance of AliTPCROC object
146 fROC = AliTPCROC::Instance();
148 fNpadrowIROC = fROC->GetNRows(0);
149 fNpadrowOROC = fROC->GetNRows(36);
150 fNpadrow = fNpadrowIROC+fNpadrowOROC;
155 //_____________________________________________________________________________
156 Int_t AliTPCmapper::GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
158 // Get the hardware address from pad coordinates for a given ROC
159 Int_t patch = GetPatch(roc, padrow, pad);
160 if ( patch < 0 ) return -1;
161 return fMapping[patch]->GetHWAddress(padrow, pad, roc);
165 //_____________________________________________________________________________
166 Int_t AliTPCmapper::GetHWAddressSector(Int_t sectorpadrow, Int_t pad) const
168 // Get the hardware address from pad coordinates
170 if ( sectorpadrow < fNpadrowIROC ) {
171 patch = GetPatch(0, sectorpadrow, pad);
172 return fMapping[patch]->GetHWAddress(sectorpadrow, pad, 0);
173 } else if ( sectorpadrow < fNpadrow ) {
174 patch = GetPatch(36, sectorpadrow - fNpadrowIROC, pad);
175 return fMapping[patch]->GetHWAddress(sectorpadrow - fNpadrowIROC,
178 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
184 //_____________________________________________________________________________
185 Int_t AliTPCmapper::GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
187 // Get the patch (rcu) index from the pad coordinates. The Roc index is
188 // needed as well to determine if it is IROC or OROC.
189 return GetPatch(roc, padrow, pad);
193 //_____________________________________________________________________________
194 Int_t AliTPCmapper::GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
196 // Get the patch (rcu) index from the pad coordinates. The Roc index is
197 // needed as well to determine if it is IROC or OROC.
199 if ( (padrow < 0) || (pad < 0) || (roc < 0) ) {
200 AliWarning(Form("Pad coordinates outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
206 Int_t padsInRow = GetNpads(padrow);
207 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
208 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
211 if ( padrow < 30 ) { return 0;
212 } else if ( padrow == 30 ) { // padrow 30 is shared between rcus 0 and 1
213 if ( (pad < 37) || (pad > 48) ) return 1;
215 } else if ( padrow < fNpadrowIROC ) { return 1;
217 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
220 } else if ( roc < 72 ) {
222 Int_t padsInRow = GetNpads(fNpadrowIROC+padrow);
223 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
224 AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
227 if ( padrow < 27 ) { return 2;
228 } else if ( padrow == 27 ) { // padrow 27 is shared between rcus 2 and 3
229 if ( (pad >= 43) && (pad <= 46) ) return 3;
231 } else if ( padrow < 54 ) { return 3;
232 } else if ( padrow < 76 ) { return 4;
233 } else if ( padrow == 76) { // padrow 76 is shared between rcus 4 and 5
234 if ( (pad >= 33) && (pad <= 88) ) return 5;
236 } else if ( padrow < fNpadrowOROC ) { return 5;
238 AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
246 //_____________________________________________________________________________
247 Int_t AliTPCmapper::GetRcuSector(Int_t sectorpadrow, Int_t pad) const
249 // Get the patch (rcu) index from the pad coordinates for a sector
250 return GetPatchSector(sectorpadrow, pad);
254 //_____________________________________________________________________________
255 Int_t AliTPCmapper::GetPatchSector(Int_t sectorpadrow, Int_t pad) const
257 // Get the patch (rcu) index from the pad coordinates for a sector
258 if ( sectorpadrow >= fNpadrow ) {
259 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
262 if ( sectorpadrow < fNpadrowIROC ) return GetPatch(0, sectorpadrow, pad);
263 else return GetPatch(36, sectorpadrow-fNpadrowIROC, pad);
267 //_____________________________________________________________________________
268 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t hwAddress) const
270 // Get Pad Row (for a ROC) from the hardware address
271 return fMapping[patch]->GetPadRow(hwAddress);
275 //_____________________________________________________________________________
276 Int_t AliTPCmapper::GetSectorPadRow(Int_t patch, Int_t hwAddress) const
278 // Get Pad Row (for full sector) from the hardware address
279 if ( patch < 2 ) return GetPadRow(patch, hwAddress);
280 else return GetPadRow(patch, hwAddress) + fNpadrowIROC;
284 //_____________________________________________________________________________
285 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t hwAddress) const
287 // Get Pad index from the hardware address
288 return fMapping[patch]->GetPad(hwAddress);
292 //_____________________________________________________________________________
293 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
296 // Get pad row (for a ROC) from hardware coordinates
297 if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
298 || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
299 AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
300 patch, branch, fec, chip, channel));
303 return GetPadRow(patch, CodeHWAddress(branch, fec, chip, channel));
307 //_____________________________________________________________________________
308 Int_t AliTPCmapper::GetSectorPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
311 // Get Pad Row (for full sector) from the hardware address
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 if ( patch < 2 ) return GetPadRow(patch, branch, fec, chip, channel);
319 else return GetPadRow(patch, branch, fec, chip, channel) + fNpadrowIROC;
323 //_____________________________________________________________________________
324 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
326 // Get pad from hardware coordinates
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 return GetPad(patch, CodeHWAddress(branch, fec, chip, channel));
337 //_____________________________________________________________________________
338 Int_t AliTPCmapper::GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
340 // Get the branch to which this pad is connected. The FECs connected to
341 // one RCU are divided into two branches: A(=0) and B(=1). This information
342 // can be extracted from the hardware address.
343 return DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
347 //_____________________________________________________________________________
348 Int_t AliTPCmapper::GetBranchSector(Int_t sectorpadrow, Int_t pad) const
350 // Get Branch from pad coordinates, where sectorpadrow is counted
351 // for a full sector (0 ... 158)
352 return DecodedHWAddressBranch(GetHWAddressSector(sectorpadrow, pad));
356 //_____________________________________________________________________________
357 Int_t AliTPCmapper::GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
359 // Get the FEC number in hardware numbering. The FECs are numbered from 0 (in the
360 // center of the partition) to 8 (partition 3, 4, 5), 9 (partition 0, 2), 11
361 // (partition 1, branch A) or 12 (partition 1, branch B). This information
362 // can be extracted from the hardware address.
363 return DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
367 //_____________________________________________________________________________
368 Int_t AliTPCmapper::GetFEChwSector(Int_t sectorpadrow, Int_t pad) const
370 // Get the FEC number in hardware numbering from pad coordinates, where
371 // sectorpadrow is counted for a full sector (0 ... 158)
372 return DecodedHWAddressFECaddr(GetHWAddressSector(sectorpadrow, pad));
376 //_____________________________________________________________________________
377 Int_t AliTPCmapper::GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
379 // Get the FEC number in offline-oriented numbering. The FECs are numbered from 0
380 // 17 (partition 3, 4, 5), 19 (partition 0, 2) or 24 (partition 1).
381 Int_t patch = GetPatch(roc, padrow, pad);
382 Int_t fec = DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
383 Int_t branch = DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
384 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
385 return HwToOffline(patch, branch, fec);
389 //_____________________________________________________________________________
390 Int_t AliTPCmapper::GetFECSector(Int_t sectorpadrow, Int_t pad) const
392 // Get the FEC number in offline-oriented numbering. Sectorpadrow is
393 // counted for a full sector (0 ... 158)
394 Int_t patch = GetPatchSector(sectorpadrow, pad);
395 Int_t fec = DecodedHWAddressFECaddr(GetHWAddressSector(sectorpadrow, pad));
396 Int_t branch = DecodedHWAddressBranch(GetHWAddressSector(sectorpadrow, pad));
397 if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
398 return HwToOffline(patch, branch, fec);
402 //_____________________________________________________________________________
403 Int_t AliTPCmapper::GetChip(Int_t roc, Int_t padrow, Int_t pad) const
405 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates
406 return DecodedHWAddressChipaddr(GetHWAddress(roc, padrow, pad));
410 //_____________________________________________________________________________
411 Int_t AliTPCmapper::GetChipSector(Int_t sectorpadrow, Int_t pad) const
413 // Get Chip (ALTRO) index (0 ... 7) from pad coordinates, where
414 // sectorpadrow is counted for a full sector (0 ... 158)
415 return DecodedHWAddressChipaddr(GetHWAddressSector(sectorpadrow, pad));
419 //_____________________________________________________________________________
420 Int_t AliTPCmapper::GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
422 // Get Channel index (0 ... 15) from pad coordinates
423 return DecodedHWAddressChanneladdr(GetHWAddress(roc, padrow, pad));
427 //_____________________________________________________________________________
428 Int_t AliTPCmapper::GetChannelSector(Int_t sectorpadrow, Int_t pad) const
430 // Get Channel index (0 ... 15) from pad coordinates, where
431 // sectorpadrow is counted for a full sector (0 ... 158)
432 return DecodedHWAddressChanneladdr(GetHWAddressSector(sectorpadrow, pad));
436 //_____________________________________________________________________________
437 Int_t AliTPCmapper::CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
439 // Get Hardware address from channel, altro, fec and branch coordinates
440 return ((branch&1)<<11) + ((fec&0xf)<<7) + ((chip&0x7)<<4) + (channel&0xf);
444 //_____________________________________________________________________________
445 Int_t AliTPCmapper::DecodedHWAddressBranch(Int_t hwAddress) const
447 // Get branch index (0, 1) from hardware address
448 if ( hwAddress < 0 ) return -1;
449 return ((hwAddress>>11)&1);
453 //_____________________________________________________________________________
454 Int_t AliTPCmapper::DecodedHWAddressFECaddr(Int_t hwAddress) const
456 // Get FEC index (0 ... 12) from hardware address
457 if ( hwAddress < 0 ) return -1;
458 return ((hwAddress>>7)&0xf);
462 //_____________________________________________________________________________
463 Int_t AliTPCmapper::DecodedHWAddressChipaddr(Int_t hwAddress) const
465 // Get ALTRO index (0 ... 7) from hardware address
466 if ( hwAddress < 0 ) return -1;
467 return ((hwAddress>>4)&0x7);
471 //_____________________________________________________________________________
472 Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
474 // Get channel index (0 ... 15) from hardware address
475 if ( hwAddress < 0 ) return -1;
476 return ((hwAddress&0xf));
480 //______________________________________________________________
481 Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
482 // Get number of pads in padrow for this ROC.
483 return fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
487 //______________________________________________________________
488 Int_t AliTPCmapper::GetNpads(Int_t sectorpadrow) const{
489 // Get number of pads in padrow, where sectorpadrow is counted for a full sector (0 ... 158)
491 if ( sectorpadrow >= fNpadrow ) {
492 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
495 if ( sectorpadrow < fNpadrowIROC ) return GetNpads(0, sectorpadrow); // IROC
496 else return GetNpads(36, sectorpadrow - fNpadrowIROC); // OROC
502 //______________________________________________________________
503 Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
505 // Get number of padrows
506 return fROC->GetNRows(roc);
510 //______________________________________________________________
512 Double_t AliTPCmapper::GetPadXlocal(Int_t sectorpadrow) const
514 // Get local x coordinate of pad, where sectorpadrow is counted for a full sector (0 ... 158)
516 if ( sectorpadrow >= fNpadrow ) {
517 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
522 if ( sectorpadrow < fNpadrowIROC )
523 return (852.25 + 7.5*(Double_t)sectorpadrow)/10.; //divide by 10 to get cm
525 sectorpadrow -= fNpadrowIROC;
527 if ( sectorpadrow < 64 ) //OROC inner part
528 return (10.* sectorpadrow + 1351.)/10.; //divide by 10 to get cm
531 return (15.*(sectorpadrow - 64) + 1993.5)/10.; //divide by 10 to get cm
535 //______________________________________________________________
537 Double_t AliTPCmapper::GetPadYlocal(Int_t sectorpadrow, Int_t pad) const
539 // Get local y coordinate of pad, where sectorpadrow is counted for a full sector (0 ... 158)
541 if ( sectorpadrow >= fNpadrow ) {
542 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
546 Int_t padsInRow = GetNpads(sectorpadrow);
547 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
548 AliWarning(Form("Pad index outside range (pad %d) !", pad));
553 if ( sectorpadrow < fNpadrowIROC )
554 return (2.* padsInRow - 4.*pad - 2.)*1.e-1; //divide by 10 to get cm
557 return (3.* padsInRow -6.*pad - 3.)*1.e-1; //divide by 10 to get cm
561 //______________________________________________________________
563 Double_t AliTPCmapper::GetPadXglobal(Int_t sectorpadrow, Int_t pad, Int_t sector) const
565 // Get global x coordinate of pad, where sectorpadrow is counted for a full sector (0 ... 158)
567 if ( sectorpadrow >= fNpadrow ) {
568 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
572 Int_t padsInRow = GetNpads(sectorpadrow);
573 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
574 AliWarning(Form("Pad index outside range (pad %d) !", pad));
578 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
579 return GetPadXlocal(sectorpadrow) * TMath::Cos(angle) -
580 GetPadYlocal(sectorpadrow, pad) * TMath::Sin(angle);
584 //______________________________________________________________
586 Double_t AliTPCmapper::GetPadYglobal(Int_t sectorpadrow, Int_t pad,Int_t sector) const
588 // Get global y coordinate of pad, where sectorpadrow is counted for a full sector (0 ... 158)
590 if ( sectorpadrow >= fNpadrow ) {
591 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
595 Int_t padsInRow = GetNpads(sectorpadrow);
596 if ( (padsInRow < 0) || (pad >= padsInRow) ) {
597 AliWarning(Form("Pad index outside range (pad %d) !", pad));
601 Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
602 return GetPadXlocal(sectorpadrow) * TMath::Sin(angle) +
603 GetPadYlocal(sectorpadrow, pad) * TMath::Cos(angle);
607 //______________________________________________________________
609 Double_t AliTPCmapper::GetPadWidth(Int_t sectorpadrow) const
611 // Get pad width, where sectorpadrow is counted for a full sector (0 ... 158)
613 if ( sectorpadrow >= fNpadrow ) {
614 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
618 if (sectorpadrow < fNpadrowIROC ) // IROC
624 //______________________________________________________________
626 Double_t AliTPCmapper::GetPadLength(Int_t sectorpadrow) const
628 // Get pad length, where sectorpadrow is counted for a full sector (0 ... 158)
630 if ( sectorpadrow >= fNpadrow ) {
631 AliWarning(Form("Padrow outside range (sectorpadrow %d) !", sectorpadrow));
635 if ( sectorpadrow < fNpadrowIROC ) return 0.75;
636 if ( sectorpadrow < 127 ) return 1.0;
641 //_____________________________________________________________________________
642 Int_t AliTPCmapper::GetNfec(Int_t patch) const
644 // Get size of readout partition (number of FECs) for this rcu (patch) index (0 ... 5)
670 //_____________________________________________________________________________
671 Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
673 // Get size of readout partition (number of FECs) for this branch
696 if( (branch == 1) && (patch == 1) ){
703 //_____________________________________________________________________________
704 Int_t AliTPCmapper::OfflineToHwFec(Int_t patch, Int_t fec) const
706 // Convert FEC position in offline-like numbering to hardware numbering (fec).
708 if ( (patch < 0) || (fec < 0) ) {
709 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
712 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
713 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
717 Int_t fecsInBranchA = GetNfec(patch, 0);
718 if ( fec < fecsInBranchA ) // branch A
719 return (fecsInBranchA - 1 - fec);
721 return (fec - fecsInBranchA);
727 //_____________________________________________________________________________
728 Int_t AliTPCmapper::OfflineToHwBranch(Int_t patch, Int_t fec) const
730 // Convert fec position in offline-like numbering to hardware numbering (branch).
732 if ( (patch < 0) || (fec < 0) ) {
733 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
736 if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
737 AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
740 if ( fec < GetNfec(patch, 0) ) return 0; // branch A
741 else return 1; // branch B
747 //_____________________________________________________________________________
748 Int_t AliTPCmapper::HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
750 // Convert hardware FEC position (branch, fec) to the offline-oriented numbering
752 if ( (patch < 0) || (fec < 0) || (branch < 0) ) {
753 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
756 if ( (patch > 5) || (branch > 1) || (fec >= GetNfec(patch, branch)) ) {
757 AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
760 Int_t fecsInBranchA = GetNfec(patch, 0);
761 if ( branch == 0 ) // branch A
762 return (fecsInBranchA - 1 - fec);
764 return (fec + fecsInBranchA);
770 //_____________________________________________________________________________
771 Int_t AliTPCmapper::GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
773 // Get EqID from pad coordinate. The Roc index is
774 // needed as well to determine if it is IROC or OROC.
776 Int_t side = GetSideFromRoc(roc);
777 if ( side < 0 ) return -1;
778 Int_t sector = GetSectorFromRoc(roc);
779 if ( sector < 0 ) return -1;
780 Int_t patch = GetPatch(roc, padrow, pad);
781 if ( patch < 0 ) return -1;
782 return GetEquipmentIDfromPatch(side, sector, patch);
786 //_____________________________________________________________________________
787 Int_t AliTPCmapper::GetEquipmentIDsector(Int_t side, Int_t sector, Int_t sectorpadrow, Int_t pad) const
789 // Get EqID from pad coordinate, where padrow is counted for a full sector (0 ... 158)
790 Int_t patch = GetPatchSector(sectorpadrow, pad);
791 if ( patch < 0 ) return -1;
792 Int_t roc = GetRocFromPatch(side, sector, patch);
793 if ( roc < 0 ) return -1;
795 if ( sectorpadrow < fNpadrowIROC )
796 return GetEquipmentID(roc, sectorpadrow, pad);
798 return GetEquipmentID(roc, sectorpadrow-fNpadrowIROC, pad);
802 //_____________________________________________________________________________
803 Int_t AliTPCmapper::GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
805 // Get EqID from patch (rcu).
807 Int_t roc = GetRocFromPatch(side, sector, patch);
809 if (patch < 2) // IROC
812 ddl = (roc-36)*4 + 36*2 + (patch-2);
813 // Add offset. TPC has detectorID = 3
818 //_____________________________________________________________________________
819 Int_t AliTPCmapper::GetPatchFromEquipmentID(Int_t equipmentID) const
821 // Get rcu (patch) index (0 ... 5) from equipment ID
824 if ( (equipmentID < (3<<8)) || (equipmentID > 983) ) {
825 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
828 if ( ( (int)equipmentID - 840 ) < 0) retval = (equipmentID-768)%2;
829 else retval = (equipmentID-840)%4 + 2;
834 //_____________________________________________________________________________
835 Int_t AliTPCmapper::GetSideFromEquipmentID(Int_t equipmentID) const
837 // Get side from Eq ID
838 if ( (equipmentID < (3<<8)) ) {
839 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
842 if ( equipmentID < 804 ) return 0;
843 else if ( equipmentID < 840 ) return 1;
844 else if ( equipmentID < 912 ) return 0;
845 else if ( equipmentID < 984 ) return 1;
847 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
853 //_____________________________________________________________________________
854 Int_t AliTPCmapper::GetSectorFromEquipmentID(Int_t equipmentID) const
856 // Get sector index (0 ... 17) from equipment ID
859 if ( (equipmentID < (3<<8)) || (equipmentID > 983) ) {
860 AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
863 if ( (equipmentID - 840) < 0 ) retval = (equipmentID-768)/2;
864 else retval = (equipmentID-840)/4;
869 //_____________________________________________________________________________
870 Int_t AliTPCmapper::GetRocFromEquipmentID(Int_t equipmentID) const
872 // Get ROC index (0 ... 71) from equipment ID
873 Int_t side = GetSideFromEquipmentID(equipmentID);
874 if ( side < 0 ) return -1;
875 Int_t sector = GetSectorFromEquipmentID(equipmentID);
876 if ( sector < 0 ) return -1;
877 Int_t patch = GetPatchFromEquipmentID(equipmentID);
878 if ( patch < 0 ) return -1;
880 return GetRocFromPatch(side, sector, patch);
884 //_____________________________________________________________________________
885 Int_t AliTPCmapper::GetSectorFromRoc(Int_t roc) const
887 // get the sector number (0 ... 17) from the roc number (0 ... 71)
890 AliWarning(Form("Roc outside range (roc %d) !", roc));
892 } else if ( roc < 18 ) { // inner sector, A side
894 } else if ( roc < 36 ) { // inner sector, C side
896 } else if ( roc < 54 ) { // outer sector, A side
898 } else if ( roc < 72 ) { // outer sector, C side
901 AliWarning(Form("Roc outside range (roc %d) !", roc));
907 //_____________________________________________________________________________
908 Int_t AliTPCmapper::GetSideFromRoc(Int_t roc) const
910 // get the side (0, 1) from the roc number (0 ... 71)
913 AliWarning(Form("Roc outside range (roc %d) !", roc));
915 } else if ( roc < 18 ) { // inner sector, A side
917 } else if ( roc < 36 ) { // inner sector, C side
919 } else if ( roc < 54 ) { // outer sector, A side
921 } else if ( roc < 72 ) { // outer sector, C side
924 AliWarning(Form("Roc outside range (roc %d) !", roc));
930 //_____________________________________________________________________________
931 Int_t AliTPCmapper::GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
933 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and patch (0 ... 5)
935 if ( (side < 0) || (side >= fNside) ) {
936 AliWarning(Form("Side outside range (side %d) !", side));
939 if ( (sector < 0) || (sector >= fNsector) ) {
940 AliWarning(Form("Sector outside range (sector %d) !", sector));
943 if ( (patch < 0) || (patch >= fNrcu) ) {
944 AliWarning(Form("Patch (rcu) outside range (patch %d) !", patch));
948 if ( side == 0 ) { // A side
949 if ( patch < 2 ) return sector; // IROC
950 else return 36+sector; // OROC
952 if ( patch < 2 ) return 18+(17-sector); // IROC
953 else return 54+(17-sector); // OROC
958 //_____________________________________________________________________________
959 Int_t AliTPCmapper::GetRoc(Int_t side, Int_t sector, Int_t sectorpadrow, Int_t pad) const
961 // Get Roc (0 ... 71) from side (0, 1), sector (0 ... 17) and pad coordinates
963 Int_t patch = GetPatchSector(sectorpadrow, pad);
964 if ( patch < 0 ) return -1;
965 return GetRocFromPatch(side, sector, patch);
969 //_____________________________________________________________________________
970 Bool_t AliTPCmapper::IsIROC(Int_t roc) const
972 // Is this ROC an IROC?
974 AliWarning(Form("Roc outside range (roc %d) !", roc));
976 } else if ( roc < 36 ) { // inner sector
978 } else if ( roc < 72 ) { // outer sector, C side
981 AliWarning(Form("Roc outside range (roc %d) !", roc));
987 //_____________________________________________________________________________
988 Bool_t AliTPCmapper::IsOROC(Int_t roc) const
990 // Is this ROC an OROC?
992 AliWarning(Form("Roc outside range (roc %d) !", roc));
994 } else if ( roc < 36 ) { // inner sector
996 } else if ( roc < 72 ) { // outer sector, C side
999 AliWarning(Form("Roc outside range (roc %d) !", roc));