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
7 //____________________________________________________________________
8 void WriteOCDBCalibMapAPD(const char * inputDBName, const char * inputMapName,
9 const char * outputFileName, const int swapSides)
12 gSystem->Load("AliEMCALCalibAPD_cxx");
13 AliEMCALCalibAPD *calibAPD = new AliEMCALCalibAPD();
15 calibAPD->ReadCalibAPDInfo(10000, inputDBName);
16 int fNCalibAPD = calibAPD->GetNCalibAPD();
17 AliEMCALCalibAPD::AliEMCALCalibAPDData * fCalib = calibAPD->GetCalibAPDData();
19 gSystem->Load("AliEMCALMapAPD_cxx");
20 AliEMCALMapAPD *mapAPD = new AliEMCALMapAPD();
22 // assume we do this for one SuperModule at a time; can merge the
23 // output files with 'cat' or so separately
25 mapAPD->ReadMapAPDInfo(nSM, inputMapName);
26 AliEMCALMapAPD::AliEMCALSuperModuleMapAPD * fMap = mapAPD->GetSuperModuleData();
29 ofstream outputFile(outputFileName);
31 // let's loop over the files..
36 for (int icol=0; icol<fgkEMCALCols; icol++) {
37 for (int irow=0; irow<fgkEMCALRows; irow++) {
41 // C side, oriented differently than A side: swap is requested
42 iCol = fgkEMCALCols-1 - iCol;
43 iRow = fgkEMCALRows-1 - iRow;
46 int apdMap = fMap[0].fAPDNum[icol][irow]; // 0 = nSM - 1
49 while (i<fNCalibAPD && apdMap!=apdCalib) {
50 apdCalib = fCalib[i].fAPDNum;
54 if (apdCalib == apdMap) { // found!
55 i--; // go back to what we found
57 // should also calculate the HardWare Id.. note that the functionality
58 // of the Tower2FEEMap and GetHardWareId calls have not been tested here..
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
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;
75 cout << " APD " << apdMap << " could not be found! " << endl;
76 // print some dummy info
83 cout << " found " << nFound << " matches " << endl;
84 cout << " did not find " << nNotFound << " APDs " << endl;
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 ); }; //
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
102 void Tower2FEEMap(const int icol, const int irow,
103 int *ircu, int *ibranch, int *card, int *icsp)
105 If you are interested in where these magic numbers come from -
107 http://dsilverm.web.cern.ch/dsilverm/mapping/emcal_mapping.html
108 http://dsilverm.web.cern.ch/dsilverm/mapping/ppt/Coordinates_and_Mapping.pdf */
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
114 *ircu = FEC / 18; // 18 FEC per RCU
115 *ibranch = (FEC%18) / 9;
118 // columns and rows within an FEC area
122 // The mapping to CSP is a bit complicated so I also define two more help variables here..
124 int TCard = tCol/2; // 0=Top (even StripModules), 1=Bottom (odd StripModules)
125 int locCol = tCol%2; // local column inside T-card
127 *icsp = (7 - tRow) + locCol*16 + TCard*8;