]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALFolder.cxx
Parameters for track finding in AliITStrackerSA added to AliITSRecoParam (F. PRino)
[u/mrichter/AliRoot.git] / EMCAL / 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
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
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//_____________________________________________________________
16d3c94d 425void AliEMCALFolder::Save(const char *fn, const char *opt)
426{
427 //
428 // Jun 5, 2007; See TFileIter and StFMC.cxx
0fc11500 429 // Jul 16 - added fgkDirOfRootFiles
430 // Sep 7, 2007 - should be changed without TFileIter
431 /*
432 TString FN = fgkDirOfRootFiles;
433 FN += fn;
16d3c94d 434 if(FN.Contains(".root")==0) FN += ".root";
435 TFileIter f(FN.Data(),opt,"EMCAL object");
436 UInt_t eventNum = 0; // just one object
0fc11500 437 UInt_t runNumber = 0; // 0 now, - may statistics on selector
16d3c94d 438 f.NextEventPut(this, eventNum, runNumber);
439 printf(" Save %s to file %s\n", GetName(), FN.Data());
0fc11500 440 */
b217491f 441 if(fn || opt);
16d3c94d 442}
443
6f377f0c 444//_____________________________________________________________
b217491f 445AliEMCALFolder* AliEMCALFolder::ReadFolder(const char *fn, const char *opt)
16d3c94d 446{
447 //
448 // Jun 27, 2007
0fc11500 449 // Jul 16 - added fgkDirOfRootFiles
16d3c94d 450 //
b217491f 451 printf("<I> AliEMCALFolder::ReadFolder(%s,%s)\n",fn,opt);
452 AliEMCALFolder* emcal = 0;
16d3c94d 453 TH1::AddDirectory(0); // this is obligatory
454
b217491f 455 TString sfn = fgkDirOfRootFiles;
456 sfn += fn;
457 if(sfn.Contains(".root")==0) sfn += ".root";
16d3c94d 458
b217491f 459 TFile f(sfn.Data(),opt);
0fc11500 460 if(f.IsOpen()) {
461 TList *l = f.GetListOfKeys();
b217491f 462 printf("<I> The total number of the objects: %d \n File %s\n", l->GetSize(), sfn.Data());
16d3c94d 463
0fc11500 464 TKey *key = (TKey*)l->At(0);
b217491f 465 emcal = (AliEMCALFolder*)key->ReadObj();
0fc11500 466 f.Close();
b217491f 467 if(emcal) emcal->InitAfterRead();
0fc11500 468 }
b217491f 469 return emcal;
16d3c94d 470}
471
6f377f0c 472//_____________________________________________________________
16d3c94d 473void AliEMCALFolder::InitAfterRead()
0fc11500 474{
b217491f 475 // Oct 15, 2007
476 fLobj = (TList*)FindObject("Objects");
477 if(fLobj) {
478 fLhists = (TList*)fLobj->FindObject("HistsOfEmcal");
0fc11500 479 }
16d3c94d 480}
481
6f377f0c 482//_____________________________________________________________
16d3c94d 483void AliEMCALFolder::DrawQA(const int nsm)
484{
485 //
486 // Jun 25, 2007
487 //
488
489 AliEMCALSuperModule* sm = GetSuperModule(nsm);
490 if(sm==0) return;
491 TList *l = sm-> GetHists();
492 Int_t nx=2, ny=2, wh=530, ww=750;
493
494 TCanvas *c = new TCanvas(Form("QA_%i",GetIterationNumber()), Form("QA_%i",GetIterationNumber()),
495 10, 10, ww, wh);
496 c->Divide(nx,ny);
497
498 int ic=1;
499 c->cd(ic++);
500 TH1 *h1 = (TH1*)l->At(0);
501 sm->FitEffMassHist();
502 u::DrawHist(h1,2);
503 h1->SetAxisRange(0.03, 0.28);
504
505 c->cd(ic++);
506 sm->DrawCC(0);
507 TH1 *hccin = (TH1*)l->At(1);
508 hccin->SetAxisRange(14., 20.);
509
510 gStyle->SetOptStat(1111);
511 c->cd(ic++);
512 TH1 *hmass = (TH1*)l->At(3);
513 u::DrawHist(hmass, 2);
514 hmass->SetAxisRange(0.12, 0.16);
515
516 c->cd(ic++);
517 TH1 *hres = (TH1*)l->At(4);
518 u::DrawHist(hres, 2);
519 hres->SetAxisRange(0.05, 0.120);
520
521 if(ic<nx*ny) {
522 c->cd(ic++);
523 u::DrawHist((TH1*)l->At(5), 2);
524
525 c->cd(ic++);
526 u::DrawHist((TH1*)l->At(6), 2);
527 }
528 c->Update();
529}
530
6f377f0c 531//_____________________________________________________________
16d3c94d 532TList* AliEMCALFolder::BookHists()
533{
b217491f 534 // Oct 15, 2007
16d3c94d 535 gROOT->cd();
536 TH1::AddDirectory(1);
537
538 new TH1F("00_HStat", "hist of common EMCAL statistics", 100, 0.5, 100.5);
539 new TH1F("01_EffMassAll", "effective mass of #gamma,#gamma(m_{#pi^{0}}=134.9766 MeV) - whole EMCAL", 250,0.0,0.5);
540
541 TList *l = AliEMCALHistoUtilities::MoveHistsToList("HistsOfEmcal", kFALSE);
542
543 TH1::AddDirectory(0);
544 return l;
545}
546
6f377f0c 547//_____________________________________________________________
16d3c94d 548void AliEMCALFolder::CreateCellNtuple()
549{
550 // Jun 28, 2007
551 if(fCellNtuple) { // Already exist
552 fCellNtuple->Print();
553 return;
554 }
555 // Create ntuple
556 Int_t bsize = int(1.e+5);
557 fCellNtuple = new TNtuple("cells","Cells Ntuple for quick analysis",
558 "fAbsId:fSupMod:fModule:fPhi:fEta:fPhiCell:fEtaCell:fCcIn:fCcOut", bsize);
559 AliEMCALCell *cell=0;
560 // Fill ntuple
561 AliEMCALSuperModule* sm = GetSuperModule(0);
562 if(sm) printf(" TNtuple was created ! sm0 %s \n", sm->GetName());
563 for(int eta=0; eta<48; eta++) { // eta row
0fc11500 564 TFolder *setEta = dynamic_cast<TFolder*>(sm->FindObject(Form("ETA%2.2i",eta)));
16d3c94d 565 if(setEta) {
566 printf(" ***** eta row %s ******\n", setEta->GetName());
0fc11500 567 TList* l = (TList*)setEta->GetListOfFolders();
568 for(int phi=0; phi<l->GetSize(); phi++) { // cycle on cells (phi directions)
569 cell = (AliEMCALCell*)l->At(phi);
16d3c94d 570 if(cell) {
571 cell->FillCellNtuple(fCellNtuple);
572 //printf(" fill cell %s : %s \n", cell->GetName(), cell->GetTitle());
573 }
574 }
575 }
576 }
577 fCellNtuple->Print();
b217491f 578 fLobj->Add(fCellNtuple);
16d3c94d 579}
580
6f377f0c 581//_____________________________________________________________
16d3c94d 582void AliEMCALFolder::CreateAndFillAdditionalHists()
583{
b217491f 584 // Oct 15, 2007
0fc11500 585 CreateCellNtuple();
16d3c94d 586 TH1::AddDirectory(0);
587 fLhists->Add(new TH1F("02_CCoutOnEdge", "cc out on edge of calorimeter (in MeV)", 70, 12., 19.));
588 fLhists->Add(new TH1F("03_CCoutInside", "cc out inside of calorimeter (in MeV)", 70, 12., 19.));
0fc11500 589 fLhists->Add(new TH1F("04_CCoutOnEdge2", "cc out on edge of calorimeter(2) (in MeV)", 70, 12., 19.));
16d3c94d 590 // Fill
591 Float_t* args;
592 for(Int_t i=0; i<(Int_t)fCellNtuple->GetEntries(); i++){
593 fCellNtuple->GetEvent(i);
594 args = fCellNtuple->GetArgs();
595 Int_t phi = (Int_t)args[5];
596 Int_t eta = (Int_t)args[6];
597 Double_t cc = (Double_t)args[8]*1000.;
0fc11500 598 if ((phi==0||phi==23) || (eta==0||eta==47)) u::FillH1(fLhists, 2, cc);
599 else if((phi==1||phi==22) || (eta==1||eta==46)) u::FillH1(fLhists, 4, cc); // next to edge
600 else u::FillH1(fLhists, 3, cc);
16d3c94d 601 }
602 // Drawing
603 Int_t wh=530, ww=750;
604 TCanvas *c = new TCanvas("c_edge","CEDGE", 10, 10, ww, wh);
605
606 gStyle->SetOptStat(1100);
607 gStyle->SetOptFit(111);
608 TH1 *h1 = (TH1*)fLhists->At(3);
609 TF1 *g = u::Gausi("ccInside", 14.7, 16.4, h1);
610 g->SetLineColor(kRed);
611 h1->Fit(g,"Q+","", 14.7, 16.4);
612 u::DrawHist(h1,2);
613 h1->SetTitle("CC distribution after #pi^{0} calibration");
614 h1->SetXTitle(" MeV ");
615 h1->SetYTitle(" N ");
6f377f0c 616 // TLatex *lat1 = u::Lat(Form("rel.width = %4.2f%%",
617 //100.*h1->GetRMS()/ h1->GetMean()), 16.5, 100., 12, 0.045);
618 //TLatex *lat2 = u::Lat(Form("rel.width = %4.2f%% (from fit)",
619 // 100.*g->GetParameter(2)/ g->GetParameter(1)), 16.5, 70., 12, 0.045);
16d3c94d 620
621 if(0) {
622 TH1 *h2 = (TH1*)fLhists->At(2);
623 u::DrawHist(h2,2,1,"same",2);
624 }
625
626 TH1F *hccFirst = AliEMCALCalibCoefs::GetHistOfCalibTableFromDb("ccTmp");
627 u::DrawHist(hccFirst,2,1,"same",3);
628
629
0fc11500 630 // Ideal calibration - Jul 18, 2007
b217491f 631 Double_t adcCHANNELEC = 0.0153, ccIdeal = adcCHANNELEC*1.e+3;
0fc11500 632 Double_t ym = h1->GetMaximum();
633 TLine *l = new TLine(ccIdeal,-ym*0.05, ccIdeal,ym*1.05);
634 l->SetLineColor(kBlue);
635 l->Draw();
636
16d3c94d 637 TLegend *leg = new TLegend(0.1,0.6, 0.45,0.85);
638 leg->AddEntry(hccFirst, "Initial cc ", "L");
639 leg->AddEntry(h1, "Final cc", "L");
0fc11500 640 TLegendEntry *le=0;
641 if(l) {
642 le = leg->AddEntry(l, "Ideal calibration", "L");
643 le->SetTextColor(l->GetLineColor());
644 }
645
646 TH1 *hCcEdge = (TH1*)fLhists->At(2);
647 TH1 *hCcEdge2 = (TH1*)fLhists->At(4);
648 if(1) {
649 u::DrawHist(hCcEdge,2,kGreen,"same",1);
650 le = leg->AddEntry(hCcEdge , "Edge cell", "L");
651 le->SetTextColor(hCcEdge->GetLineColor());
652
653 u::DrawHist(hCcEdge2,2, 28,"same",1); // 28 - like brown
654 le = leg->AddEntry(hCcEdge2 , "Edge cell (2)", "L");
655 le->SetTextColor(hCcEdge2->GetLineColor());
656 u::DrawHist(h1,2,1,"same");
657 }
658
16d3c94d 659 leg->Draw();
660
661 c->Update();
662}
663
6f377f0c 664//_____________________________________________________________
16d3c94d 665void AliEMCALFolder::TestSMStruct()
666{
667 // testing May 22, 2007
668 for(int m=0; m<12; m++) {
669 AliEMCALSuperModule *sm = new AliEMCALSuperModule(m);
670 Add(sm);
0fc11500 671 sm->SetParent(this);
16d3c94d 672 }
673}
674