]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/totEt/AliAnalysisHadEtCorrections.cxx
Transition PWG4/JetTasks -> PWGJE and PWG4/totET -> PWGLF/totET
[u/mrichter/AliRoot.git] / PWGLF / totEt / AliAnalysisHadEtCorrections.cxx
1 //Created by Christine Nattrass, Rebecca Scott, Irakli Martashvili
2 //University of Tennessee at Knoxville
3 // This is a container class for the correction factors for the hadronic 
4 // component of transverse energy
5 // It is filled by the output of AliAnalysisTaskHadEt from spinning over Monte 
6 // Carlo data (using AliAnalysisHadEtMonteCarlo)
7 //It is used by AliAnalysisTaskHadEt while spinning over reconstructed data 
8 // (using AliAnalysisHadEtReconstructed)
9 //Please see https://twiki.cern.ch/twiki/bin/view/ALICE/ETCaloAnalysis
10 #include "AliAnalysisHadEtCorrections.h"
11 #include "TMath.h"
12 #include <iostream>
13 #include "Rtypes.h"
14 #include "TObjArray.h"
15 #include "AliLog.h"
16 #include "TH1D.h"
17
18 using namespace std;
19
20 ClassImp(AliAnalysisHadEtCorrections);
21
22
23 AliAnalysisHadEtCorrections::AliAnalysisHadEtCorrections() : TNamed(),
24                                                              fEtaCut(0)
25                                                            ,fAcceptanceCorrectionFull(0)
26                                                            ,fAcceptanceCorrectionEMCAL(0)
27                                                            ,fAcceptanceCorrectionPHOS(0)
28                                                            ,fNeutralCorrection(0)
29                                                            ,fNotHadronicCorrection(0)
30                                                            ,fpTcutCorrectionTPC(0)
31                                                            ,fpTcutCorrectionITS(0)
32                                                            ,fNotIDConstTPC(0)
33                                                            ,fNotIDConstITS(0)
34                                                            ,fNotIDConstTPCNoID(0)
35                                                            ,fNotIDConstITSNoID(0)
36                                                            ,fNeutralCorrectionLow(0)
37                                                            ,fNotHadronicCorrectionLow(0)
38                                                            ,ffpTcutCorrectionTPCLow(0)
39                                                            ,ffpTcutCorrectionITSLow(0)
40                                                            ,fNeutralCorrectionHigh(0)
41                                                            ,fNotHadronicCorrectionHigh(0)
42                                                            ,ffpTcutCorrectionTPCHigh(0)
43                                                            ,ffpTcutCorrectionITSHigh(0)
44                                                            ,fNotIDConstTPCLow(0)
45                                                            ,fNotIDConstITSLow(0)
46                                                            ,fNotIDConstTPCNoIDLow(0)
47                                                            ,fNotIDConstITSNoIDLow(0)
48                                                            ,fNotIDConstTPCHigh(0)
49                                                            ,fNotIDConstITSHigh(0)
50                                                            ,fNotIDConstTPCNoIDHigh(0)
51                                                            ,fNotIDConstITSNoIDHigh(0)
52                                                            ,fnotIDTPC(0)
53                                                            ,fnotIDITS(0)
54                                                            ,fnotIDNoID(0)
55                                                            ,fEfficiencyPionTPC(0)
56                                                            ,fEfficiencyKaonTPC(0)
57                                                            ,fEfficiencyProtonTPC(0)
58                                                            ,fEfficiencyHadronTPC(0)
59                                                            ,fEfficiencyPionITS(0)
60                                                            ,fEfficiencyKaonITS(0)
61                                                            ,fEfficiencyProtonITS(0)
62                                                            ,fEfficiencyHadronITS(0)
63                                                            ,fEfficiencyTPC(0)
64                                                            ,fEfficiencyITS(0)
65                                                            ,fEfficiencyErrorLow(0)
66                                                            ,fEfficiencyErrorHigh(0)
67                                                            ,fBackgroundErrorLow(0)
68                                                            ,fBackgroundErrorHigh(0)
69                                                            ,fBackgroundTPC(0)
70                                                            ,fBackgroundITS(0)
71                                                            ,fIsEMCal(kTRUE)
72                                                            ,fIsData(kFALSE)
73                                                            ,fDataSet(2009)
74                                                            ,fProduction("ProductionName")
75                                                            ,fProductionDescription("Long production description")
76 {//default constructor
77   Init();
78 }
79 void AliAnalysisHadEtCorrections::Init() 
80 {  //This seems to solve a compiler error
81    cout<<"Creating new AliAnalysisHadEtCorrections"<<endl;
82    fEfficiencyTPC = new TObjArray();
83    fEfficiencyITS = new TObjArray();
84 }
85
86 AliAnalysisHadEtCorrections::~AliAnalysisHadEtCorrections()
87 {//destructor
88   //Clear();
89     fnotIDTPC->Clear();
90     fnotIDITS->Clear();
91     fnotIDNoID->Clear();
92     fEfficiencyPionTPC->Clear();
93     fEfficiencyKaonTPC->Clear();
94     fEfficiencyProtonTPC->Clear();
95     fEfficiencyHadronTPC->Clear();
96     fEfficiencyPionITS->Clear();
97     fEfficiencyKaonITS->Clear();
98     fEfficiencyProtonITS->Clear();
99     fEfficiencyHadronITS->Clear();
100     fBackgroundTPC->Clear();
101     fBackgroundITS->Clear();
102     delete fnotIDTPC;
103     delete fnotIDITS;
104     delete fnotIDNoID;
105     delete fEfficiencyPionTPC;
106     delete fEfficiencyKaonTPC;
107     delete fEfficiencyProtonTPC;
108     delete fEfficiencyHadronTPC;
109     delete fEfficiencyPionITS;
110     delete fEfficiencyKaonITS;
111     delete fEfficiencyProtonITS;
112     delete fEfficiencyHadronITS;
113     delete fEfficiencyTPC;
114     delete fEfficiencyITS;
115     delete fBackgroundTPC;
116     delete fBackgroundITS;
117 }
118 AliAnalysisHadEtCorrections::AliAnalysisHadEtCorrections(const AliAnalysisHadEtCorrections *g): TNamed(),
119                                                                                                 fEtaCut(g->fEtaCut)
120                                                                                               ,fAcceptanceCorrectionFull(g->fAcceptanceCorrectionFull)
121                                                                                               ,fAcceptanceCorrectionEMCAL(g->fAcceptanceCorrectionEMCAL)
122                                                                                               ,fAcceptanceCorrectionPHOS(g->fAcceptanceCorrectionPHOS)
123                                                                                               ,fNeutralCorrection(g->fNeutralCorrection)
124                                                                                               ,fNotHadronicCorrection(g->fNotHadronicCorrection)
125                                                                                               ,fpTcutCorrectionTPC(g->fpTcutCorrectionTPC)
126                                                                                               ,fpTcutCorrectionITS(g->fpTcutCorrectionITS)
127                                                                                               ,fNotIDConstTPC(g->fNotIDConstTPC)
128                                                                                               ,fNotIDConstITS(g->fNotIDConstITS)
129                                                                                               ,fNotIDConstTPCNoID(g->fNotIDConstTPCNoID)
130                                                                                               ,fNotIDConstITSNoID(g->fNotIDConstITSNoID)
131                                                                                               ,fNeutralCorrectionLow(g->fNeutralCorrectionLow)
132                                                                                               ,fNotHadronicCorrectionLow(g->fNotHadronicCorrectionLow)
133                                                                                               ,ffpTcutCorrectionTPCLow(g->ffpTcutCorrectionTPCLow)
134                                                                                               ,ffpTcutCorrectionITSLow(g->ffpTcutCorrectionITSLow)
135                                                                                               ,fNeutralCorrectionHigh(g->fNeutralCorrectionHigh)
136                                                                                               ,fNotHadronicCorrectionHigh(g->fNotHadronicCorrectionHigh)
137                                                                                               ,ffpTcutCorrectionTPCHigh(g->ffpTcutCorrectionTPCHigh)
138                                                                                               ,ffpTcutCorrectionITSHigh(g->ffpTcutCorrectionITSHigh)
139                                                                                               ,fNotIDConstTPCLow(g->fNotIDConstTPCLow)
140                                                                                               ,fNotIDConstITSLow(g->fNotIDConstITSLow)
141                                                                                               ,fNotIDConstTPCNoIDLow(g->fNotIDConstTPCNoIDLow)
142                                                                                               ,fNotIDConstITSNoIDLow(g->fNotIDConstITSNoIDLow)
143                                                                                               ,fNotIDConstTPCHigh(g->fNotIDConstTPCHigh)
144                                                                                               ,fNotIDConstITSHigh(g->fNotIDConstITSHigh)
145                                                                                               ,fNotIDConstTPCNoIDHigh(g->fNotIDConstTPCNoIDHigh)
146                                                                                               ,fNotIDConstITSNoIDHigh(g->fNotIDConstITSNoIDHigh)
147                                                                                               ,fnotIDTPC(0)
148                                                                                               ,fnotIDITS(0)
149                                                                                               ,fnotIDNoID(0)
150                                                                                               ,fEfficiencyPionTPC(0)
151                                                                                               ,fEfficiencyKaonTPC(0)
152                                                                                               ,fEfficiencyProtonTPC(0)
153                                                                                               ,fEfficiencyHadronTPC(0)
154                                                                                               ,fEfficiencyPionITS(0)
155                                                                                               ,fEfficiencyKaonITS(0)
156                                                                                               ,fEfficiencyProtonITS(0)
157                                                                                               ,fEfficiencyHadronITS(0)
158                                                                                               ,fEfficiencyTPC(0)
159                                                                                               ,fEfficiencyITS(0)
160                                                                                               ,fEfficiencyErrorLow(g->fEfficiencyErrorLow)
161                                                                                               ,fEfficiencyErrorHigh(g->fEfficiencyErrorHigh)
162                                                                                               ,fBackgroundErrorLow(g->fBackgroundErrorLow)
163                                                                                               ,fBackgroundErrorHigh(g->fBackgroundErrorHigh)
164                                                                                               ,fBackgroundTPC(0)
165                                                                                               ,fBackgroundITS(0)
166                                                                                               ,fIsEMCal(g->fIsEMCal)
167                                                                                               ,fIsData(g->fIsData)
168                                                                                               ,fDataSet(g->fDataSet)
169                                                                                               ,fProduction(g->fProduction)
170                                                                                               ,fProductionDescription(g->fProductionDescription)
171 {//copy constructor
172   //SetName(g->GetName());
173   fnotIDTPC = new TH1D(*(g->fnotIDTPC));
174   fnotIDITS = new TH1D(*(g->fnotIDITS));
175   fnotIDNoID = new TH1D(*(g->fnotIDNoID));
176   fEfficiencyPionTPC = new TH1D(*(g->fEfficiencyPionTPC));
177   fEfficiencyKaonTPC = new TH1D(*(g->fEfficiencyKaonTPC));
178   fEfficiencyProtonTPC = new TH1D(*(g->fEfficiencyProtonTPC));
179   fEfficiencyHadronTPC = new TH1D(*(g->fEfficiencyHadronTPC));
180   fEfficiencyPionITS = new TH1D(*(g->fEfficiencyPionITS));
181   fEfficiencyKaonITS = new TH1D(*(g->fEfficiencyKaonITS));
182   fEfficiencyProtonITS = new TH1D(*(g->fEfficiencyProtonITS));
183   fEfficiencyHadronITS = new TH1D(*(g->fEfficiencyHadronITS));
184   fEfficiencyTPC = new TObjArray(*(g->fEfficiencyTPC));
185   fEfficiencyITS = new TObjArray(*(g->fEfficiencyITS));
186   fBackgroundTPC = new TH1D(*(g->fBackgroundTPC));
187   fBackgroundITS = new TH1D(*(g->fBackgroundITS));
188 }
189
190
191 Float_t AliAnalysisHadEtCorrections::GetConstantCorrections(Bool_t totEt, Float_t ptcut, TString type) const {//Get the correction values that are not pt dependent
192   Float_t acceptance = 0.0;
193   Float_t neutral = 0.0;
194   Float_t ptcorr = 0.0;
195   float correction = 0.0;
196
197   //TString *type = new TString(mytype);
198
199   if(type.Contains("Full")) acceptance = fAcceptanceCorrectionFull;
200   if(type.Contains("EMCAL")) acceptance = fAcceptanceCorrectionEMCAL;
201   if(type.Contains("PHOS")) acceptance = fAcceptanceCorrectionPHOS;
202
203   if(type.Contains("High")){//high bound
204     if(totEt) neutral = fNotHadronicCorrectionHigh;
205     else{neutral = fNeutralCorrectionHigh;}
206     if(ptcut>0.12){ptcorr = ffpTcutCorrectionTPCHigh;}
207     else{ptcorr = ffpTcutCorrectionITSHigh;}
208     cout<<"Setting correction factor to "<<correction<<endl;
209     return correction;
210   }
211   if(type.Contains("Low")){//high bound
212     if(totEt) neutral = fNotHadronicCorrectionLow;
213     else{neutral = fNeutralCorrectionLow;}
214     if(ptcut>0.12){ptcorr = ffpTcutCorrectionTPCLow;}
215     else{ptcorr = ffpTcutCorrectionITSLow;}
216     cout<<"Setting correction factor to "<<correction<<endl;
217     return correction;
218   }
219
220   if(totEt) neutral = fNotHadronicCorrection;
221   else{neutral = fNeutralCorrection;}
222   if(ptcut>0.12){ptcorr = fpTcutCorrectionTPC;}
223   else{ptcorr = fpTcutCorrectionITS;}
224
225   correction = acceptance*neutral*ptcorr;
226   cout<<"Setting correction factor for ";
227   if(totEt) cout<<"total et";
228   else{cout<<"hadronic et";}
229   cout<<" with the pt cut off "<<ptcut<<" for "<<type<<" acceptance to "<<correction<<endl;
230   //cout<<" Acceptance "<<acceptance<<" neutral "<<neutral<<" ptcorr "<<ptcorr<<endl;
231   return correction;
232
233 }
234 Float_t AliAnalysisHadEtCorrections::GetSystematicErrorBound(Float_t et,Bool_t isLowBound, Bool_t isHadronic, Bool_t isTPC) const{
235   //we calculate factors for each value and then multiply them to get the overall bounds
236   //neutral corrections, pt cut, pid, efficiency, background
237   float neutral = 1.0;
238   float ptcut = 1.0;
239   float pid = 1.0;
240   float efficiency = 1.0;
241   float background = 1.0;
242   if(isLowBound){//is lower bound
243     if(isHadronic) neutral= fNeutralCorrectionLow/fNeutralCorrection;
244     else{neutral = fNotHadronicCorrectionLow/fNotHadronicCorrection;}
245     if(isTPC) ptcut = ffpTcutCorrectionTPCLow/fpTcutCorrectionTPC;
246     else{ptcut = ffpTcutCorrectionITSLow/fpTcutCorrectionITS;}
247     pid = fNotIDConstTPCLow/fNotIDConstTPC;
248     efficiency = fEfficiencyErrorLow;
249     background = fBackgroundErrorLow;
250   }
251   else{//is higher bound
252     if(isHadronic) neutral= fNeutralCorrectionHigh/fNeutralCorrection;
253     else{neutral= fNotHadronicCorrectionHigh/fNotHadronicCorrection;}
254     if(isTPC) ptcut = ffpTcutCorrectionTPCHigh/fpTcutCorrectionTPC;
255     else{ptcut = ffpTcutCorrectionITSHigh/fpTcutCorrectionITS;}
256     pid = fNotIDConstTPCHigh/fNotIDConstTPC;
257     efficiency = fEfficiencyErrorHigh;
258     background = fBackgroundErrorHigh;
259   }
260   //cout<<"neutral "<<neutral<<" ptcut "<<ptcut<<" pid "<<pid<<" efficiency "<<efficiency<<" background "<<background<<" overall "<<neutral*ptcut*pid*efficiency*background<<endl;
261   return neutral*ptcut*pid*efficiency*background*et;
262 }
263 // AliAnalysisHadEtCorrections & operator = (const AliAnalysisHadEtCorrections & g) {
264
265 //   fEtaCut=g->fEtaCut;
266 //   fAcceptanceCorrectionFull=g->fAcceptanceCorrectionFull;
267 //   fAcceptanceCorrectionEMCAL=g->fAcceptanceCorrectionEMCAL;
268 //   fAcceptanceCorrectionPHOS=g->fAcceptanceCorrectionPHOS;
269 //   fNeutralCorrection=g->fNeutralCorrection;
270 //   fNotHadronicCorrection=g->fNotHadronicCorrection;
271 //   fpTcutCorrectionTPC=g->fpTcutCorrectionTPC;
272 //   fpTcutCorrectionITS=g->fpTcutCorrectionITS;
273 //   fNeutralCorrectionLow=g->fNeutralCorrectionLow;
274 //   fNotHadronicCorrectionLow=g->fNotHadronicCorrectionLow;
275 //   ffpTcutCorrectionTPCLow=g->ffpTcutCorrectionTPCLow;
276 //   ffpTcutCorrectionITSLow=g->ffpTcutCorrectionITSLow;
277 //   fNeutralCorrectionHigh=g->fNeutralCorrectionHigh;
278 //   fNotHadronicCorrectionHigh=g->fNotHadronicCorrectionHigh;
279 //   ffpTcutCorrectionTPCHigh=g->ffpTcutCorrectionTPCHigh;
280 //   ffpTcutCorrectionITSHigh=g->ffpTcutCorrectionITSHigh;
281
282 //   fnotIDTPC = g->fnotIDTPC;
283 //   fnotIDITS = g->fnotIDITS;
284 //   fnotIDNoID = g->fnotIDNoID;
285 //   fEfficiencyPionTPC = g->fEfficiencyPionTPC;
286 //   fEfficiencyKaonTPC = g->fEfficiencyKaonTPC;
287 //   fEfficiencyProtonTPC = g->fEfficiencyProtonTPC;
288 //   fEfficiencyHadronTPC = g->fEfficiencyHadronTPC;
289 //   fEfficiencyPionITS = g->fEfficiencyPionITS;
290 //   fEfficiencyKaonITS = g->fEfficiencyKaonITS;
291 //   fEfficiencyProtonITS = g->fEfficiencyProtonITS;
292 //   fEfficiencyHadronITS = g->fEfficiencyHadronITS;
293 //   fBackgroundTPC = g->fBackgroundTPC;
294 //   fBackgroundITS = g->fBackgroundITS;
295 // }
296 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyPionTPC(const int cb){//Get centrality dependent efficiency
297   if(cb==-1){return fEfficiencyPionTPC;}
298   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",cb));}
299 }
300 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyKaonTPC(const int cb){//Get centrality dependent efficiency
301   if(cb==-1){return fEfficiencyKaonTPC;}
302   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",cb));}
303 }
304 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyProtonTPC(const int cb){//Get centrality dependent efficiency
305   if(cb==-1){return fEfficiencyProtonTPC;}
306   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",cb));}
307 }
308 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyHadronTPC(const int cb){//Get centrality dependent efficiency
309   if(cb==-1){return fEfficiencyHadronTPC;}
310   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",cb));}
311 }
312 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyPionITS(const int cb){//Get centrality dependent efficiency
313   if(cb==-1){return fEfficiencyPionITS;}
314   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",cb));}
315 }
316 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyKaonITS(const int cb){//Get centrality dependent efficiency
317   if(cb==-1){return fEfficiencyKaonITS;}
318   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",cb));}
319 }
320 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyProtonITS(const int cb){//Get centrality dependent efficiency
321   if(cb==-1){return fEfficiencyProtonITS;}
322   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",cb));}
323 }//Proton
324 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyHadronITS(const int cb){//Get centrality dependent efficiency
325   if(cb==-1){return fEfficiencyHadronITS;}
326   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",cb));}
327 }
328 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionPion(const float pT, const int cb){//Get the efficiency for reconstructing a pion in the TPC
329   float eff = -1.0;
330   if(cb ==-1){//pp
331     if(!fEfficiencyPionTPC){cerr<<"No histogram fEfficiencyPionTPC!"<<endl; return -1.0;}
332     eff = fEfficiencyPionTPC->GetBinContent(fEfficiencyPionTPC->FindBin(pT));
333     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
334   }
335   else{
336     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",cb));
337     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyPionTPC%i",cb)<<endl; return -1.0;}
338     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
339     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
340   }
341   return 1.0/eff;
342 }
343 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionKaon(const float pT, const int cb){//Get the efficiency for reconstructing a kaon in the TPC
344   float eff = -1.0;
345   if(cb ==-1){//pp
346     if(!fEfficiencyKaonTPC){cerr<<"No histogram fEfficiencyKaonTPC!"<<endl; return -1.0;}
347     eff = fEfficiencyKaonTPC->GetBinContent(fEfficiencyKaonTPC->FindBin(pT));
348     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
349   }
350   else{
351     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",cb));
352     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyKaonTPC%i",cb)<<endl; return -1.0;}
353     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
354     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
355   }
356   return 1.0/eff;
357 }
358 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionProton(const float pT, const int cb){//Get the efficiency for reconstructing a proton in the TPC
359   float eff = -1.0;
360   if(cb ==-1){//pp
361     if(!fEfficiencyProtonTPC){cerr<<"No histogram fEfficiencyProtonTPC!"<<endl; return -1.0;}
362     eff = fEfficiencyProtonTPC->GetBinContent(fEfficiencyProtonTPC->FindBin(pT));
363     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
364   }
365   else{
366     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",cb));
367     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyProtonTPC%i",cb)<<endl; return -1.0;}
368     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
369     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
370   }
371   return 1.0/eff;
372 }
373 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionHadron(const float pT, const int cb){//Get the efficiency for reconstructing a hadron in the TPC
374   float eff = -1.0;
375   if(cb ==-1){//pp
376     if(!fEfficiencyHadronTPC){cerr<<"No histogram fEfficiencyHadronTPC!"<<endl; return -1.0;}
377     eff = fEfficiencyHadronTPC->GetBinContent(fEfficiencyHadronTPC->FindBin(pT));
378     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
379   }
380   else{
381     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",cb));
382     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyHadronTPC%i",cb)<<endl; return -1.0;}
383     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
384     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
385   }
386   return 1.0/eff;
387 }
388 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionPion(const float pT, const int cb){//Get the efficiency for reconstructing a pion in the ITS
389   float eff = -1.0;
390   if(cb ==-1){//pp
391     if(!fEfficiencyPionITS){cerr<<"No histogram fEfficiencyPionITS!"<<endl; return -1.0;}
392     eff = fEfficiencyPionITS->GetBinContent(fEfficiencyPionITS->FindBin(pT));
393     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
394   }
395   else{
396     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",cb));
397     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyPionITS%i",cb)<<endl; return -1.0;}
398     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
399     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
400   }
401   return 1.0/eff;
402 }
403 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionKaon(const float pT, const int cb){//Get the efficiency for reconstructing a kaon in the ITS
404   float eff = -1.0;
405   if(cb ==-1){//pp
406     if(!fEfficiencyKaonITS){cerr<<"No histogram fEfficiencyKaonITS!"<<endl; return -1.0;}
407     eff = fEfficiencyKaonITS->GetBinContent(fEfficiencyKaonITS->FindBin(pT));
408     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
409   }
410   else{
411     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",cb));
412     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyKaonITS%i",cb)<<endl; return -1.0;}
413     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
414     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
415   }
416   return 1.0/eff;
417 }
418 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionProton(const float pT, const int cb){//Get the efficiency for reconstructing a proton in the ITS
419   float eff = -1.0;
420   if(cb ==-1){//pp
421     if(!fEfficiencyProtonITS){cerr<<"No histogram fEfficiencyProtonITS!"<<endl; return -1.0;}
422     eff = fEfficiencyProtonITS->GetBinContent(fEfficiencyProtonITS->FindBin(pT));
423     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
424   }
425   else{
426     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",cb));
427     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyProtonITS%i",cb)<<endl; return -1.0;}
428     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
429     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
430   }
431   return 1.0/eff;
432 }
433 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionHadron(const float pT, const int cb){//Get the efficiency for reconstructing a hadron in the ITS
434   float eff = -1.0;
435   if(cb ==-1){//pp
436     if(!fEfficiencyHadronITS){cerr<<"No histogram fEfficiencyHadronITS!"<<endl; return -1.0;}
437     eff = fEfficiencyHadronITS->GetBinContent(fEfficiencyHadronITS->FindBin(pT));
438     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
439   }
440   else{
441     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",cb));
442     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyHadronITS%i",cb)<<endl; return -1.0;}
443     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
444     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
445   }
446   return 1.0/eff;
447 }
448 void AliAnalysisHadEtCorrections::SetEfficiencyPionTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
449   if(histo){
450     //first check to see if the histogram exists already
451     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",cb));
452     if(old){
453       fEfficiencyTPC->Remove(old);
454       delete old;
455     }
456     //then if the new histogram exists, add it to the array
457     histo->SetName(Form("fEfficiencyPionTPC%i",cb));
458     fEfficiencyTPC->Add(histo);
459   }
460   else{cerr<<"Histogram does not exist!"<<endl;}
461 }
462 void AliAnalysisHadEtCorrections::SetEfficiencyKaonTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
463   if(histo){
464     //first check to see if the histogram exists already
465     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",cb));
466     if(old){
467       fEfficiencyTPC->Remove(old);
468       delete old;
469     }
470     //then if the new histogram exists, add it to the array
471     histo->SetName(Form("fEfficiencyKaonTPC%i",cb));
472     fEfficiencyTPC->Add(histo);
473   }
474   else{cerr<<"Histogram does not exist!"<<endl;}
475 }//Kaon
476 void AliAnalysisHadEtCorrections::SetEfficiencyProtonTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
477   if(histo){
478     //first check to see if the histogram exists already
479     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",cb));
480     if(old){
481       fEfficiencyTPC->Remove(old);
482       delete old;
483     }
484     //then if the new histogram exists, add it to the array
485     histo->SetName(Form("fEfficiencyProtonTPC%i",cb));
486     fEfficiencyTPC->Add(histo);
487   }
488   else{cerr<<"Histogram does not exist!"<<endl;}
489 }//Proton
490 void AliAnalysisHadEtCorrections::SetEfficiencyHadronTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
491   if(histo){
492     //first check to see if the histogram exists already
493     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",cb));
494     if(old){
495       fEfficiencyTPC->Remove(old);
496       delete old;
497     }
498     //then if the new histogram exists, add it to the array
499     histo->SetName(Form("fEfficiencyHadronTPC%i",cb));
500     fEfficiencyTPC->Add(histo);
501   }
502   else{cerr<<"Histogram does not exist!"<<endl;}
503 }
504 void AliAnalysisHadEtCorrections::SetEfficiencyPionITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
505   if(histo){
506     //first check to see if the histogram exists already
507     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",cb));
508     if(old){
509       fEfficiencyITS->Remove(old);
510       delete old;
511     }
512     //then if the new histogram exists, add it to the array
513     histo->SetName(Form("fEfficiencyPionITS%i",cb));
514     fEfficiencyITS->Add(histo);
515   }
516   else{cerr<<"Histogram does not exist!"<<endl;}
517 }
518 void AliAnalysisHadEtCorrections::SetEfficiencyKaonITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
519   if(histo){
520     //first check to see if the histogram exists already
521     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",cb));
522     if(old){
523       fEfficiencyITS->Remove(old);
524       delete old;
525     }
526     //then if the new histogram exists, add it to the array
527     histo->SetName(Form("fEfficiencyKaonITS%i",cb));
528     fEfficiencyITS->Add(histo);
529   }
530   else{cerr<<"Histogram does not exist!"<<endl;}
531 }//Kaon
532 void AliAnalysisHadEtCorrections::SetEfficiencyProtonITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
533   if(histo){
534     //first check to see if the histogram exists already
535     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",cb));
536     if(old){
537       fEfficiencyITS->Remove(old);
538       delete old;
539     }
540     //then if the new histogram exists, add it to the array
541     histo->SetName(Form("fEfficiencyProtonITS%i",cb));
542     fEfficiencyITS->Add(histo);
543   }
544   else{cerr<<"Histogram does not exist!"<<endl;}
545 }//Proton
546 void AliAnalysisHadEtCorrections::SetEfficiencyHadronITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
547   if(histo){
548     //first check to see if the histogram exists already
549     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",cb));
550     if(old){
551       fEfficiencyITS->Remove(old);
552       delete old;
553     }
554     //then if the new histogram exists, add it to the array
555     histo->SetName(Form("fEfficiencyHadronITS%i",cb));
556     fEfficiencyITS->Add(histo);
557   }
558   else{cerr<<"Histogram does not exist!"<<endl;}
559 }
560
561
562 Float_t AliAnalysisHadEtCorrections::GetNotIDCorrectionTPC(const float pT){//get correction for unidentified particles in the TPC
563   Float_t val = fnotIDTPC->GetBinContent(fnotIDTPC->FindBin(pT));
564   if(val>0.0) return 1.0/(val);
565   else{return 0.0;}
566 }
567 Float_t AliAnalysisHadEtCorrections::GetNotIDCorrectionITS(const float pT){//Get correction for unidentified particles in the ITS
568   Float_t val = fnotIDITS->GetBinContent(fnotIDITS->FindBin(pT));
569   if(val>0.0) return 1.0/(val);
570   else{return 0.0;}
571 }
572 Float_t AliAnalysisHadEtCorrections::GetNotIDCorrectionNoPID(const float pT){//Get correction for particles in the case that there is no particle identification
573   Float_t val = fnotIDNoID->GetBinContent(fnotIDNoID->FindBin(pT));
574   if(val>0.0) return 1.0/(val);
575   else{return 0.0;}
576 }
577 Float_t AliAnalysisHadEtCorrections::GetBackgroundCorrectionTPC(const float pT){//Get background correction for TPC tracks
578   return (1.0-fBackgroundTPC->GetBinContent(fBackgroundTPC->FindBin(pT)));
579 }
580 Float_t AliAnalysisHadEtCorrections::GetBackgroundCorrectionITS(const float pT){//Get background correction for ITS tracks
581   return (1.0-fBackgroundITS->GetBinContent(fBackgroundITS->FindBin(pT)));
582 }
583 void AliAnalysisHadEtCorrections::Report(){//Gives a report on the status of all corrections
584   //This is primarily for cross checking that the results we get from the macro that fills this class, GetCorrections.C, are sane
585   cout<<"======================================================================="<<endl;
586   cout<<"                   Report from "<<GetName()<<endl;
587   cout<<"======================================================================="<<endl;
588   cout<<fProductionDescription<<" created from "<<fProduction<<endl;
589   cout<<"This for determination of EThad from ";
590   if(fIsData) cout<<"data of ";
591   else{cout<<"simulation of ";}
592   switch(fDataSet){
593   case 2009:
594     cout<<"p+p collisions at 900 GeV"<<endl;
595     break;
596   case 2010:
597     cout<<"p+p collisions at 7 TeV"<<endl;
598     break;
599   case 20111:
600     cout<<"p+p collisions at 2.76 TeV"<<endl;
601     break;
602   case 20100:
603     cout<<"Pb+Pb collisions at 2.76 TeV"<<endl;
604     break;
605   default:
606     cout<<"an undetermined collision system and energy"<<endl;
607   }
608   cout<<"This is initialized for the ";
609   if(fIsEMCal) cout<<"EMCal";
610   else{cout<<"PHOS";}
611   cout<<" acceptance"<<endl<<endl;
612
613   cout<<"The acceptance correction for the full  "<<fAcceptanceCorrectionFull<<endl;
614   cout<<"                                  EMCal "<<fAcceptanceCorrectionEMCAL<<endl;
615   cout<<"                                  PHOS  "<<fAcceptanceCorrectionPHOS<<endl<<endl;
616
617   cout<<Form("The neutral energy correction is %2.4f [%2.4f,%2.4f]",fNeutralCorrection,fNeutralCorrectionLow,fNeutralCorrectionHigh)<<endl;
618   cout<<Form("    total                        %2.4f [%2.4f,%2.4f]",fNotHadronicCorrection,fNotHadronicCorrectionLow,fNotHadronicCorrectionHigh)<<endl<<endl;
619
620   cout<<Form("The pT cut correction for 100 MeV is %2.4f [%2.4f,%2.4f]",fpTcutCorrectionITS,ffpTcutCorrectionITSLow,ffpTcutCorrectionITSHigh)<<endl;
621   cout<<Form("                          150 MeV    %2.4f [%2.4f,%2.4f]",fpTcutCorrectionTPC,ffpTcutCorrectionTPCLow,ffpTcutCorrectionTPCHigh)<<endl<<endl;
622
623   cout<<Form("The correction for unidentified ITS tracks is %2.4f [%2.4f,%2.4f]",fNotIDConstITS,fNotIDConstITSLow,fNotIDConstITSHigh)<<endl;
624   cout<<Form("                                TPC tracks    %2.4f [%2.4f,%2.4f]",fNotIDConstTPC,fNotIDConstTPCLow,fNotIDConstTPCHigh)<<endl<<endl;
625
626   cout<<"Background correction histogram for ITS tracks is";
627   if(!fBackgroundITS)cout<<" not set"<<endl;
628   else{cout<<" set and has "<<fBackgroundITS->GetEntries()<<" entries"<<endl;}
629   cout<<"                                    TPC          ";
630   if(!fBackgroundTPC)cout<<" not set"<<endl;
631   else{cout<<" set and has "<<fBackgroundTPC->GetEntries()<<" entries"<<endl;}
632   cout<<endl;
633
634
635   cout<<"Efficiency histogram for ITS tracks for hadrons is";
636   if(!fEfficiencyHadronITS)cout<<" not set"<<endl;
637   else{cout<<" set and has "<<fEfficiencyHadronITS->GetEntries()<<" entries"<<endl;}
638   cout<<"                         TPC            hadrons   ";
639   if(!fEfficiencyHadronTPC)cout<<" not set"<<endl;
640   else{cout<<" set and has "<<fEfficiencyHadronTPC->GetEntries()<<" entries"<<endl;}
641   cout<<"                         ITS            pions     ";
642   if(!fEfficiencyPionITS)cout<<" not set"<<endl;
643   else{cout<<" set and has "<<fEfficiencyPionITS->GetEntries()<<" entries"<<endl;}
644   cout<<"                         TPC            pions     ";
645   if(!fEfficiencyPionTPC)cout<<" not set"<<endl;
646   else{cout<<" set and has "<<fEfficiencyPionTPC->GetEntries()<<" entries"<<endl;}
647   cout<<"                         ITS            kaons     ";
648   if(!fEfficiencyKaonITS)cout<<" not set"<<endl;
649   else{cout<<" set and has "<<fEfficiencyKaonITS->GetEntries()<<" entries"<<endl;}
650   cout<<"                         TPC            kaons     ";
651   if(!fEfficiencyKaonTPC)cout<<" not set"<<endl;
652   else{cout<<" set and has "<<fEfficiencyKaonTPC->GetEntries()<<" entries"<<endl;}
653   cout<<"                         ITS            protons   ";
654   if(!fEfficiencyProtonITS)cout<<" not set"<<endl;
655   else{cout<<" set and has "<<fEfficiencyProtonITS->GetEntries()<<" entries"<<endl;}
656   cout<<"                         TPC            protons   ";
657   if(!fEfficiencyProtonTPC)cout<<" not set"<<endl;
658   else{cout<<" set and has "<<fEfficiencyProtonTPC->GetEntries()<<" entries"<<endl;}
659   cout<<endl;
660
661   if(fDataSet==20100){//if Pb+Pb
662     cout<<"Efficiency histogram for TPC tracks for hadrons is set for centrality bins ";
663     for(int i = 0;i<=21;i++){
664       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",i));
665       if(histo) cout<<i<<" ";
666     }
667     cout<<endl;
668     cout<<"                                        pions                              ";
669     for(int i = 0;i<=21;i++){
670       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",i));
671       if(histo) cout<<i<<" ";
672     }
673     cout<<endl;
674     cout<<"                                        kaons                              ";
675     for(int i = 0;i<=21;i++){
676       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",i));
677       if(histo) cout<<i<<" ";
678     }
679     cout<<endl;
680     cout<<"                                        protons                            ";
681     for(int i = 0;i<=21;i++){
682       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",i));
683       if(histo) cout<<i<<" ";
684     }
685     cout<<endl;
686     cout<<"                         ITS            hadrons                            ";
687     for(int i = 0;i<=21;i++){
688       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",i));
689       if(histo) cout<<i<<" ";
690     }
691     cout<<endl;
692     cout<<"                                        pions                              ";
693     for(int i = 0;i<=21;i++){
694       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",i));
695       if(histo) cout<<i<<" ";
696     }
697     cout<<endl;
698     cout<<"                                        kaons                              ";
699     for(int i = 0;i<=21;i++){
700       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",i));
701       if(histo) cout<<i<<" ";
702     }
703     cout<<endl;
704     cout<<"                                        protons                            ";
705     for(int i = 0;i<=21;i++){
706       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",i));
707       if(histo) cout<<i<<" ";
708     }
709     cout<<endl;
710
711
712     int nEntries = fEfficiencyTPC->GetEntries();
713     int nbadhistograms = 0;
714     for(int i=0;i<nEntries;i++){
715       TH1D *histo = (TH1D*) fEfficiencyTPC->At(i);
716       if(!histo){
717         cout<<"Warning:  Histogram in fEfficiencyTPC at "<<i<<" is NULL!"<<endl;
718         nbadhistograms++;
719       }
720       else{
721         if(histo->GetEntries()<=1e-2){
722           cout<<"Warning: Histogram "<<histo->GetName()<<" in fEfficiencyTPC is empty!"<<endl;
723           nbadhistograms++;
724         }
725       }
726     }
727     cout<<nbadhistograms<<" bad histograms in fEfficiencyTPC"<<endl;
728
729     nEntries = fEfficiencyITS->GetEntries();
730     nbadhistograms = 0;
731     for(int i=0;i<nEntries;i++){
732       TH1D *histo = (TH1D*) fEfficiencyITS->At(i);
733       if(!histo){
734         cout<<"Warning:  Histogram in fEfficiencyITS at "<<i<<" is NULL!"<<endl;
735         nbadhistograms++;
736       }
737       else{
738         if(histo->GetEntries()<=1e-2){
739           cout<<"Warning: Histogram "<<histo->GetName()<<" in fEfficiencyITS is empty!"<<endl;
740           nbadhistograms++;
741         }
742       }
743     }
744     cout<<nbadhistograms<<" bad histograms in fEfficiencyITS"<<endl;
745
746
747   }
748
749
750   cout<<endl;
751   cout<<"======================================================================="<<endl;
752   cout<<"======================================================================="<<endl;
753 }
754