corrected warnings with gcc 4.3
[u/mrichter/AliRoot.git] / EMCAL / Calib / AliEMCALPi0Calibration.cxx
CommitLineData
6e6f8407 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/* History of svn commits:
16 *
17 * $Log$
18 *
19 */
20
21//_________________________________________________________________________
22// This is analysis task for doing EMCAL pi0 calibration
23//-- Authors: Aleksei Pavlinov (WSU)
24//-- Feb 17, 2007 - Sep 11, 2007
25//-- Pi0 calibration
26//-- Recalibration, linearity, shower profile
27//-- May 2008 - move to AliAnalysisTaskSE
28//-- You should load next library before running:
29// root [0] gSystem->Load("libANALYSIS");
30// root [1] gSystem->Load("libANALYSISalice");
31// root [2] gSystem->Load("libEMCALcalib");
32//_________________________________________________________________________
33
34#include "AliEMCALPi0Calibration.h"
35#include "AliEMCALFolder.h"
36#include "AliEMCALSuperModule.h"
37#include "AliEMCALCell.h"
38#include "AliEMCALCellInfo.h"
39#include "AliEMCALPi0SelectionParam.h"
40#include "AliEMCALHistoUtilities.h"
41#include "AliEMCALCalibCoefs.h"
42#include "AliEMCALGeometry.h"
43#include "AliLog.h"
44#include "AliESD.h"
45#include "AliEMCALRecPoint.h"
46#include "AliRunLoader.h"
47#include "AliStack.h"
48#include "AliEMCALDigit.h"
49#include "AliESDEvent.h"
50
51#include <iostream>
52#include <iomanip>
53#include <fstream>
54#include <cassert>
55#include <map>
56#include <string>
57
58#include <TROOT.h>
59#include <TStyle.h>
60#include <TSystem.h>
61#include <TCanvas.h>
62#include <TVector3.h>
63#include <TLorentzVector.h>
64#include <TParticle.h>
65#include <TChain.h>
66#include <TFile.h>
67#include <TH1F.h>
68#include <TH1D.h>
69#include <TH2F.h>
70#include <TF1.h>
71#include <TMath.h>
72#include <TBrowser.h>
73#include <TList.h>
74#include <TCanvas.h>
75#include <TLine.h>
76#include <TObjString.h>
77#include <TArrayI.h>
78#include <TGraphErrors.h>
79#include <TLegend.h>
80#include <TLegendEntry.h>
81#include <TNtuple.h>
82
83using namespace std;
84
85typedef AliEMCALHistoUtilities u;
86
87AliEMCALGeometry* AliEMCALPi0Calibration::fgEmcalGeo=0;
88Int_t AliEMCALPi0Calibration::fgNmaxCell = 4*12*24*11;
89
90Double_t AliEMCALPi0Calibration::fgDistEff = 3.;
91Double_t AliEMCALPi0Calibration::fgW0 = 4.5;
92Double_t AliEMCALPi0Calibration::fgSlopePhiShift = 0.01; // ?? just guess
93
94AliEMCALFolder* AliEMCALPi0Calibration::fgEMCAL = 0;
95AliEMCALFolder* AliEMCALPi0Calibration::fgEMCALOld = 0;
96
97Char_t **AliEMCALPi0Calibration::fgAnaOpt=0;
98Int_t AliEMCALPi0Calibration::fgNanaOpt = 0;
99enum keyOpt{
100 kCORR1,
101 kRECALIB,
102 kIDEAL,
103 kPI0,
104 kGAMMA,
105 kKINE,
106 kPROF,
107 kFIT,
108 //--
109 kEND
110};
111
112// Enumeration variables
113// enum {kUndefined=-1, kLed=0, kBeam=1};
114// enum {kPatchResponse=0, kClusterResponse=1};
115// enum {kSkip=0, kSaveToMemory=1};
116
117ClassImp(AliEMCALPi0Calibration)
118
119AliEMCALPi0Calibration::AliEMCALPi0Calibration() :
120 AliAnalysisTaskSE(),
121 fPmom(0),
122 fChain(0),
123 fLofHistsPC(0),
124 fLofHistsRP(0),
125 fLKineVsRP(0),
126 fLShowerProfile(0),
127 fCellsInfo(0),
128 fEmcalPool(0),
129 fRunOpts(0),
130 fArrOpts(0),
131 fKeyOpts(0)
132{
133 // Default constructor - for reading
134}
135
136AliEMCALPi0Calibration::AliEMCALPi0Calibration(const char* name) :
137 AliAnalysisTaskSE(name),
138 fPmom(0),
139 fChain(0),
140 fLofHistsPC(0),
141 fLofHistsRP(0),
142 fLKineVsRP(0),
143 fLShowerProfile(0),
144 fCellsInfo(0),
145 fEmcalPool(0),
146 fRunOpts(0),
147 fArrOpts(0),
148 fKeyOpts(0)
149{
150 //
151 // Constructor. Initialization of pointers
152 //
153 Char_t *anaOpt[]={
154 "CORR1", // GetCorrectedEnergyForGamma1(Double_t eRec);
155 "RECALIB",
156 "IDEAL",
157 "PI0",
158 "GAMMA",
159 "KINE", // reading kine file
160 "PROF", // Shower profile: phi direction now
161 "FIT" // define parameters : deff, w0 and phislope
162 };
163
164 fgNanaOpt = sizeof(anaOpt) / sizeof(Char_t*);
165 fgAnaOpt = new Char_t*[fgNanaOpt];
166 for(int i=0; i<fgNanaOpt; i++) fgAnaOpt[i] = anaOpt[i];
167}
168
169AliEMCALPi0Calibration::AliEMCALPi0Calibration(const AliAnalysisTaskSE& obj) :
170 AliAnalysisTaskSE(),
171 fPmom(0),
172 fChain(0),
173 fLofHistsPC(0),
174 fLofHistsRP(0),
175 fLKineVsRP(0),
176 fLShowerProfile(0),
177 fCellsInfo(0),
178 fEmcalPool(0),
179 fRunOpts(0),
180 fArrOpts(0),
181 fKeyOpts(0)
182{
6e6f8407 183 // Copy constructor - unused
abad76ae 184// if(&obj); //FOR WHAT IS THIS, commented due to warnings
6e6f8407 185}
186
187AliEMCALPi0Calibration& AliEMCALPi0Calibration::operator=(const AliAnalysisTaskSE& other)
188{
6e6f8407 189 // Assignment
abad76ae 190// if(&other); //FOR WHAT IS THIS, commented due to warnings
191 return *this;
6e6f8407 192}
193
194AliEMCALPi0Calibration::~AliEMCALPi0Calibration()
195{
196 //
197 // Destructor
198 //
199
200 // histograms are in the output list and deleted when the output
201 // list is deleted by the TSelector dtor
202}
203
204void AliEMCALPi0Calibration::InitStructure(Int_t it)
205{
206 //
207 // Initialize the common structure of selector
208 //
209 fgEmcalGeo = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE"); // initialize geometry just once
210 fCellsInfo = AliEMCALCellInfo::GetTableForGeometry(fgEmcalGeo);
211
212 if(fRunOpts.Length()>0) CheckRunOpts();
213
214 Int_t key = 0;
215 if(GetKeyOptsValue(kGAMMA)) key = 1;
216 fLofHistsRP = DefineHistsOfRP("RP", fPmom, key);
217 fLofHistsPC = DefineHistsOfRP("PseudoCl", fPmom);
218
219 fEmcalPool = new TFolder("PoolOfEMCAL","");
220 if(it <= 1) {
221 fgEMCAL = new AliEMCALFolder(it); // folder for first itteration
222 fEmcalPool->Add(fgEMCAL);
223 }
224 //if(it<=0) SetName("GammaSel"); // For convinience
225 //else SetName("Pi0Sel");
226 if(GetKeyOptsValue(kKINE)) fLKineVsRP = DefineHistsOfKineVsRP("KineVsRP",fPmom, key);
227 if(GetKeyOptsValue(kPROF)) fLShowerProfile = DefineHistsForShowerProfile("ProfY", fPmom);
228}
229
230void AliEMCALPi0Calibration::CheckRunOpts()
231{
232 // Check run options
233 fRunOpts.ToUpper();
234 int nopt = u::ParseString(fRunOpts, fArrOpts);
235 printf("<I> AliEMCALPi0Calibration::CheckRunOpts() analyze %i(%i) options : fgNanaOpt %i\n",
236 nopt, fArrOpts.GetEntries(), fgNanaOpt);
237 if(nopt <=0) return;
238
239 fKeyOpts = new TArrayI(fgNanaOpt);
240 for(Int_t i=0; i<fgNanaOpt; i++) (*fKeyOpts)[i] = 0;
241
242 for(Int_t i=0; i<fArrOpts.GetEntries(); i++ ) {
243 TObjString *o = (TObjString*)fArrOpts.At(i);
244
245 TString runOpt = o->String();
246 Int_t indj=-1;
247
248 for(Int_t j=0; j<fgNanaOpt; j++) {
249 TString opt = fgAnaOpt[j];
250 if(runOpt.Contains(opt,TString::kIgnoreCase)) {
251 indj = j;
252 break;
253 }
254 }
255 if(indj<0) {
256 printf("<E> option |%s| unavailable **\n",
257 runOpt.Data());
258 assert(0);
259 } else {
260 (*fKeyOpts)[indj] = 1;
261 printf("<I> option |%s| is valid : number %i : |%s| \n",
262 runOpt.Data(), indj, fgAnaOpt[indj]);
263 }
264 }
265}
266
267Int_t AliEMCALPi0Calibration::GetKeyOptsValue(Int_t key)
268{
269 // Oct 14, 2007
270 static Int_t val=0;
271 val = 0;
272 if(fKeyOpts && key>=0 && key<fKeyOpts->GetSize()) {
273 val = fKeyOpts->At(key);
274 }
275 // printf(" key %i : val %i : opt %s \n", key, val, fgAnaOpt[key]);
276 return val;
277}
278
279void AliEMCALPi0Calibration::UserExec(const Option_t* /* */)
280{
281 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(InputEvent());
282
283 if (!esd)
284 {
285 AliDebug(AliLog::kError, "ESD branch not available");
286 return;
287 }
288
289 static AliEMCALPi0SelectionParRec* rPar = GetEmcalFolder()->GetPi0SelectionParRow(0);
290
291 static Int_t nEmcalClusters, indOfFirstEmcalRP, nEmcalRP,nEmcalPseudoClusters;
292 nEmcalClusters = esd->GetNumberOfEMCALClusters();
293 indOfFirstEmcalRP = esd->GetFirstEMCALCluster();
294 u::FillH1(fLofHistsRP, 1, double(indOfFirstEmcalRP));
295
296 static AliRunLoader* rl = 0;
297 static Int_t nev = 0; // Temporary - 0nly for reading one file now !!
298
299 static AliESDCaloCluster *cl = 0;
300 nEmcalRP = nEmcalPseudoClusters = 0;
301 TList *l=0;
302 double eDigi=0;
303
304 TClonesArray lvM1("TLorentzVector", 100); // for convenience; 100 is enough now
305 TArrayI indLv(100); // index of RP
306
307 static TLorentzVector v, vcl;
308 int nrp = 0; // # of RP for gg analysis
309 static Double_t erec=0., ecorr=0.0;
310 for(int i=indOfFirstEmcalRP; i<indOfFirstEmcalRP+nEmcalClusters; i++) {
311 cl = esd->GetCaloCluster(i);
312 if(cl->GetClusterType() == AliESDCaloCluster::kEMCALPseudoCluster) {
313 nEmcalPseudoClusters++;
314 l = fLofHistsPC;
315 } else if(cl->GetClusterType() == AliESDCaloCluster::kEMCALClusterv1){
316 nEmcalRP++;
317 if(fgEMCAL->GetIterationNumber()>1||GetKeyOptsValue(kIDEAL)||GetKeyOptsValue(kRECALIB)||GetKeyOptsValue(kFIT)) {
318 AliEMCALRecPoint *rp=0;
319 if(GetKeyOptsValue(kFIT) == kFALSE) fgDistEff = -1.; // No fitting ; Sep 4, 2007
320 if(GetKeyOptsValue(kIDEAL)) {
321 rp = AliEMCALFolder::GetRecPoint(cl, fgEMCAL->GetCCFirst(), 0, fLofHistsRP, fgDistEff, fgW0, fgSlopePhiShift);
322 } else {
323 rp = AliEMCALFolder::GetRecPoint(cl, fgEMCAL->GetCCFirst(), fgEMCAL->GetCCIn(), fLofHistsRP, fgDistEff, fgW0, fgSlopePhiShift);
324 }
325 if(GetKeyOptsValue(kPROF)) {
326 FillHistsForShowerProfile( GetListShowerProfile(), rp, GetCellsInfo());
327 }
328 //if(rp->GetPointEnergy()>=rPar->fEOfRpMin && u::GetLorentzVectorFromRecPoint(v, rp)) {
329 if(u::GetLorentzVectorFromRecPoint(v, rp)) { // comparing with RP
330 if(GetKeyOptsValue(kCORR1)) {
331 erec = v.Rho();
332 ecorr = u::GetCorrectedEnergyForGamma1(erec);
333 v.SetRho(ecorr);
334 v.SetE(ecorr); // This is gamma
335 //printf("<1> erec %f | ecorr %f \n", erec, ecorr);
336 }
337 new(lvM1[nrp]) TLorentzVector(v);
338 indLv[nrp] = i;
339 nrp++;
340 // Conroling of recalibration
341 u::GetLorentzVectorFromESDCluster(vcl, cl);
342 u::FillH1(fLofHistsRP, 11, vcl.P()-v.P());
343 u::FillH1(fLofHistsRP, 12, TMath::RadToDeg()*(vcl.Theta()-v.Theta()));
344 u::FillH1(fLofHistsRP, 13, TMath::RadToDeg()*(vcl.Phi()-v.Phi()));
345
346 u::FillH1(fLofHistsRP, 16, v.P());
347 u::FillH2(fLofHistsRP, 17, vcl.P(), vcl.P()-v.P());
348 l = 0; // no filling
349 if(GetKeyOptsValue(kIDEAL) || GetKeyOptsValue(kRECALIB)) l = fLofHistsRP;
350 }
351 if(rp) delete rp;
352 } else { // first iteration
353 // if(cl->E()>=rPar->fEOfRpMin && u::GetLorentzVectorFromESDCluster(v, cl)) {
354 if(u::GetLorentzVectorFromESDCluster(v, cl)) { // comparing with RP
355 // cut 0.4 GeV may be high !
356 if(GetKeyOptsValue(kCORR1)) {
357 erec = v.Rho();
358 ecorr = u::GetCorrectedEnergyForGamma1(erec);
359 v.SetRho(ecorr);
360 v.SetE(ecorr); // This is gamma now
361 // printf("<2> erec %f | ecorr %f \n", erec, ecorr);
362 // printf(" v.Rho() %f \n", v.Rho());
363 }
364 new(lvM1[nrp]) TLorentzVector(v);
365 indLv[nrp] = i;
366 nrp++;
367 l = fLofHistsRP;
368 }
369 }
370
371 } else {
372 printf(" wrong cluster type : %i\n", cl->GetClusterType());
373 assert(0);
374 }
375 u::FillH1(l, 2, double(cl->GetClusterType()));
376
377 u::FillH1(l, 3, double(cl->GetNumberOfDigits()));
378 u::FillH1(l, 4, double(cl->E()));
379 // Cycle on digits (towers)
380 Short_t *digiAmpl = cl->GetDigitAmplitude()->GetArray();
381 Short_t *digiTime = cl->GetDigitTime()->GetArray();
382 Short_t *digiAbsId = cl->GetDigitIndex()->GetArray();
383 for(int id=0; id<cl->GetNumberOfDigits(); id++) {
384 eDigi = double(digiAmpl[id]) / 500.; // See AliEMCALClusterizerv1
385 // if(eDigi <= 0.0) { // sometimes it is happen
386 //if(eDigi > 10.0 && cl->GetClusterType() == AliESDCaloCluster::kEMCALClusterv1) {
387 // printf(" %i digiAmpl %i : %f \n", id, int(digiAmpl[id]), eDigi);
388 //}
389 u::FillH1(l, 5, eDigi);
390 u::FillH1(l, 6, double(digiTime[id]));
391 u::FillH1(l, 7, double(digiAbsId[id]));
392 if(int(digiAbsId[id]) >= fgNmaxCell) {
393 printf(" id %i : digiAbsId[id] %i (%i) : %s \n",
394 id, int(digiAbsId[id]), fgNmaxCell, l->GetName());
395 }
396 }
397 }
398 u::FillH1(fLofHistsRP, 0, double(nEmcalRP));
399 u::FillH1(fLofHistsPC, 0, double(nEmcalPseudoClusters));
400
401 static TLorentzVector *lv1=0, *lv2=0, lgg;
402 for(int i1=0; i1<nrp; i1++){
403 lv1 = (TLorentzVector*)lvM1.At(i1);
404 u::FillH1(fLofHistsRP, 18, lv1->P());
405 }
406 static Double_t mgg, pgg;
407 mgg = pgg = 0.;
408 nrp = lvM1.GetEntriesFast();
409 if(nrp >= 2) {
410 // eff.mass analysis
411 for(int i1=0; i1<nrp-1; i1++){
412 lv1 = (TLorentzVector*)lvM1.At(i1);
413 for(int i2=i1+1; i2<nrp; i2++){
414 lv2 = (TLorentzVector*)lvM1.At(i2);
415 lgg = (*lv1) + (*lv2);
416 mgg = lgg.M(); // eff.mass
417 pgg = lgg.P(); // momentum
418 u::FillH1(fLofHistsRP, 8, mgg);
419
420 if((mgg>=rPar->fMassGGMin && mgg<=rPar->fMassGGMax)) {// pi0 candidates
421 if((pgg>=rPar->fMomPi0Min && pgg>=rPar->fMomPi0Min)) {
422 if(fgEMCAL && fgEMCAL->GetIterationNumber()>=1) {
423 fgEMCAL->FillPi0Candidate(mgg,esd->GetCaloCluster(indLv[i1]),esd->GetCaloCluster(indLv[i2]));
424 u::FillH1(fLofHistsRP, 9, pgg);
425 u::FillH1(fLofHistsRP,10, lv1->P());
426 u::FillH1(fLofHistsRP,10, lv2->P());
427 }
428 }
429 }
430 }
431 }
432 }
433
434 // static Int_t fileNumber = 0;
435 static TString curFileName;
436 // if(GetKeyOptsValue(kKINE) && nev<fChain->GetEntries()) {
437 if(GetKeyOptsValue(kKINE)) {
438 // Get galice.root file in current directory
439 if(nev%1000==0) {
440 printf(" current file |%s|\n", fChain->GetCurrentFile()->GetName());
441 curFileName = fChain->GetCurrentFile()->GetName();
442 curFileName.ReplaceAll("AliESDs.","galice.");
443 }
444 rl = u::InitKinematics(nev, curFileName.Data());
445 // Compare kineamtics vs EMCal clusters
446 FillHistsOfKineVsRP(fLKineVsRP, rl, lvM1);
447 }
448
449 lvM1.Delete();
450
451 if(nEmcalClusters != (nEmcalRP+nEmcalPseudoClusters))
452 Info("Process","nEmcalClusters %i : RP %i + PC %i ",nEmcalClusters, nEmcalRP, nEmcalPseudoClusters);
453
454 nev++;
455
456 return;
457}
458
459//
460TList *AliEMCALPi0Calibration::DefineHistsOfRP(const char *name,Double_t p,Int_t keyOpt)
461{
462 //
463 // Define histogramms of rec.points
464 //
465 printf("<I> DefineHistsOfRP :%s : p %f : keyOpt %i \n", name, p, keyOpt);
466 Double_t adcChannelEC = 0.0153; // ~15mev per adc count
467 Double_t xma = p*1.4, xmi=0.0, step=0.0, xmic=xmi, xmac = xma;
468 if(xma<0) xma = 20.;
469 Int_t nmax=1000, scale=4, nmaxc = nmax;
470
471 gROOT->cd();
472 TH1::AddDirectory(1);
473 new TH1F("00_EmcalMultiplicity", "multiplicity of EMCAL ", 201, -0.5, 200.5); // real and pseudo
474 new TH1F("01_IndexOfFirstEmcal", "index of first emcal rec.points ", 201, -0.5, 200.5);
475
476 new TH1F("02_NumberOf", "number of ", 6, -0.5, 5.5);
477 new TH1F("03_NumberOfDigitsIn", "number of digits(towers) in rec.points ", 101, -0.5, 100.5);
478
479 if(keyOpt==1 && p>0.1) {
480 if (p>=100.) scale=12;
481 else if(p>=50.) scale=10;
482 else if(p>=30.) scale=8;
483 xma = p + scale*(0.15*TMath::Sqrt(p));
484 xmi = p - scale*(0.15*TMath::Sqrt(p));
485 step = (xma-xmi)/nmax;
486 }
487
488 if(step < 0.0153) {
489 nmax = int((xma-xmi) / adcChannelEC)+1;
490 xma = xmi + adcChannelEC*nmax;
491 }
492 new TH1F("04_EnergyOf", "energy of ", nmax, xmi, xma);
493 nmaxc = nmax; xmic=xmi; xmac = xma;
494
495 nmax = 10000;
496 xmi = adcChannelEC/2.; xma = xmi + adcChannelEC*nmax;
497 // All energy(momentum) unit is GeV if don't notice
498 new TH1F("05_DigitEnergyIn", "digit energy in ", nmaxc, xmic, xmac);
499 new TH1F("06_DigitTimeIn", "digit time in 10ps(0.01ns) ", 1000, 0.0, 3.e+3); // ns/100 = 10 ps
500 new TH1F("07_DigitAbsIdIn", "digit abs id in ", fgNmaxCell, -0.5, double(fgNmaxCell)-0.5);
501 new TH1F("08_EffMass", "effective mass of #gamma,#gamma(m_{#pi^{0}}=134.9766 MeV)", 100, 0.0, 0.5);
502 new TH1F("09_MomOfPi0Candidate", "momentum of #pi^{0} candidates (0.085 <mgg<0.185)", 600, 0.0, 30.0);
503 new TH1F("10_MomOfRpPi0Candidate", "momentum of RP for #pi^{0} candidates (0.085 <mgg<0.185)", 600, 0.0, 30.0);
504 // Recalibration staf
505 Double_t pmax=11., dpmax=0.20;
506 if(p>0.1) {
507 pmax=p*1.2;
508 dpmax *= p;
509 }
510 new TH1F("11_MomClESD-RpRecalib", "difference of momentum cl(ESD) - rp(Recalib)", 100, -.01, dpmax);
511 new TH1F("12_ThetaClESD-RpRecalib", "difference of #theta cl(ESD) - rp(Recalib) in degree", 100, -0.05, +0.05);
512 new TH1F("13_PhiClESD-RpRecalib", "difference of #phi cl(ESD) - rp(Recalib) in degree ", 100, -0.05, +0.05);
513 // Digi
514 new TH1F("14_EDigiRecalib", "energy of digits after recalibration", 2000, 0.0, 20.);
515 // AliEMCALGeometry* g = AliEMCALGeometry::GetInstance();
516 new TH1F("15_AbsIdRecalib", "abs Id of digits after recalibration", fgEmcalGeo->GetNCells(),-0.5,Double_t(fgEmcalGeo->GetNCells())-0.5);
517 new TH1F("16_EnergyOfRecalibRp_", "energy of recalibrated rec.points", nmaxc, xmic, xmac); // Jul 12, 2007
518 new TH2F("17_ShiftRecalib_", "E(clESD) - E(recalib)", 110,0.0, pmax, 50,0.0,dpmax); // Jul 13, 2007
519
520 // Corrected staff
521 new TH1F("18_EnergyOfCorrectedLV", "energy of corrected LV", nmaxc, xmic, xmac);
522
523 TString st = Form("ListOfHists%s_P=%5.1f",name,p);
524 st.ReplaceAll(" ","");
525 TList *l = u::MoveHistsToList(st.Data(), kFALSE);
526 st = Form("%s_P=%5.1f",name,p);
527 st.ReplaceAll(" ","");
528 u::AddToNameAndTitleToList(l, st.Data(), st.Data());
529
530 return l;
531}
532
533TList* AliEMCALPi0Calibration::DefineHistsOfKineVsRP(const char *name, Double_t p, Int_t keyOpt)
534{
535 //
536 // Define histogramms for comparing a initial kinematics with rec.points
537 //
538 printf("<I> DefineHistsOfKineVsRP :%s : p %f : keyOpt %i \n", name, p, keyOpt);
539
540 gROOT->cd();
541 TH1::AddDirectory(1);
542 new TH1F("00_hVx",Form("Vx of primary vertex"), 100, -5., +5.); // 00
543 new TH1F("01_hVy",Form("Vy of primary vertex"), 100, -5., +5.); // 01
544 new TH1F("02_hVz",Form("Vz of primary vertex"), 100, -50., +50.); // 02
545
546 // Double_t adcChannelEC = 0.0153; // ~15mev per adc count
547 Double_t xma = p*1.4, xmi=0.0, sig=0.15*TMath::Sqrt(p);
548 // Double_t step=0.0, xmic=xmi, xmac = xma;
549 if(xma<0) xma = 20.;
550 //Int_t nmax=1000;
551 // scale=4, nmaxc = nmax;
552
553 new TH1F("03_hGidPrimar", "Geant Id of primary particle ", 101, 0.5, 100.5); // 03
554 new TH1F("04_hPmomPrim","momentum of primary particle", 100, xmi, xma); // 04
555 new TH1F("05_hEtaPrim","#eta of primary particle ", 200, -1., 1.); // 05
556 new TH1F("06_hPhiPrim","#phi of primary particle ", 63*2, 0.0,TMath::Pi()*2.); // 06
557 new TH1F("07_hThetaPrim","#theta of primary particle", 63, 0.0,TMath::Pi()); // 07
558 new TH1F("08_hPhiPrimInDegree","#phi of primary particle in degree", 120, 75.0, 195.0); // 08
559 new TH1F("09_hThetaPrimInDegree","#theta of primary particle in degree", 90, 45., 135.); // 09
560
561 // Particle vs cluster
562 new TH1F("10_hE(P)-E(RP)"," E(p) - E(RP) ", 100, -10.*sig, 10.*sig); // 10
563
564 new TH1F("11_hPvsRpAngleInDegree","angle between P and RP (in degree)", 110, 0.0, 1.0); // 11
565 double dphi=0.5; // for fitting
566 new TH1F("12_hPvsRpDPhiInDegree","dif(#phi) between P and RP (in degree)", 100, -dphi, dphi); // 12
567 new TH1F("13_hPvsRpDThetaInDegree","dif(#theta) between P and RP (in degree)", 100, -0.5, 0.5); // 13
568
569 new TH1F("14_hPvsRpDPhiInDegree","dif(#phi) between P and RP (in degree) right part of SM", 100, -dphi, +dphi); // 14
570 new TH1F("15_hPvsRpDPhiInDegree","dif(#phi) between P and RP (in degree) left part of SM", 100, -dphi, dphi); // 15
571
572 new TH1F("16_hPvsRpDThetaInDegree","dif(#theta) between P and RP (even index)", 100, -0.5, 0.5); // 16
573 new TH1F("17_hPvsRpDThetaInDegree","dif(#theta) between P and RP (odd index)", 100, -0.5, 0.5); // 17
574
575 TString st = Form("ListOfHists%s_P=%5.1f",name,p);
576 st.ReplaceAll(" ","");
577 TList *l = u::MoveHistsToList(st.Data(), kFALSE);
578 st = Form("%s_P=%5.1f",name,p);
579 st.ReplaceAll(" ","");
580 u::AddToNameAndTitleToList(l, st.Data(), st.Data());
581 return l;
582}
583
584TList *AliEMCALPi0Calibration::DefineHistsForShowerProfile(const char *name, Double_t p)
585{
586 // Aug 1, 2007 - shower profile business as in testbeam analysis
587 // Phi direction here is Y direction in testbeam
588 printf("<I> DefineHistsForShowerProfile: %s : p %f \n",
589 name, p);
590
591 gROOT->cd();
592 TH1::AddDirectory(1);
593
594 // Cell unit
595 new TH1F("00_hPHiMean"," mean in #phi direction ", 24*10, 0.0, 24.);
596 new TH1F("01_hPHiLog"," mean with log in #phi direction ", 24*10, 0.0, 24.);
597 new TH2F("02_XmeanVsXlog", "xmean vs xlog", 240,0.0, 24.,240,0.0, 24.);
598 new TH2F("03_XmeanVsXlog", "xmean vs xlog (system of cell with max energy, first half on #eta)",
599 50,-0.5,+0.5, 100,-1.,+1.);
600 new TH2F("04_XmeanVsXlog", "xmean vs xlog (system of cell with max energy, second half on #eta)",
601 50,-0.5,+0.5, 100,-1.,+1.);
602
603 new TH2F("05_PhiShowerProfile", " #phi shower profile - cumulative distribution",
604 6*25,-3.,3., 201, -0.0025, 1.0025); // 00; x direction in cell unit
605
606 TString st = Form("L%s_P=%5.1f",name,p);
607 st.ReplaceAll(" ","");
608 TList *l = u::MoveHistsToList(st.Data(), kFALSE);
609 st = Form("%s_P=%5.1f",name,p);
610 st.ReplaceAll(" ","");
611 u::AddToNameAndTitleToList(l, st.Data(), st.Data());
612
613 return l;
614}
615
616void AliEMCALPi0Calibration::FillHistsOfKineVsRP(TList *l, AliRunLoader* rl, TClonesArray &lvM)
617{
618 //
619 // lvM - array of TLorentzVector's which was cretaef from AliESDCaloCluster's
620 //
621
622 if(l==0 || rl==0) return;
623
624 // TNtuple for qucik analysis
625 static TNtuple *nt=0;
626 if(nt==0) {
627 gROOT->cd();
628 Int_t bsize = int(1.e+7);
629 nt = new TNtuple("angle","angle ntuple for quick analysis",
630 "dPhi:dTheta:phiP:thetaP", bsize);
631 gROOT->GetListOfBrowsables()->Add(nt);
632 }
633 static AliStack* st=0;
634 static TParticle *p=0;
635 static Int_t gid=0, ic=0, pdg=0, i=0;
636 gid = ic = pdg = 0;
637
638 st = rl->Stack();
639 if(st == 0) return;
640 // first primary particle
641 p = st->Particle(0);
642 if(p == 0) return;
643
644 u::FillH1(l, ic++, p->Vx());
645 u::FillH1(l, ic++, p->Vy());
646 u::FillH1(l, ic++, p->Vz());
647
648 pdg = p->GetPdgCode();
649 //gid = gMC->IdFromPDG(pdg); // gMc should be defined
650
651 u::FillH1(l, ic++, Double_t(gid));
652 u::FillH1(l, ic++, p->P());
653 u::FillH1(l, ic++, p->Eta());
654 u::FillH1(l, ic++, TVector2::Phi_0_2pi(p->Phi()) );
655 u::FillH1(l, ic++, p->Theta());
656 // In degree
657 u::FillH1(l, ic++, TVector2::Phi_0_2pi(p->Phi())*TMath::RadToDeg());
658 u::FillH1(l, ic++, p->Theta()*TMath::RadToDeg()); // 09
659
660 if(lvM.GetEntriesFast() == 0) return;
661 //
662 // Initial kinematics vs Calo clusters
663 //
664 static TLorentzVector *lv = 0, lvp;
665 lvp.SetPxPyPzE(p->Px(),p->Py(),p->Pz(),p->Energy()); // Particle
666
667 Double_t angle = 0.0, angleMin = 180.0, eDiff=0.0, dPhi=0., dTheta=0., phiP=0.0, thetaP=0.0;
668 Int_t indMin = 0;
669 phiP = lvp.Phi() * TMath::RadToDeg();
670 if (phiP<81. || phiP>99.) return; // cut phi boundaries
671 thetaP = lvp.Theta() * TMath::RadToDeg();
672 if (thetaP<56. || thetaP>89.) return; // cut theta boundaries
673
674 for(i=0; i<lvM.GetEntriesFast(); i++) {
675 lv = (TLorentzVector*)lvM.At(i);
676 angle = lv->Angle(lvp.Vect())*TMath::RadToDeg();
677 if(angleMin > angle) {
678 angleMin = angle;
679 indMin = i;
680 }
681 }
682 lv = (TLorentzVector*)lvM.At(indMin);
683 eDiff = lvp.E() - lv->E();
684 u::FillH1(l, ic++, eDiff);
685
686 dPhi = TVector2::Phi_mpi_pi(lvp.Phi()-lv->Phi())*TMath::RadToDeg();
687 dTheta = TVector2::Phi_mpi_pi(lvp.Theta()-lv->Theta())*TMath::RadToDeg();
688 u::FillH1(l, ic++, angleMin);
689 u::FillH1(l, ic++, dPhi);
690 u::FillH1(l, ic++, dTheta);
691
692 if (phiP>=81. && phiP<=90.) {
693 u::FillH1(l, 14, dPhi);
694 } else if(phiP> 90. && phiP<=99.) {
695 u::FillH1(l, 15, dPhi);
696 }
697 // Unfinished - have to get absid of digit with max energy
698 u::FillH1(l, 16, dTheta);
699 u::FillH1(l, 17, dTheta);
700 if(nt) {
701 nt->Fill(dPhi,dTheta,phiP,thetaP);
702 /*
703 tv__tree = (TTree *) gROOT->FindObject("angle");
704 tv__tree->Draw("dPhi:phiP","abs(dPhi)<0.5","", 9182, 0);
705 tv__tree->Draw("dTheta:thetaP","abs(dTheta)<0.5","", 9182, 0);
706 */
707 }
708}
709
710void AliEMCALPi0Calibration::FillHistsForShowerProfile
711(TList *l, AliEMCALRecPoint *rp, AliEMCALCellInfo * t)
712{
713 // Aug 1, 2007
714 if(l==0 || rp==0 || t==0) return;
715 // --
716 static Double_t xmean=0., xlog=0.;
717 static AliEMCALCellIndexes rMax;
718 static Int_t phiSize;
719
720 if(rp->GetPointEnergy() < 1.0) return;
721 //if(rp->GetPointEnergy() > 8.0) return; // discard merged clusters for pi0 case
722
723 EvalLocalPhiPosition(1., rp, t, xmean, phiSize, rMax);
724 if(phiSize == 0) return; // just one row in cell directions
725
726 EvalLocalPhiPosition(5.5, rp, t, xlog, phiSize, rMax);
727 if(rMax.fIPhi>1.5&&rMax.fIPhi<21.5 && rMax.fIEta>1.5&&rMax.fIEta<46.5) {
728 u::FillH1(l, 0, xmean);
729 u::FillH1(l, 1, xlog);
730 u::FillH2(l, 2, xlog, xmean);
731 // Select two central modules
732 if((rMax.fIPhim==5 || rMax.fIPhim==6)){
733 // Transition to system of cell with max energy
734 xmean -= (double(rMax.fIPhi)+0.5);
735 xlog -= (double(rMax.fIPhi)+0.5);
736 if(rMax.fIEtam>=2 && rMax.fIEtam<=12){ // approximatively first half on eta
737 u::FillH2(l, 3, xlog, xmean);
738 } else {// approximatively second half on eta
739 u::FillH2(l, 4, xlog, xmean);
740 }
741 }
742 }
743}
744
745void AliEMCALPi0Calibration::EvalLocalPhiPosition(const Double_t wlog, const AliEMCALRecPoint *rp, const AliEMCALCellInfo* t, Double_t &xcog, Int_t &phiSize, AliEMCALCellIndexes &rMax)
746{
747 // wlog = 1 - usual center of gravity; >1 - with logarithmic weight.
748 // digits - array of digits
749 // t -
750 //==
751 // xcog - position of center of gravity in cell unit
752 if(wlog<1.0 || rp==0 || t==0) return;
753 xcog = 0;
754
755 static Double_t wtot=0., w=0., edigi=0., e=0., edigiMax=0.;
756 static Int_t absid = 0, phiMin=0, phiMax=0;
757 static AliEMCALCellIndexes* r=0;
758
759 e = rp->GetPointEnergy();
760 wtot = 0.0;
761 edigiMax=0.;
762
763 phiMin = 23; phiMax = 0;
764 for(Int_t iDigit=0; iDigit<rp->GetMultiplicity(); iDigit++) {
765 absid = rp->GetAbsId()[iDigit];
766 edigi = rp->GetEnergiesList()[iDigit];
767 if(wlog > 1.0) w = TMath::Max( 0., wlog + TMath::Log(edigi/e));
768 else w = edigi; // just energy
769
770 r = t->GetTable(absid);
771 xcog += w*(Double_t(r->fIPhi) + 0.5);
772 wtot += w;
773 if(edigi > edigiMax) {
774 edigiMax = edigi;
775 rMax = (*r);
776 }
777 if(phiMin > r->fIPhi) phiMin = r->fIPhi;
778 if(phiMax < r->fIPhi) phiMax = r->fIPhi;
779 }
780 xcog /= wtot;
781 phiSize = phiMax - phiMin;
782 // printf("phiSize %i \n", phiSize);
783}
784/* unused now
785TList *AliEMCALPi0Calibration::DefineHistsOfTowers(const char *name)
786{
787 //
788 // ESD: towers information was saved to pseudo clusters
789 //
790 gROOT->cd();
791 TH1::AddDirectory(1);
792 new TH1F("00_EmcalMultiplicity", "multiplicity of EMCAL ", 201, -0.5, 200.5); // number of pseudo RP
793
794 new TH1F("01_EnergyOf", "energy of ", 1000, 0.0, 100.);
795
796 TList *l = u::MoveHistsToList(Form("ListOfHists%s",name, " - ESD"), kFALSE);
797 u::AddToNameAndTitleToList(l, name, name);
798
799 return l;
800}
801*/
802
803void AliEMCALPi0Calibration::FitEffMassHist()
804{
805 TH1* h = (TH1*)fLofHistsRP->At(8);
806 AliEMCALCell::FitHist(h, GetName(), "draw");
807}
808
809void AliEMCALPi0Calibration::PrintInfo()
810{
811 // Service routine
812 printf("\n %i Entrie(s) | Option(s) |%s| \n", GetOptsArray().GetEntries(), fRunOpts.Data());
813 for(int i=0; i<fgNanaOpt; i++) {
814 if(GetKeyOptsValue(i)) printf(" %i |%s| \n", i, fgAnaOpt[i]);
815 }
816
817 TList *l[2] = {fLofHistsPC, fLofHistsRP};
818 printf("\n");
819 for(int i=0; i<2; i++){
820 TH1F *h = (TH1F*)l[i]->At(2);
821 printf(" %s \t: %i \n", h->GetTitle(), int(h->GetEntries()));
822 }
823 printf(" fgDistEff %f fgW0 %f fgSlopePhiShift %f \n", fgDistEff, fgW0, fgSlopePhiShift);
824}
825
826void AliEMCALPi0Calibration::SetMomentum(Double_t p)
827{ // Jul 9, 2007
828 fPmom = p;
829 // SetName(Form("%s_p_%f5.1", GetName(), p));
830}
831
832
833AliEMCALFolder* AliEMCALPi0Calibration::CreateEmcalFolder(const Int_t it)
834{
835 //
836 // Create emcal folder for iteration number it
837 //
838 AliEMCALFolder* newFolder = new AliEMCALFolder(it); // folder for iteration #it
839 if(it>1) {
840 fgEMCALOld = fgEMCAL;
841 AliEMCALCalibCoefs* tabOldOut = fgEMCALOld->GetCCOut();
842 AliEMCALCalibCoefs* tabNewIn = new AliEMCALCalibCoefs(*tabOldOut);
843 tabNewIn->SetName(AliEMCALFolder::GetCCinName().Data());
844 newFolder->Add(tabNewIn);
845 }
846 fEmcalPool->Add(newFolder);
847 fgEMCAL = newFolder;
848
849 return fgEMCAL;
850}
851
852AliEMCALFolder* AliEMCALPi0Calibration::GetEmcalOldFolder(const Int_t nsm)
853{
854 // Return emcal folder with number nsm
855 AliEMCALFolder* folder=0;
856 if(fEmcalPool) folder = (AliEMCALFolder*)fEmcalPool->FindObject(Form("EMCAL_%2.2i",nsm));
857 return folder;
858}
859
860
861void AliEMCALPi0Calibration::SetEmcalFolder(AliEMCALFolder* folder)
862{
863 fgEMCAL = folder;
864 fEmcalPool->Add(fgEMCAL);
865}
866
867void AliEMCALPi0Calibration::SetEmcalOldFolder(AliEMCALFolder* folder)
868{
869 fgEMCALOld = folder;
870 fEmcalPool->Add(fgEMCALOld);
871}
872
873void AliEMCALPi0Calibration::Browse(TBrowser* b)
874{
875 // What we see at browser
876 // if(esd) b->Add(esd);
877 if(fChain) b->Add(fChain);
878 if(fEmcalPool) b->Add(fEmcalPool);
879 if(fgEmcalGeo) b->Add(fgEmcalGeo);
880 if(fCellsInfo) b->Add(fCellsInfo);
881 //
882 if(fLofHistsPC) b->Add(fLofHistsPC);
883 if(fLofHistsRP) b->Add(fLofHistsRP);
884 if(fLKineVsRP) b->Add(fLKineVsRP);
885 if(fLShowerProfile) b->Add(fLShowerProfile);
886 // if(u) b->Add(u);
887}
888
889Bool_t AliEMCALPi0Calibration::IsFolder() const
890{
891 if(fLofHistsRP || fEmcalPool) return kTRUE;
892 return kFALSE;
893}
894
895void AliEMCALPi0Calibration::Save(Int_t ver, const char *optIO)
896{
897 // Aug 3, 2007
898 // Save selector to file
899 TString dir("/home/pavlinov/ALICE/SHISHKEBAB/RF/CALIB/"); // Root directory for saving
900 TString nf=dir;
901 if(GetKeyOptsValue(kPROF)) {
902 nf += "PROF/PROFILE_";
903 nf += ver;
904 nf += ".root";
905 TFile f(nf.Data(), optIO);
906 if(f.IsOpen()) {
907 this->Write();
908 f.Close();
909 printf("<I> Save selectort to file |%s| : optIO %s \n",nf.Data(), optIO);
910 } else {
911 printf("<W> File %s exits ! Increase version : ver %i !\n", nf.Data(), ver);
912 }
913 } else {
914 printf("No PROF option -> no saving now !\n");
915 }
916}
917
918AliEMCALPi0Calibration* AliEMCALPi0Calibration::ReadSelector(const char* nf)
919{
920 // Read selector to file
921 AliEMCALPi0Calibration* selector=0;
922
923 TH1::AddDirectory(0);
924 TFile f(nf,"READ");
925 if(f.IsOpen()) {
926 TObject *o = f.Get("AliEMCALPi0Calibration");
927 if(o) selector = dynamic_cast<AliEMCALPi0Calibration *>(o);
928 }
929 // printf("<I> read selector %p : file |%s| \n", selector, nf);
930 return selector;
931}
932
933void AliEMCALPi0Calibration::ReadAllEmcalFolders()
934{
935 // Oct 14, 2007
936 if(fEmcalPool==0) {
937 fEmcalPool = new TFolder("PoolOfEMCAL","");
938 for(Int_t it=1; it<=10; it++){
939 AliEMCALFolder* fold = AliEMCALFolder::ReadFolder(Form("EMCALFOLDER_It%i_fit.root",it), "READ");
940 // AliEMCALFolder* fold = AliEMCALFolder::Read(Form("EMCALFOLDER_It%i_fit.root",it), "READ");
941 if(fold) fEmcalPool->Add(fold);
942 }
943 }
944}
945
946void AliEMCALPi0Calibration::PictVsIterNumber(const Int_t ind, const Int_t nsm)
947{
948 // Jun 27, 2007 - unfinished; which picture is the best
949 if(ind<0 || ind>5) return;
950 gROOT->cd();
951 TH1::AddDirectory(1);
952
953 Int_t itMax = 10, it=0;
954 map <int, char*> indName;
955 indName[0] = "eff.mass";
956 indName[3] = "mass of #pi_{0}";
957 indName[4] = "resolution of #pi_{0}";
958 indName[5] = "chi^{2}/ndf";
959
960 TH1F *hout = new TH1F(indName[ind], indName[ind], itMax, 0.5, double(itMax)+0.5);
961
962 TH1::AddDirectory(0);
963 Double_t content, error;
964 TList* col = (TList*)fEmcalPool->GetListOfFolders();
965 for(Int_t i=0; i<col->GetSize(); i++) { // cycle on EMCAL folders
966 AliEMCALFolder* folder = static_cast<AliEMCALFolder*>(col->At(i));
967 if(folder==0) continue;
968 it = folder->GetIterationNumber();
969
970 AliEMCALSuperModule* sm = folder->GetSuperModule(nsm);
971 if(sm==0) continue;
972
973 TList* l = sm->GetHists();
974 if(l==0) continue;
975
976 TH1F *hin = (TH1F*)l->At(ind);
977 if(hin==0) continue;
978
979 if(ind !=0 ) {
980 content = hin->GetMean();
981 error = hin->GetRMS();
982 } else {
983 sm->FitEffMassHist();
984 TF1 *f = (TF1*)hin->GetListOfFunctions()->At(0);
985 content = error = -1.;
986 if(f) {
987 // content = f->GetParameter(1);
988 //error = f->GetParameter(2);
989 content = f->GetParameter(2);
990 error = f->GetParError(2);
991 }
992 }
993
994 if(content > 0.0) {
995 hout->SetBinContent(it, content);
996 hout->SetBinError(it, error);
997 printf(" it %i content %f +/- %f \n", it, content, error);
998 }
999 }
1000
1001 u::DrawHist(hout,2);
1002 hout->SetMinimum(0.0);
1003
1004}
1005
1006TH1F* AliEMCALPi0Calibration::FitHistOfRecPointEnergy(const char *opt)
1007{
1008 // Fit hist of rec.point energy
1009 TH1::AddDirectory(0);
1010
1011 TString sopt(opt);
1012 sopt.ToUpper();
1013
1014 Int_t ind = 4, ind2 = 16;
1015 if(GetKeyOptsValue(kIDEAL)) {
1016 ind = 16; // Jul 12, 2007
1017 ind2 = 4;
1018 } else if(GetKeyOptsValue(kCORR1)) {
1019 ind = 18;
1020 ind2 = 4;
1021 }
1022 TH1F *hold = (TH1F*)fLofHistsRP->At(ind), *h=0;
1023 if(hold == 0) return 0;
1024 if(hold->GetEntries() <10.) return hold;
1025
1026 if(sopt.Contains("CLONE")) {
1027 TString newName(Form("C_%s",hold->GetName()));
1028 h = (TH1F*)hold->Clone(newName.Data());
1029 printf(" Clone hist %s -> |%s|%s| \n",hold->GetName(),h->GetName(),h->GetTitle());
1030 } else {
1031 h = hold;
1032 }
1033 TH1F* h2 = (TH1F*)fLofHistsRP->At(ind2);
1034
1035 Double_t xmax = h->GetXaxis()->GetXmax(), xmin = 0.4*xmax;;
1036 TF1 *g = u::Gausi("fRecPointE", xmin, xmax, h);
1037 g->SetLineColor(kRed);
1038 gStyle->SetOptFit(111);
1039
1040 h->Fit(g,"N","", xmin, xmax);
1041 printf(" (1) xmin %f : xmax %f \n", xmin, xmax);
1042
1043 xmin = g->GetParameter(1) - 4.*g->GetParameter(2);
1044 xmax = g->GetParameter(1) + 4.*g->GetParameter(2);
1045 h->Fit(g,"Q+","", xmin, xmax);
1046 u::DrawHist(h2,1, 1, "same",2);
1047 printf(" (2) xmin %f : xmax %f \n", xmin, xmax);
1048
1049 return h;
1050}
1051
1052TCanvas *AliEMCALPi0Calibration::Linearity(TList *l, int ifun)
1053{
1054 // Jul 10, 2007
1055 // Draw picture of EMCal linearity
1056 if(l==0) {
1057 printf("<E> AliEMCALPi0Calibration::Linearity :TList is zero ! Bye ! \n");
1058 return 0;
1059 }
1060 Double_t p[9]={0.5, 1., 3., 5., 10., 20., 30., 50., 100.}, ep[9];
1061 // see macro rHits.C ->defineSampleFraction
1062 TH1F* hErecOverEin = new TH1F("hErecOverEin","Ratio E_{rec}/E_{#gamma} vs E_{#gamma}", 101,0.5,101.5);
1063 // Fill hist
1064 TArrayD invRat(9), eInvRat(9), erec(9),derec(9), residual(9);
1065 TArrayD res(9), eres(9); // resolution
1066 Int_t np=9;
1067 for(Int_t var=0; var<9; var++){
1068 TH1F *h = (TH1F*)l->At(var);
1069 TF1 *f = (TF1*)h->GetListOfFunctions()->At(0);
1070 Double_t mean = f->GetParameter(1);
1071 Double_t emean = f->GetParError(1);
1072
1073 Int_t bin = hErecOverEin->FindBin(p[var]);
1074 hErecOverEin->SetBinContent(bin, mean/p[var]);
1075 hErecOverEin->SetBinError(bin, emean/p[var]);
1076 //
1077 invRat[var] = p[var]/mean;
1078 eInvRat[var] = emean/p[var]*invRat[var];
1079 erec[var] = mean;
1080 derec[var] = emean;
1081 // Resolution in %
1082 res[var] = 100.*f->GetParameter(2)/p[var];
1083 eres[var] = 100.*f->GetParError(2)/p[var];
1084 ep[var] = 0.0;
1085 }
1086
1087 TCanvas *c = new TCanvas("Linearity","Linearity", 20,20, 700, 500);
1088 gStyle->SetOptStat(0);
1089 if(0) { // E(rec) / E(gamma)
1090 u::DrawHist(hErecOverEin,2);
1091 hErecOverEin->SetMinimum(0.984);
1092 hErecOverEin->SetMaximum(1.001);
1093 }
1094 Int_t markerColor=1;
1095 char *fun="", *optFit="";
1096 TF1 *f = 0;
1097 if(0) {
1098 if(ifun==-5) {
1099 fun = "fun5"; optFit="R+";
1100 f = new TF1(fun,"([0]*(x-7.5)*(x-7.5))*exp([1]+[2]*x+[3]*x*x)+1.", 0.0, 100.);
1101 f->FixParameter(0, 1.95380e-05);
1102 // f->SetParameter(0, 1.95380e-05);
1103 // f->SetParameter(1, 1.0);
1104 } else if(ifun==-4) {
1105 fun = "fun4"; optFit="R+";
1106 f = new TF1(fun,"([0]*(x-7.5)*(x-7.5))*([1]+[2]*abs(x)+[3]*(x-[4])*(x-[4]))+1.", 0.0, 100.);
1107 f->FixParameter(0, 1.95380e-05);
1108 f->SetParameter(4, 50.);
1109 // f = new TF1(fun,"exp(([0]+[1]*x)*(x-[2])*(x-[3]))", 0.0, 100.);
1110 //f = new TF1(fun,"([0]+[1]*x)*(x-[2])*(x-[3])", 0.0, 100.);
1111 //f->SetParameter(0, 1.);
1112 //f->SetParameter(1, 1.);
1113
1114 // f->SetParameter(2, 5.);
1115 //f->SetParLimits(2, 3.,8.);
1116 //f->SetParameter(3, 10.);
1117 //f->SetParLimits(3, 9.,15.);
1118 //f->SetParameter(2, 2.e-4);
1119 } else if(ifun==-3) {
1120 fun = "fun3"; optFit="R+";
1121 f = new TF1(fun,"[0]+[1]*x+[2]*x*x+[3]*x*x*x", 0.0, 11.);
1122 } else if(ifun==-2) {
1123 fun = "fun2"; optFit="R+";
1124
1125 /*
1126 f = new TF1(fun,"[0]*(x-7.5)+[1]*(x-7.5)*(x-7.5)+[2]", 0.0, 10.1);
1127 f->SetParameter(0, 5.98727e-04);
1128 f->SetParameter(1, 2.12045e-04);
1129 f->SetParameter(2, 1.);
1130 */
1131 f = new TF1(fun,"[0]+[1]*x+[2]*x*x", 9.0, 100.1);
1132 } else if(ifun==-1) {
1133 fun = "fun0"; optFit="R+";
1134 f = new TF1(fun,"[0]", 0.0, 100.1);
1135 } else if(ifun>=2) {
1136 fun = Form("pol%i",ifun);
1137 optFit="+";
1138 }
1139 TGraphErrors *gr = u::DrawGraphErrors(np, erec.GetArray(),invRat.GetArray(),derec.GetArray(),eInvRat.GetArray(),
1140 // markerColor,21+markerColor,"AP", " Ratio E_{#gamma}/E_{Rec} ", "E_{Rec} "," E_{#gamma}/E_{Rec}",
1141 markerColor,21+markerColor,"AP", " Ratio E_{#gamma}/E_{Rec}^{corr} ", "E_{Rec}^{corr} "," E_{#gamma}/E_{Rec}^{corr}",
1142 ifun, optFit, fun);
1143 gr->GetHistogram()->SetAxisRange(0.0,100.);
1144 // double xmi=0.999, xma=1.017;
1145 double xmi=0.995, xma=1.005;
1146 gr->GetHistogram()->SetMaximum(xma);
1147 gr->GetHistogram()->SetMinimum(xmi);
1148 gr->GetHistogram()->SetTitleOffset(1.4,"y");
1149 if(ifun==0) {
1150 f = new TF1("fres", "AliEMCALHistoUtilities::EnergyCorrectionForGamma1(x)", 0., 101.);
1151 f->Draw("same");
1152 }
1153 }
1154 TLine *line = new TLine(0.0,1.0, 100.,1.0);
1155 line->Draw();
1156
1157 if(0) {
1158 c->Clear();
1159 for(int i=0; i<9; i++) {
1160 residual[i] = 100.*(invRat[i] - u::GetCorrectionCoefficientForGamma1(erec[i])); // in percent
1161 printf(" erec %f : residual %5.3f \n", erec[i], residual[i]);
1162 }
1163 markerColor = 2;
1164 TGraphErrors *gr2=u::DrawGraphErrors(np, erec.GetArray(),residual.GetArray(),derec.GetArray(),eInvRat.GetArray(),
1165 markerColor,21+markerColor,"AP"," residual in %, rec.point level", "E_{Rec} "," residual in %",
1166 -1, "", 0);
1167 gr2->GetHistogram()->SetAxisRange(0.0,100.);
1168 gr2->GetHistogram()->SetMaximum(0.2);
1169 gr2->GetHistogram()->SetMinimum(-0.1);
1170 line = new TLine(0.0,0.0, 101.,0.0);
1171 line->Draw();
1172 TLatex *lat = u::Lat("linearity better 0.2% after correction",20., 0.15, 12, 0.06, 1);
abad76ae 1173 //if(lat); //For what is this?, commented due to compilation warnings
6e6f8407 1174 }
1175 if(1) {
1176 TString latexName;
1177 c->Clear();
1178 gStyle->SetOptFit(111);
1179 markerColor = 1;
1180 ifun = -11;
1181 f = u::GetResolutionFunction("FRES2", latexName);
1182 f->SetNpx(10000);
1183 f->SetLineColor(kBlack);
1184
1185 TGraphErrors *gr3=u::DrawGraphErrors(np, p,res.GetArray(), ep, eres.GetArray(),
1186 markerColor,21+markerColor,"AP"," resolution in %, rec.point level","E_{#gamma} "," resolution in %",
1187 ifun, "+", f->GetName());
1188 gr3->GetHistogram()->SetAxisRange(0.0,101.);
1189 gr3->GetHistogram()->SetMaximum(14.);
1190 gr3->GetHistogram()->SetMinimum(0.0);
1191 gr3->SetMarkerSize(1.5);
1192
1193 TLatex *lat = u::Lat(latexName.Data(),82., 11., 12, 0.06, 1);
abad76ae 1194 if(lat); //For what is this?, commented due to compilation warnings
6e6f8407 1195 // Exp. data
1196 TF1 *fexp = new TF1(*f);
1197 fexp->SetName("fexp");
1198 fexp->SetParameter(0, 2.168);
1199 fexp->SetParameter(1, 8.818);
1200 fexp->SetLineWidth(1);
1201 fexp->SetLineColor(kRed);
1202 fexp->SetLineStyle(1);
1203 fexp->Draw("same");
1204
1205 TLegend *leg = new TLegend(0.21,0.36, 0.68,0.82);
1206 leg->AddEntry(gr3, "MC data", "P");
1207 leg->AddEntry(f, "fit of MC data", "L");
1208 TLegendEntry *ent3 = leg->AddEntry(fexp, "#splitline{fit of exp.data}{FNAL, Nov 2005}", "L");
1209 ent3->SetTextColor(fexp->GetLineColor());
1210 leg->Draw();
1211 }
1212 c->Update();
1213
1214 return c;
1215}
1216
1217TCanvas *AliEMCALPi0Calibration::DrawKineVsRP(TList *l)
1218{
1219 //Jul 25, 2007
1220 if(l==0) {
1221 printf("<W> AliEMCALPi0Calibration::DrawKineVsRP : TList is zero ! \n");
1222 return 0;
1223 }
1224 TCanvas *c = new TCanvas("KineVsRP","KineVsRP", 20,20, 700, 500);
1225 gStyle->SetOptStat(1110);
1226 c->Divide(2,2);
1227
1228 c->cd(1);
1229 TH1F* h1 = (TH1F*)l->At(10);
1230 u::DrawHist(h1,2);
1231
1232 c->cd(2);
1233 TH1F* h2 = (TH1F*)l->At(11);
1234 u::DrawHist(h2,2);
1235
1236 c->cd(3);
1237 TH1F* h3 = (TH1F*)l->At(12);
1238 u::DrawHist(h3,2);
1239 u::DrawHist((TH1F*)l->At(14), 1,kRed,"same");
1240 u::DrawHist((TH1F*)l->At(15), 1,kGreen,"same");
1241
1242 c->cd(4);
1243 TH1F* h4 = (TH1F*)l->At(13);
1244 u::DrawHist(h4, 2);
1245 u::DrawHist((TH1F*)l->At(16), 1,kRed,"same");
1246 u::DrawHist((TH1F*)l->At(17), 1,kGreen,"same");
1247
1248 /*
1249 TH1F* h2 = (TH1F*)l->At(11);
1250 u::DrawHist(h2,2);
1251 */
1252
1253 c->Update();
1254 return c;
1255}
1256
1257TCanvas* AliEMCALPi0Calibration::DrawMeanVsLog(TH2F *h2)
1258{
1259 // h - input histogramm : mean vds log coordinates
1260 if(h2==0) return 0;
1261
1262 TCanvas *c = new TCanvas("KineVsRP","KineVsRP", 20,20, 700, 500);
1263
1264 TH1F *hid1 = new TH1F("h1","h1 title ", h2->GetNbinsX(),
1265 h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax());
1266
1267 gROOT->cd();
1268 TH1::AddDirectory(1);
1269 TString newName;
1270 for(int ix=1; ix<=h2->GetNbinsX();ix++) {
1271 newName = "hd_"; newName += ix;
1272 TH1D *hd = h2->ProjectionY(newName.Data(),ix,ix);
1273 if(hd->Integral()>=4.) {
1274 // lhd->Add(hd);
1275 hid1->SetBinContent(ix, hd->GetMean());
1276 hid1->SetBinError(ix, hd->GetRMS());
1277 }
1278 }
1279 TF1 *f1 = new TF1("fcg", "0.5*TMath::SinH(x/[0])/TMath::SinH(0.5/[0])", -0.5, 0.5);
1280 f1->SetParameter(0,0.13);
1281 f1->SetLineColor(kRed);
1282 f1->SetLineWidth(1);
1283
1284 gStyle->SetOptStat(0);
1285 gStyle->SetOptFit(111);
1286 hid1->Fit(f1,"R+");
1287
1288 u::DrawHist(hid1,2);
1289
1290//u::DrawHist(h2,2);
1291
1292 c->Update();
1293 return c;
1294}
1295
1296TCanvas* AliEMCALPi0Calibration::DrawPhiEtaAnglesDistribution(const char* gn)
1297{
1298 // Aug 6, 2007
1299 // Proper geometry should be defined already
1300 // dTheta distibution has two peaks which coresponding different cells inside module !
1301
1302 TCanvas *c = new TCanvas("Geometry","Geometry", 20,20, 700, 500);
1303 c->Divide(2,2);
1304
1305 if(fgEmcalGeo==0) fgEmcalGeo = AliEMCALGeometry::GetInstance(gn);
1306
1307 gROOT->cd();
1308 TH1::AddDirectory(1);
1309 TH1F *hDtheta = new TH1F("hDtheta","#Delta#theta in one SM", 60, -2.0, +1.0); // in degree
1310 TH2F *hDtheta2 = new TH2F("hDtheta2","#Delta#theta vs fIEta of cell", 48, -0.5, 47.5, 60,-2.0,+1.0);
1311
1312 TH1F *hDphi = new TH1F("hDphi","#Delta#ph in one SM", 2000, -10.0, +10.0); // in degree
1313
1314 TVector3 vg3;
1315 AliEMCALCellInfo* t = GetCellsInfo();
1316 Double_t thetaCell=0., thetaModule=0.;
1317 Double_t phiCell=0., dphi=0.;
1318
1319 for(int absid=0; absid<12*24*4; absid++){
1320 AliEMCALCellIndexes *r = t->GetTable(absid);
1321 fgEmcalGeo->GetGlobal(absid, vg3);
1322
1323 thetaCell = vg3.Theta()*TMath::RadToDeg();
1324 thetaModule = 90. - 1.5*r->fIEtam;
1325 hDtheta->Fill(thetaCell - thetaModule);
1326 hDtheta2->Fill(double(r->fIEta), thetaCell - thetaModule);
1327
1328 phiCell = vg3.Phi()*TMath::RadToDeg();
1329 dphi = phiCell - 90.;
1330 hDphi->Fill(dphi);
1331 }
1332
1333 c->cd(1);
1334 u::DrawHist(hDtheta,2);
1335 c->cd(2);
1336 u::DrawHist(hDtheta2,2);
1337 c->cd(3);
1338 u::DrawHist(hDphi,2);
1339
1340 c->Update();
1341 return c;
1342}
1343
1344TCanvas* AliEMCALPi0Calibration::DrawDeffVsEnergy()
1345{
1346 // Aug 31, 2007 - obsolete
1347 Double_t p[]={0.5, 1.0, 3., 5., 10., 20.,30.,50.,100.};
1348 Double_t ep[]={0., 0., 0., 0., 0., 0., 0., 0., 0.};
1349 // 2 pars
1350 Double_t deff[]={9.07515, 10.0835, 11.2032, 11.4229, 12.3578, 13.0332, 13.3281, 13.7910, 14.3319};
1351 Double_t edeff[]={2.69645e-03, 3.52180e-03, 4.19236e-02, 1.21201e-01, 1.58886e-01, 3.96680e-01, 3.29985e-02, 1.17113e-01, 5.22763e-01};
1352 //
1353 Double_t w0[]={3.44679e+00, 3.82714e+00, 4.15035e+0, 4.36650e+00, 4.51511e+00, 4.65590, 4.63289e+00, 4.66568, 4.68125};
1354 Double_t ew0[]={7.58982e-01, 1.26420e-02, 2.36129e-10, 1.21201e-01, 2.12999e-01, 7.95650e-02, 6.15307e-03, 1.88803e-01, 5.18022e-05};
1355 int np=sizeof(p)/sizeof(Double_t);
1356 printf("<I> AliEMCALPi0Calibration::DrawDeffVsEnergy() | np %i \n", np);
1357
1358 TCanvas *c = new TCanvas("Deff","Deff", 20,20, 700, 500);
1359 c->Divide(2,1);
1360
1361 Int_t markerColor=1;
1362 c->cd(1);
1363 TF1 *fdeff= new TF1("fdeff","[0]+[1]*log(x)",0.4, 100.4);
abad76ae 1364 if(fdeff); //For what is this?, commented due to compilation warnings
6e6f8407 1365 TGraphErrors *gr = u::DrawGraphErrors(np, p,deff, ep, edeff,
1366 markerColor,21+markerColor,"AP"," D_{eff} vs E_{#gamma} ","E_{#gamma} "," D_{eff} in cm ",
1367 -1, "", 0);
1368 // -1, "+", fdeff->GetName());
1369 gr->GetHistogram()->SetMaximum(15.);
1370 gPad->SetLogx(1);
1371
1372 c->cd(2);
1373 TGraphErrors *gr2 = u::DrawGraphErrors(np, p,w0, ep, ew0,
1374 markerColor,21+markerColor,"AP"," w_{0} vs E_{#gamma} ","E_{#gamma} "," w_{0} ",
1375 -1, "", 0);
1376
1377 gr2->GetHistogram()->SetMaximum(5.);
1378 gPad->SetLogx(1);
1379
1380 c->Update();
1381 return c;
1382}
1383
1384TCanvas* AliEMCALPi0Calibration::DrawDeffVsEnergy2(const char *opt)
1385{
1386 // Aug 28, 2008 - read pars and pars errors from files
1387 Double_t p[]={0.5, 1.0, 3., 5., 10., 20.,30.,50.,100.};
1388 Double_t ep[]={0., 0., 0., 0., 0., 0., 0., 0., 0.};
1389 // 2 pars
1390 Double_t deff[9], edeff[9], w0[9], ew0[9]; // max size now
1391 TString sopt(opt);
1392
1393 int np = sizeof(p)/sizeof(Double_t);
1394 printf("<I> AliEMCALPi0Calibration::DrawDeffVsEnergy2() | np %i \n", np);
1395 ReadParsDeffAndW0("/data/r22b/ALICE/CALIB/FIT/", deff, edeff, w0, ew0, 1);
1396
1397 TCanvas *c = new TCanvas("Deff","Deff", 20,20, 700, 500);
1398 c->Divide(2,1);
1399
1400 TF1 *fdeff = 0, *fw0 = 0;
1401 TString optFit(""), funName("");
1402 if(sopt.Contains("fit1")) {
1403 fdeff= new TF1("fdeff","[0]+[1]*log(x)",0.1, 101.);
1404 fdeff->SetLineColor(kRed);
1405 fdeff->SetLineWidth(1);
1406
1407 /* good description - "[0]/(1.+exp([1]*x))"
1408 1 p0 4.82208e+00 9.93617e-04 -0.00000e+00 7.16648e-06
1409 2 p1 -7.79655e-01 4.07500e-03 -0.00000e+00 2.01009e-03
1410 better description - "[0]/(1.+exp([1]*(x-[2])))" (like the Woods-Saxon potential)
1411 1 p0 4.83713e+00 1.00437e-03 -6.98984e-10 4.90371e-07
1412 2 p1 -2.77970e-01 3.35587e-03 -1.79239e-09 2.67312e-07
1413 3 p2 4.41116e+00 8.72191e-02 1.82791e-04 1.55643e-05
1414 */
1415 fw0= new TF1("fw0","[0]/(1.+exp([1]*(x+[2])))",0.1, 101.);
1416 fw0->SetLineColor(kRed);
1417 fw0->SetLineWidth(1);
1418 fw0->SetParameter(0, 4.8);
1419 fw0->SetParameter(1, -2.77970e-01);
1420 fw0->SetParameter(2, 4.41116);
1421 optFit = "+";
1422 }
1423 if(fdeff) funName = fdeff->GetName();
1424
1425 Int_t markerColor=1;
1426 c->cd(1);
1427 gStyle->SetOptFit(111);
1428 TGraphErrors *gr = u::DrawGraphErrors(np, p,deff, ep, edeff,
1429 markerColor,21+markerColor,"AP"," D_{eff} vs E_{#gamma} ","E_{#gamma} "," D_{eff} in cm ",
1430 -1, optFit.Data(), funName.Data());
1431 gr->GetHistogram()->SetMaximum(15.);
1432 gPad->SetLogx(1);
1433 TLegend *leg1 = new TLegend(0.12,0.76, 0.70,0.90);
1434 TLegendEntry *le1 = leg1->AddEntry(fdeff, Form("%s",fdeff->GetTitle()), "lp");
1435 //TLegendEntry *le1 = leg1->AddEntry(fdeff, Form("%4.2f+%4.2f*log(E_{#gamma})",
1436 //fdeff->GetParameter(0),fdeff->GetParameter(1)), "lp");
1437 le1->SetTextColor(fdeff->GetLineColor());
1438 leg1->Draw();
1439
1440 c->cd(2);
1441 gStyle->SetOptFit(111);
1442 if(fw0) funName = fw0->GetName();
1443 TGraphErrors *gr2 = u::DrawGraphErrors(np, p,w0, ep, ew0,
1444 markerColor,21+markerColor,"AP"," w_{0} vs E_{#gamma} ","E_{#gamma} "," w_{0} ",
1445 -1, optFit.Data(), funName.Data());
1446
1447 gr2->GetHistogram()->SetMaximum(5.);
1448
1449 TLegend *leg2 = new TLegend(0.17,0.6, 0.99,0.72);
1450 TLegendEntry *le2 = leg2->AddEntry(fw0, Form("%s",fw0->GetTitle()), "lp");
1451 //TLegendEntry *le2 = leg2->AddEntry(fw0, Form("#frac{%4.2f}{1.+exp(%4.2f*(x+%4.2f)}",
1452 //fw0->GetParameter(0),fw0->GetParameter(1),fw0->GetParameter(2)), "lp");
1453 le2->SetTextColor(fw0->GetLineColor());
1454 leg2->Draw();
1455 //gPad->SetLogx(1);
1456
1457 c->Update();
1458 return c;
1459}
1460
1461void AliEMCALPi0Calibration::ReadParsDeffAndW0
1462(const char *dirName, double *deff, double *edeff, double *w0, double *ew0, const Int_t pri)
1463{
1464 // read pars and W0
1465 int strategy = 0, itmp=0;
1466 char line[100];
1467 for(int var=11; var<=19; var++){
1468 int ind = var -11;
1469 ifstream fin;
1470 TString fname = Form("%s/fitVar%iStrategy%i.txt", dirName, var, strategy);
1471 //printf(" open file %s \n", fname.Data());
1472 fin.open(fname.Data());
1473
1474 for(int i=1; i<=2; i++) { // skip to lines
1475 fin.getline(line,100).eof();
1476 if(pri>=2) printf("%s \n", line);
1477 }
1478
1479 fin >> itmp >> deff[ind] >> edeff[ind];
1480 fin >> itmp >> w0[ind] >> ew0[ind];
1481 if(pri>=1)
1482 printf(" %i def %f+/-%f : def %f+/-%f\n", ind, deff[ind],edeff[ind],w0[ind],ew0[ind]);
1483 fin.getline(line,100).eof(); // skip last line
1484 fin.close();
1485 }
1486}
1487
1488TCanvas* AliEMCALPi0Calibration::DrawSpaceResolution()
1489{
1490 // Sep 4, 2007;
1491 // Space resolution vs optimised space resolution
1492 Double_t p[]={0.5, 1.0, 3., 5., 10., 20.,30.,50.,100.};
1493 Double_t ep[]={0., 0., 0., 0., 0., 0., 0., 0., 0.};
1494 Double_t spAng[]={0.1877, 0.1351, 0.08144, 0.06331, 0.05384, 0.04876, 0.04706, 0.04656, 0.04726};
1495 Double_t rmsSpAng[]={0.1033, 0.07685, 0.05235, 0.03992, 0.04012, 0.04257, 0.03472, 0.02814, 0.02784};
1496 Double_t spAngOpt[]={0.1733, 0.1311, 0.07961, 0.06401, 0.05347, 0.04618, 0.04288, 0.04, 0.03802};
1497 Double_t rmsSpAngOpt[]={0.09476, 0.07472, 0.05011, 0.04242, 0.04075, 0.04304, 0.03545, 0.02744, 0.02593};
1498
1499 int np=sizeof(p)/sizeof(Double_t);
1500 printf("<I> AliEMCALPi0Calibration::DrawSpaceResolution() | np %i \n", np);
1501
1502 Double_t* eSpAng = new Double_t[np];
1503 Double_t* eSpAngOpt = new Double_t[np];
1504 Double_t cc=TMath::Sqrt(8000.), cc2 = 1000.*TMath::DegToRad();
1505 for(int i=0; i<np; i++){
1506 spAng[i] *= cc2;
1507 rmsSpAng[i] *= cc2;
1508 spAngOpt[i] *= cc2;
1509 rmsSpAngOpt[i] *= cc2;
1510
1511 eSpAng[i] = spAng[i]/cc;
1512 eSpAngOpt[i] = spAngOpt[i]/cc;
1513 }
1514
1515 TCanvas *c = new TCanvas("Deff","Deff", 20,20, 700, 500);
1516 //c->Divide(2,1);
1517
1518 c->cd(1);
1519 gStyle->SetOptFit(111);
1520
1521 TGraphErrors *gr = u::DrawGraphErrors(np, p,spAng, ep, eSpAng,
1522 kBlack, 21,"AP","Angle resolution (mrad) vs E_{#gamma} ","E_{#gamma} "," anlgle resolution (mrad) ",
1523 -1, "", 0);
1524 gr->GetHistogram()->SetMaximum(4.);
1525 gr->GetHistogram()->SetMinimum(0.6);
1526 gPad->SetLogx(1);
1527 gPad->SetLogy(1);
1528
1529 TF1 *fang = new TF1("fang","[0]+[1]/sqrt(x)",0.1, 101.);
1530 fang->SetLineColor(kRed);
1531 fang->SetLineWidth(1);
1532
1533 TGraphErrors *gr2 = u::DrawGraphErrors(np, p,spAngOpt, ep, eSpAngOpt,
1534 kRed,22,"P"," space vs E_{#gamma} ","E_{#gamma} "," anlgle resolution (mrad) ",
1535 -1, "+", fang->GetName());
1536 TLegend *leg1 = new TLegend(0.40,0.57, 0.92,0.87);
1537 TLegendEntry *le1 = leg1->AddEntry(gr, "Initial angle resolution", "p");
1538 le1->SetTextColor(gr->GetLineColor());
1539
1540 TLegendEntry *le2 = leg1->AddEntry(gr2, "Optimized angle resolution", "p");
1541 le2->SetTextColor(gr2->GetLineColor());
1542
1543 TLegendEntry *le3 = leg1->AddEntry(fang,
1544 Form("%3.2f+#frac{%4.2f}{#sqrt{E}}",fang->GetParameter(0),fang->GetParameter(1)), "lp");
1545 le3->SetTextColor(fang->GetLineColor());
1546
1547 leg1->Draw();
1548
1549 c->Update();
1550
1551 return c;
1552}
1553
1554void AliEMCALPi0Calibration::ResetAllListOfHists()
1555{
1556 // Reset all list of hits
1557 u::ResetListOfHists(fLofHistsPC);
1558 u::ResetListOfHists(fLofHistsRP);
1559 u::ResetListOfHists(fLKineVsRP);
1560 u::ResetListOfHists(fLShowerProfile);
1561}
1562
1563void AliEMCALPi0Calibration::ReloadChain(Long64_t entry)
1564{
1565 // Oct 14, 2007 - unused now
1566 if(fChain) {
1567 fChain->LoadTree(entry);
1568 }
1569}
1570
1571void AliEMCALPi0Calibration::GetInitialParsForFit(const Int_t var, Double_t &deff, Double_t &w0, Double_t &phislope, const int phiCase)
1572{
1573 // int phiCase=0; // 0 or 1
1574 phislope = 0.001;
1575 if(var==11) { // stay here
1576 deff = 9.07515;
1577 w0 = 3.44679;
1578 } else if(var==12) {
1579 deff = 1.00835e+01;
1580 w0 = 3.82714e+00;
1581 } else if(var==13) {
1582 deff = 1.12032e+01;
1583 w0 = 4.15035e+00;
1584 } else if(var==14) {
1585 deff = 1.14229e+01;
1586 w0 = 4.36650;
1587 } else if(var==15) {
1588 deff = 1.21361e+01;
1589 w0 = 4.72875;
1590 } else if(var==16) {
1591 deff = 1.28096e+01;
1592 w0 = 4.81753e+00;
1593 } else if(var==17) {
1594 deff = 1.33281e+01;
1595 w0 = 4.63289e+00;
1596 } else if(var==18) {
1597 deff = 1.37910e+01;
1598 w0 = 4.66568;
1599 } else if(var==19) {// Aug 15, 2007
1600 switch (phiCase) {
1601 case 0: // phislope was defined than deff and w0 were fixed
1602 deff = 1.43319e+01;
1603 w0 = 4.69279;
1604 phislope = 2.41419e-04;
1605 break;
1606 case 1: // all parameters free
1607 deff = 1.46327e+01;
1608 w0 = 4.68125;
1609 phislope = 8.95559e-04;
1610 break;
1611 }
1612 } else {
1613 printf("<E> var % i -> no definition ! \n", var);
1614 assert(0);
1615 }
1616 printf("<I> AliEMCALPi0Calibration::GetInitialParForFit()\n deff %f w0 %f phislope %f \n",
1617 deff,w0, phislope);
1618}