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