]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/macros/FEEToTower.C
update ITS simulation class
[u/mrichter/AliRoot.git] / EMCAL / macros / FEEToTower.C
1 // some global var/constants
2 const Int_t kNRCU = 2; // per SM
3 AliCaloAltroMapping *fMapping[4]; // 1 for each side (A/C) and each RCU (0/1), i.e. 2*2 total
4 //
5 const Bool_t kDebug = kFALSE;
6 const char *branchStr[] = {"A", "B"};
7
8 // help methods
9 Int_t GetHWAddress(Int_t branch, Int_t FEC, Int_t chip, Int_t chan);
10 void GetMapping();
11
12 // main method
13 void 
14 FEEToTower(Int_t iSM=0, Int_t iRCU=0, Int_t branch=0, Int_t FEC=1, Int_t chip=0, Int_t chan=0)
15 {
16   // Get mapping file info, and clear arrays
17   GetMapping();
18
19   Int_t isect = iSM / 2; //
20   Int_t iside = iSM % 2; // A or C side
21
22   Int_t iRCUSide = iside*2 + iRCU;
23   Int_t iDDL = iRCU + iSM * kNRCU;
24
25   Int_t hwAddress = GetHWAddress(branch, FEC, chip, chan);
26
27   Int_t icol = fMapping[iRCUSide]->GetPad(hwAddress);
28   Int_t irow = fMapping[iRCUSide]->GetPadRow(hwAddress); 
29   Int_t caloflag = fMapping[iRCUSide]->GetSector(hwAddress);
30   
31   // report channel info
32   printf(" iSM %d iRCU %d (iDDL %d EqId %d) : branch %d (%s) FEC %d chip %d chan %d \n corresponds to \n iSM %d icol %d irow %d caloflag (igain) %d \n", 
33          iSM, iRCU, iDDL, iDDL + 0x1200, 
34          branch, branchStr[branch], FEC, chip, chan,
35          iSM, icol, irow, caloflag);
36
37   return;
38 }
39
40 Int_t
41 GetHWAddress(Int_t branch, Int_t FEC, Int_t chip, Int_t chan)
42 {
43   Int_t hwAddr = (branch << 11) | (FEC << 7) | (chip << 4) | chan; 
44   return hwAddr;
45 }
46
47 void 
48 GetMapping()
49 {  
50   TString sides[]={"A","C"};
51   // Read mapping files from $ALICE_ROOT/CALO/mapping/*.data
52   TString path = gSystem->Getenv("ALICE_ROOT");
53   path += "/EMCAL/mapping/RCU";
54   TString path2;
55   for(Int_t j = 0; j < 2; j++){ // sides
56     for(Int_t i = 0; i < 2; i++) { // RCU
57       path2 = path;
58       path2 += i;
59       path2 += sides[j];
60       path2 += ".data";
61       if (kDebug) { printf("Mapping file: %s\n",path2.Data()); }
62       fMapping[j*2 + i] = new AliCaloAltroMapping(path2.Data());
63     }
64   }
65   return;
66 }
67