1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // Objects of this class contain info on APD calibration and map info
26 #include "AliEMCALCalibMapAPD.h"
30 ClassImp(AliEMCALCalibMapAPD)
32 //____________________________________________________________________________
33 AliEMCALCalibMapAPD::AliEMCALCalibMapAPD(const int nSM) :
37 //Default constructor.
38 for (int i=0; i<fNSuperModule; i++) {
39 fSuperModuleData.Add(new AliEMCALSuperModuleCalibMapAPD(i));
41 fSuperModuleData.Compress(); // compress the TObjArray
44 //____________________________________________________________________________
45 void AliEMCALCalibMapAPD::ReadTextCalibMapAPDInfo(Int_t nSM, const TString &txtFileName,
48 //Read data from txt file. ; coordinates given on SuperModule basis
50 std::ifstream inputFile(txtFileName.Data());
52 printf("AliEMCALCalibMapAPD::ReadCalibMapAPDInfo - Cannot open the APD info file %s\n", txtFileName.Data());
58 Int_t iSM = 0; // SuperModule index
61 // list of values to be read
66 Float_t ParErr[3] = {0};
68 Float_t DarkCurrent = 0;
71 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
73 for (Int_t i = 0; i < fNSuperModule; i++) {
74 AliEMCALSuperModuleCalibMapAPD * t = (AliEMCALSuperModuleCalibMapAPD*) fSuperModuleData[i];
76 printf("AliEMCALCalibMapAPD::ReadCalibMapAPDInfo - Error while reading input file; likely EOF..");
80 t->SetSuperModuleNum(iSM);
82 for (Int_t j=0; j<nAPDPerSM; j++) {
83 inputFile >> iCol >> iRow >> iHW
85 >> Par[0] >> Par[1] >> Par[2]
86 >> ParErr[0] >> ParErr[1] >> ParErr[2]
87 >> BreakDown >> DarkCurrent;
89 // assume that this info is already swapped and done for this basis?
91 // C side, oriented differently than A side: swap is requested
92 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
93 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
96 AliEMCALCalibMapAPDVal * v = t->GetAPDVal(iCol, iRow);
98 v->SetHardWareId(iHW);
101 v->SetPar(0, Par[0]);
102 v->SetPar(1, Par[1]);
103 v->SetPar(2, Par[2]);
104 v->SetParErr(0, ParErr[0]);
105 v->SetParErr(1, ParErr[1]);
106 v->SetParErr(2, ParErr[2]);
107 v->SetBreakDown(BreakDown);
108 v->SetDarkCurrent(DarkCurrent);
118 //____________________________________________________________________________
119 void AliEMCALCalibMapAPD::WriteTextCalibMapAPDInfo(const TString &txtFileName,
122 // write data to txt file. ; coordinates given on SuperModule basis
124 std::ofstream outputFile(txtFileName.Data());
126 printf("AliEMCALCalibMapAPD::WriteCalibMapAPDInfo - Cannot open the APD output file %s\n", txtFileName.Data());
133 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
135 for (Int_t i = 0; i < fNSuperModule; i++) {
136 AliEMCALSuperModuleCalibMapAPD * t = (AliEMCALSuperModuleCalibMapAPD*) fSuperModuleData[i];
137 outputFile << t->GetSuperModuleNum() << endl;
139 for (Int_t j=0; j<nAPDPerSM; j++) {
140 iCol = j / AliEMCALGeoParams::fgkEMCALRows;
141 iRow = j % AliEMCALGeoParams::fgkEMCALRows;
143 AliEMCALCalibMapAPDVal * v = t->GetAPDVal(iCol, iRow);
146 // C side, oriented differently than A side: swap is requested
147 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
148 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
151 outputFile << iCol << " " << iRow << " " << v->GetHardWareId()
152 << " " << v->GetAPDNum() << " " << v->GetV30()
153 << " " << v->GetPar(0) << " " << v->GetPar(1) << " " << v->GetPar(2)
154 << " " << v->GetParErr(0) << " " << v->GetParErr(1) << " " << v->GetParErr(2)
155 << " " << v->GetBreakDown() << " " << v->GetDarkCurrent() << endl;
165 //____________________________________________________________________________
166 void AliEMCALCalibMapAPD::ReadRootCalibMapAPDInfo(const TString &rootFileName,
169 //Read data from root file. ; coordinates given on SuperModule basis
170 TFile inputFile(rootFileName, "read");
172 TTree *tree = (TTree*) inputFile.Get("tree");
174 ReadTreeCalibMapAPDInfo(tree, swapSides);
181 //____________________________________________________________________________
182 void AliEMCALCalibMapAPD::ReadTreeCalibMapAPDInfo(TTree *tree,
185 // how many SuperModule's worth of entries / APDs do we have?
186 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
187 fNSuperModule = tree->GetEntries() / nAPDPerSM;
189 Int_t iSM = 0; // SuperModule index
192 // list of values to be read
196 Float_t Par[3] = {0};
197 Float_t ParErr[3] = {0};
199 Float_t DarkCurrent = 0;
202 // declare the branches
203 tree->SetBranchAddress("iSM", &iSM);
204 tree->SetBranchAddress("iCol", &iCol);
205 tree->SetBranchAddress("iRow", &iRow);
206 tree->SetBranchAddress("iHW", &iHW);
207 tree->SetBranchAddress("APDNum", &APDNum);
208 tree->SetBranchAddress("V30", &V30);
209 tree->SetBranchAddress("Par", Par);
210 tree->SetBranchAddress("ParErr", ParErr);
211 tree->SetBranchAddress("BreakDown", &BreakDown);
212 tree->SetBranchAddress("DarkCurrent", &DarkCurrent);
214 for (int ient=0; ient<tree->GetEntries(); ient++) {
215 tree->GetEntry(ient);
217 // assume the index SuperModules come in order: i=iSM
218 AliEMCALSuperModuleCalibMapAPD * t = (AliEMCALSuperModuleCalibMapAPD*) fSuperModuleData[iSM];
219 t->SetSuperModuleNum(iSM);
221 // assume that this info is already swapped and done for this basis?
223 // C side, oriented differently than A side: swap is requested
224 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
225 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
228 AliEMCALCalibMapAPDVal * v = t->GetAPDVal(iCol, iRow);
230 v->SetHardWareId(iHW);
231 v->SetAPDNum(APDNum);
233 v->SetPar(0, Par[0]);
234 v->SetPar(1, Par[1]);
235 v->SetPar(2, Par[2]);
236 v->SetParErr(0, ParErr[0]);
237 v->SetParErr(1, ParErr[1]);
238 v->SetParErr(2, ParErr[2]);
239 v->SetBreakDown(BreakDown);
240 v->SetDarkCurrent(DarkCurrent);
246 //____________________________________________________________________________
247 void AliEMCALCalibMapAPD::WriteRootCalibMapAPDInfo(const TString &rootFileName,
250 // write data to root file. ; coordinates given on SuperModule basis
251 TFile destFile(rootFileName, "recreate");
252 if (destFile.IsZombie()) {
257 TTree *tree = new TTree("tree","");
259 // variables for filling the TTree
260 Int_t iSM = 0; // SuperModule index
264 Float_t Par[3] = {0};
265 Float_t ParErr[3] = {0};
267 Float_t DarkCurrent = 0;
271 // declare the branches
272 tree->Branch("iSM", &iSM, "iSM/I");
273 tree->Branch("iCol", &iCol, "iCol/I");
274 tree->Branch("iRow", &iRow, "iRow/I");
275 tree->Branch("iHW", &iHW, "iHW/I");
276 tree->Branch("APDNum", &APDNum, "APDNum/I");
277 tree->Branch("V30", &V30, "V30/F");
278 tree->Branch("Par", &Par, "Par[3]/F");
279 tree->Branch("ParErr", &ParErr, "ParErr[3]/F");
280 tree->Branch("BreakDown", &BreakDown, "BreakDown/I");
281 tree->Branch("DarkCurrent", &DarkCurrent, "DarkCurrent/F");
283 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
285 for (iSM = 0; iSM < fNSuperModule; iSM++) {
286 AliEMCALSuperModuleCalibMapAPD * t = (AliEMCALSuperModuleCalibMapAPD *) fSuperModuleData[iSM];
288 for (Int_t j=0; j<nAPDPerSM; j++) {
289 iCol = j / AliEMCALGeoParams::fgkEMCALRows;
290 iRow = j % AliEMCALGeoParams::fgkEMCALRows;
292 AliEMCALCalibMapAPDVal * v = t->GetAPDVal(iCol, iRow);
295 // C side, oriented differently than A side: swap is requested
296 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
297 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
300 iHW = v->GetHardWareId();
301 APDNum = v->GetAPDNum();
303 for (int k=0; k<3; k++) {
304 Par[k] = v->GetPar(k);
305 ParErr[k] = v->GetParErr(k);
307 BreakDown = v->GetBreakDown();
308 DarkCurrent = v->GetDarkCurrent();
321 //____________________________________________________________________________
322 AliEMCALCalibMapAPD::~AliEMCALCalibMapAPD()
324 fSuperModuleData.Delete();
327 //____________________________________________________________________________
328 AliEMCALSuperModuleCalibMapAPD * AliEMCALCalibMapAPD::GetSuperModuleCalibMapAPDNum(Int_t supModIndex)const
330 for (int i=0; i<fNSuperModule; i++) {
331 AliEMCALSuperModuleCalibMapAPD * t = (AliEMCALSuperModuleCalibMapAPD*) fSuperModuleData[i];
332 if (t->GetSuperModuleNum() == supModIndex) {
337 // if we arrived here, then nothing was found.. just return a NULL pointer