]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/totEt/AliAnalysisHadEtCorrections.cxx
Changing eta cut for the EMCal since we arent getting clusters on the edges anyways
[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") || type.Contains("PiKP")) acceptance = fAcceptanceCorrectionFull;
200   if(type.Contains("EMCAL")) acceptance = fAcceptanceCorrectionEMCAL;
201   if(type.Contains("PHOS")) acceptance = fAcceptanceCorrectionPHOS;
202
203   if(type.Contains("PiKP")){
204     if(ptcut>0.12){ptcorr = fpTcutCorrectionTPC;}
205     else{ptcorr = fpTcutCorrectionITS;}
206     if(type.Contains("High")){
207       if(ptcut>0.12){ptcorr = ffpTcutCorrectionTPCHigh;}
208       else{ptcorr = ffpTcutCorrectionITSHigh;}
209     }
210     if(type.Contains("Low")){
211       if(ptcut>0.12){ptcorr = ffpTcutCorrectionTPCLow;}
212       else{ptcorr = ffpTcutCorrectionITSLow;}
213     }
214   }
215
216   if(type.Contains("High")){//high bound
217     if(totEt) neutral = fNotHadronicCorrectionHigh;
218     else{neutral = fNeutralCorrectionHigh;}
219     if(ptcut>0.12){ptcorr = ffpTcutCorrectionTPCHigh;}
220     else{ptcorr = ffpTcutCorrectionITSHigh;}
221     cout<<"Setting correction factor to "<<correction<<endl;
222     return correction;
223   }
224   if(type.Contains("Low")){//high bound
225     if(totEt) neutral = fNotHadronicCorrectionLow;
226     else{neutral = fNeutralCorrectionLow;}
227     if(ptcut>0.12){ptcorr = ffpTcutCorrectionTPCLow;}
228     else{ptcorr = ffpTcutCorrectionITSLow;}
229     cout<<"Setting correction factor to "<<correction<<endl;
230     return correction;
231   }
232
233   if(totEt) neutral = fNotHadronicCorrection;
234   else{neutral = fNeutralCorrection;}
235   if(ptcut>0.12){ptcorr = fpTcutCorrectionTPC;}
236   else{ptcorr = fpTcutCorrectionITS;}
237
238   correction = acceptance*neutral*ptcorr;
239   cout<<"Setting correction factor for ";
240   if(totEt) cout<<"total et";
241   else{cout<<"hadronic et";}
242   cout<<" with the pt cut off "<<ptcut<<" for "<<type<<" acceptance to "<<correction<<endl;
243   //cout<<" Acceptance "<<acceptance<<" neutral "<<neutral<<" ptcorr "<<ptcorr<<endl;
244   return correction;
245
246 }
247 Float_t AliAnalysisHadEtCorrections::GetSystematicErrorBound(Float_t et,Bool_t isLowBound, Bool_t isHadronic, Bool_t isTPC) const{
248   //we calculate factors for each value and then multiply them to get the overall bounds
249   //neutral corrections, pt cut, pid, efficiency, background
250   float neutral = 1.0;
251   float ptcut = 1.0;
252   float pid = 1.0;
253   float efficiency = 1.0;
254   float background = 1.0;
255   if(isLowBound){//is lower bound
256     if(isHadronic) neutral= fNeutralCorrectionLow/fNeutralCorrection;
257     else{neutral = fNotHadronicCorrectionLow/fNotHadronicCorrection;}
258     if(isTPC) ptcut = ffpTcutCorrectionTPCLow/fpTcutCorrectionTPC;
259     else{ptcut = ffpTcutCorrectionITSLow/fpTcutCorrectionITS;}
260     pid = fNotIDConstTPCLow/fNotIDConstTPC;
261     efficiency = fEfficiencyErrorLow;
262     background = fBackgroundErrorLow;
263   }
264   else{//is higher bound
265     if(isHadronic) neutral= fNeutralCorrectionHigh/fNeutralCorrection;
266     else{neutral= fNotHadronicCorrectionHigh/fNotHadronicCorrection;}
267     if(isTPC) ptcut = ffpTcutCorrectionTPCHigh/fpTcutCorrectionTPC;
268     else{ptcut = ffpTcutCorrectionITSHigh/fpTcutCorrectionITS;}
269     pid = fNotIDConstTPCHigh/fNotIDConstTPC;
270     efficiency = fEfficiencyErrorHigh;
271     background = fBackgroundErrorHigh;
272   }
273   //cout<<"neutral "<<neutral<<" ptcut "<<ptcut<<" pid "<<pid<<" efficiency "<<efficiency<<" background "<<background<<" overall "<<neutral*ptcut*pid*efficiency*background<<endl;
274   return neutral*ptcut*pid*efficiency*background*et;
275 }
276 // AliAnalysisHadEtCorrections & operator = (const AliAnalysisHadEtCorrections & g) {
277
278 //   fEtaCut=g->fEtaCut;
279 //   fAcceptanceCorrectionFull=g->fAcceptanceCorrectionFull;
280 //   fAcceptanceCorrectionEMCAL=g->fAcceptanceCorrectionEMCAL;
281 //   fAcceptanceCorrectionPHOS=g->fAcceptanceCorrectionPHOS;
282 //   fNeutralCorrection=g->fNeutralCorrection;
283 //   fNotHadronicCorrection=g->fNotHadronicCorrection;
284 //   fpTcutCorrectionTPC=g->fpTcutCorrectionTPC;
285 //   fpTcutCorrectionITS=g->fpTcutCorrectionITS;
286 //   fNeutralCorrectionLow=g->fNeutralCorrectionLow;
287 //   fNotHadronicCorrectionLow=g->fNotHadronicCorrectionLow;
288 //   ffpTcutCorrectionTPCLow=g->ffpTcutCorrectionTPCLow;
289 //   ffpTcutCorrectionITSLow=g->ffpTcutCorrectionITSLow;
290 //   fNeutralCorrectionHigh=g->fNeutralCorrectionHigh;
291 //   fNotHadronicCorrectionHigh=g->fNotHadronicCorrectionHigh;
292 //   ffpTcutCorrectionTPCHigh=g->ffpTcutCorrectionTPCHigh;
293 //   ffpTcutCorrectionITSHigh=g->ffpTcutCorrectionITSHigh;
294
295 //   fnotIDTPC = g->fnotIDTPC;
296 //   fnotIDITS = g->fnotIDITS;
297 //   fnotIDNoID = g->fnotIDNoID;
298 //   fEfficiencyPionTPC = g->fEfficiencyPionTPC;
299 //   fEfficiencyKaonTPC = g->fEfficiencyKaonTPC;
300 //   fEfficiencyProtonTPC = g->fEfficiencyProtonTPC;
301 //   fEfficiencyHadronTPC = g->fEfficiencyHadronTPC;
302 //   fEfficiencyPionITS = g->fEfficiencyPionITS;
303 //   fEfficiencyKaonITS = g->fEfficiencyKaonITS;
304 //   fEfficiencyProtonITS = g->fEfficiencyProtonITS;
305 //   fEfficiencyHadronITS = g->fEfficiencyHadronITS;
306 //   fBackgroundTPC = g->fBackgroundTPC;
307 //   fBackgroundITS = g->fBackgroundITS;
308 // }
309 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyPionTPC(const int cb){//Get centrality dependent efficiency
310   if(cb==-1){return fEfficiencyPionTPC;}
311   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",cb));}
312 }
313 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyKaonTPC(const int cb){//Get centrality dependent efficiency
314   if(cb==-1){return fEfficiencyKaonTPC;}
315   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",cb));}
316 }
317 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyProtonTPC(const int cb){//Get centrality dependent efficiency
318   if(cb==-1){return fEfficiencyProtonTPC;}
319   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",cb));}
320 }
321 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyHadronTPC(const int cb){//Get centrality dependent efficiency
322   if(cb==-1){return fEfficiencyHadronTPC;}
323   else{return (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",cb));}
324 }
325 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyPionITS(const int cb){//Get centrality dependent efficiency
326   if(cb==-1){return fEfficiencyPionITS;}
327   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",cb));}
328 }
329 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyKaonITS(const int cb){//Get centrality dependent efficiency
330   if(cb==-1){return fEfficiencyKaonITS;}
331   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",cb));}
332 }
333 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyProtonITS(const int cb){//Get centrality dependent efficiency
334   if(cb==-1){return fEfficiencyProtonITS;}
335   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",cb));}
336 }//Proton
337 TH1D *AliAnalysisHadEtCorrections::GetEfficiencyHadronITS(const int cb){//Get centrality dependent efficiency
338   if(cb==-1){return fEfficiencyHadronITS;}
339   else{return (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",cb));}
340 }
341 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionPion(const float pT, const int cb){//Get the efficiency for reconstructing a pion in the TPC
342   float eff = -1.0;
343   if(cb ==-1){//pp
344     if(!fEfficiencyPionTPC){cerr<<"No histogram fEfficiencyPionTPC!"<<endl; return -1.0;}
345     eff = fEfficiencyPionTPC->GetBinContent(fEfficiencyPionTPC->FindBin(pT));
346     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
347   }
348   else{
349     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",cb));
350     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyPionTPC%i",cb)<<endl; return -1.0;}
351     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
352     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
353   }
354   return 1.0/eff;
355 }
356 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionKaon(const float pT, const int cb){//Get the efficiency for reconstructing a kaon in the TPC
357   float eff = -1.0;
358   if(cb ==-1){//pp
359     if(!fEfficiencyKaonTPC){cerr<<"No histogram fEfficiencyKaonTPC!"<<endl; return -1.0;}
360     eff = fEfficiencyKaonTPC->GetBinContent(fEfficiencyKaonTPC->FindBin(pT));
361     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
362   }
363   else{
364     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",cb));
365     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyKaonTPC%i",cb)<<endl; return -1.0;}
366     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
367     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
368   }
369   return 1.0/eff;
370 }
371 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionProton(const float pT, const int cb){//Get the efficiency for reconstructing a proton in the TPC
372   float eff = -1.0;
373   if(cb ==-1){//pp
374     if(!fEfficiencyProtonTPC){cerr<<"No histogram fEfficiencyProtonTPC!"<<endl; return -1.0;}
375     eff = fEfficiencyProtonTPC->GetBinContent(fEfficiencyProtonTPC->FindBin(pT));
376     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
377   }
378   else{
379     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",cb));
380     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyProtonTPC%i",cb)<<endl; return -1.0;}
381     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
382     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
383   }
384   return 1.0/eff;
385 }
386 Float_t AliAnalysisHadEtCorrections::GetTPCEfficiencyCorrectionHadron(const float pT, const int cb){//Get the efficiency for reconstructing a hadron in the TPC
387   float eff = -1.0;
388   if(cb ==-1){//pp
389     if(!fEfficiencyHadronTPC){cerr<<"No histogram fEfficiencyHadronTPC!"<<endl; return -1.0;}
390     eff = fEfficiencyHadronTPC->GetBinContent(fEfficiencyHadronTPC->FindBin(pT));
391     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
392   }
393   else{
394     TH1D *fEfficiency = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",cb));
395     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyHadronTPC%i",cb)<<endl; return -1.0;}
396     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
397     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
398   }
399   return 1.0/eff;
400 }
401 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionPion(const float pT, const int cb){//Get the efficiency for reconstructing a pion in the ITS
402   float eff = -1.0;
403   if(cb ==-1){//pp
404     if(!fEfficiencyPionITS){cerr<<"No histogram fEfficiencyPionITS!"<<endl; return -1.0;}
405     eff = fEfficiencyPionITS->GetBinContent(fEfficiencyPionITS->FindBin(pT));
406     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
407   }
408   else{
409     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",cb));
410     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyPionITS%i",cb)<<endl; return -1.0;}
411     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
412     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
413   }
414   return 1.0/eff;
415 }
416 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionKaon(const float pT, const int cb){//Get the efficiency for reconstructing a kaon in the ITS
417   float eff = -1.0;
418   if(cb ==-1){//pp
419     if(!fEfficiencyKaonITS){cerr<<"No histogram fEfficiencyKaonITS!"<<endl; return -1.0;}
420     eff = fEfficiencyKaonITS->GetBinContent(fEfficiencyKaonITS->FindBin(pT));
421     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
422   }
423   else{
424     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",cb));
425     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyKaonITS%i",cb)<<endl; return -1.0;}
426     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
427     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
428   }
429   return 1.0/eff;
430 }
431 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionProton(const float pT, const int cb){//Get the efficiency for reconstructing a proton in the ITS
432   float eff = -1.0;
433   if(cb ==-1){//pp
434     if(!fEfficiencyProtonITS){cerr<<"No histogram fEfficiencyProtonITS!"<<endl; return -1.0;}
435     eff = fEfficiencyProtonITS->GetBinContent(fEfficiencyProtonITS->FindBin(pT));
436     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
437   }
438   else{
439     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",cb));
440     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyProtonITS%i",cb)<<endl; return -1.0;}
441     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
442     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
443   }
444   return 1.0/eff;
445 }
446 Float_t AliAnalysisHadEtCorrections::GetITSEfficiencyCorrectionHadron(const float pT, const int cb){//Get the efficiency for reconstructing a hadron in the ITS
447   float eff = -1.0;
448   if(cb ==-1){//pp
449     if(!fEfficiencyHadronITS){cerr<<"No histogram fEfficiencyHadronITS!"<<endl; return -1.0;}
450     eff = fEfficiencyHadronITS->GetBinContent(fEfficiencyHadronITS->FindBin(pT));
451     if(eff<=0.0){AliInfo("Efficiency is zero!");  return 0.0;}
452   }
453   else{
454     TH1D *fEfficiency = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",cb));
455     if(!fEfficiency){cerr<<"No histogram "<<Form("fEfficiencyHadronITS%i",cb)<<endl; return -1.0;}
456     eff = fEfficiency->GetBinContent(fEfficiency->FindBin(pT));
457     if(eff<=0.0){AliInfo(Form("Pion efficiency is zero for centrality bin %i!",cb));  return 0.0;}
458   }
459   return 1.0/eff;
460 }
461 void AliAnalysisHadEtCorrections::SetEfficiencyPionTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
462   if(histo){
463     //first check to see if the histogram exists already
464     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",cb));
465     if(old){
466       fEfficiencyTPC->Remove(old);
467       delete old;
468     }
469     //then if the new histogram exists, add it to the array
470     histo->SetName(Form("fEfficiencyPionTPC%i",cb));
471     fEfficiencyTPC->Add(histo);
472   }
473   else{cerr<<"Histogram does not exist!"<<endl;}
474 }
475 void AliAnalysisHadEtCorrections::SetEfficiencyKaonTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
476   if(histo){
477     //first check to see if the histogram exists already
478     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",cb));
479     if(old){
480       fEfficiencyTPC->Remove(old);
481       delete old;
482     }
483     //then if the new histogram exists, add it to the array
484     histo->SetName(Form("fEfficiencyKaonTPC%i",cb));
485     fEfficiencyTPC->Add(histo);
486   }
487   else{cerr<<"Histogram does not exist!"<<endl;}
488 }//Kaon
489 void AliAnalysisHadEtCorrections::SetEfficiencyProtonTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
490   if(histo){
491     //first check to see if the histogram exists already
492     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",cb));
493     if(old){
494       fEfficiencyTPC->Remove(old);
495       delete old;
496     }
497     //then if the new histogram exists, add it to the array
498     histo->SetName(Form("fEfficiencyProtonTPC%i",cb));
499     fEfficiencyTPC->Add(histo);
500   }
501   else{cerr<<"Histogram does not exist!"<<endl;}
502 }//Proton
503 void AliAnalysisHadEtCorrections::SetEfficiencyHadronTPC(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
504   if(histo){
505     //first check to see if the histogram exists already
506     TH1D *old = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",cb));
507     if(old){
508       fEfficiencyTPC->Remove(old);
509       delete old;
510     }
511     //then if the new histogram exists, add it to the array
512     histo->SetName(Form("fEfficiencyHadronTPC%i",cb));
513     fEfficiencyTPC->Add(histo);
514   }
515   else{cerr<<"Histogram does not exist!"<<endl;}
516 }
517 void AliAnalysisHadEtCorrections::SetEfficiencyPionITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
518   if(histo){
519     //first check to see if the histogram exists already
520     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",cb));
521     if(old){
522       fEfficiencyITS->Remove(old);
523       delete old;
524     }
525     //then if the new histogram exists, add it to the array
526     histo->SetName(Form("fEfficiencyPionITS%i",cb));
527     fEfficiencyITS->Add(histo);
528   }
529   else{cerr<<"Histogram does not exist!"<<endl;}
530 }
531 void AliAnalysisHadEtCorrections::SetEfficiencyKaonITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
532   if(histo){
533     //first check to see if the histogram exists already
534     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",cb));
535     if(old){
536       fEfficiencyITS->Remove(old);
537       delete old;
538     }
539     //then if the new histogram exists, add it to the array
540     histo->SetName(Form("fEfficiencyKaonITS%i",cb));
541     fEfficiencyITS->Add(histo);
542   }
543   else{cerr<<"Histogram does not exist!"<<endl;}
544 }//Kaon
545 void AliAnalysisHadEtCorrections::SetEfficiencyProtonITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
546   if(histo){
547     //first check to see if the histogram exists already
548     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",cb));
549     if(old){
550       fEfficiencyITS->Remove(old);
551       delete old;
552     }
553     //then if the new histogram exists, add it to the array
554     histo->SetName(Form("fEfficiencyProtonITS%i",cb));
555     fEfficiencyITS->Add(histo);
556   }
557   else{cerr<<"Histogram does not exist!"<<endl;}
558 }//Proton
559 void AliAnalysisHadEtCorrections::SetEfficiencyHadronITS(TH1D *histo, const int cb){//Set centrality dependent efficiency for centrality bin cb
560   if(histo){
561     //first check to see if the histogram exists already
562     TH1D *old = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",cb));
563     if(old){
564       fEfficiencyITS->Remove(old);
565       delete old;
566     }
567     //then if the new histogram exists, add it to the array
568     histo->SetName(Form("fEfficiencyHadronITS%i",cb));
569     fEfficiencyITS->Add(histo);
570   }
571   else{cerr<<"Histogram does not exist!"<<endl;}
572 }
573
574
575 Float_t AliAnalysisHadEtCorrections::GetNotIDCorrectionTPC(const float pT){//get correction for unidentified particles in the TPC
576   Float_t val = fnotIDTPC->GetBinContent(fnotIDTPC->FindBin(pT));
577   if(val>0.0) return 1.0/(val);
578   else{return 0.0;}
579 }
580 Float_t AliAnalysisHadEtCorrections::GetNotIDCorrectionITS(const float pT){//Get correction for unidentified particles in the ITS
581   Float_t val = fnotIDITS->GetBinContent(fnotIDITS->FindBin(pT));
582   if(val>0.0) return 1.0/(val);
583   else{return 0.0;}
584 }
585 Float_t AliAnalysisHadEtCorrections::GetNotIDCorrectionNoPID(const float pT){//Get correction for particles in the case that there is no particle identification
586   Float_t val = fnotIDNoID->GetBinContent(fnotIDNoID->FindBin(pT));
587   if(val>0.0) return 1.0/(val);
588   else{return 0.0;}
589 }
590 Float_t AliAnalysisHadEtCorrections::GetBackgroundCorrectionTPC(const float pT){//Get background correction for TPC tracks
591   return (1.0-fBackgroundTPC->GetBinContent(fBackgroundTPC->FindBin(pT)));
592 }
593 Float_t AliAnalysisHadEtCorrections::GetBackgroundCorrectionITS(const float pT){//Get background correction for ITS tracks
594   return (1.0-fBackgroundITS->GetBinContent(fBackgroundITS->FindBin(pT)));
595 }
596 void AliAnalysisHadEtCorrections::Report(){//Gives a report on the status of all corrections
597   //This is primarily for cross checking that the results we get from the macro that fills this class, GetCorrections.C, are sane
598   cout<<"======================================================================="<<endl;
599   cout<<"                   Report from "<<GetName()<<endl;
600   cout<<"======================================================================="<<endl;
601   cout<<fProductionDescription<<" created from "<<fProduction<<endl;
602   cout<<"This for determination of EThad from ";
603   if(fIsData) cout<<"data of ";
604   else{cout<<"simulation of ";}
605   switch(fDataSet){
606   case 2009:
607     cout<<"p+p collisions at 900 GeV"<<endl;
608     break;
609   case 2010:
610     cout<<"p+p collisions at 7 TeV"<<endl;
611     break;
612   case 20111:
613     cout<<"p+p collisions at 2.76 TeV"<<endl;
614     break;
615   case 20100:
616     cout<<"Pb+Pb collisions at 2.76 TeV"<<endl;
617     break;
618   default:
619     cout<<"an undetermined collision system and energy"<<endl;
620   }
621   cout<<"This is initialized for the ";
622   if(fIsEMCal) cout<<"EMCal";
623   else{cout<<"PHOS";}
624   cout<<" acceptance"<<endl<<endl;
625
626   cout<<"The acceptance correction for the full  "<<fAcceptanceCorrectionFull<<endl;
627   cout<<"                                  EMCal "<<fAcceptanceCorrectionEMCAL<<endl;
628   cout<<"                                  PHOS  "<<fAcceptanceCorrectionPHOS<<endl<<endl;
629
630   cout<<Form("The neutral energy correction is %2.4f [%2.4f,%2.4f]",fNeutralCorrection,fNeutralCorrectionLow,fNeutralCorrectionHigh)<<endl;
631   cout<<Form("    total                        %2.4f [%2.4f,%2.4f]",fNotHadronicCorrection,fNotHadronicCorrectionLow,fNotHadronicCorrectionHigh)<<endl<<endl;
632
633   cout<<Form("The pT cut correction for 100 MeV is %2.4f [%2.4f,%2.4f]",fpTcutCorrectionITS,ffpTcutCorrectionITSLow,ffpTcutCorrectionITSHigh)<<endl;
634   cout<<Form("                          150 MeV    %2.4f [%2.4f,%2.4f]",fpTcutCorrectionTPC,ffpTcutCorrectionTPCLow,ffpTcutCorrectionTPCHigh)<<endl<<endl;
635
636   cout<<Form("The correction for unidentified ITS tracks is %2.4f [%2.4f,%2.4f]",fNotIDConstITS,fNotIDConstITSLow,fNotIDConstITSHigh)<<endl;
637   cout<<Form("                                TPC tracks    %2.4f [%2.4f,%2.4f]",fNotIDConstTPC,fNotIDConstTPCLow,fNotIDConstTPCHigh)<<endl<<endl;
638
639   cout<<"Background correction histogram for ITS tracks is";
640   if(!fBackgroundITS)cout<<" not set"<<endl;
641   else{cout<<" set and has "<<fBackgroundITS->GetEntries()<<" entries"<<endl;}
642   cout<<"                                    TPC          ";
643   if(!fBackgroundTPC)cout<<" not set"<<endl;
644   else{cout<<" set and has "<<fBackgroundTPC->GetEntries()<<" entries"<<endl;}
645   cout<<endl;
646
647
648   cout<<"Efficiency histogram for ITS tracks for hadrons is";
649   if(!fEfficiencyHadronITS)cout<<" not set"<<endl;
650   else{cout<<" set and has "<<fEfficiencyHadronITS->GetEntries()<<" entries"<<endl;}
651   cout<<"                         TPC            hadrons   ";
652   if(!fEfficiencyHadronTPC)cout<<" not set"<<endl;
653   else{cout<<" set and has "<<fEfficiencyHadronTPC->GetEntries()<<" entries"<<endl;}
654   cout<<"                         ITS            pions     ";
655   if(!fEfficiencyPionITS)cout<<" not set"<<endl;
656   else{cout<<" set and has "<<fEfficiencyPionITS->GetEntries()<<" entries"<<endl;}
657   cout<<"                         TPC            pions     ";
658   if(!fEfficiencyPionTPC)cout<<" not set"<<endl;
659   else{cout<<" set and has "<<fEfficiencyPionTPC->GetEntries()<<" entries"<<endl;}
660   cout<<"                         ITS            kaons     ";
661   if(!fEfficiencyKaonITS)cout<<" not set"<<endl;
662   else{cout<<" set and has "<<fEfficiencyKaonITS->GetEntries()<<" entries"<<endl;}
663   cout<<"                         TPC            kaons     ";
664   if(!fEfficiencyKaonTPC)cout<<" not set"<<endl;
665   else{cout<<" set and has "<<fEfficiencyKaonTPC->GetEntries()<<" entries"<<endl;}
666   cout<<"                         ITS            protons   ";
667   if(!fEfficiencyProtonITS)cout<<" not set"<<endl;
668   else{cout<<" set and has "<<fEfficiencyProtonITS->GetEntries()<<" entries"<<endl;}
669   cout<<"                         TPC            protons   ";
670   if(!fEfficiencyProtonTPC)cout<<" not set"<<endl;
671   else{cout<<" set and has "<<fEfficiencyProtonTPC->GetEntries()<<" entries"<<endl;}
672   cout<<endl;
673
674   if(fDataSet==20100){//if Pb+Pb
675     cout<<"Efficiency histogram for TPC tracks for hadrons is set for centrality bins ";
676     for(int i = 0;i<=21;i++){
677       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyHadronTPC%i",i));
678       if(histo) cout<<i<<" ";
679     }
680     cout<<endl;
681     cout<<"                                        pions                              ";
682     for(int i = 0;i<=21;i++){
683       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyPionTPC%i",i));
684       if(histo) cout<<i<<" ";
685     }
686     cout<<endl;
687     cout<<"                                        kaons                              ";
688     for(int i = 0;i<=21;i++){
689       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyKaonTPC%i",i));
690       if(histo) cout<<i<<" ";
691     }
692     cout<<endl;
693     cout<<"                                        protons                            ";
694     for(int i = 0;i<=21;i++){
695       TH1D *histo = (TH1D*) fEfficiencyTPC->FindObject(Form("fEfficiencyProtonTPC%i",i));
696       if(histo) cout<<i<<" ";
697     }
698     cout<<endl;
699     cout<<"                         ITS            hadrons                            ";
700     for(int i = 0;i<=21;i++){
701       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyHadronITS%i",i));
702       if(histo) cout<<i<<" ";
703     }
704     cout<<endl;
705     cout<<"                                        pions                              ";
706     for(int i = 0;i<=21;i++){
707       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyPionITS%i",i));
708       if(histo) cout<<i<<" ";
709     }
710     cout<<endl;
711     cout<<"                                        kaons                              ";
712     for(int i = 0;i<=21;i++){
713       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyKaonITS%i",i));
714       if(histo) cout<<i<<" ";
715     }
716     cout<<endl;
717     cout<<"                                        protons                            ";
718     for(int i = 0;i<=21;i++){
719       TH1D *histo = (TH1D*) fEfficiencyITS->FindObject(Form("fEfficiencyProtonITS%i",i));
720       if(histo) cout<<i<<" ";
721     }
722     cout<<endl;
723
724
725     int nEntries = fEfficiencyTPC->GetEntries();
726     int nbadhistograms = 0;
727     for(int i=0;i<nEntries;i++){
728       TH1D *histo = (TH1D*) fEfficiencyTPC->At(i);
729       if(!histo){
730         cout<<"Warning:  Histogram in fEfficiencyTPC at "<<i<<" is NULL!"<<endl;
731         nbadhistograms++;
732       }
733       else{
734         if(histo->GetEntries()<=1e-2){
735           cout<<"Warning: Histogram "<<histo->GetName()<<" in fEfficiencyTPC is empty!"<<endl;
736           nbadhistograms++;
737         }
738       }
739     }
740     cout<<nbadhistograms<<" bad histograms in fEfficiencyTPC"<<endl;
741
742     nEntries = fEfficiencyITS->GetEntries();
743     nbadhistograms = 0;
744     for(int i=0;i<nEntries;i++){
745       TH1D *histo = (TH1D*) fEfficiencyITS->At(i);
746       if(!histo){
747         cout<<"Warning:  Histogram in fEfficiencyITS at "<<i<<" is NULL!"<<endl;
748         nbadhistograms++;
749       }
750       else{
751         if(histo->GetEntries()<=1e-2){
752           cout<<"Warning: Histogram "<<histo->GetName()<<" in fEfficiencyITS is empty!"<<endl;
753           nbadhistograms++;
754         }
755       }
756     }
757     cout<<nbadhistograms<<" bad histograms in fEfficiencyITS"<<endl;
758
759
760   }
761
762
763   cout<<endl;
764   cout<<"======================================================================="<<endl;
765   cout<<"======================================================================="<<endl;
766 }
767