29 void GetPedVal(
const Int_t iSM,
const Int_t igain,
const TProfile2D *h2);
30 void GetPedValLEDRef(
const Int_t iSM,
const Int_t igain,
const TProfile *h);
33 Int_t
GetHWAddress(Int_t iside, Int_t icol, Int_t irow, Int_t igain);
35 void DecodeHWAddress(Int_t hwAddr, Int_t & branch, Int_t & FEC, Int_t & chip, Int_t & chan);
58 for (Int_t iSM=0; iSM<
kNSM; iSM++)
60 GetPedVal ( iSM, 0, emcCalibPedestal->GetPedProfileLowGain(iSM) );
61 GetPedVal ( iSM, 1, emcCalibPedestal->GetPedProfileHighGain(iSM) );
62 GetPedValLEDRef( iSM, 0, emcCalibPedestal->GetPedLEDRefProfileLowGain(iSM) );
63 GetPedValLEDRef( iSM, 1, emcCalibPedestal->GetPedLEDRefProfileHighGain(iSM) );
73 GetPedVal(
const Int_t iSM,
const Int_t igain,
const TProfile2D *h2)
75 Int_t isect = iSM / 2;
76 Int_t iside = iSM % 2;
77 Int_t nCols = h2->GetNbinsX();
78 Int_t nRows = h2->GetNbinsY();
81 printf(
"GetPedVal: iSM %d isect %d iside %d igain %d nRows %d nCols %d\n",
82 iSM, isect, iside, igain, nRows, nCols);
96 for (icol=0; icol<nCols; icol++)
98 for (irow=0; irow<nRows; irow++)
101 hwAddress =
GetHWAddress(iside, icol, irow, igain, iRCU);
103 bin = h2->FindBin(icol, irow);
106 fMeanPed[iSM][iRCU][branch][FEC][chip][chan] = h2->GetBinContent(bin);
107 fRmsPed[iSM][iRCU][branch][FEC][chip][chan] = h2->GetBinError(bin);
110 if (h2->GetBinError(bin) >
kBadRMS)
112 printf(
" bad pedestal RMS: iSM %d icol %d irow %d igain %d iRCU %d branch %d FEC %d chip %d chan %d - mean %4.1f rms %4.1f\n",
113 iSM, icol, irow, igain, iRCU, branch, FEC, chip, chan,
114 h2->GetBinContent(bin), h2->GetBinError(bin));
127 Int_t isect = iSM / 2;
128 Int_t iside = iSM % 2;
129 Int_t nStrips = h->GetNbinsX();
133 printf(
"GetPedValLEDRef: iSM %d isect %d iside %d igain %d nStrips %d\n",
134 iSM, isect, iside, igain, nStrips);
148 for (
int istrip=0; istrip<nStrips; istrip++)
152 bin = h->FindBin(istrip);
155 fMeanPed[iSM][iRCU][branch][FEC][chip][chan] = h->GetBinContent(bin);
156 fRmsPed[iSM][iRCU][branch][FEC][chip][chan] = h->GetBinError(bin);
167 const char * sideStr[] = {
"A",
"C"};
168 const char * branchStr[] = {
"A",
"B"};
170 int RCUWrite = 0x200000;
173 char scriptLine[200];
183 for (iSM=0; iSM<
kNSM; iSM++)
187 for (iRCU=0; iRCU<
kNRCU; iRCU++)
189 sprintf(filename,
"setSM%1s%dRCU%d.scr",
190 sideStr[iside], isect, iRCU);
191 ofstream
fout(filename);
192 int nscriptLines = 0;
194 for (ibranch=0; ibranch<
kNBranch; ibranch++)
198 if (ibranch==0 && iRCU==0)
203 for (iFEC=firstFEC; iFEC<
kNFEC; iFEC++)
205 for (ichip=0; ichip<
kNChip; ichip++)
208 for (ichan=0; ichan<
kNChan; ichan++)
211 if (iFEC!=0 || (ichan<8 || ichan>11))
214 Ped = TMath::Nint(
fMeanPed[iSM][iRCU][ibranch][iFEC][ichip][ichan]);
217 printf(
" bad pedestal RMS: iSM %d iRCU %d ibranch %d iFEC %d ichip %d ichan %d - raising from %d to 0x3ff\n",
218 iSM, iRCU, ibranch, iFEC, ichip, ichan, Ped);
223 int writeAddr = (ibranch << 16) | (iFEC << 12) | (ichip << 9) |
224 (ichan << 5) | VFPED | RCUWrite;
225 sprintf(scriptLine,
"w 0x%04x 0x%06x # Branch %s, Card %d, Altro %d, Chan %d",
226 nscriptLines, writeAddr, branchStr[ibranch],
228 fout << scriptLine << endl;
231 int writeVal = (Ped | RCUWrite);
232 sprintf(scriptLine,
"w 0x%04x 0x%06x # Pedestal 0x%x = %d",
233 nscriptLines, writeVal, Ped, Ped);
234 fout << scriptLine << endl;
244 sprintf(scriptLine,
"w 0x%04x 0x380000 # End of the sequence",
246 fout << scriptLine << endl;
249 sprintf(scriptLine,
"w 0x%04x 0x3F0000 # End of the instruction memory",
251 fout << scriptLine << endl;
254 fout <<
"wait 100 us" << endl;
255 fout <<
"w 0x5304 0x0 \# execute and update registers" << endl;
268 for (Int_t iSM=0; iSM<
kNSM; iSM++)
270 for (Int_t iRCU=0; iRCU<
kNRCU; iRCU++)
272 for (Int_t ibranch=0; ibranch<
kNBranch; ibranch++)
274 for (Int_t iFEC=0; iFEC<
kNFEC; iFEC++)
276 for (Int_t ichip=0; ichip<
kNChip; ichip++)
278 for (Int_t ichan=0; ichan<
kNChan; ichan++)
280 fMeanPed[iSM][iRCU][ibranch][iFEC][ichip][ichan] = 0;
281 fRmsPed[iSM][iRCU][ibranch][iFEC][ichip][ichan] = 0;
289 for (
int istrip=0; istrip<
kNStrips; istrip++)
301 DecodeHWAddress(Int_t hwAddr, Int_t & branch, Int_t & FEC, Int_t & chip, Int_t & chan)
304 chip = (hwAddr >> 4) & 0x7;
305 FEC = (hwAddr >> 7) & 0xf;
306 branch = (hwAddr >> 11) & 0x1;
313 GetHWAddress(Int_t iside, Int_t icol, Int_t irow, Int_t igain, Int_t & iRCU)
318 if (0<=irow&&irow<8) iRCU=0;
319 else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0;
322 else if(8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1;
324 else if(16<=irow&&irow<24) iRCU=1;
327 Int_t iRCUSide = iRCU;
334 Int_t hwAddress =
fMapping[iRCUSide]->GetHWAddress(irow, icol, igain);
357 TString sides[]={
"A",
"C"};
359 TString
path = gSystem->Getenv(
"ALICE_ROOT");
360 path +=
"/EMCAL/mapping/RCU";
363 for(Int_t j = 0; j < 2; j++)
365 for(Int_t i = 0; i < 2; i++)
371 if (
kDebug) {
printf(
"Mapping file: %s\n",path2.Data());
374 fMapping[j*2 + i] =
new AliCaloAltroMapping(path2.Data());
388 Int_t maxAddr = 1 << 7;
390 int nLEDRefFEEChan = 0;
396 for (
int hwaddr = 0; hwaddr<maxAddr; hwaddr++)
399 if ( (chip!=1 && chip<
kNChip) &&
400 (chan<8 || chan>11) )
403 int istrip =
fMapping[iRCU]->GetPad(hwaddr);
404 int igain =
fMapping[iRCU]->GetPadRow(hwaddr);
405 int iflag =
fMapping[iRCU]->GetSector(hwaddr);
407 if (iflag == caloflag)
415 if (
kDebug) { cout <<
" nLEDRefFEEChan " << nLEDRefFEEChan << endl; }
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TFile * Open(const char *filename, Long64_t &nevents)
Float_t fRmsPed[kNSM][kNRCU][kNBranch][kNFEC][kNChip][kNChan]
Float_t fMeanPed[kNSM][kNRCU][kNBranch][kNFEC][kNChip][kNChan]
void PrintScript()
Add comment.
void GetMapping()
Add comment.
Int_t fHWAddrLEDRef[kNStrips][2]
Int_t GetHWAddress(Int_t iside, Int_t icol, Int_t irow, Int_t igain)
void DecodeHWAddress(Int_t hwAddr, Int_t &branch, Int_t &FEC, Int_t &chip, Int_t &chan)
Add comment.
AliCaloAltroMapping * fMapping[4]
void GetPedValLEDRef(const Int_t iSM, const Int_t igain, const TProfile *h)
Add comment.
void CreateMappingLEDRef()
Add comment.
void GetPedVal(const Int_t iSM, const Int_t igain, const TProfile2D *h2)
Add comment.
void GeneratePedestalScript(const char *filename="Run117756_117756_v1_s0.root")
Main method.
Int_t GetHWAddressLEDRef(Int_t istrip, Int_t igain)
Add comment.