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