]>
Commit | Line | Data |
---|---|---|
d81e6423 | 1 | /* |
2 | */ | |
3 | // from AliEMCALGeoParams.h | |
4 | static const int fgkEMCALRows = 24; // number of rows per module for EMCAL | |
5 | static const int fgkEMCALCols = 48; // number of columns per module for EMCAL | |
6 | ||
7 | //____________________________________________________________________ | |
8 | void WriteOCDBCalibMapAPD(const char * inputDBName, const char * inputMapName, | |
9 | const char * outputFileName, const int swapSides) | |
10 | { | |
11 | ||
12 | gSystem->Load("AliEMCALCalibAPD_cxx"); | |
13 | AliEMCALCalibAPD *calibAPD = new AliEMCALCalibAPD(); | |
14 | ||
15 | calibAPD->ReadCalibAPDInfo(10000, inputDBName); | |
16 | int fNCalibAPD = calibAPD->GetNCalibAPD(); | |
17 | AliEMCALCalibAPD::AliEMCALCalibAPDData * fCalib = calibAPD->GetCalibAPDData(); | |
18 | ||
19 | gSystem->Load("AliEMCALMapAPD_cxx"); | |
20 | AliEMCALMapAPD *mapAPD = new AliEMCALMapAPD(); | |
21 | ||
22 | // assume we do this for one SuperModule at a time; can merge the | |
23 | // output files with 'cat' or so separately | |
24 | int nSM = 1; | |
25 | mapAPD->ReadMapAPDInfo(nSM, inputMapName); | |
26 | AliEMCALMapAPD::AliEMCALSuperModuleMapAPD * fMap = mapAPD->GetSuperModuleData(); | |
27 | ||
28 | // set up ouput file | |
29 | ofstream outputFile(outputFileName); | |
30 | ||
31 | // let's loop over the files.. | |
32 | int nFound = 0; | |
33 | int nNotFound = 0; | |
34 | int iCol = 0; | |
35 | int iRow = 0; | |
36 | for (int icol=0; icol<fgkEMCALCols; icol++) { | |
37 | for (int irow=0; irow<fgkEMCALRows; irow++) { | |
38 | iCol = icol; | |
39 | iRow = irow; | |
40 | if (swapSides) { | |
41 | // C side, oriented differently than A side: swap is requested | |
42 | iCol = fgkEMCALCols-1 - iCol; | |
43 | iRow = fgkEMCALRows-1 - iRow; | |
44 | } | |
45 | ||
46 | int apdMap = fMap[0].fAPDNum[icol][irow]; // 0 = nSM - 1 | |
47 | int i = 0; | |
48 | int apdCalib = -1; | |
49 | while (i<fNCalibAPD && apdMap!=apdCalib) { | |
50 | apdCalib = fCalib[i].fAPDNum; | |
51 | i++; | |
52 | } | |
53 | ||
54 | if (apdCalib == apdMap) { // found! | |
55 | i--; // go back to what we found | |
56 | ||
57 | // should also calculate the HardWare Id.. note that the functionality | |
58 | // of the Tower2FEEMap and GetHardWareId calls have not been tested here.. | |
59 | ||
60 | int ircu, ibranch, card, icsp; | |
61 | Tower2FEEMap(icol, irow, &ircu, &ibranch, &card, &icsp); | |
62 | int iHW = GetCSPAddress(ibranch, card, icsp); | |
63 | iHW |= (ircu << 12); // RCU not part of normal HW addresses, but we add an extra bit for it here, just in case it might be useful | |
64 | ||
65 | // print some info.. | |
66 | outputFile << iCol << " " << iRow << " " << iHW | |
67 | << " " << fCalib[i].fAPDNum << " " << fCalib[i].fV30 | |
68 | << " " << fCalib[i].fPar[0] << " " << fCalib[i].fPar[1] << " " << fCalib[i].fPar[2] | |
69 | << " " << fCalib[i].fParErr[0] << " " << fCalib[i].fParErr[1] << " " << fCalib[i].fParErr[2] | |
70 | << " " << fCalib[i].fBreakDown << " " << fCalib[i].fDarkCurrent << endl; | |
71 | ||
72 | nFound++; | |
73 | } | |
74 | else { | |
75 | cout << " APD " << apdMap << " could not be found! " << endl; | |
76 | // print some dummy info | |
77 | nNotFound++; | |
78 | } | |
79 | ||
80 | } | |
81 | } | |
82 | ||
83 | cout << " found " << nFound << " matches " << endl; | |
84 | cout << " did not find " << nNotFound << " APDs " << endl; | |
85 | ||
86 | // close down | |
87 | outputFile.close(); | |
88 | } | |
89 | ||
90 | // from AliEMCALGeoParams.h: | |
91 | Int_t GetCSPAddress(Int_t iBranch, Int_t iFEC, Int_t iCSP) const | |
92 | { return ( (iBranch<<11) | (iFEC<<7) | iCSP ); }; // | |
93 | ||
94 | // from DCSGenerateAPD.C; the method assumes that the columns and rows | |
95 | // are labelled as we have them on the A side (normal case for calibrations | |
96 | // before the installation) | |
97 | const int NRCU = 2; // per SM | |
98 | const int NBranch = 2; // per RCU | |
99 | const int NFEC = 9; // per branch, labelled 1..9 | |
100 | const int NCSP = 32; // per FEC | |
101 | ||
102 | void Tower2FEEMap(const int icol, const int irow, | |
103 | int *ircu, int *ibranch, int *card, int *icsp) | |
104 | { /* | |
105 | If you are interested in where these magic numbers come from - | |
106 | See mapping info on | |
107 | http://dsilverm.web.cern.ch/dsilverm/mapping/emcal_mapping.html | |
108 | http://dsilverm.web.cern.ch/dsilverm/mapping/ppt/Coordinates_and_Mapping.pdf */ | |
109 | ||
110 | // each FEC covers a 4x8 tower area | |
111 | int C = irow/8; // Cable bundle | |
112 | int FEC = C*12 + icol/4; // FEC in 0..35 range | |
113 | ||
114 | *ircu = FEC / 18; // 18 FEC per RCU | |
115 | *ibranch = (FEC%18) / 9; | |
116 | *card = FEC % 9; | |
117 | ||
118 | // columns and rows within an FEC area | |
119 | int tCol = icol%4; | |
120 | int tRow = irow%8; | |
121 | ||
122 | // The mapping to CSP is a bit complicated so I also define two more help variables here.. | |
123 | // which T-card? | |
124 | int TCard = tCol/2; // 0=Top (even StripModules), 1=Bottom (odd StripModules) | |
125 | int locCol = tCol%2; // local column inside T-card | |
126 | ||
127 | *icsp = (7 - tRow) + locCol*16 + TCard*8; | |
128 | } |