]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/macros/TowerToFEE.C
Setting of aliases to rawReader done only once. Base decision on cosmic or calib...
[u/mrichter/AliRoot.git] / EMCAL / macros / TowerToFEE.C
CommitLineData
4d4342fd 1// some global var/constants
2const Int_t kNRCU = 2; // per SM
3AliCaloAltroMapping *fMapping[4]; // 1 for each side (A/C) and each RCU (0/1), i.e. 2*2 total
4//
5const Bool_t kDebug = kFALSE;
6const char *branchStr[] = {"A", "B"};
7
8// help methods
9Int_t GetHWAddress(Int_t iside, Int_t icol, Int_t irow, Int_t igain);
10void DecodeHWAddress(Int_t hwAddr, Int_t & branch, Int_t & FEC, Int_t & chip, Int_t & chan);
11void GetMapping();
12
13// main method
14void
15TowerToFEE(Int_t iSM=0, Int_t icol=0, Int_t irow=0, Int_t igain=0)
16{
17 // Get mapping file info, and clear arrays
18 GetMapping();
19
20 Int_t isect = iSM / 2; //
21 Int_t iside = iSM % 2; // A or C side
22
23 Int_t hwAddress = 0;
24 Int_t iRCU = 0;
25 Int_t branch = 0;
26 Int_t FEC = 0;
27 Int_t chip = 0;
28 Int_t chan = 0;
29
30 hwAddress = GetHWAddress(iside, icol, irow, igain, iRCU);
31 DecodeHWAddress(hwAddress, branch, FEC, chip, chan);
32
33 Int_t iDDL = iRCU + iSM * kNRCU;
34
35 // report channel info
36 printf(" iSM %d icol %d irow %d caloflag (igain) %d \n corresponds to \n iSM %d iRCU %d (iDDL %d EqId %d) : branch %d (%s) FEC %d chip %d chan %d\n",
37 iSM, icol, irow, igain,
38 iSM, iRCU, iDDL, iDDL + 0x1200,
39 branch, branchStr[branch], FEC, chip, chan);
40
41 return;
42}
43
44void
45DecodeHWAddress(Int_t hwAddr, Int_t & branch, Int_t & FEC, Int_t & chip, Int_t & chan)
46{
47 chan = hwAddr & 0xf;
48 chip = (hwAddr >> 4) & 0x7;
49 FEC = (hwAddr >> 7) & 0xf;
50 branch = (hwAddr >> 11) & 0x1;
51 return;
52}
53
54Int_t
55GetHWAddress(Int_t iside, Int_t icol, Int_t irow, Int_t igain, Int_t & iRCU)
56{
57 iRCU = -111;
58
59 //RCU0
60 if (0<=irow&&irow<8) iRCU=0; // first cable row
61 else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
62 //second cable row
63 //RCU1
64 else if(8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
65 //second cable row
66 else if(16<=irow&&irow<24) iRCU=1; // third cable row
67
68 // swap for odd=C side, to allow us to cable both sides the same
69 Int_t iRCUSide = iRCU;
70 if (iside == 1) {
71 iRCU = 1 - iRCU;
72 iRCUSide = iRCU + 2; // to make it map file index
73 }
74 Int_t hwAddress = fMapping[iRCUSide]->GetHWAddress(irow, icol, igain);
75
76 return hwAddress;
77}
78
79void
80GetMapping()
81{
82 TString sides[]={"A","C"};
83 // Read mapping files from $ALICE_ROOT/CALO/mapping/*.data
84 TString path = gSystem->Getenv("ALICE_ROOT");
85 path += "/EMCAL/mapping/RCU";
86 TString path2;
87 for(Int_t j = 0; j < 2; j++){ // sides
88 for(Int_t i = 0; i < 2; i++) { // RCU
89 path2 = path;
90 path2 += i;
91 path2 += sides[j];
92 path2 += ".data";
93 if (kDebug) { printf("Mapping file: %s\n",path2.Data()); }
94 fMapping[j*2 + i] = new AliCaloAltroMapping(path2.Data());
95 }
96 }
97 return;
98}
99