]>
Commit | Line | Data |
---|---|---|
16d3c94d | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
b217491f | 19 | // Top EMCAL folder which will keep all |
20 | // information about EMCAL itself, | |
21 | // super Modules (SM), modules, towers, | |
22 | // set of hists and so on. | |
16d3c94d | 23 | // |
24 | //*-- Author: Aleksei Pavlinov (WSU, Detroit, USA) | |
25 | ||
26 | #include "AliEMCALFolder.h" | |
27 | #include "AliEMCALHistoUtilities.h" | |
28 | #include "AliEMCALGeometry.h" | |
29 | #include "AliEMCALSuperModule.h" | |
30 | #include "AliEMCALCell.h" | |
31 | #include "AliESDCaloCluster.h" | |
32 | ||
33 | #include "AliRun.h" | |
34 | ||
35 | #include "AliEMCALCalibData.h" | |
36 | #include "AliCDBMetaData.h" | |
37 | #include "AliCDBId.h" | |
38 | #include "AliCDBEntry.h" | |
39 | #include "AliCDBManager.h" | |
40 | #include "AliCDBStorage.h" | |
41 | ||
42 | #include "AliEMCALCalibCoefs.h" | |
43 | #include "AliEMCALDigit.h" | |
44 | #include "AliEMCALRecPoint.h" | |
45 | ||
46 | #include "AliEMCALPi0SelectionParam.h" | |
47 | ||
48 | #include <cassert> | |
49 | ||
50 | #include <TROOT.h> | |
51 | #include <TStyle.h> | |
52 | #include <TList.h> | |
53 | #include <TH1.h> | |
54 | #include <TF1.h> | |
55 | #include <TFile.h> | |
16d3c94d | 56 | #include <TCanvas.h> |
57 | #include <TClonesArray.h> | |
58 | #include <TKey.h> | |
59 | #include <TNtuple.h> | |
60 | #include <TLegend.h> | |
0fc11500 | 61 | #include <TLegendEntry.h> |
62 | #include <TLine.h> | |
16d3c94d | 63 | |
64 | const TString AliEMCALFolder::fgkBaseFolderName("EMCAL"); | |
65 | const TString AliEMCALFolder::fgkCCFirstName("CCFIRST"); | |
66 | const TString AliEMCALFolder::fgkCCinName("CCIN"); | |
67 | const TString AliEMCALFolder::fgkCCoutName("CCOUT"); | |
0fc11500 | 68 | const TString AliEMCALFolder::fgkDirOfRootFiles("$HOME/ALICE/SHISHKEBAB/RF/CALIB/JUL16/"); |
16d3c94d | 69 | |
70 | typedef AliEMCALHistoUtilities u; | |
71 | ||
72 | ClassImp(AliEMCALFolder) | |
73 | ||
74 | //AliEMCALGeometry* AliEMCALFolder::fGeometry = 0; | |
75 | ||
16d3c94d | 76 | AliEMCALFolder::AliEMCALFolder() : |
0fc11500 | 77 | TFolder(), |
16d3c94d | 78 | fCounter(0), fGeometry(0), fNumOfCell(0), fLhists(0), fLofCells(0),fPi0SelPar(0),fCalibData(0), |
b217491f | 79 | fCellNtuple(0),fLobj(0) |
16d3c94d | 80 | { |
81 | } | |
82 | ||
83 | AliEMCALFolder::AliEMCALFolder(const char* name, const char* title, Bool_t putToBrowser) : | |
0fc11500 | 84 | TFolder(name,title), |
16d3c94d | 85 | fCounter(-1), fGeometry(0), fNumOfCell(0), fLhists(0), fLofCells(0),fPi0SelPar(0),fCalibData(0), |
b217491f | 86 | fCellNtuple(0),fLobj(0) |
16d3c94d | 87 | { |
16d3c94d | 88 | Init(putToBrowser); |
89 | } | |
90 | ||
91 | AliEMCALFolder::AliEMCALFolder(const Int_t it, const char* title, Bool_t putToBrowser) : | |
0fc11500 | 92 | TFolder(Form("%s_%2.2i", AliEMCALFolder::fgkBaseFolderName.Data(),it),title), |
16d3c94d | 93 | fCounter(it), fGeometry(0), fNumOfCell(0), fLhists(0), fLofCells(0),fPi0SelPar(0),fCalibData(0), |
b217491f | 94 | fCellNtuple(0),fLobj(0) |
16d3c94d | 95 | { |
16d3c94d | 96 | Init(putToBrowser); |
97 | } | |
98 | ||
99 | AliEMCALFolder::~AliEMCALFolder() | |
100 | { | |
101 | // dtor | |
102 | } | |
103 | ||
104 | void AliEMCALFolder::Init(Bool_t putToBrowser) | |
105 | { | |
b217491f | 106 | // Initialize all data structure |
107 | fLobj = new TList; | |
108 | fLobj->SetName("Objects"); // name is good ? | |
109 | this->Add((TObject*)fLobj); | |
110 | //this->AddObject((TObject*)fLobj, kTRUE); | |
16d3c94d | 111 | // Get default geometry - "SHISH_77_TRD1_2X2_FINAL_110DEG"; May 29, 2007 |
112 | fGeometry = AliEMCALGeometry::GetInstance(); // should be define before | |
b217491f | 113 | fLobj->Add(fGeometry); |
16d3c94d | 114 | |
115 | // Initial cc with decalibration | |
0fc11500 | 116 | // Jun 13, 2007; |
117 | // Jul 13 - See ~/macros/ALICE/sim.C for choice of CDB | |
118 | AliEMCALCalibData *calData[1]; | |
119 | // Get from defined arrea; | |
120 | // First table is table which used in rec.points finder. | |
121 | Add(AliEMCALCalibCoefs::GetCalibTableFromDb(fgkCCFirstName.Data(),calData)); | |
122 | fCalibData = calData[0]; | |
b217491f | 123 | fLobj->Add(fCalibData); |
0fc11500 | 124 | if(GetIterationNumber()<=1) { |
125 | Add(AliEMCALCalibCoefs::GetCalibTableFromDb(fgkCCinName.Data(), calData)); | |
16d3c94d | 126 | } |
0fc11500 | 127 | |
16d3c94d | 128 | // Selection Parameter |
129 | fPi0SelPar = AliEMCALPi0SelectionParam::Set1(); | |
130 | this->Add(fPi0SelPar); | |
131 | // | |
132 | fLhists = BookHists(); | |
b217491f | 133 | fLobj->Add(fLhists); |
16d3c94d | 134 | |
135 | // dimension should be get from geometry - 4*12*24*11); | |
136 | fNumOfCell = fGeometry->GetNCells(); | |
137 | fLofCells = new AliEMCALCell*[fNumOfCell]; | |
138 | for(int i=0; i<fNumOfCell; i++) fLofCells[i] = 0; | |
139 | ||
140 | printf("<I> Create AliEMCALFolder : it %i : name %s\n ", fCounter, GetName()); | |
141 | ||
142 | if(putToBrowser) gROOT->GetListOfBrowsables()->Add(this); // for testing purpuse | |
143 | } | |
144 | ||
145 | AliEMCALSuperModule* AliEMCALFolder::GetSuperModule(const Int_t nm) | |
146 | { | |
b217491f | 147 | // Oct 15, 2007 |
16d3c94d | 148 | AliEMCALSuperModule *sm = 0; |
149 | ||
0fc11500 | 150 | TObject *set = FindObject(Form("SM%2.2i",nm)); |
16d3c94d | 151 | if(set) sm = (AliEMCALSuperModule*)set; |
152 | ||
153 | return sm; | |
154 | } | |
155 | ||
156 | ||
157 | AliEMCALCell* AliEMCALFolder::GetCell(const Int_t absId) | |
158 | { // May 30, 2007 | |
159 | if(absId<0 || absId >= fNumOfCell) return 0; | |
160 | else return fLofCells[absId]; | |
161 | } | |
162 | ||
163 | void AliEMCALFolder::SetCell(AliEMCALCell *cell, const Int_t absId) | |
164 | { | |
b217491f | 165 | // Oct 15, 2007 |
16d3c94d | 166 | if(absId>=0 && absId < fNumOfCell) { |
167 | fLofCells[absId] = cell; | |
168 | } | |
169 | } | |
170 | ||
b217491f | 171 | AliEMCALPi0SelectionParRec* AliEMCALFolder::GetPi0SelectionParRow(Int_t nrow) |
16d3c94d | 172 | { |
b217491f | 173 | // Oct 15, 2007 |
174 | AliEMCALPi0SelectionParRec* r=0; | |
16d3c94d | 175 | if(fPi0SelPar) { |
176 | r = fPi0SelPar->GetTable(nrow); | |
177 | } | |
178 | return r; | |
179 | } | |
180 | ||
181 | void AliEMCALFolder::FillPi0Candidate(const Double_t mgg, AliESDCaloCluster* cl1, AliESDCaloCluster* cl2) | |
182 | { | |
b217491f | 183 | // Oct 15, 2007 |
16d3c94d | 184 | static Int_t absIdMax, nm1, nm2; |
185 | ||
186 | u::FillH1(fLhists, 0, 1.); // number entries | |
187 | u::FillH1(fLhists, 1, mgg); | |
188 | ||
189 | nm1 = GetSMNumber(cl1); | |
190 | nm2 = GetSMNumber(cl2); | |
191 | ||
192 | if(nm1==-1 || nm2==-1) assert(0); | |
193 | ||
194 | if(nm1 != nm2) return; // Both cluster should be in the same SM | |
195 | ||
196 | AliESDCaloCluster* cl = cl1; | |
197 | if(cl1->E() < cl2->E()) cl = cl2; // Get cluster with highest energy | |
198 | ||
b217491f | 199 | const Int_t kNdigits = cl->GetNumberOfDigits(); |
0fc11500 | 200 | const Short_t* absId = cl->GetDigitIndex()->GetArray(); |
201 | ||
202 | AliEMCALCalibCoefs *tFirst = GetCCFirst(); | |
b217491f | 203 | AliEMCALCalibCoef *rFirst=0; |
16d3c94d | 204 | |
0fc11500 | 205 | int indMax = 0, id=0; |
206 | id = Int_t(absId[0]); | |
207 | rFirst = tFirst->GetTable(id); | |
e649177a | 208 | double emax = 0;//cl->GetTrueDigitEnergy(indMax, rFirst->fCc); |
b217491f | 209 | if(kNdigits > 1) { |
210 | for(int i=1; i<kNdigits; i++) { | |
0fc11500 | 211 | id = Int_t(absId[i]); |
212 | rFirst = tFirst->GetTable(id); | |
e649177a | 213 | if(emax < 0){//cl->GetTrueDigitEnergy(i, rFirst->fCc)) { |
16d3c94d | 214 | indMax = i; |
e649177a | 215 | emax = 0;//cl->GetTrueDigitEnergy(i, rFirst->fCc); |
16d3c94d | 216 | } |
217 | } | |
218 | } | |
219 | if(emax/cl->E() > 0.5) { // more than 50% of cluster energy | |
220 | u::FillH1(fLhists, 0, 2.); // number "good" entries | |
221 | absIdMax = Int_t(absId[indMax]); | |
222 | FillPi0Candidate(mgg, absIdMax, nm1); | |
223 | } | |
224 | } | |
225 | ||
226 | void AliEMCALFolder::FillPi0Candidate(const Double_t mgg, Int_t absIdMax, Int_t nm) | |
227 | { | |
b217491f | 228 | // Jun 08 |
16d3c94d | 229 | static Int_t nSupModMax, nModuleMax, nIphiMax, nIetaMax, iphiCellMax, ietaCellMax; |
230 | static AliEMCALCell* cell; | |
0fc11500 | 231 | static TFolder *set; |
16d3c94d | 232 | static AliEMCALSuperModule *sm; |
233 | ||
234 | fGeometry->GetCellIndex(absIdMax, nSupModMax, nModuleMax, nIphiMax, nIetaMax); | |
235 | if(nm != nSupModMax) assert(0); | |
236 | ||
237 | fGeometry->GetCellPhiEtaIndexInSModule(nSupModMax, nModuleMax, nIphiMax, nIetaMax, iphiCellMax, ietaCellMax); | |
238 | ||
239 | cell = 0; | |
240 | set = 0; | |
241 | sm = 0; | |
242 | if(GetCell(absIdMax)==0) { | |
243 | cell = new AliEMCALCell(absIdMax, Form("sm%2.2i:phi%2.2i:eta%2.2i(%4.4i)",nSupModMax,iphiCellMax,ietaCellMax,absIdMax)); | |
244 | SetCell(cell, absIdMax); | |
245 | // For browser | |
0fc11500 | 246 | set = dynamic_cast<TFolder*>(FindObject(Form("SM%2.2i",nSupModMax))); |
16d3c94d | 247 | if(set==0) { |
248 | sm = new AliEMCALSuperModule(nSupModMax); | |
249 | Add(sm); | |
0fc11500 | 250 | sm->SetParent(this); |
16d3c94d | 251 | sm->Init(); |
252 | } else { | |
0fc11500 | 253 | sm = dynamic_cast<AliEMCALSuperModule*>(set); |
254 | } | |
255 | if(sm) { | |
256 | sm->AddCellToEtaRow(cell, ietaCellMax); | |
257 | cell->SetParent(sm); | |
16d3c94d | 258 | } |
16d3c94d | 259 | // |
260 | cell->SetCCfromCCTable(GetCCIn()); | |
261 | } else { | |
262 | cell = GetCell(absIdMax); | |
0fc11500 | 263 | set = dynamic_cast<TFolder*>(FindObject(Form("SM%2.2i",nm))); |
16d3c94d | 264 | if(set) sm = (AliEMCALSuperModule*)set; |
265 | } | |
266 | if(sm == 0) assert(0); | |
267 | if(nm != sm->GetSMNumber()) assert(0); | |
268 | ||
269 | u::FillH1(sm->GetHists(), 0, mgg); | |
270 | cell->FillEffMass(mgg); | |
271 | } | |
272 | ||
273 | void AliEMCALFolder::FitAllSMs() | |
274 | { // Jun 14, 2007 | |
275 | // Only first SM now - should be changed in the future | |
276 | AliEMCALSuperModule *sm0 = GetSuperModule(0); | |
277 | sm0->FitForAllCells(); | |
278 | // Get input calibration table | |
279 | AliEMCALCalibCoefs *ccIn = GetCCIn(); | |
280 | if(ccIn == 0) { | |
281 | printf("<E> no input cc \n"); | |
282 | return; | |
283 | } | |
284 | // New calibration table | |
285 | AliEMCALCalibCoefs *ccOut = new AliEMCALCalibCoefs(fgkCCoutName.Data(), ccIn->GetNRows()); | |
b217491f | 286 | AliEMCALCalibCoef *rIn=0, rOut; |
16d3c94d | 287 | for(Int_t i=0; i<ccIn->GetNRows(); i++){ |
288 | rIn = ccIn->GetTable(i); | |
289 | rOut = (*rIn); | |
b217491f | 290 | AliEMCALCell* cell = GetCell(rIn->fAbsId); |
16d3c94d | 291 | if(cell && cell->GetSupMod() == 0) { // only first module now |
b217491f | 292 | rOut.fCc = cell->GetCcOut(); |
16d3c94d | 293 | } |
294 | ccOut->AddAt(&rOut); | |
295 | } | |
296 | ccOut->Purge(); | |
297 | Add(ccOut); | |
298 | } | |
299 | ||
b217491f | 300 | AliEMCALCalibCoefs* AliEMCALFolder::GetCCTable(const char* name) const |
16d3c94d | 301 | { |
b217491f | 302 | // Oct 15, 2007 |
0fc11500 | 303 | TObject *obj = FindObject(name); |
304 | if(obj) return (AliEMCALCalibCoefs*)obj; | |
305 | else return 0; | |
16d3c94d | 306 | } |
307 | ||
308 | Int_t AliEMCALFolder::GetSMNumber(AliESDCaloCluster* cl) | |
309 | { | |
b217491f | 310 | // Oct 15, 2007 |
16d3c94d | 311 | static Int_t absId, nSupMod, nModule, nIphi, nIeta; |
312 | nSupMod = -1; // if negative something wrong | |
313 | if(cl) { | |
314 | absId = Int_t(cl->GetDigitIndex()->At(0)); | |
315 | fGeometry->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
316 | } | |
317 | return nSupMod; | |
318 | } | |
319 | ||
320 | // Recalibration staf - Jun 18,2007 | |
321 | AliEMCALRecPoint* AliEMCALFolder::GetRecPoint(AliESDCaloCluster *cl, AliEMCALCalibCoefs *tOld,AliEMCALCalibCoefs *tNew, | |
0fc11500 | 322 | TList *l, Double_t deff, Double_t w0, Double_t phiSlope) |
16d3c94d | 323 | { |
324 | // | |
325 | // Static function; | |
326 | // Get recalibrated rec.point from ESD cluster | |
b217491f | 327 | // If tNew == 0 -> get ideal calibration with adcCHANNELEC |
16d3c94d | 328 | // |
b217491f | 329 | static Double_t adcCHANNELEC = 0.0153; // Update 24 Apr 2007: 250./16/1024 - width of one ADC channel in GeV |
0fc11500 | 330 | //static Float_t ECAW0 = 4.5; // hard coded now - see AliEMCALClusterizerv1::InitParameters() |
b217491f | 331 | static Double_t eCAW0 = 5.5; // Beter case for simulation |
0fc11500 | 332 | Int_t ampDigi=0, indMax=-1; |
333 | Double_t eDigiNew=0.0, eDigiMax=0.0; | |
334 | static TArrayD ed; | |
16d3c94d | 335 | |
b217491f | 336 | if(w0 > 0.5) eCAW0 = w0; |
16d3c94d | 337 | AliEMCALRecPoint *rp=0; |
b217491f | 338 | AliEMCALCalibCoef *rOld=0, *rNew=0; |
339 | // printf(" AliEMCALFolder::GetRecPoint() : RECALIBRATION : w0 %f eCAW0 %f \n", w0, eCAW0); | |
0fc11500 | 340 | if(cl && tOld){ |
16d3c94d | 341 | // cl->PrintClusterInfo(1); |
b217491f | 342 | const Int_t kNdg = cl->GetNumberOfDigits(); |
343 | // const Int_t nkPrim = cl->GetNumberOfPrimaries(); | |
16d3c94d | 344 | |
b217491f | 345 | const Short_t kPrim = cl->GetLabel(); |
16d3c94d | 346 | const Short_t* dgAbsId = cl->GetDigitIndex()->GetArray(); |
0fc11500 | 347 | // const UShort_t* dgAmp = cl->GetDigitAmplitude(); // This is energy - bad definition |
16d3c94d | 348 | |
349 | rp = new AliEMCALRecPoint(""); // opt="" | |
8ada0ffe | 350 | rp->SetClusterType(AliESDCaloCluster::kEMCALClusterv1); |
16d3c94d | 351 | AliEMCALDigit* dg=0; |
b217491f | 352 | TClonesArray digits("AliEMCALDigit", kNdg); |
16d3c94d | 353 | Int_t absId = 0; |
b217491f | 354 | ed.Set(kNdg); // resize array |
355 | for(Int_t i=0; i<kNdg; i++){ | |
16d3c94d | 356 | // Save just abs id and amplitude of digits which will be used for recalculation of |
357 | // cluster energy and position | |
0fc11500 | 358 | absId = Int_t(dgAbsId[i]); |
359 | rOld = tOld->GetTable(absId); | |
e649177a | 360 | //ampDigi = cl->GetTrueDigitAmplitude(i, rOld->fCc); // True amplitude |
16d3c94d | 361 | |
b217491f | 362 | new(digits[i]) AliEMCALDigit(Int_t(kPrim),0, absId, ampDigi, 0.0, i, 0.0); |
16d3c94d | 363 | dg = (AliEMCALDigit*)digits[i]; |
0fc11500 | 364 | |
365 | if(tNew) rNew = tNew->GetTable(absId); | |
366 | if(rNew) { | |
367 | rNew = tNew->GetTable(absId); | |
b217491f | 368 | eDigiNew = Double_t(ampDigi) * rNew->fCc; // Recalibrate with new cc |
0fc11500 | 369 | } else { |
b217491f | 370 | eDigiNew = Double_t(ampDigi) * adcCHANNELEC; // Ideal calibration |
0fc11500 | 371 | } |
372 | //eDigiNew = Double_t(cl->GetTrueDigitEnergy(i)); // Copy from ESD for checking | |
16d3c94d | 373 | rp->AddDigit(*dg, Float_t(eDigiNew)); |
0fc11500 | 374 | ed[i] = eDigiNew; |
375 | if(eDigiMax<eDigiNew) { | |
376 | eDigiMax = eDigiNew; | |
377 | indMax = i; | |
378 | } | |
16d3c94d | 379 | u::FillH1(l, 14, eDigiNew); |
380 | u::FillH1(l, 15, Double_t(absId)); | |
b217491f | 381 | //printf("<I> digit %i amp %i rOld->fCc %6.5f GeV rNew->fCc %6.5f GeV\n", i, ampDigi, rOld->fCc, rNew->fCc); |
16d3c94d | 382 | } |
383 | //printf("<I> recalibration of digits was done ! \n"); | |
b217491f | 384 | // rp->EvalAll(eCAW0, &digits); |
0fc11500 | 385 | if(indMax>=0) rp->SetIndMaxDigit(indMax); |
386 | if(deff > 0.0) { // for fit | |
b217491f | 387 | rp->EvalLocalPositionFit(deff, eCAW0, phiSlope, &digits); // I need just position |
0fc11500 | 388 | } else { // get w0 and deff from parametrisation - Sep 4, 2007 |
389 | rp->EvalLocalPosition2(&digits, ed); | |
390 | } | |
16d3c94d | 391 | digits.Delete(); |
392 | } | |
393 | //rp->Print("print"); | |
394 | return rp; | |
395 | } | |
396 | ||
397 | void AliEMCALFolder::Save(const char *fn, const char *opt) | |
398 | { | |
399 | // | |
400 | // Jun 5, 2007; See TFileIter and StFMC.cxx | |
0fc11500 | 401 | // Jul 16 - added fgkDirOfRootFiles |
402 | // Sep 7, 2007 - should be changed without TFileIter | |
403 | /* | |
404 | TString FN = fgkDirOfRootFiles; | |
405 | FN += fn; | |
16d3c94d | 406 | if(FN.Contains(".root")==0) FN += ".root"; |
407 | TFileIter f(FN.Data(),opt,"EMCAL object"); | |
408 | UInt_t eventNum = 0; // just one object | |
0fc11500 | 409 | UInt_t runNumber = 0; // 0 now, - may statistics on selector |
16d3c94d | 410 | f.NextEventPut(this, eventNum, runNumber); |
411 | printf(" Save %s to file %s\n", GetName(), FN.Data()); | |
0fc11500 | 412 | */ |
b217491f | 413 | if(fn || opt); |
16d3c94d | 414 | } |
415 | ||
b217491f | 416 | AliEMCALFolder* AliEMCALFolder::ReadFolder(const char *fn, const char *opt) |
16d3c94d | 417 | { |
418 | // | |
419 | // Jun 27, 2007 | |
0fc11500 | 420 | // Jul 16 - added fgkDirOfRootFiles |
16d3c94d | 421 | // |
b217491f | 422 | printf("<I> AliEMCALFolder::ReadFolder(%s,%s)\n",fn,opt); |
423 | AliEMCALFolder* emcal = 0; | |
16d3c94d | 424 | TH1::AddDirectory(0); // this is obligatory |
425 | ||
b217491f | 426 | TString sfn = fgkDirOfRootFiles; |
427 | sfn += fn; | |
428 | if(sfn.Contains(".root")==0) sfn += ".root"; | |
16d3c94d | 429 | |
b217491f | 430 | TFile f(sfn.Data(),opt); |
0fc11500 | 431 | if(f.IsOpen()) { |
432 | TList *l = f.GetListOfKeys(); | |
b217491f | 433 | printf("<I> The total number of the objects: %d \n File %s\n", l->GetSize(), sfn.Data()); |
16d3c94d | 434 | |
0fc11500 | 435 | TKey *key = (TKey*)l->At(0); |
b217491f | 436 | emcal = (AliEMCALFolder*)key->ReadObj(); |
0fc11500 | 437 | f.Close(); |
b217491f | 438 | if(emcal) emcal->InitAfterRead(); |
0fc11500 | 439 | } |
b217491f | 440 | return emcal; |
16d3c94d | 441 | } |
442 | ||
443 | ||
444 | void AliEMCALFolder::InitAfterRead() | |
0fc11500 | 445 | { |
b217491f | 446 | // Oct 15, 2007 |
447 | fLobj = (TList*)FindObject("Objects"); | |
448 | if(fLobj) { | |
449 | fLhists = (TList*)fLobj->FindObject("HistsOfEmcal"); | |
0fc11500 | 450 | } |
16d3c94d | 451 | } |
452 | ||
453 | void AliEMCALFolder::DrawQA(const int nsm) | |
454 | { | |
455 | // | |
456 | // Jun 25, 2007 | |
457 | // | |
458 | ||
459 | AliEMCALSuperModule* sm = GetSuperModule(nsm); | |
460 | if(sm==0) return; | |
461 | TList *l = sm-> GetHists(); | |
462 | Int_t nx=2, ny=2, wh=530, ww=750; | |
463 | ||
464 | TCanvas *c = new TCanvas(Form("QA_%i",GetIterationNumber()), Form("QA_%i",GetIterationNumber()), | |
465 | 10, 10, ww, wh); | |
466 | c->Divide(nx,ny); | |
467 | ||
468 | int ic=1; | |
469 | c->cd(ic++); | |
470 | TH1 *h1 = (TH1*)l->At(0); | |
471 | sm->FitEffMassHist(); | |
472 | u::DrawHist(h1,2); | |
473 | h1->SetAxisRange(0.03, 0.28); | |
474 | ||
475 | c->cd(ic++); | |
476 | sm->DrawCC(0); | |
477 | TH1 *hccin = (TH1*)l->At(1); | |
478 | hccin->SetAxisRange(14., 20.); | |
479 | ||
480 | gStyle->SetOptStat(1111); | |
481 | c->cd(ic++); | |
482 | TH1 *hmass = (TH1*)l->At(3); | |
483 | u::DrawHist(hmass, 2); | |
484 | hmass->SetAxisRange(0.12, 0.16); | |
485 | ||
486 | c->cd(ic++); | |
487 | TH1 *hres = (TH1*)l->At(4); | |
488 | u::DrawHist(hres, 2); | |
489 | hres->SetAxisRange(0.05, 0.120); | |
490 | ||
491 | if(ic<nx*ny) { | |
492 | c->cd(ic++); | |
493 | u::DrawHist((TH1*)l->At(5), 2); | |
494 | ||
495 | c->cd(ic++); | |
496 | u::DrawHist((TH1*)l->At(6), 2); | |
497 | } | |
498 | c->Update(); | |
499 | } | |
500 | ||
501 | TList* AliEMCALFolder::BookHists() | |
502 | { | |
b217491f | 503 | // Oct 15, 2007 |
16d3c94d | 504 | gROOT->cd(); |
505 | TH1::AddDirectory(1); | |
506 | ||
507 | new TH1F("00_HStat", "hist of common EMCAL statistics", 100, 0.5, 100.5); | |
508 | new TH1F("01_EffMassAll", "effective mass of #gamma,#gamma(m_{#pi^{0}}=134.9766 MeV) - whole EMCAL", 250,0.0,0.5); | |
509 | ||
510 | TList *l = AliEMCALHistoUtilities::MoveHistsToList("HistsOfEmcal", kFALSE); | |
511 | ||
512 | TH1::AddDirectory(0); | |
513 | return l; | |
514 | } | |
515 | ||
516 | void AliEMCALFolder::CreateCellNtuple() | |
517 | { | |
518 | // Jun 28, 2007 | |
519 | if(fCellNtuple) { // Already exist | |
520 | fCellNtuple->Print(); | |
521 | return; | |
522 | } | |
523 | // Create ntuple | |
524 | Int_t bsize = int(1.e+5); | |
525 | fCellNtuple = new TNtuple("cells","Cells Ntuple for quick analysis", | |
526 | "fAbsId:fSupMod:fModule:fPhi:fEta:fPhiCell:fEtaCell:fCcIn:fCcOut", bsize); | |
527 | AliEMCALCell *cell=0; | |
528 | // Fill ntuple | |
529 | AliEMCALSuperModule* sm = GetSuperModule(0); | |
530 | if(sm) printf(" TNtuple was created ! sm0 %s \n", sm->GetName()); | |
531 | for(int eta=0; eta<48; eta++) { // eta row | |
0fc11500 | 532 | TFolder *setEta = dynamic_cast<TFolder*>(sm->FindObject(Form("ETA%2.2i",eta))); |
16d3c94d | 533 | if(setEta) { |
534 | printf(" ***** eta row %s ******\n", setEta->GetName()); | |
0fc11500 | 535 | TList* l = (TList*)setEta->GetListOfFolders(); |
536 | for(int phi=0; phi<l->GetSize(); phi++) { // cycle on cells (phi directions) | |
537 | cell = (AliEMCALCell*)l->At(phi); | |
16d3c94d | 538 | if(cell) { |
539 | cell->FillCellNtuple(fCellNtuple); | |
540 | //printf(" fill cell %s : %s \n", cell->GetName(), cell->GetTitle()); | |
541 | } | |
542 | } | |
543 | } | |
544 | } | |
545 | fCellNtuple->Print(); | |
b217491f | 546 | fLobj->Add(fCellNtuple); |
16d3c94d | 547 | } |
548 | ||
549 | void AliEMCALFolder::CreateAndFillAdditionalHists() | |
550 | { | |
b217491f | 551 | // Oct 15, 2007 |
0fc11500 | 552 | CreateCellNtuple(); |
16d3c94d | 553 | TH1::AddDirectory(0); |
554 | fLhists->Add(new TH1F("02_CCoutOnEdge", "cc out on edge of calorimeter (in MeV)", 70, 12., 19.)); | |
555 | fLhists->Add(new TH1F("03_CCoutInside", "cc out inside of calorimeter (in MeV)", 70, 12., 19.)); | |
0fc11500 | 556 | fLhists->Add(new TH1F("04_CCoutOnEdge2", "cc out on edge of calorimeter(2) (in MeV)", 70, 12., 19.)); |
16d3c94d | 557 | // Fill |
558 | Float_t* args; | |
559 | for(Int_t i=0; i<(Int_t)fCellNtuple->GetEntries(); i++){ | |
560 | fCellNtuple->GetEvent(i); | |
561 | args = fCellNtuple->GetArgs(); | |
562 | Int_t phi = (Int_t)args[5]; | |
563 | Int_t eta = (Int_t)args[6]; | |
564 | Double_t cc = (Double_t)args[8]*1000.; | |
0fc11500 | 565 | if ((phi==0||phi==23) || (eta==0||eta==47)) u::FillH1(fLhists, 2, cc); |
566 | else if((phi==1||phi==22) || (eta==1||eta==46)) u::FillH1(fLhists, 4, cc); // next to edge | |
567 | else u::FillH1(fLhists, 3, cc); | |
16d3c94d | 568 | } |
569 | // Drawing | |
570 | Int_t wh=530, ww=750; | |
571 | TCanvas *c = new TCanvas("c_edge","CEDGE", 10, 10, ww, wh); | |
572 | ||
573 | gStyle->SetOptStat(1100); | |
574 | gStyle->SetOptFit(111); | |
575 | TH1 *h1 = (TH1*)fLhists->At(3); | |
576 | TF1 *g = u::Gausi("ccInside", 14.7, 16.4, h1); | |
577 | g->SetLineColor(kRed); | |
578 | h1->Fit(g,"Q+","", 14.7, 16.4); | |
579 | u::DrawHist(h1,2); | |
580 | h1->SetTitle("CC distribution after #pi^{0} calibration"); | |
581 | h1->SetXTitle(" MeV "); | |
582 | h1->SetYTitle(" N "); | |
0fc11500 | 583 | TLatex *lat1 = u::Lat(Form("rel.width = %4.2f%%", |
16d3c94d | 584 | 100.*h1->GetRMS()/ h1->GetMean()), 16.5, 100., 12, 0.045); |
0fc11500 | 585 | TLatex *lat2 = u::Lat(Form("rel.width = %4.2f%% (from fit)", |
16d3c94d | 586 | 100.*g->GetParameter(2)/ g->GetParameter(1)), 16.5, 70., 12, 0.045); |
587 | ||
588 | if(0) { | |
589 | TH1 *h2 = (TH1*)fLhists->At(2); | |
590 | u::DrawHist(h2,2,1,"same",2); | |
591 | } | |
592 | ||
593 | TH1F *hccFirst = AliEMCALCalibCoefs::GetHistOfCalibTableFromDb("ccTmp"); | |
594 | u::DrawHist(hccFirst,2,1,"same",3); | |
595 | ||
596 | ||
0fc11500 | 597 | // Ideal calibration - Jul 18, 2007 |
b217491f | 598 | Double_t adcCHANNELEC = 0.0153, ccIdeal = adcCHANNELEC*1.e+3; |
0fc11500 | 599 | Double_t ym = h1->GetMaximum(); |
600 | TLine *l = new TLine(ccIdeal,-ym*0.05, ccIdeal,ym*1.05); | |
601 | l->SetLineColor(kBlue); | |
602 | l->Draw(); | |
603 | ||
16d3c94d | 604 | TLegend *leg = new TLegend(0.1,0.6, 0.45,0.85); |
605 | leg->AddEntry(hccFirst, "Initial cc ", "L"); | |
606 | leg->AddEntry(h1, "Final cc", "L"); | |
0fc11500 | 607 | TLegendEntry *le=0; |
608 | if(l) { | |
609 | le = leg->AddEntry(l, "Ideal calibration", "L"); | |
610 | le->SetTextColor(l->GetLineColor()); | |
611 | } | |
612 | ||
613 | TH1 *hCcEdge = (TH1*)fLhists->At(2); | |
614 | TH1 *hCcEdge2 = (TH1*)fLhists->At(4); | |
615 | if(1) { | |
616 | u::DrawHist(hCcEdge,2,kGreen,"same",1); | |
617 | le = leg->AddEntry(hCcEdge , "Edge cell", "L"); | |
618 | le->SetTextColor(hCcEdge->GetLineColor()); | |
619 | ||
620 | u::DrawHist(hCcEdge2,2, 28,"same",1); // 28 - like brown | |
621 | le = leg->AddEntry(hCcEdge2 , "Edge cell (2)", "L"); | |
622 | le->SetTextColor(hCcEdge2->GetLineColor()); | |
623 | u::DrawHist(h1,2,1,"same"); | |
624 | } | |
625 | ||
16d3c94d | 626 | leg->Draw(); |
627 | ||
628 | c->Update(); | |
629 | } | |
630 | ||
631 | void AliEMCALFolder::TestSMStruct() | |
632 | { | |
633 | // testing May 22, 2007 | |
634 | for(int m=0; m<12; m++) { | |
635 | AliEMCALSuperModule *sm = new AliEMCALSuperModule(m); | |
636 | Add(sm); | |
0fc11500 | 637 | sm->SetParent(this); |
16d3c94d | 638 | } |
639 | } | |
640 |