AliRoot Core  3dc7879 (3dc7879)
AliTPCmapper.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
36 
37 #include <TMath.h>
38 #include <TSystem.h>
39 #include <TString.h>
40 
41 #include "AliTPCmapper.h"
42 #include "AliTPCAltroMapping.h"
43 #include "AliTPCROC.h"
44 #include "AliLog.h"
45 #include "AliDAQ.h"
46 
48 ClassImp(AliTPCmapper)
50 //______________________________________________________________
52  fNside(0),
53  fNsector(0),
54  fNrcu(0),
55  fNbranch(0),
56  fNaltro(0),
57  fNchannel(0),
58  fNpadrow(0),
59  fNpadrowIROC(0),
60  fNpadrowOROC(0),
61  fTpcDdlOffset(0)
62 {
63  //
64  // Constructor
65  //
66  for ( Int_t i = 0; i < 6; i++ ) fMapping[i]=0;
67 }
68 
69 //______________________________________________________________
70 AliTPCmapper::AliTPCmapper(const char * dirname) :
71  fNside(0),
72  fNsector(0),
73  fNrcu(0),
74  fNbranch(0),
75  fNaltro(0),
76  fNchannel(0),
77  fNpadrow(0),
78  fNpadrowIROC(0),
79  fNpadrowOROC(0),
80  fTpcDdlOffset(0)
81 {
85 
86  Init(dirname);
87 }
88 
89 //______________________________________________________________
91 {
93 
94  for ( Int_t i = 0; i < fNrcu; i++ ) {
95  delete fMapping[i];
96  fMapping[i] = 0;
97  }
98 }
99 
100 
101 //_____________________________________________________________________________
103  TObject(mapper),
104  fNside(mapper.fNside),
105  fNsector(mapper.fNsector),
106  fNrcu(mapper.fNrcu),
107  fNbranch(mapper.fNbranch),
108  fNaltro(mapper.fNaltro),
109  fNchannel(mapper.fNchannel),
110  fNpadrow(mapper.fNpadrow),
111  fNpadrowIROC(mapper.fNpadrowIROC),
112  fNpadrowOROC(mapper.fNpadrowOROC),
114 {
116 
117  for ( Int_t i = 0; i < 6; i++ ) fMapping[i]=0;
118  for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
119 }
120 
121 //_____________________________________________________________________________
123 {
125 
126  if(&mapper == this) return *this;
127  ((TObject *)this)->operator=(mapper);
128 
129  for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
130 
131  fNside = mapper.fNside;
132  fNsector = mapper.fNsector;
133  fNrcu = mapper.fNrcu;
134  fNbranch = mapper.fNbranch;
135  fNaltro = mapper.fNaltro;
136  fNchannel = mapper.fNchannel;
137  fNpadrow = mapper.fNpadrow;
138  fNpadrowIROC = mapper.fNpadrowIROC;
139  fNpadrowOROC = mapper.fNpadrowOROC;
140  fTpcDdlOffset = mapper.fTpcDdlOffset;
141 
142  return *this;
143 }
144 
145 //______________________________________________________________
146 void AliTPCmapper::Init(const char *dirname)
147 {
149 
150  fNside = 2;
151  fNsector = 18;
152  fNrcu = 6;
153  fNbranch = 2;
154  fNaltro = 8;
155  fNchannel = 16;
156 
157  // Load and read mapping files. AliTPCAltroMapping contains the mapping for
158  // each patch (rcu).
159  TString path;
160  if (dirname==0){
161  path =gSystem->Getenv("ALICE_ROOT");
162  path += "/TPC/mapping/Patch";
163  }else{
164  path = dirname;
165  path +="Patch";
166  }
167 
168  TString path2;
169  for(Int_t i = 0; i < fNrcu; i++) {
170  path2 = path;
171  path2 += i;
172  path2 += ".data";
173  fMapping[i] = new AliTPCAltroMapping(path2.Data());
174  }
175 
176  // Get instance of AliTPCROC object
177  AliTPCROC *fROC = AliTPCROC::Instance();
178  fNpadrowIROC = fROC->GetNRows(0);
179  fNpadrowOROC = fROC->GetNRows(36);
181 
182  AliDAQ daq;
183  fTpcDdlOffset = daq.DdlIDOffset("TPC");
184 
185 }
186 
187 
188 //_____________________________________________________________________________
189 Int_t AliTPCmapper::GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
190 {
192 
193  Int_t patch = GetPatch(roc, padrow, pad);
194  if ( (patch >= fNrcu) || (patch < 0) ) return -1;
195  return fMapping[patch]->GetHWAddress(padrow, pad, roc);
196 }
197 
198 
199 //_____________________________________________________________________________
200 Int_t AliTPCmapper::GetHWAddressSector(Int_t globalpadrow, Int_t pad) const
201 {
203 
204  Int_t patch = 0;
205  Int_t hwAddress=-1;
206  if ( globalpadrow < fNpadrowIROC ) {
207  patch = GetPatch(0, globalpadrow, pad);
208  if (patch>-1)
209  hwAddress = fMapping[patch]->GetHWAddress(globalpadrow, pad, 0);
210  } else if ( globalpadrow < fNpadrow ) {
211  patch = GetPatch(36, globalpadrow - fNpadrowIROC, pad);
212  if (patch>-1)
213  hwAddress = fMapping[patch]->GetHWAddress(globalpadrow - fNpadrowIROC, pad, 36);
214  } else {
215  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
216  hwAddress = -1;
217  }
218  return hwAddress;
219 }
220 
221 
222 //_____________________________________________________________________________
223 Int_t AliTPCmapper::GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
224 {
227 
228  return GetPatch(roc, padrow, pad);
229 }
230 
231 
232 //_____________________________________________________________________________
233 Int_t AliTPCmapper::GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
234 {
237 
238  if ( (padrow < 0) || (pad < 0) || (roc < 0) ) {
239  AliWarning(Form("Pad coordinates outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
240  return -1;
241  }
242 
243  if ( roc < 36 ) {
244  // IROC (ROCs 0 ... 35)
245  Int_t padsInRow = GetNpads(padrow);
246  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
247  AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
248  return -1;
249  }
250  if ( padrow < 30 ) { return 0;
251  } else if ( padrow == 30 ) { // padrow 30 is shared between rcus 0 and 1
252  if ( (pad < 37) || (pad > 48) ) return 1;
253  else return 0;
254  } else if ( padrow < fNpadrowIROC ) { return 1;
255  } else {
256  AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
257  return -1;
258  }
259  } else if ( roc < 72 ) {
260  // OROC (ROCs 36 ... 71)
261  Int_t padsInRow = GetNpads(fNpadrowIROC+padrow);
262  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
263  AliWarning(Form("Pad index outside range (padrow %d, pad %d, roc %d) !", padrow, pad, roc));
264  return -1;
265  }
266  if ( padrow < 27 ) { return 2;
267  } else if ( padrow == 27 ) { // padrow 27 is shared between rcus 2 and 3
268  if ( (pad >= 43) && (pad <= 46) ) return 3;
269  else return 2;
270  } else if ( padrow < 54 ) { return 3;
271  } else if ( padrow < 76 ) { return 4;
272  } else if ( padrow == 76) { // padrow 76 is shared between rcus 4 and 5
273  if ( (pad >= 33) && (pad <= 88) ) return 5;
274  else return 4;
275  } else if ( padrow < fNpadrowOROC ) { return 5;
276  } else {
277  AliWarning(Form("Padrow outside range (padrow %d, roc %d) !", padrow, roc));
278  return -1;
279  }
280  }
281  return -1;
282 }
283 
284 
285 //_____________________________________________________________________________
286 Int_t AliTPCmapper::GetRcuSector(Int_t globalpadrow, Int_t pad) const
287 {
289 
290  return GetPatchSector(globalpadrow, pad);
291 }
292 
293 
294 //_____________________________________________________________________________
295 Int_t AliTPCmapper::GetPatchSector(Int_t globalpadrow, Int_t pad) const
296 {
298 
299  if ( globalpadrow >= fNpadrow ) {
300  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
301  return -1;
302  }
303  if ( globalpadrow < fNpadrowIROC ) return GetPatch(0, globalpadrow, pad);
304  else return GetPatch(36, globalpadrow-fNpadrowIROC, pad);
305 }
306 
307 
308 //_____________________________________________________________________________
309 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t hwAddress) const
310 {
312 
313  if ( (patch >= fNrcu) || (patch < 0) ) {
314  AliWarning(Form("Patch index outside range (patch %d) !", patch));
315  return -1;
316  }
317  return fMapping[patch]->GetPadRow(hwAddress);
318 }
319 
320 
321 //_____________________________________________________________________________
322  Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
323 {
325 
326  if ( patch < 2 ) return GetPadRow(patch, hwAddress);
327  else return GetPadRow(patch, hwAddress) + fNpadrowIROC;
328 }
329 
330 
331 //_____________________________________________________________________________
332 Int_t AliTPCmapper::GetPad(Int_t patch, Int_t hwAddress) const
333 {
335 
336  if ( (patch >= fNrcu) || (patch < 0) ) {
337  AliWarning(Form("Patch index outside range (patch %d) !", patch));
338  return -1;
339  }
340  return fMapping[patch]->GetPad(hwAddress);
341 }
342 
343 
344 //_____________________________________________________________________________
345 Int_t AliTPCmapper::GetPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
346  Int_t channel) const
347 {
349 
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));
354  return -1;
355  }
356  return GetPadRow(patch, CodeHWAddress(branch, fec, chip, channel));
357 }
358 
359 
360 //_____________________________________________________________________________
361 Int_t AliTPCmapper::GetGlobalPadRow(Int_t patch, Int_t branch, Int_t fec, Int_t chip,
362  Int_t channel) const
363 {
365 
366  if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
367  || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
368  AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
369  patch, branch, fec, chip, channel));
370  return -1;
371  }
372  if ( patch < 2 ) return GetPadRow(patch, branch, fec, chip, channel);
373  else return GetPadRow(patch, branch, fec, chip, channel) + fNpadrowIROC;
374 }
375 
376 
377 //_____________________________________________________________________________
378  Int_t AliTPCmapper::GetPad(Int_t patch, Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
379 {
381 
382  if ( (patch >= fNrcu) || (branch >= fNbranch) || (chip >= fNaltro) || (channel >= fNchannel)
383  || (patch < 0) || (branch < 0) || (chip < 0) || (channel < 0) ) {
384  AliWarning(Form("Coordinates outside range (patch %d, branch %d, fec %d, chip %d, channel %d)) !",
385  patch, branch, fec, chip, channel));
386  return -1;
387  }
388  return GetPad(patch, CodeHWAddress(branch, fec, chip, channel));
389 }
390 
391 
392 //_____________________________________________________________________________
393 Int_t AliTPCmapper::GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
394 {
398 
399  return DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
400 }
401 
402 
403 //_____________________________________________________________________________
404 Int_t AliTPCmapper::GetBranchSector(Int_t globalpadrow, Int_t pad) const
405 {
408 
409  return DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
410 }
411 
412 
413 //_____________________________________________________________________________
414 Int_t AliTPCmapper::GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
415 {
420 
421  return DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
422 }
423 
424 
425 //_____________________________________________________________________________
426 Int_t AliTPCmapper::GetFEChwSector(Int_t globalpadrow, Int_t pad) const
427 {
430 
431  return DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
432 }
433 
434 
435 //_____________________________________________________________________________
436 Int_t AliTPCmapper::GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
437 {
440 
441  Int_t patch = GetPatch(roc, padrow, pad);
442  Int_t fec = DecodedHWAddressFECaddr(GetHWAddress(roc, padrow, pad));
443  Int_t branch = DecodedHWAddressBranch(GetHWAddress(roc, padrow, pad));
444  if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
445  return HwToOffline(patch, branch, fec);
446 }
447 
448 
449 //_____________________________________________________________________________
450 Int_t AliTPCmapper::GetFECSector(Int_t globalpadrow, Int_t pad) const
451 {
454 
455  Int_t patch = GetPatchSector(globalpadrow, pad);
456  Int_t fec = DecodedHWAddressFECaddr(GetHWAddressSector(globalpadrow, pad));
457  Int_t branch = DecodedHWAddressBranch(GetHWAddressSector(globalpadrow, pad));
458  if ( (fec < 0) || (branch < 0) || (patch < 0) ) return -1;
459  return HwToOffline(patch, branch, fec);
460 }
461 
462 
463 //_____________________________________________________________________________
464 Int_t AliTPCmapper::GetChip(Int_t roc, Int_t padrow, Int_t pad) const
465 {
467 
468  return DecodedHWAddressChipaddr(GetHWAddress(roc, padrow, pad));
469 }
470 
471 
472 //_____________________________________________________________________________
473 Int_t AliTPCmapper::GetChipSector(Int_t globalpadrow, Int_t pad) const
474 {
477 
478  return DecodedHWAddressChipaddr(GetHWAddressSector(globalpadrow, pad));
479 }
480 
481 
482 //_____________________________________________________________________________
483 Int_t AliTPCmapper::GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
484 {
486 
487  return DecodedHWAddressChanneladdr(GetHWAddress(roc, padrow, pad));
488 }
489 
490 
491 //_____________________________________________________________________________
492 Int_t AliTPCmapper::GetChannelSector(Int_t globalpadrow, Int_t pad) const
493 {
496 
497  return DecodedHWAddressChanneladdr(GetHWAddressSector(globalpadrow, pad));
498 }
499 
500 
501 //_____________________________________________________________________________
502 Int_t AliTPCmapper::CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
503 {
505 
506  return ((branch&1)<<11) + ((fec&0xf)<<7) + ((chip&0x7)<<4) + (channel&0xf);
507 }
508 
509 
510 //_____________________________________________________________________________
511 Int_t AliTPCmapper::DecodedHWAddressBranch(Int_t hwAddress) const
512 {
514 
515  if ( hwAddress < 0 ) return -1;
516  return ((hwAddress>>11)&1);
517 }
518 
519 
520 //_____________________________________________________________________________
521 Int_t AliTPCmapper::DecodedHWAddressFECaddr(Int_t hwAddress) const
522 {
524 
525  if ( hwAddress < 0 ) return -1;
526  return ((hwAddress>>7)&0xf);
527 }
528 
529 
530 //_____________________________________________________________________________
531 Int_t AliTPCmapper::DecodedHWAddressChipaddr(Int_t hwAddress) const
532 {
534 
535  if ( hwAddress < 0 ) return -1;
536  return ((hwAddress>>4)&0x7);
537 }
538 
539 
540 //_____________________________________________________________________________
541 Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
542 {
544 
545  if ( hwAddress < 0 ) return -1;
546  return ((hwAddress&0xf));
547 }
548 
549 
550 //______________________________________________________________
551 Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
553 
554  AliTPCROC *fROC = AliTPCROC::Instance();
555  Int_t retval = fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
556  return retval;
557 }
558 
559 
560 //______________________________________________________________
561 Int_t AliTPCmapper::GetNpads(Int_t globalpadrow) const{
563 
564  if ( globalpadrow >= fNpadrow ) {
565  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
566  return -1;
567  }
568  if ( globalpadrow < fNpadrowIROC ) return GetNpads(0, globalpadrow); // IROC
569  else return GetNpads(36, globalpadrow - fNpadrowIROC); // OROC
570 
571  return -1;
572 }
573 
574 
575 //______________________________________________________________
576 Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
577 {
579 
580  if (roc < 36) return fNpadrowIROC;
581  else if (roc < 72) return fNpadrowOROC;
582  return -1;
583 }
584 
585 
586 //______________________________________________________________
587 /*
588 Double_t AliTPCmapper::GetPadXlocal(Int_t globalpadrow) const
589 {
590  // Get local x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
591 
592  if ( globalpadrow >= fNpadrow ) {
593  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
594  return -1.0;
595  }
596 
597  //IROC
598  if ( globalpadrow < fNpadrowIROC )
599  return (852.25 + 7.5*(Double_t)globalpadrow)/10.; //divide by 10 to get cm
600 
601  globalpadrow -= fNpadrowIROC;
602 
603  if ( globalpadrow < 64 ) //OROC inner part
604  return (10.* globalpadrow + 1351.)/10.; //divide by 10 to get cm
605 
606  //OROC outer part
607  return (15.*(globalpadrow - 64) + 1993.5)/10.; //divide by 10 to get cm
608 }
609 */
610 
611 //______________________________________________________________
612 /*
613 Double_t AliTPCmapper::GetPadYlocal(Int_t globalpadrow, Int_t pad) const
614 {
615  // Get local y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
616 
617  if ( globalpadrow >= fNpadrow ) {
618  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
619  return -1.0;
620  }
621 
622  Int_t padsInRow = GetNpads(globalpadrow);
623  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
624  AliWarning(Form("Pad index outside range (pad %d) !", pad));
625  return -1.0;
626  }
627 
628  //IROC
629  if ( globalpadrow < fNpadrowIROC )
630  return (2.* padsInRow - 4.*pad - 2.)*1.e-1; //divide by 10 to get cm
631 
632  //OROC
633  return (3.* padsInRow -6.*pad - 3.)*1.e-1; //divide by 10 to get cm
634 }
635 */
636 
637 //______________________________________________________________
638 /*
639 Double_t AliTPCmapper::GetPadXglobal(Int_t globalpadrow, Int_t pad, Int_t sector) const
640 {
641  // Get global x coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
642 
643  if ( globalpadrow >= fNpadrow ) {
644  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
645  return -1.0;
646  }
647 
648  Int_t padsInRow = GetNpads(globalpadrow);
649  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
650  AliWarning(Form("Pad index outside range (pad %d) !", pad));
651  return -1.0;
652  }
653 
654  Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
655  return GetPadXlocal(globalpadrow) * TMath::Cos(angle) -
656  GetPadYlocal(globalpadrow, pad) * TMath::Sin(angle);
657 }
658 */
659 
660 //______________________________________________________________
661 /*
662 Double_t AliTPCmapper::GetPadYglobal(Int_t globalpadrow, Int_t pad,Int_t sector) const
663 {
664  // Get global y coordinate of pad, where globalpadrow is counted for a full sector (0 ... 158)
665 
666  if ( globalpadrow >= fNpadrow ) {
667  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
668  return -1.0;
669  }
670 
671  Int_t padsInRow = GetNpads(globalpadrow);
672  if ( (padsInRow < 0) || (pad >= padsInRow) ) {
673  AliWarning(Form("Pad index outside range (pad %d) !", pad));
674  return -1.0;
675  }
676 
677  Double_t angle = (Double_t)(( sector * 20. ) + 10. ) * TMath::DegToRad();
678  return GetPadXlocal(globalpadrow) * TMath::Sin(angle) +
679  GetPadYlocal(globalpadrow, pad) * TMath::Cos(angle);
680 }
681 */
682 
683 //______________________________________________________________
684 /*
685 Double_t AliTPCmapper::GetPadWidth(Int_t globalpadrow) const
686 {
687  // Get pad width, where globalpadrow is counted for a full sector (0 ... 158)
688 
689  if ( globalpadrow >= fNpadrow ) {
690  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
691  return -1.0;
692  }
693 
694  if (globalpadrow < fNpadrowIROC ) // IROC
695  return 0.4;
696  return 0.6;
697 }
698 */
699 
700 //______________________________________________________________
701 /*
702 Double_t AliTPCmapper::GetPadLength(Int_t globalpadrow) const
703 {
704  // Get pad length, where globalpadrow is counted for a full sector (0 ... 158)
705 
706  if ( globalpadrow >= fNpadrow ) {
707  AliWarning(Form("Padrow outside range (globalpadrow %d) !", globalpadrow));
708  return -1.0;
709  }
710 
711  if ( globalpadrow < fNpadrowIROC ) return 0.75;
712  if ( globalpadrow < 127 ) return 1.0;
713  return 1.5;
714 }
715 */
716 
717 //_____________________________________________________________________________
718 Int_t AliTPCmapper::GetNfec(Int_t patch) const
719 {
721 
722  Int_t retval = 0;
723  switch(patch){
724  case(0):
725  retval = 18;
726  break;
727  case(1):
728  retval = 25;
729  break;
730  case(2):
731  retval = 18;
732  break;
733  case(3):
734  retval = 20;
735  break;
736  case(4):
737  retval = 20;
738  break;
739  case(5):
740  retval = 20;
741  break;
742  };
743  return retval;
744 }
745 
746 
747 //_____________________________________________________________________________
748 Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
749 {
751 
752  Int_t retval = 0;
753  switch(patch){
754  case(0):
755  retval = 9;
756  break;
757  case(1):
758  retval = 13;
759  break;
760  case(2):
761  retval = 9;
762  break;
763  case(3):
764  retval = 10;
765  break;
766  case(4):
767  retval = 10;
768  break;
769  case(5):
770  retval = 10;
771  break;
772  };
773 
774  if( (branch == 1) && (patch == 1) ){
775  retval = 12;
776  }
777 
778  return retval;
779 }
780 
781 
782 //_____________________________________________________________________________
783 Int_t AliTPCmapper::OfflineToHwFec(Int_t patch, Int_t fec) const
784 {
786 
787  if ( (patch < 0) || (fec < 0) ) {
788  AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
789  return -1;
790  }
791  if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
792  AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
793  return -1;
794  }
795 
796  Int_t fecsInBranchA = GetNfec(patch, 0);
797  if ( fec < fecsInBranchA ) // branch A
798  return (fecsInBranchA - 1 - fec);
799  else // branch B
800  return (fec - fecsInBranchA);
801 
802  return -1;
803 }
804 
805 
806 //_____________________________________________________________________________
807 Int_t AliTPCmapper::OfflineToHwBranch(Int_t patch, Int_t fec) const
808 {
810 
811  if ( (patch < 0) || (fec < 0) ) {
812  AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
813  return -1;
814  }
815  if ( (patch > 5) || (fec >= GetNfec(patch)) ) {
816  AliWarning(Form("Patch (%d) or Fec number (%d) outside range !", patch, fec));
817  return -1;
818  }
819  if ( fec < GetNfec(patch, 0) ) return 0; // branch A
820  else return 1; // branch B
821 
822  return -1;
823 }
824 
825 
826 //_____________________________________________________________________________
827 Int_t AliTPCmapper::HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
828 {
830 
831  if ( (patch < 0) || (fec < 0) || (branch < 0) ) {
832  AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
833  return -1;
834  }
835  if ( (patch > 5) || (branch > 1) || (fec >= GetNfec(patch, branch)) ) {
836  AliWarning(Form("Patch (%d), branch (%d) or Fec number (%d) outside range !", patch, branch, fec));
837  return -1;
838  }
839  Int_t fecsInBranchA = GetNfec(patch, 0);
840  if ( branch == 0 ) // branch A
841  return (fecsInBranchA - 1 - fec);
842  else // branch B
843  return (fec + fecsInBranchA);
844 
845  return -1;
846 }
847 
848 
849 //_____________________________________________________________________________
850 Int_t AliTPCmapper::GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
851 {
854 
855  Int_t side = GetSideFromRoc(roc);
856  if ( side < 0 ) return -1;
857  Int_t sector = GetSectorFromRoc(roc);
858  if ( sector < 0 ) return -1;
859  Int_t patch = GetPatch(roc, padrow, pad);
860  if ( patch < 0 ) return -1;
861  return GetEquipmentIDfromPatch(side, sector, patch);
862 }
863 
864 
865 //_____________________________________________________________________________
866 Int_t AliTPCmapper::GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
867 {
869 
870  Int_t patch = GetPatchSector(globalpadrow, pad);
871  if ( patch < 0 ) return -1;
872  Int_t roc = GetRocFromPatch(side, sector, patch);
873  if ( roc < 0 ) return -1;
874 
875  if ( globalpadrow < fNpadrowIROC )
876  return GetEquipmentID(roc, globalpadrow, pad);
877  else
878  return GetEquipmentID(roc, globalpadrow-fNpadrowIROC, pad);
879 }
880 
881 
882 //_____________________________________________________________________________
883 Int_t AliTPCmapper::GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
884 {
886 
887  Int_t roc = GetRocFromPatch(side, sector, patch);
888  Int_t ddl = 0;
889  if (patch < 2) // IROC
890  ddl = roc*2 + patch;
891  else // OROC
892  ddl = (roc-36)*4 + 36*2 + (patch-2);
893  // Add offset. TPC has detectorID = 3
894  return ddl+fTpcDdlOffset;
895 }
896 
897 
898 //_____________________________________________________________________________
899 Int_t AliTPCmapper::GetPatchFromEquipmentID(Int_t equipmentID) const
900 {
902 
903  Int_t retval = 0;
904 
905  if ( (equipmentID < fTpcDdlOffset) || (equipmentID > 983) ) {
906  AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
907  return -1;
908  }
909  if ( ( (int)equipmentID - 840 ) < 0) retval = (equipmentID-768)%2;
910  else retval = (equipmentID-840)%4 + 2;
911  return retval;
912 }
913 
914 
915 //_____________________________________________________________________________
916 Int_t AliTPCmapper::GetSideFromEquipmentID(Int_t equipmentID) const
917 {
919 
920  if ( equipmentID < fTpcDdlOffset ) {
921  AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
922  return -1;
923  }
924  if ( equipmentID < 804 ) return 0;
925  else if ( equipmentID < 840 ) return 1;
926  else if ( equipmentID < 912 ) return 0;
927  else if ( equipmentID < 984 ) return 1;
928  else {
929  AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
930  return -1;
931  }
932 }
933 
934 
935 //_____________________________________________________________________________
936 Int_t AliTPCmapper::GetSectorFromEquipmentID(Int_t equipmentID) const
937 {
939 
940  Int_t retval = 0;
941  if ( (equipmentID < fTpcDdlOffset) || (equipmentID >= fTpcDdlOffset+216) ) {
942  AliWarning(Form("Equipment ID (%d) outside range !", equipmentID));
943  return -1;
944  }
945  Int_t side = GetSideFromEquipmentID(equipmentID);
946  if ( side < 0 ) return -1;
947 
948  if ( (equipmentID - 840) < 0 ) { // IROC
949  if ( side == 0 ) retval = (equipmentID-fTpcDdlOffset)/2;
950  else retval = (equipmentID-fTpcDdlOffset-18*2)/2;
951  } else { // OROC
952  if ( side == 0 ) retval = (equipmentID-840)/4;
953  else retval = (equipmentID-840-18*4)/4;
954  }
955  return retval;
956 }
957 
958 
959 //_____________________________________________________________________________
960 Int_t AliTPCmapper::GetRocFromEquipmentID(Int_t equipmentID) const
961 {
963 
964  Int_t side = GetSideFromEquipmentID(equipmentID);
965  if ( side < 0 ) return -1;
966  Int_t sector = GetSectorFromEquipmentID(equipmentID);
967  if ( sector < 0 ) return -1;
968  Int_t patch = GetPatchFromEquipmentID(equipmentID);
969  if ( patch < 0 ) return -1;
970 
971  return GetRocFromPatch(side, sector, patch);
972 }
973 
974 
975 //_____________________________________________________________________________
976 Int_t AliTPCmapper::GetSectorFromRoc(Int_t roc) const
977 {
979 
980  if ( roc < 0 ) {
981  AliWarning(Form("Roc outside range (roc %d) !", roc));
982  return -1;
983  } else if ( roc < 18 ) { // inner sector, A side
984  return roc;
985  } else if ( roc < 36 ) { // inner sector, C side
986  return (roc-18);
987  } else if ( roc < 54 ) { // outer sector, A side
988  return (roc-36);
989  } else if ( roc < 72 ) { // outer sector, C side
990  return (roc-54);
991  } else {
992  AliWarning(Form("Roc outside range (roc %d) !", roc));
993  return -1;
994  }
995 }
996 
997 
998 //_____________________________________________________________________________
999 Int_t AliTPCmapper::GetSideFromRoc(Int_t roc) const
1000 {
1002 
1003  if ( roc < 0 ) {
1004  AliWarning(Form("Roc outside range (roc %d) !", roc));
1005  return -1;
1006  } else if ( roc < 18 ) { // inner sector, A side
1007  return 0;
1008  } else if ( roc < 36 ) { // inner sector, C side
1009  return 1;
1010  } else if ( roc < 54 ) { // outer sector, A side
1011  return 0;
1012  } else if ( roc < 72 ) { // outer sector, C side
1013  return 1;
1014  } else {
1015  AliWarning(Form("Roc outside range (roc %d) !", roc));
1016  return -1;
1017  }
1018 }
1019 
1020 
1021 //_____________________________________________________________________________
1022 Int_t AliTPCmapper::GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
1023 {
1025 
1026  if ( (side < 0) || (side >= fNside) ) {
1027  AliWarning(Form("Side outside range (side %d) !", side));
1028  return -1;
1029  }
1030  if ( (sector < 0) || (sector >= fNsector) ) {
1031  AliWarning(Form("Sector outside range (sector %d) !", sector));
1032  return -1;
1033  }
1034  if ( (patch < 0) || (patch >= fNrcu) ) {
1035  AliWarning(Form("Patch (rcu) outside range (patch %d) !", patch));
1036  return -1;
1037  }
1038 
1039  if ( side == 0 ) { // A side
1040  if ( patch < 2 ) return sector; // IROC
1041  else return 36+sector; // OROC
1042  } else { // C side
1043  if ( patch < 2 ) return 18+sector; // IROC
1044  else return 54+sector; // OROC
1045  }
1046 }
1047 
1048 
1049 //_____________________________________________________________________________
1050 Int_t AliTPCmapper::GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
1051 {
1053 
1054  Int_t patch = GetPatchSector(globalpadrow, pad);
1055  if ( patch < 0 ) return -1;
1056  return GetRocFromPatch(side, sector, patch);
1057 }
1058 
1059 
1060 //_____________________________________________________________________________
1061  Bool_t AliTPCmapper::IsIROC(Int_t roc) const
1062 {
1064 
1065  if ( roc < 0 ) {
1066  AliWarning(Form("Roc outside range (roc %d) !", roc));
1067  return -1;
1068  } else if ( roc < 36 ) { // inner sector
1069  return true;
1070  } else if ( roc < 72 ) { // outer sector, C side
1071  return false;
1072  } else {
1073  AliWarning(Form("Roc outside range (roc %d) !", roc));
1074  return -1;
1075  }
1076 }
1077 
1078 
1079 //_____________________________________________________________________________
1080  Bool_t AliTPCmapper::IsOROC(Int_t roc) const
1081 {
1083 
1084  if ( roc < 0 ) {
1085  AliWarning(Form("Roc outside range (roc %d) !", roc));
1086  return -1;
1087  } else if ( roc < 36 ) { // inner sector
1088  return false;
1089  } else if ( roc < 72 ) { // outer sector, C side
1090  return true;
1091  } else {
1092  AliWarning(Form("Roc outside range (roc %d) !", roc));
1093  return -1;
1094  }
1095 }
1096 
1097 // EOF
UInt_t GetNPads(UInt_t sector, UInt_t row) const
Definition: AliTPCROC.h:30
Int_t GetChipSector(Int_t globalpadrow, Int_t pad) const
Int_t DecodedHWAddressChipaddr(Int_t hwAddress) const
Bool_t IsIROC(Int_t roc) const
Int_t GetGlobalPadRow(Int_t patch, Int_t hwAddress) const
virtual ~AliTPCmapper()
Int_t GetNpads(Int_t roc, Int_t padrow) const
Int_t GetFECSector(Int_t globalpadrow, Int_t pad) const
Int_t GetRcu(Int_t roc, Int_t padrow, Int_t pad) const
Int_t GetHWAddressSector(Int_t globalpadrow, Int_t pad) const
Int_t DecodedHWAddressChanneladdr(Int_t hwAddress) const
const char * path
Int_t GetRoc(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
AliTPCmapper.
Definition: AliTPCmapper.h:15
Int_t GetPad(Int_t patch, Int_t hwAddress) const
Int_t GetEquipmentIDsector(Int_t side, Int_t sector, Int_t globalpadrow, Int_t pad) const
AliTPCAltroMapping * fMapping[6]
The ALTRO mapping for each patch (rcu)
Definition: AliTPCmapper.h:119
Int_t GetFEChwSector(Int_t globalpadrow, Int_t pad) const
Int_t GetNfec(Int_t patch, Int_t branch) const
Int_t OfflineToHwBranch(Int_t patch, Int_t fec) const
Int_t GetFEC(Int_t roc, Int_t padrow, Int_t pad) const
Int_t CodeHWAddress(Int_t branch, Int_t fec, Int_t chip, Int_t channel) const
#define AliWarning(message)
Definition: AliLog.h:541
Int_t GetPatch(Int_t roc, Int_t padrow, Int_t pad) const
Int_t GetEquipmentID(Int_t roc, Int_t padrow, Int_t pad) const
Int_t GetFEChw(Int_t roc, Int_t padrow, Int_t pad) const
Int_t GetSideFromEquipmentID(Int_t equipmentID) const
Definition: AliDAQ.h:31
Int_t GetChannel(Int_t roc, Int_t padrow, Int_t pad) const
Int_t GetRocFromPatch(Int_t side, Int_t sector, Int_t patch) const
Int_t GetBranchSector(Int_t globalpadrow, Int_t pad) const
Int_t DecodedHWAddressBranch(Int_t hwAddress) const
Geometry class for a single ROC.
Definition: AliTPCROC.h:14
AliTPCmapper & operator=(const AliTPCmapper &mapper)
Int_t GetPadRow(Int_t patch, Int_t hwAddress) const
Int_t OfflineToHwFec(Int_t patch, Int_t fec) const
Int_t fNrcu
Sector has 6 RCUs (patches)
Definition: AliTPCmapper.h:109
Int_t fNpadrowIROC
IROC has 63 padrows.
Definition: AliTPCmapper.h:114
Int_t GetChip(Int_t roc, Int_t padrow, Int_t pad) const
Int_t GetPatchFromEquipmentID(Int_t equipmentID) const
Int_t DecodedHWAddressFECaddr(Int_t hwAddress) const
static Int_t DdlIDOffset(const char *detectorName)
Definition: AliDAQ.cxx:238
AliCaloAltroMapping * fMapping[4]
Int_t fNpadrow
Sector has 159 padrows.
Definition: AliTPCmapper.h:113
Int_t fNside
TPC has 2 sides.
Definition: AliTPCmapper.h:107
Int_t GetSectorFromRoc(Int_t roc) const
Int_t fNaltro
FEC has 8 ALTROs.
Definition: AliTPCmapper.h:111
Int_t fTpcDdlOffset
DDL offset for TPC.
Definition: AliTPCmapper.h:117
Int_t fNsector
TPC side has 18 sectors.
Definition: AliTPCmapper.h:108
Int_t GetRcuSector(Int_t globalpadrow, Int_t pad) const
virtual Int_t GetPadRow(Int_t hwAddress) const
Int_t fNpadrowOROC
OROC has 96 padrows.
Definition: AliTPCmapper.h:115
Int_t GetEquipmentIDfromPatch(Int_t side, Int_t sector, Int_t patch) const
Int_t GetRocFromEquipmentID(Int_t equipmentID) const
virtual Int_t GetPad(Int_t hwAddress) const
Int_t GetChannelSector(Int_t globalpadrow, Int_t pad) const
Int_t fNbranch
RCU has 2 branches.
Definition: AliTPCmapper.h:110
static AliTPCROC * Instance()
Definition: AliTPCROC.cxx:34
Int_t GetSideFromRoc(Int_t roc) const
Int_t GetHWAddress(Int_t roc, Int_t padrow, Int_t pad) const
Int_t fNchannel
ALTRO has 16 channels.
Definition: AliTPCmapper.h:112
Bool_t IsOROC(Int_t roc) const
Int_t HwToOffline(Int_t patch, Int_t branch, Int_t fec) const
Int_t GetSectorFromEquipmentID(Int_t equipmentID) const
Int_t GetBranch(Int_t roc, Int_t padrow, Int_t pad) const
Int_t GetNpadrows(Int_t roc) const
virtual Int_t GetHWAddress(Int_t padrow, Int_t pad, Int_t sector)
void Init(const char *dirname)
Int_t GetPatchSector(Int_t globalpadrow, Int_t pad) const