o First Version of TRDnSigma implementation (Xianguo) o still requires some catching...
[u/mrichter/AliRoot.git] / PWGLF / totEt / AliAnalysisHadEtReconstructed.cxx
1 //_________________________________________________________________________
2 //  Utility Class for transverse energy studies, charged hadrons
3 //  Base class for ESD analysis
4 //  - reconstruction output
5 // implementation file
6 //
7 //Created by Christine Nattrass, Rebecca Scott, Irakli Martashvili
8 //University of Tennessee at Knoxville
9 //_________________________________________________________________________
10
11 #include <TROOT.h>
12 #include <TSystem.h>
13 #include <TInterpreter.h>
14 #include "AliAnalysisHadEtReconstructed.h"
15 #include "AliAnalysisEtCuts.h"
16 #include "AliESDtrack.h"
17 #include "AliESDCaloCluster.h"
18 #include "AliVEvent.h"
19 #include "AliESDEvent.h"
20 #include "AliESDtrackCuts.h"
21 #include "AliESDpid.h"
22 #include "AliVParticle.h"
23 #include <iostream>
24 #include "AliAnalysisHadEtCorrections.h"
25 #include "TFile.h"
26 #include "TString.h"
27 #include "AliAnalysisEtCommon.h"
28 #include "AliAnalysisHadEt.h"
29 #include "AliCentrality.h"
30 #include "AliLog.h"
31 #include "AliPIDResponse.h"
32 #include "AliTPCPIDResponse.h" 
33 #include "AliInputEventHandler.h"
34 #include "AliAnalysisManager.h"
35 #include "AliPWG0Helper.h"
36
37 using namespace std;
38
39 ClassImp(AliAnalysisHadEtReconstructed);
40
41
42 AliAnalysisHadEtReconstructed::AliAnalysisHadEtReconstructed() :
43   AliAnalysisHadEt()
44   ,fCorrections(0)
45   ,fConfigFile("ConfigHadEtAnalysis.C")
46   ,fCorrTotEtFullAcceptanceTPC(0)
47   ,fCorrTotEtFullAcceptanceITS(0)
48   ,fCorrHadEtFullAcceptanceTPC(0)
49   ,fCorrHadEtFullAcceptanceITS(0)
50   ,fCorrPiKPEtFullAcceptanceTPC(0)
51   ,fCorrPiKPEtFullAcceptanceITS(0)
52   ,fCorrTotEtEMCALAcceptanceTPC(0)
53   ,fCorrTotEtEMCALAcceptanceITS(0)
54   ,fCorrHadEtEMCALAcceptanceTPC(0)
55   ,fCorrHadEtEMCALAcceptanceITS(0)
56   ,fCorrTotEtPHOSAcceptanceTPC(0)
57   ,fCorrTotEtPHOSAcceptanceITS(0)
58   ,fCorrHadEtPHOSAcceptanceTPC(0)
59   ,fCorrHadEtPHOSAcceptanceITS(0)
60   ,fCorrectedHadEtFullAcceptanceTPCNoPID(0)
61   ,fCorrectedHadEtFullAcceptanceITSNoPID(0)
62   ,fCorrectedHadEtEMCALAcceptanceTPCNoPID(0)
63   ,fCorrectedHadEtEMCALAcceptanceITSNoPID(0)
64   ,fCorrectedHadEtPHOSAcceptanceTPCNoPID(0)
65   ,fCorrectedHadEtPHOSAcceptanceITSNoPID(0)
66   ,fCorrectedHadEtFullAcceptanceTPC(0)
67   ,fCorrectedHadEtFullAcceptanceITS(0)
68   ,fCorrectedHadEtFullAcceptanceTPCAssumingPion(0)
69   ,fCorrectedHadEtFullAcceptanceITSAssumingPion(0)
70   ,fCorrectedHadEtFullAcceptanceTPCAssumingProton(0)
71   ,fCorrectedHadEtFullAcceptanceITSAssumingProton(0)
72   ,fCorrectedHadEtFullAcceptanceTPCAssumingKaon(0)
73   ,fCorrectedHadEtFullAcceptanceITSAssumingKaon(0)
74   ,fCorrectedHadEtEMCALAcceptanceTPC(0)
75   ,fCorrectedHadEtEMCALAcceptanceITS(0)
76   ,fCorrectedHadEtPHOSAcceptanceTPC(0)
77   ,fCorrectedHadEtPHOSAcceptanceITS(0)
78   ,fRawEtFullAcceptanceTPC(0)
79   ,fRawEtFullAcceptanceITS(0)
80   ,fRawEtEMCALAcceptanceTPC(0)
81   ,fRawEtEMCALAcceptanceITS(0)
82   ,fRawEtPHOSAcceptanceTPC(0)
83   ,fRawEtPHOSAcceptanceITS(0)
84   ,fRawEtFullAcceptanceTPCNoPID(0)
85   ,fRawEtFullAcceptanceITSNoPID(0)
86   ,fRawEtEMCALAcceptanceTPCNoPID(0)
87   ,fRawEtEMCALAcceptanceITSNoPID(0)
88   ,fRawEtPHOSAcceptanceTPCNoPID(0)
89   ,fRawEtPHOSAcceptanceITSNoPID(0)
90   ,kIsOfflineV0AND(0)
91   ,kDoTriggerChecks(0)
92   ,kDoTriggerChecksOnly(0)
93 {
94 }
95
96 AliAnalysisHadEtReconstructed::~AliAnalysisHadEtReconstructed() 
97 {
98   delete fCorrections;
99 }
100
101 Int_t AliAnalysisHadEtReconstructed::AnalyseEvent(AliVEvent* ev, Int_t eventtype)
102 { // analyse ESD event
103   if(kDoTriggerChecksOnly){return 1;}//In this case we are just after trigger efficiencies and don't care about the ET reconstructed.
104   if(kDoTriggerChecks && !kIsOfflineV0AND){return 1;}//In this case we are just after trigger efficiencies and don't care about the ET reconstructed.
105   ResetEventValues();
106   if(!ev){
107     AliFatal("ERROR: Event does not exist");   
108     return 0;
109   }
110
111   AliESDEvent *realEvent = dynamic_cast<AliESDEvent*>(ev);
112   if(!realEvent){  
113     AliFatal("ERROR: ESD Event does not exist");
114     return 0;
115   }
116   fCentBin= -1;
117   fGoodEvent = kTRUE;//for p+p collisions if we made it this far we have a good event
118   if(fDataSet==20100||fDataSet==2011){//If this is Pb+Pb or pPb
119     AliCentrality *centrality = realEvent->GetCentrality();
120     if(fNCentBins<21) fCentBin= centrality->GetCentralityClass10(fCentralityMethod);
121     else{ fCentBin= centrality->GetCentralityClass5(fCentralityMethod);}
122     if(fCentBin ==-1){
123       if(fDataSet==2013){
124         fCentBin = 19;//For pPb we don't want to throw these events out but there is no CB 19
125       }
126       else{
127         fGoodEvent = kFALSE;//but for Pb+Pb events we don't want to count events where we did not find a centrality
128       }
129     }
130   }
131   //for PID
132   AliESDpid *pID = new AliESDpid();
133   pID->MakePID(realEvent);
134   TString *strTPC = new TString("TPC");
135   TString *strITS = new TString("ITS");
136   TString *strTPCITS = new TString("TPCITS");
137   for(Int_t cutset=0;cutset<2;cutset++){
138     bool isTPC = false;
139     TString *cutName = NULL;
140     TObjArray* list = NULL;
141     switch(cutset){
142     case 0:
143       cutName = strTPCITS;
144       list = fEsdtrackCutsITSTPC->GetAcceptedTracks(realEvent);
145       isTPC = true;
146       break;
147     case 1:
148       cutName = strITS;
149       list = fEsdtrackCutsITS->GetAcceptedTracks(realEvent);
150       break;
151     case 2:
152       cutName = strTPC;
153       list = fEsdtrackCutsTPC->GetAcceptedTracks(realEvent);
154       break;
155     default:
156       cerr<<"Error:  cannot fill histograms!"<<endl;
157       return -1;
158     }
159     Int_t nGoodTracks = list->GetEntries();
160     for (Int_t iTrack = 0; iTrack < nGoodTracks; iTrack++)
161       {
162
163
164         AliESDtrack *track = dynamic_cast<AliESDtrack*> (list->At(iTrack));
165         if (!track)
166           {
167             Printf("ERROR: Could not get track %d", iTrack);
168             continue;
169           }
170         else{
171           if(TMath::Abs(track->Eta())>fCorrections->GetEtaCut()) continue;
172           Float_t nSigmaPion,nSigmaProton,nSigmaKaon,nSigmaElectron;
173 //        pID->MakeTPCPID(track);
174 //        pID->MakeITSPID(track);
175           //if(!fPIDResponse) cout<<"Uh-oh!  No PID Response!"<<endl;
176           if(cutset!=1){
177             nSigmaPion = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion)); 
178             nSigmaProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton)); 
179             nSigmaKaon =TMath::Abs( fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon)); 
180             nSigmaElectron =TMath::Abs( fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron)); 
181
182 //          nSigmaPion = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kPion));
183 //          nSigmaProton = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kProton));
184 //          nSigmaKaon = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kKaon));
185 //          nSigmaElectron = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kElectron));
186           }
187           else{
188             nSigmaPion = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kPion)); 
189             nSigmaProton = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kProton)); 
190             nSigmaKaon = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kKaon)); 
191             nSigmaElectron = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kElectron)); 
192 //          nSigmaPion = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kPion));
193 //          nSigmaProton = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kProton));
194 //          nSigmaKaon = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kKaon));
195 //          nSigmaElectron = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kElectron));
196           }
197           //cout<<"Nsigma pion "<<nSigmaPion<<" proton "<<nSigmaProton<<" kaon "<<nSigmaKaon<<" electron "<<nSigmaElectron<<endl;
198           //        bool isPion = (nSigmaPion<3.0 && nSigmaProton>2.0 && nSigmaKaon>2.0);
199           //        bool isElectron = (nSigmaElectron<2.0 && nSigmaPion>4.0 && nSigmaProton>3.0 && nSigmaKaon>3.0);
200           //        bool isKaon = (nSigmaPion>3.0 && nSigmaProton>2.0 && nSigmaKaon<2.0);
201           //        bool isProton = (nSigmaPion>3.0 && nSigmaProton<2.0 && nSigmaKaon>2.0);
202           bool isPion = (nSigmaPion<3.0 && nSigmaProton>2.0 && nSigmaKaon>2.0);
203           bool isElectron = (nSigmaElectron<2.0 && nSigmaPion>4.0 && nSigmaProton>3.0 && nSigmaKaon>3.0);
204           bool isKaon = (nSigmaPion>3.0 && nSigmaProton>3.0 && nSigmaKaon<3.0 && track->Pt()<0.45);
205           bool isProton = (nSigmaPion>3.0 && nSigmaProton<3.0 && nSigmaKaon>3.0 && track->Pt()<0.9);
206
207           bool unidentified = (!isProton && !isKaon && !isElectron && !isPion);
208           if(cutset==1){//ITS dE/dx identification requires tighter cuts on the tracks and we don't gain much from that so we won't do it
209             unidentified = true;
210             isPion=false;
211             isElectron=false;
212             isKaon=false;
213             isProton=false;
214           }
215           Float_t dEdx = track->GetTPCsignal();
216           if(cutset==1) dEdx = track->GetITSsignal();
217           FillHisto2D(Form("dEdxDataAll%s",cutName->Data()),track->P(),dEdx,1.0);
218
219           bool inPHOS = IsInPHOS(track);
220           bool inEMCAL = IsInEMCAL(track);
221
222           Float_t corrBkgd=0.0;
223           Float_t corrNotID=0.0;
224           Float_t corrNoID = fCorrections->GetNotIDCorrectionNoPID(track->Pt());
225           Float_t corrEff = 0.0;
226           Float_t corrEffNoID = 0.0;
227           if(cutset!=1){//TPC
228             corrBkgd = fCorrections->GetBackgroundCorrectionTPC(track->Pt());
229             corrEffNoID = fCorrections->GetTPCEfficiencyCorrectionHadron(track->Pt(),fCentBin);
230             corrNotID = fCorrections->GetNotIDConstCorrectionTPC();
231             corrNoID = fCorrections->GetNotIDConstCorrectionTPCNoID();
232           }
233           if(cutset==1){//ITS
234             corrBkgd = fCorrections->GetBackgroundCorrectionITS(track->Pt());
235             corrEffNoID = fCorrections->GetITSEfficiencyCorrectionHadron(track->Pt(),fCentBin);
236             corrNotID = fCorrections->GetNotIDConstCorrectionITS();
237             corrNoID = fCorrections->GetNotIDConstCorrectionITSNoID();
238           }
239           if(fDataSet==20100||fDataSet==2011){
240             FillHisto2D("fbkgdVsCentralityBin",fCentBin,corrBkgd,1.0);
241             FillHisto2D("fnotIDVsCentralityBin",fCentBin,corrNotID,1.0);
242             FillHisto2D("fpTcutVsCentralityBin",fCentBin,fCorrections->GetpTCutCorrectionTPC(),1.0);
243             if(fCorrHadEtFullAcceptanceTPC>0.0) FillHisto2D("fneutralVsCentralityBin",fCentBin,1.0/fCorrHadEtFullAcceptanceTPC,1.0);
244             if(fCorrections->GetNeutralCorrection()>0.0) FillHisto2D("ConstantCorrectionsVsCentralityBin",fCentBin,1.0/fCorrections->GetNeutralCorrection(),1.0);
245           }
246           Float_t et = 0.0;
247           Float_t etNoID = Et(track->P(),track->Theta(),fgPiPlusCode,track->Charge());
248           Float_t etpartialcorrected = 0.0;
249           Float_t etpartialcorrectedPion = 0.0;
250           Float_t etpartialcorrectedKaon = 0.0;
251           Float_t etpartialcorrectedProton = 0.0;
252           Float_t etpartialcorrectedNoID = corrNoID*corrBkgd*corrEffNoID*etNoID;
253           FillHisto2D(Form("EtDataRaw%sNoID",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrectedNoID);
254
255           if(isPion){
256             FillHisto2D(Form("dEdxDataPion%s",cutName->Data()),track->P(),dEdx,1.0);
257             et = Et(track->P(),track->Theta(),fgPiPlusCode,track->Charge());
258             if(cutset==0){corrEff = fCorrections->GetTPCEfficiencyCorrectionPion(track->Pt(),fCentBin);}
259             etpartialcorrected = et*corrBkgd*corrEff*corrNotID;
260             if(corrEff>0.0&&(fDataSet==20100||fDataSet==2011))FillHisto2D("feffPionVsCentralityBin",fCentBin,1.0/corrEff,1.0);
261             if(track->Charge()>0.0){
262               FillHisto2D(Form("EtDataRaw%sPiPlus",cutName->Data()),track->Pt(),track->Eta(),et);
263               FillHisto2D(Form("EtDataCorrected%sPiPlus",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrected);
264             }
265             else{
266               FillHisto2D(Form("EtDataRaw%sPiMinus",cutName->Data()),track->Pt(),track->Eta(),et);
267               FillHisto2D(Form("EtDataCorrected%sPiMinus",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrected);
268             }
269           }
270           if(isKaon){
271             FillHisto2D(Form("dEdxDataKaon%s",cutName->Data()),track->P(),dEdx,1.0);
272             et = Et(track->P(),track->Theta(),fgKPlusCode,track->Charge());
273             if(cutset==0){corrEff = fCorrections->GetTPCEfficiencyCorrectionKaon(track->Pt(),fCentBin);}
274             etpartialcorrected = et*corrBkgd*corrEff*corrNotID;
275             if(corrEff>0.0&&(fDataSet==20100||fDataSet==2011))FillHisto2D("feffKaonVsCentralityBin",fCentBin,1.0/corrEff,1.0);
276               
277             if(track->Charge()>0.0){
278               FillHisto2D(Form("EtDataRaw%sKPlus",cutName->Data()),track->Pt(),track->Eta(),et);
279               FillHisto2D(Form("EtDataCorrected%sKPlus",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrected);
280             }
281             else{
282               FillHisto2D(Form("EtDataRaw%sKMinus",cutName->Data()),track->Pt(),track->Eta(),et);
283               FillHisto2D(Form("EtDataCorrected%sKMinus",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrected);
284             }
285           }
286           if(isProton){
287             FillHisto2D(Form("dEdxDataProton%s",cutName->Data()),track->P(),dEdx,1.0);
288             et = Et(track->P(),track->Theta(),fgProtonCode,track->Charge());
289             if(cutset==0){corrEff = fCorrections->GetTPCEfficiencyCorrectionProton(track->Pt(),fCentBin);}
290             etpartialcorrected = et*corrBkgd*corrEff*corrNotID;
291             if(corrEff>0.0&&(fDataSet==20100||fDataSet==2011))FillHisto2D("feffProtonVsCentralityBin",fCentBin,1.0/corrEff,1.0);
292               
293             if(track->Charge()>0.0){
294               FillHisto2D(Form("EtDataRaw%sProton",cutName->Data()),track->Pt(),track->Eta(),et);
295               FillHisto2D(Form("EtDataCorrected%sProton",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrected);
296             }
297             else{
298               FillHisto2D(Form("EtDataRaw%sAntiProton",cutName->Data()),track->Pt(),track->Eta(),et);
299               FillHisto2D(Form("EtDataCorrected%sAntiProton",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrected);
300             }
301           }
302           if(isElectron){
303             FillHisto2D(Form("dEdxDataElectron%s",cutName->Data()),track->P(),dEdx,1.0);
304           }
305           if(unidentified){
306             if(isPion) cerr<<"I should not be here!!  AliAnalysisHadEtReconstructed 273"<<endl; 
307             FillHisto2D(Form("dEdxDataUnidentified%s",cutName->Data()),track->P(),dEdx,1.0);
308             et = Et(track->P(),track->Theta(),fgPiPlusCode,track->Charge());
309             Float_t etProton = Et(track->P(),track->Theta(),fgProtonCode,track->Charge());
310             Float_t etKaon = Et(track->P(),track->Theta(),fgKPlusCode,track->Charge());
311             if(corrEff>0.0&&(fDataSet==20100||fDataSet==2011))FillHisto2D("feffHadronVsCentralityBin",fCentBin,1.0/corrEff,1.0);
312             etpartialcorrected = et*corrBkgd*corrEffNoID*corrNotID;
313             etpartialcorrectedPion = et*corrBkgd*corrEffNoID;
314             etpartialcorrectedProton = etProton*corrBkgd*corrEffNoID;
315             etpartialcorrectedKaon = etKaon*corrBkgd*corrEffNoID;
316             FillHisto2D(Form("EtDataCorrected%sUnidentified",cutName->Data()),track->Pt(),track->Eta(),etpartialcorrected);
317           }
318           else{
319             etpartialcorrectedPion = etpartialcorrected;
320             etpartialcorrectedKaon = etpartialcorrected;
321             etpartialcorrectedProton = etpartialcorrected;
322           }
323           if(!isTPC){
324             etpartialcorrected = etpartialcorrectedNoID;//Not using PID for ITS
325           }
326           AddEt(et,etNoID,etpartialcorrected,etpartialcorrectedPion,etpartialcorrectedProton,etpartialcorrectedKaon,etpartialcorrectedNoID,track->Pt(),isTPC,inPHOS,inEMCAL);
327         }
328       }
329     delete list;
330   }
331
332   Int_t nondiff = 0;//(Int_t) AliPWG0Helper::kND;
333   Int_t doublediff = 0;//(Int_t) AliPWG0Helper::kDD;
334   Int_t singlediff = 0;//(Int_t) AliPWG0Helper::kSD;
335   if(fDataSet!=20100 && fDataSet!=2011){
336     nondiff = (Int_t) AliPWG0Helper::kND;
337     doublediff = (Int_t) AliPWG0Helper::kDD;
338     singlediff = (Int_t) AliPWG0Helper::kSD;
339   }
340   if(eventtype == nondiff && fGoodEvent){
341     FillHisto1D("RecoHadEtFullAcceptanceTPCND",GetCorrectedHadEtFullAcceptanceTPC(),1.0);
342     FillHisto1D("RecoPiKPEtFullAcceptanceTPCND",GetCorrectedPiKPEtFullAcceptanceTPC(),1.0);
343     FillHisto1D("RecoTotEtFullAcceptanceTPCND",GetCorrectedTotEtFullAcceptanceTPC(),1.0);
344     FillHisto1D("RecoHadEtFullAcceptanceITSND",GetCorrectedHadEtFullAcceptanceITS(),1.0);
345     FillHisto1D("RecoPiKPEtFullAcceptanceITSND",GetCorrectedPiKPEtFullAcceptanceITS(),1.0);
346     FillHisto1D("RecoTotEtFullAcceptanceITSND",GetCorrectedTotEtFullAcceptanceITS(),1.0);
347     FillHisto1D("RecoHadEtFullAcceptanceTPCNoPIDND",GetCorrectedHadEtFullAcceptanceTPCNoPID(),1.0);
348     FillHisto1D("RecoPiKPEtFullAcceptanceTPCNoPIDND",GetCorrectedPiKPEtFullAcceptanceTPCNoPID(),1.0);
349     FillHisto1D("RecoTotEtFullAcceptanceTPCNoPIDND",GetCorrectedTotEtFullAcceptanceTPCNoPID(),1.0);
350     FillHisto1D("RecoHadEtFullAcceptanceITSNoPIDND",GetCorrectedHadEtFullAcceptanceITSNoPID(),1.0);
351     FillHisto1D("RecoPiKPEtFullAcceptanceITSNoPIDND",GetCorrectedPiKPEtFullAcceptanceITSNoPID(),1.0);
352     FillHisto1D("RecoTotEtFullAcceptanceITSNoPIDND",GetCorrectedTotEtFullAcceptanceITSNoPID(),1.0);
353
354     FillHisto1D("RecoRawEtFullAcceptanceTPCND",GetRawEtFullAcceptanceTPC(),1.0);
355     FillHisto1D("RecoRawEtFullAcceptanceTPCNoPIDND",GetRawEtFullAcceptanceTPCNoPID(),1.0);
356     FillHisto1D("RecoRawEtFullAcceptanceITSND",GetRawEtFullAcceptanceITS(),1.0);
357     FillHisto1D("RecoRawEtFullAcceptanceITSNoPIDND",GetRawEtFullAcceptanceITSNoPID(),1.0);
358
359   }
360   if(eventtype == doublediff){
361     FillHisto1D("RecoHadEtFullAcceptanceTPCDD",GetCorrectedHadEtFullAcceptanceTPC(),1.0);
362     FillHisto1D("RecoPiKPEtFullAcceptanceTPCDD",GetCorrectedPiKPEtFullAcceptanceTPC(),1.0);
363     FillHisto1D("RecoTotEtFullAcceptanceTPCDD",GetCorrectedTotEtFullAcceptanceTPC(),1.0);
364     FillHisto1D("RecoPiKPEtFullAcceptanceITSDD",GetCorrectedPiKPEtFullAcceptanceITS(),1.0);
365     FillHisto1D("RecoHadEtFullAcceptanceITSDD",GetCorrectedHadEtFullAcceptanceITS(),1.0);
366     FillHisto1D("RecoTotEtFullAcceptanceITSDD",GetCorrectedTotEtFullAcceptanceITS(),1.0);
367     FillHisto1D("RecoHadEtFullAcceptanceTPCNoPIDDD",GetCorrectedHadEtFullAcceptanceTPCNoPID(),1.0);
368     FillHisto1D("RecoPiKPEtFullAcceptanceTPCNoPIDDD",GetCorrectedPiKPEtFullAcceptanceTPCNoPID(),1.0);
369     FillHisto1D("RecoTotEtFullAcceptanceTPCNoPIDDD",GetCorrectedTotEtFullAcceptanceTPCNoPID(),1.0);
370     FillHisto1D("RecoHadEtFullAcceptanceITSNoPIDDD",GetCorrectedHadEtFullAcceptanceITSNoPID(),1.0);
371     FillHisto1D("RecoPiKPEtFullAcceptanceITSNoPIDDD",GetCorrectedPiKPEtFullAcceptanceITSNoPID(),1.0);
372     FillHisto1D("RecoTotEtFullAcceptanceITSNoPIDDD",GetCorrectedTotEtFullAcceptanceITSNoPID(),1.0);
373     FillHisto1D("RecoRawEtFullAcceptanceTPCDD",GetRawEtFullAcceptanceTPC(),1.0);
374     FillHisto1D("RecoRawEtFullAcceptanceTPCNoPIDDD",GetRawEtFullAcceptanceTPCNoPID(),1.0);
375     FillHisto1D("RecoRawEtFullAcceptanceITSDD",GetRawEtFullAcceptanceITS(),1.0);
376     FillHisto1D("RecoRawEtFullAcceptanceITSNoPIDDD",GetRawEtFullAcceptanceITSNoPID(),1.0);//ND
377   }
378   if(eventtype == singlediff){
379     FillHisto1D("RecoPiKPEtFullAcceptanceTPCSD",GetCorrectedPiKPEtFullAcceptanceTPC(),1.0);
380     FillHisto1D("RecoHadEtFullAcceptanceTPCSD",GetCorrectedHadEtFullAcceptanceTPC(),1.0);
381     FillHisto1D("RecoTotEtFullAcceptanceTPCSD",GetCorrectedTotEtFullAcceptanceTPC(),1.0);
382     FillHisto1D("RecoHadEtFullAcceptanceITSSD",GetCorrectedHadEtFullAcceptanceITS(),1.0);
383     FillHisto1D("RecoPiKPEtFullAcceptanceITSSD",GetCorrectedPiKPEtFullAcceptanceITS(),1.0);
384     FillHisto1D("RecoTotEtFullAcceptanceITSSD",GetCorrectedTotEtFullAcceptanceITS(),1.0);
385     FillHisto1D("RecoHadEtFullAcceptanceTPCNoPIDSD",GetCorrectedHadEtFullAcceptanceTPCNoPID(),1.0);
386     FillHisto1D("RecoPiKPEtFullAcceptanceTPCNoPIDSD",GetCorrectedPiKPEtFullAcceptanceTPCNoPID(),1.0);
387     FillHisto1D("RecoTotEtFullAcceptanceTPCNoPIDSD",GetCorrectedTotEtFullAcceptanceTPCNoPID(),1.0);
388     FillHisto1D("RecoHadEtFullAcceptanceITSNoPIDSD",GetCorrectedHadEtFullAcceptanceITSNoPID(),1.0);
389     FillHisto1D("RecoPiKPEtFullAcceptanceITSNoPIDSD",GetCorrectedPiKPEtFullAcceptanceITSNoPID(),1.0);
390     FillHisto1D("RecoTotEtFullAcceptanceITSNoPIDSD",GetCorrectedTotEtFullAcceptanceITSNoPID(),1.0);
391     FillHisto1D("RecoRawEtFullAcceptanceTPCSD",GetRawEtFullAcceptanceTPC(),1.0);
392     FillHisto1D("RecoRawEtFullAcceptanceTPCNoPIDSD",GetRawEtFullAcceptanceTPCNoPID(),1.0);
393     FillHisto1D("RecoRawEtFullAcceptanceITSSD",GetRawEtFullAcceptanceITS(),1.0);
394     FillHisto1D("RecoRawEtFullAcceptanceITSNoPIDSD",GetRawEtFullAcceptanceITSNoPID(),1.0);
395   }
396   if(fGoodEvent){
397     FillHisto1D("RecoPiKPEtFullAcceptanceTPC",GetCorrectedPiKPEtFullAcceptanceTPC(),1.0);
398     FillHisto1D("RecoPiKPEtFullAcceptanceITS",GetCorrectedPiKPEtFullAcceptanceITS(),1.0);
399     FillHisto1D("RecoPiKPEtFullAcceptanceTPCNoPID",GetCorrectedPiKPEtFullAcceptanceTPCNoPID(),1.0);
400     FillHisto1D("RecoPiKPEtFullAcceptanceITSNoPID",GetCorrectedPiKPEtFullAcceptanceITSNoPID(),1.0);
401     FillHisto1D("RecoHadEtFullAcceptanceTPC",GetCorrectedHadEtFullAcceptanceTPC(),1.0);
402     FillHisto1D("RecoTotEtFullAcceptanceTPC",GetCorrectedTotEtFullAcceptanceTPC(),1.0);
403     FillHisto1D("RecoHadEtFullAcceptanceTPCAssumingPion",GetCorrectedHadEtFullAcceptanceTPCAssumingPion(),1.0);
404     FillHisto1D("RecoHadEtFullAcceptanceTPCAssumingProton",GetCorrectedHadEtFullAcceptanceTPCAssumingProton(),1.0);
405     FillHisto1D("RecoHadEtFullAcceptanceTPCAssumingKaon",GetCorrectedHadEtFullAcceptanceTPCAssumingKaon(),1.0);
406     FillHisto1D("RecoHadEtEMCALAcceptanceTPC",GetCorrectedHadEtEMCALAcceptanceTPC(),1.0);
407     FillHisto1D("RecoTotEtEMCALAcceptanceTPC",GetCorrectedTotEtEMCALAcceptanceTPC(),1.0);
408     FillHisto1D("RecoHadEtPHOSAcceptanceTPC",GetCorrectedHadEtPHOSAcceptanceTPC(),1.0);
409     FillHisto1D("RecoTotEtPHOSAcceptanceTPC",GetCorrectedTotEtPHOSAcceptanceTPC(),1.0);
410     FillHisto1D("RecoHadEtFullAcceptanceTPCNoPID",GetCorrectedHadEtFullAcceptanceTPCNoPID(),1.0);
411     FillHisto1D("RecoTotEtFullAcceptanceTPCNoPID",GetCorrectedTotEtFullAcceptanceTPCNoPID(),1.0);
412     FillHisto1D("RecoHadEtEMCALAcceptanceTPCNoPID",GetCorrectedHadEtEMCALAcceptanceTPCNoPID(),1.0);
413     FillHisto1D("RecoTotEtEMCALAcceptanceTPCNoPID",GetCorrectedTotEtEMCALAcceptanceTPCNoPID(),1.0);
414     FillHisto1D("RecoHadEtPHOSAcceptanceTPCNoPID",GetCorrectedHadEtPHOSAcceptanceTPCNoPID(),1.0);
415     FillHisto1D("RecoTotEtPHOSAcceptanceTPCNoPID",GetCorrectedTotEtPHOSAcceptanceTPCNoPID(),1.0);
416     FillHisto1D("RecoHadEtFullAcceptanceITS",GetCorrectedHadEtFullAcceptanceITS(),1.0);
417     FillHisto1D("RecoHadEtFullAcceptanceITSAssumingPion",GetCorrectedHadEtFullAcceptanceITSAssumingPion(),1.0);
418     FillHisto1D("RecoHadEtFullAcceptanceITSAssumingProton",GetCorrectedHadEtFullAcceptanceITSAssumingProton(),1.0);
419     FillHisto1D("RecoHadEtFullAcceptanceITSAssumingKaon",GetCorrectedHadEtFullAcceptanceITSAssumingKaon(),1.0);
420     FillHisto1D("RecoTotEtFullAcceptanceITS",GetCorrectedTotEtFullAcceptanceITS(),1.0);
421     FillHisto1D("RecoHadEtEMCALAcceptanceITS",GetCorrectedHadEtEMCALAcceptanceITS(),1.0);
422     FillHisto1D("RecoTotEtEMCALAcceptanceITS",GetCorrectedTotEtEMCALAcceptanceITS(),1.0);
423     FillHisto1D("RecoHadEtPHOSAcceptanceITS",GetCorrectedHadEtPHOSAcceptanceITS(),1.0);
424     FillHisto1D("RecoTotEtPHOSAcceptanceITS",GetCorrectedTotEtPHOSAcceptanceITS(),1.0);
425     FillHisto1D("RecoHadEtFullAcceptanceITSNoPID",GetCorrectedHadEtFullAcceptanceITSNoPID(),1.0);
426     FillHisto1D("RecoTotEtFullAcceptanceITSNoPID",GetCorrectedTotEtFullAcceptanceITSNoPID(),1.0);
427     FillHisto1D("RecoHadEtEMCALAcceptanceITSNoPID",GetCorrectedHadEtEMCALAcceptanceITSNoPID(),1.0);
428     FillHisto1D("RecoTotEtEMCALAcceptanceITSNoPID",GetCorrectedTotEtEMCALAcceptanceITSNoPID(),1.0);
429     FillHisto1D("RecoHadEtPHOSAcceptanceITSNoPID",GetCorrectedHadEtPHOSAcceptanceITSNoPID(),1.0);
430     FillHisto1D("RecoTotEtPHOSAcceptanceITSNoPID",GetCorrectedTotEtPHOSAcceptanceITSNoPID(),1.0);
431
432     FillHisto1D("RecoRawEtFullAcceptanceTPC",GetRawEtFullAcceptanceTPC(),1.0);
433     FillHisto1D("RecoRawEtEMCALAcceptanceTPC",GetRawEtEMCALAcceptanceTPC(),1.0);
434     FillHisto1D("RecoRawEtPHOSAcceptanceTPC",GetRawEtPHOSAcceptanceTPC(),1.0);
435     FillHisto1D("RecoRawEtFullAcceptanceTPCNoPID",GetRawEtFullAcceptanceTPCNoPID(),1.0);
436     FillHisto1D("RecoRawEtEMCALAcceptanceTPCNoPID",GetRawEtEMCALAcceptanceTPCNoPID(),1.0);
437     FillHisto1D("RecoRawEtPHOSAcceptanceTPCNoPID",GetRawEtPHOSAcceptanceTPCNoPID(),1.0);
438     FillHisto1D("RecoRawEtFullAcceptanceITS",GetRawEtFullAcceptanceITS(),1.0);
439     FillHisto1D("RecoRawEtEMCALAcceptanceITS",GetRawEtEMCALAcceptanceITS(),1.0);
440     FillHisto1D("RecoRawEtPHOSAcceptanceITS",GetRawEtPHOSAcceptanceITS(),1.0);
441     FillHisto1D("RecoRawEtFullAcceptanceITSNoPID",GetRawEtFullAcceptanceITSNoPID(),1.0);
442     FillHisto1D("RecoRawEtEMCALAcceptanceITSNoPID",GetRawEtEMCALAcceptanceITSNoPID(),1.0);
443     FillHisto1D("RecoRawEtPHOSAcceptanceITSNoPID",GetRawEtPHOSAcceptanceITSNoPID(),1.0);
444     if(fCentBin>-1){//if we have Pb+Pb and found a centrality bin
445       FillHisto1D(Form("RecoHadEtFullAcceptanceTPCCB%i",fCentBin),GetCorrectedHadEtFullAcceptanceTPC(),1.0);
446       FillHisto1D(Form("RecoTotEtFullAcceptanceTPCCB%i",fCentBin),GetCorrectedTotEtFullAcceptanceTPC(),1.0);
447       FillHisto1D(Form("RecoHadEtFullAcceptanceITSCB%i",fCentBin),GetCorrectedHadEtFullAcceptanceITS(),1.0);
448       FillHisto1D(Form("RecoTotEtFullAcceptanceITSCB%i",fCentBin),GetCorrectedTotEtFullAcceptanceITS(),1.0);
449       FillHisto1D(Form("RecoRawEtFullAcceptanceTPCCB%i",fCentBin),GetRawEtFullAcceptanceTPC(),1.0);
450       FillHisto1D(Form("RecoRawEtFullAcceptanceITSCB%i",fCentBin),GetRawEtFullAcceptanceITS(),1.0);
451     }
452   }
453   delete pID;
454   delete strTPC;
455   delete strITS;
456   delete strTPCITS;
457   // cout<<"Reconstructed pi/k/p et "<<GetCorrectedPiKPEtFullAcceptanceTPC()<<endl;
458   return 1;
459 }
460 void AliAnalysisHadEtReconstructed::AddEt(Float_t rawEt, Float_t rawEtNoPID, Float_t corrEt, Float_t corrEtPion, Float_t corrEtProton, Float_t corrEtKaon, Float_t corrEtNoPID, Float_t pt, Bool_t IsTPC, Bool_t InPHOS, Bool_t InEMCAL) {//Adding Et to each of the variables that tracks et event by event
461   if(pt>=AliAnalysisHadEt::fgPtTPCCutOff && IsTPC){//TPC tracks
462     //adding to the raw Et
463     fRawEtFullAcceptanceTPC += rawEt;
464     if(InPHOS)fRawEtPHOSAcceptanceTPC += rawEt;
465     if(InEMCAL)fRawEtEMCALAcceptanceTPC += rawEt;
466     fRawEtFullAcceptanceTPCNoPID += rawEtNoPID;
467     if(InPHOS)fRawEtPHOSAcceptanceTPCNoPID += rawEtNoPID;
468     if(InEMCAL)fRawEtEMCALAcceptanceTPCNoPID += rawEtNoPID;
469     //adding to the corrected Et
470     fCorrectedHadEtFullAcceptanceTPC += corrEt;//the pi/k/p et
471     fCorrectedHadEtFullAcceptanceTPCAssumingPion += corrEtPion;
472     fCorrectedHadEtFullAcceptanceTPCAssumingProton += corrEtProton;
473     fCorrectedHadEtFullAcceptanceTPCAssumingKaon += corrEtKaon;
474     if(InPHOS)fCorrectedHadEtPHOSAcceptanceTPC += corrEt;
475     if(InEMCAL)fCorrectedHadEtEMCALAcceptanceTPC += corrEt;
476     fCorrectedHadEtFullAcceptanceTPCNoPID += corrEtNoPID;
477     if(InPHOS)fCorrectedHadEtPHOSAcceptanceTPCNoPID += corrEtNoPID;
478     if(InEMCAL)fCorrectedHadEtEMCALAcceptanceTPCNoPID += corrEtNoPID;
479   }
480   //if(pt<AliAnalysisHadEt::fgPtTPCCutOff &&pt>=AliAnalysisHadEt::fgPtITSCutOff && !IsTPC){//ITS tracks
481   //If we use standalone tracks - not pure standalone tracks - the only tracks we get are ones that were missed by the TPC+ITS tracking.  Therefore we don't need to add a momentum cut-off
482   if(pt<AliAnalysisHadEt::fgPtTPCCutOff && !IsTPC){//ITS tracks
483     //adding to the raw Et
484     fRawEtFullAcceptanceITS += rawEt;
485     if(InPHOS)fRawEtPHOSAcceptanceITS += rawEt;
486     if(InEMCAL)fRawEtEMCALAcceptanceITS += rawEt;
487     fRawEtFullAcceptanceITSNoPID += rawEtNoPID;
488     if(InPHOS)fRawEtPHOSAcceptanceITSNoPID += rawEtNoPID;
489     if(InEMCAL)fRawEtEMCALAcceptanceITSNoPID += rawEtNoPID;
490     //adding to the corrected Et
491     fCorrectedHadEtFullAcceptanceITS += corrEt;
492     fCorrectedHadEtFullAcceptanceITSAssumingPion += corrEtPion;
493     fCorrectedHadEtFullAcceptanceITSAssumingProton += corrEtProton;
494     fCorrectedHadEtFullAcceptanceITSAssumingKaon += corrEtKaon;
495     if(InPHOS)fCorrectedHadEtPHOSAcceptanceITS += corrEt;
496     if(InEMCAL)fCorrectedHadEtEMCALAcceptanceITS += corrEt;
497     fCorrectedHadEtFullAcceptanceITSNoPID += corrEtNoPID;
498     if(InPHOS)fCorrectedHadEtPHOSAcceptanceITSNoPID += corrEtNoPID;
499     if(InEMCAL)fCorrectedHadEtEMCALAcceptanceITSNoPID += corrEtNoPID;
500   }
501 }
502
503 Bool_t AliAnalysisHadEtReconstructed::IsInPHOS(AliESDtrack *track){//This function will need to be elaborated on later to include PHOS dead channels
504   if(!track){
505     cout<<"Error: Track does not exist!!"<<endl;
506     return kFALSE;
507   }
508   return   TMath::Abs(track->Eta()) < fCuts->GetGeometryPhosEtaAccCut()//in eta acceptance
509     && track->Phi()*180.0/TMath::Pi() > fCuts->GetGeometryPhosPhiAccMinCut()//greater than the minimum phi
510     && track->Phi()*180.0/TMath::Pi() < fCuts->GetGeometryPhosPhiAccMaxCut();//less than the maximum phi
511 }
512 Bool_t AliAnalysisHadEtReconstructed::IsInEMCAL(AliESDtrack *track){//This function will need to be elaborated on later to include EMCAL dead channels
513   if(!track){
514     cout<<"Error: Track does not exist!!"<<endl;
515     return kFALSE;
516   }
517   return   TMath::Abs(track->Eta()) < fCuts->GetGeometryEmcalEtaAccCut()//in eta acceptance
518     && track->Phi()*180.0/TMath::Pi() > fCuts->GetGeometryEmcalPhiAccMinCut()//greater than the minimum phi
519     && track->Phi()*180.0/TMath::Pi() < fCuts->GetGeometryEmcalPhiAccMaxCut();//less than the maximum phi
520 }
521 Bool_t AliAnalysisHadEtReconstructed::CheckGoodVertex(AliVParticle* track)
522 { // check vertex
523
524   Float_t bxy = 999.;
525   Float_t bz = 999.;
526   if(!track){
527     AliError("ERROR: no track");
528     return kFALSE;
529   }
530   AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
531   if(!esdTrack){
532     AliError("ERROR: no track");
533     return kFALSE;
534   }
535   esdTrack->GetImpactParametersTPC(bxy,bz);
536
537   bool status = (TMath::Abs(track->Xv()) < fCuts->GetReconstructedVertexXCut()) && 
538     (TMath::Abs(track->Yv()) < fCuts->GetReconstructedVertexYCut()) && 
539     (TMath::Abs(track->Zv()) < fCuts->GetReconstructedVertexZCut()) && 
540     (TMath::Abs(bxy) < fCuts->GetReconstructedIPxyCut()) && 
541     (TMath::Abs(bz) < fCuts->GetReconstructedIPzCut()); 
542
543   return status;
544 }
545
546 void AliAnalysisHadEtReconstructed::Init()
547 { // Init
548   AliAnalysisHadEt::Init();
549   if(fCorrections){
550     fCorrTotEtFullAcceptanceTPC = fCorrections->GetConstantCorrections(kTRUE,fgPtTPCCutOff,"Full");
551     fCorrTotEtFullAcceptanceITS = fCorrections->GetConstantCorrections(kTRUE,fgPtITSCutOff,"Full");
552     fCorrHadEtFullAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"Full");
553     fCorrHadEtFullAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"Full");
554     fCorrPiKPEtFullAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"PiKP");
555     fCorrPiKPEtFullAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"PiKP");
556     fCorrTotEtEMCALAcceptanceTPC = fCorrections->GetConstantCorrections(kTRUE,fgPtTPCCutOff,"EMCAL");
557     fCorrTotEtEMCALAcceptanceITS = fCorrections->GetConstantCorrections(kTRUE,fgPtITSCutOff,"EMCAL");
558     fCorrHadEtEMCALAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"EMCAL");
559     fCorrHadEtEMCALAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"EMCAL");
560     fCorrTotEtPHOSAcceptanceTPC = fCorrections->GetConstantCorrections(kTRUE,fgPtTPCCutOff,"PHOS");
561     fCorrTotEtPHOSAcceptanceITS = fCorrections->GetConstantCorrections(kTRUE,fgPtITSCutOff,"PHOS");
562     fCorrHadEtPHOSAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"PHOS");
563     fCorrHadEtPHOSAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"PHOS");
564   }
565   else{
566     cout<<"Warning!  You have not set corrections.  Your code will crash.  You have to set the corrections."<<endl;
567   }
568 }
569
570 void AliAnalysisHadEtReconstructed::ResetEventValues(){//resetting event by event et's
571   AliAnalysisHadEt::ResetEventValues();
572   fCorrectedHadEtFullAcceptanceTPCNoPID=0.0;
573   fCorrectedHadEtFullAcceptanceITSNoPID=0.0;
574   fCorrectedHadEtEMCALAcceptanceTPCNoPID=0.0;
575   fCorrectedHadEtEMCALAcceptanceITSNoPID=0.0;
576   fCorrectedHadEtPHOSAcceptanceTPCNoPID=0.0;
577   fCorrectedHadEtPHOSAcceptanceITSNoPID=0.0;
578   fCorrectedHadEtFullAcceptanceTPC=0.0;
579   fCorrectedHadEtFullAcceptanceITS=0.0;
580   fCorrectedHadEtFullAcceptanceTPCAssumingPion=0.0;
581   fCorrectedHadEtFullAcceptanceITSAssumingPion=0.0;
582   fCorrectedHadEtFullAcceptanceTPCAssumingProton=0.0;
583   fCorrectedHadEtFullAcceptanceITSAssumingProton=0.0;
584   fCorrectedHadEtFullAcceptanceTPCAssumingKaon=0.0;
585   fCorrectedHadEtFullAcceptanceITSAssumingKaon=0.0;
586   fCorrectedHadEtEMCALAcceptanceTPC=0.0;
587   fCorrectedHadEtEMCALAcceptanceITS=0.0;
588   fCorrectedHadEtPHOSAcceptanceTPC=0.0;
589   fCorrectedHadEtPHOSAcceptanceITS=0.0;
590   fRawEtFullAcceptanceTPC=0.0;
591   fRawEtFullAcceptanceITS=0.0;
592   fRawEtEMCALAcceptanceTPC=0.0;
593   fRawEtEMCALAcceptanceITS=0.0;
594   fRawEtPHOSAcceptanceTPC=0.0;
595   fRawEtPHOSAcceptanceITS=0.0;
596   fRawEtFullAcceptanceTPCNoPID=0.0;
597   fRawEtFullAcceptanceITSNoPID=0.0;
598   fRawEtEMCALAcceptanceTPCNoPID=0.0;
599   fRawEtEMCALAcceptanceITSNoPID=0.0;
600   fRawEtPHOSAcceptanceTPCNoPID=0.0;
601   fRawEtPHOSAcceptanceITSNoPID=0.0;
602
603   if(TMath::Abs(fCorrTotEtFullAcceptanceTPC)<1e-3){
604     if (fConfigFile.Length()) {
605       cout<<"Warning: Rereading fCorrections file..."<<endl;
606       gROOT->LoadMacro(fConfigFile);
607       fCorrections = (AliAnalysisHadEtCorrections *) gInterpreter->ProcessLine("ConfigHadEtAnalysis()");
608       fCorrTotEtFullAcceptanceTPC = fCorrections->GetConstantCorrections(kTRUE,fgPtTPCCutOff,"Full");
609       fCorrTotEtFullAcceptanceITS = fCorrections->GetConstantCorrections(kTRUE,fgPtITSCutOff,"Full");
610       fCorrHadEtFullAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"Full");
611       fCorrHadEtFullAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"Full");
612       fCorrPiKPEtFullAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"PiKP");
613       fCorrPiKPEtFullAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"PiKP");
614       fCorrTotEtEMCALAcceptanceTPC = fCorrections->GetConstantCorrections(kTRUE,fgPtTPCCutOff,"EMCAL");
615       fCorrTotEtEMCALAcceptanceITS = fCorrections->GetConstantCorrections(kTRUE,fgPtITSCutOff,"EMCAL");
616       fCorrHadEtEMCALAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"EMCAL");
617       fCorrHadEtEMCALAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"EMCAL");
618       fCorrTotEtPHOSAcceptanceTPC = fCorrections->GetConstantCorrections(kTRUE,fgPtTPCCutOff,"PHOS");
619       fCorrTotEtPHOSAcceptanceITS = fCorrections->GetConstantCorrections(kTRUE,fgPtITSCutOff,"PHOS");
620       fCorrHadEtPHOSAcceptanceTPC = fCorrections->GetConstantCorrections(kFALSE,fgPtTPCCutOff,"PHOS");
621       fCorrHadEtPHOSAcceptanceITS = fCorrections->GetConstantCorrections(kFALSE,fgPtITSCutOff,"PHOS");
622     }
623     else{cerr<<"Uh-oh!  Unable to open configuration file!"<<endl;}
624   }
625 }
626 void AliAnalysisHadEtReconstructed::CreateHistograms(){//Creating histograms and adding them to the output TList
627
628   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
629   if (!man) {
630     AliFatal("Analysis manager needed");
631     return;
632   }
633   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
634   if (!inputHandler) {
635     AliFatal("Input handler needed");
636     return;
637   }
638
639   //pid response object
640   fPIDResponse=inputHandler->GetPIDResponse();
641   if (!fPIDResponse) AliError("PIDResponse object was not created");
642
643
644   if(kDoTriggerChecksOnly){return;}//In this case we are just after trigger efficiencies and don't care about the ET reconstructed.
645   //TString *strTPC = new TString("TPC");
646   TString *strITS = new TString("ITS");
647   TString *strTPCITS = new TString("TPCITS");
648   for(Int_t i=0;i<2;i++){
649     TString *cutName = NULL;
650     Float_t maxPtdEdx = 10;
651     Float_t mindEdx = 35;
652     Float_t maxdEdx = 150.0;
653     switch(i){
654     case 0:
655       cutName = strTPCITS;
656       break;
657     case 1:
658       cutName = strITS;
659       maxPtdEdx = 5;
660       maxdEdx = 500.0;
661       break;
662       //not deleting this completely since we might want to add it back in later
663       //     case 2:
664       //       cutName = strTPC;
665       //       maxPtdEdx = 5;
666       //       maxdEdx = 500.0;
667       //       break;
668     default:
669       cerr<<"Error:  cannot make histograms!"<<endl;
670       return;
671     }
672
673     CreateEtaPtHisto2D(Form("EtDataRaw%sPiPlus",cutName->Data()),"Raw reconstructed E_{T} from identified #pi^{+}");
674     CreateEtaPtHisto2D(Form("EtDataRaw%sPiMinus",cutName->Data()),"Raw reconstructed E_{T} from identified #pi^{-}");
675     CreateEtaPtHisto2D(Form("EtDataRaw%sKPlus",cutName->Data()),"Raw reconstructed E_{T} from identified K^{+}");
676     //     CreateEtaPtHisto2D(Form("EtDataRaw%sEMinus",cutName->Data()),"Raw reconstructed E_{T} from identified e^{-}");
677     //     CreateEtaPtHisto2D(Form("EtDataRaw%sEPlus",cutName->Data()),"Raw reconstructed E_{T} from identified e^{+}");
678     CreateEtaPtHisto2D(Form("EtDataRaw%sKMinus",cutName->Data()),"Raw reconstructed E_{T} from identified K^{-}");
679     CreateEtaPtHisto2D(Form("EtDataRaw%sProton",cutName->Data()),"Raw reconstructed E_{T} from identified p");
680     CreateEtaPtHisto2D(Form("EtDataRaw%sAntiProton",cutName->Data()),"Raw reconstructed E_{T} from identified #bar{p}");
681     CreateEtaPtHisto2D(Form("EtDataRaw%sUnidentified",cutName->Data()),"Raw reconstructed E_{T} from unidentified particles using real mass");
682     CreateEtaPtHisto2D(Form("EtDataRaw%sNoID",cutName->Data()),"Raw reconstructed E_{T} from unidentified particles using real mass");
683
684     CreateEtaPtHisto2D(Form("EtDataCorrected%sPiPlus",cutName->Data()),"Corrected reconstructed E_{T} from identified #pi^{+}");
685     CreateEtaPtHisto2D(Form("EtDataCorrected%sPiMinus",cutName->Data()),"Corrected reconstructed E_{T} from identified #pi^{-}");
686     CreateEtaPtHisto2D(Form("EtDataCorrected%sKPlus",cutName->Data()),"Corrected reconstructed E_{T} from identified K^{+}");
687     //     CreateEtaPtHisto2D(Form("EtDataCorrected%sEMinus",cutName->Data()),"Corrected reconstructed E_{T} from identified e^{-}");
688     //     CreateEtaPtHisto2D(Form("EtDataCorrected%sEPlus",cutName->Data()),"Corrected reconstructed E_{T} from identified e^{+}");
689     CreateEtaPtHisto2D(Form("EtDataCorrected%sKMinus",cutName->Data()),"Corrected reconstructed E_{T} from identified K^{-}");
690     CreateEtaPtHisto2D(Form("EtDataCorrected%sProton",cutName->Data()),"Corrected reconstructed E_{T} from identified p");
691     CreateEtaPtHisto2D(Form("EtDataCorrected%sAntiProton",cutName->Data()),"Corrected reconstructed E_{T} from identified #bar{p}");
692     CreateEtaPtHisto2D(Form("EtDataCorrected%sUnidentified",cutName->Data()),"Corrected reconstructed E_{T} from unidentified particles using real mass");
693     CreateEtaPtHisto2D(Form("EtDataCorrected%sNoID",cutName->Data()),"Corrected reconstructed E_{T} from unidentified particles using real mass");
694
695
696     CreateEtaPtHisto2D(Form("EtNData%sPiPlus",cutName->Data()),"Number of reconstructed #pi^{+}");
697     CreateEtaPtHisto2D(Form("EtNData%sPiMinus",cutName->Data()),"Number of reconstructed #pi^{-}");
698     CreateEtaPtHisto2D(Form("EtNData%sKPlus",cutName->Data()),"Number of reconstructed K^{+}");
699     CreateEtaPtHisto2D(Form("EtNData%sKMinus",cutName->Data()),"Number of reconstructed K^{-}");
700     CreateEtaPtHisto2D(Form("EtNData%sProton",cutName->Data()),"Number of reconstructed p");
701     CreateEtaPtHisto2D(Form("EtNData%sAntiProton",cutName->Data()),"Number of reconstructed #bar{p}");
702     CreateEtaPtHisto2D(Form("EtNData%sUnidentified",cutName->Data()),"Number of Reconstructed unidentified particles");
703
704     CreateHisto2D(Form("dEdxDataAll%s",cutName->Data()),"dE/dx for all particles","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
705     CreateHisto2D(Form("dEdxDataPion%s",cutName->Data()),"dE/dx for #pi^{#pm}","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
706     CreateHisto2D(Form("dEdxDataKaon%s",cutName->Data()),"dE/dx for K^{#pm}","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
707     CreateHisto2D(Form("dEdxDataProton%s",cutName->Data()),"dE/dx for p(#bar{p})","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
708     CreateHisto2D(Form("dEdxDataElectron%s",cutName->Data()),"dE/dx for e^{#pm}","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
709     CreateHisto2D(Form("dEdxDataUnidentified%s",cutName->Data()),"dE/dx for unidentified particles","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
710   }
711
712   Float_t minEt = 0.0;
713   Float_t maxEt = 100.0;
714   Float_t minEtPiKP = 0.0;
715   Float_t maxEtPiKP = 100.0;
716   if(fDataSet==20100||fDataSet==2011){
717     maxEt=4000.0;
718     maxEtPiKP = 2500;
719   }
720   if(fDataSet==2013){
721     maxEt=100.0;
722     maxEtPiKP = 100.0;
723   }
724   Int_t nbinsEt = 200;
725   char histoname[200];
726   char histotitle[200];
727   char xtitle[50];
728   TString *ytitle = new TString("Number of events");
729   TString *sTPC = new TString("TPC");
730   TString *sITS = new TString("ITS");
731   TString *sTPCpt = new TString("0.15");
732   TString *sITSpt = new TString("0.10");
733   TString *sPID = new TString("");
734   TString *sNoPID = new TString("NoPID");
735   TString *sNoPIDString = new TString(", No PID");
736   TString *sHadEt = new TString("HadEt");
737   TString *sPiKPEt = new TString("PiKPEt");
738   TString *sRawEt = new TString("RawEt");
739   TString *sTotEt = new TString("TotEt");
740   TString *sTotEtString = new TString("total E_{T}");
741   TString *sHadEtString = new TString("hadronic E_{T}");
742   TString *sPiKPEtString = new TString("E_{T}^{#pi,K,p}");
743   TString *sRawEtString = new TString("raw E_{T}");
744   TString *sFull = new TString("Full");
745   TString *sEMCAL = new TString("EMCAL");
746   TString *sPHOS = new TString("PHOS");
747   
748   for(int tpc = 0;tpc<2;tpc++){
749     for(int hadet = 0;hadet<3;hadet++){
750       for(int type = 0;type<3;type++){
751         for(int pid = 0;pid<2;pid++){
752           TString *detector = NULL;
753           TString *partid = NULL;
754           TString *et = sHadEt;
755           TString *acceptance = NULL;
756           TString *ptstring = NULL;
757           TString *partidstring = NULL;
758           TString *etstring = sHadEtString;
759           if(tpc==1) {detector = sTPC; ptstring = sTPCpt;}
760           else{detector = sITS; ptstring = sITSpt;}
761           if(pid==1){partid = sPID; partidstring = sPID;}
762           else{partid = sNoPID; partidstring = sNoPIDString;}
763           if(hadet==1) {et = sHadEt; etstring = sHadEtString;}
764           if(hadet==0){et = sTotEt; etstring = sTotEtString;}
765           if(hadet==2){et = sRawEt; etstring = sRawEtString;}
766           switch(type){
767           case 0:
768             acceptance = sFull;
769             break;
770           case 1:
771             acceptance = sEMCAL;
772             break;
773           case 2:
774             acceptance = sPHOS;
775             break;
776           default:
777             acceptance = sFull;
778           }
779           snprintf(histoname,200,"Reco%s%sAcceptance%s%s",et->Data(),acceptance->Data(),detector->Data(),partid->Data());
780           snprintf(histotitle,200,"Reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
781           snprintf(xtitle,50,"Reconstructed %s",etstring->Data());
782           CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEt,maxEt);
783           if(type==0){//full acceptance only
784             snprintf(xtitle,50,"Reconstructed %s",etstring->Data());
785
786             snprintf(histoname,200,"Reco%s%sAcceptance%s%sND",et->Data(),acceptance->Data(),detector->Data(),partid->Data());
787             snprintf(histotitle,200,"Reconstructed non-diffractive events %s with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
788             CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEt,maxEt);
789             snprintf(histoname,200,"Reco%s%sAcceptance%s%sDD",et->Data(),acceptance->Data(),detector->Data(),partid->Data());
790             snprintf(histotitle,200,"Reconstructed doubly-diffractive events %s with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
791             CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEt,maxEt);
792             snprintf(histoname,200,"Reco%s%sAcceptance%s%sSD",et->Data(),acceptance->Data(),detector->Data(),partid->Data());
793             snprintf(histotitle,200,"Reconstructed singly-diffractive events %s with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
794             CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEt,maxEt);
795
796
797
798           snprintf(histoname,200,"Reco%s%sAcceptance%s%s",sPiKPEt->Data(),acceptance->Data(),detector->Data(),partid->Data());
799           snprintf(histotitle,200,"Reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s",sPiKPEtString->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
800           snprintf(xtitle,50,"Reconstructed %s",sPiKPEtString->Data());
801           CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEtPiKP,maxEtPiKP);
802
803             snprintf(xtitle,50,"Reconstructed %s",sPiKPEt->Data());
804             snprintf(histoname,200,"Reco%s%sAcceptance%s%sND",sPiKPEt->Data(),acceptance->Data(),detector->Data(),partid->Data());
805             snprintf(histotitle,200,"Reconstructed non-diffractive events %s with %s acceptance for p_{T}>%s GeV/c%s",sPiKPEtString->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
806             CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEtPiKP,maxEtPiKP);
807             snprintf(histoname,200,"Reco%s%sAcceptance%s%sDD",sPiKPEt->Data(),acceptance->Data(),detector->Data(),partid->Data());
808             snprintf(histotitle,200,"Reconstructed doubly-diffractive events %s with %s acceptance for p_{T}>%s GeV/c%s",sPiKPEtString->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
809             CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEtPiKP,maxEtPiKP);
810             snprintf(histoname,200,"Reco%s%sAcceptance%s%sSD",sPiKPEt->Data(),acceptance->Data(),detector->Data(),partid->Data());
811             snprintf(histotitle,200,"Reconstructed singly-diffractive events %s with %s acceptance for p_{T}>%s GeV/c%s",sPiKPEtString->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
812             CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEtPiKP,maxEtPiKP);//et
813
814           }
815           if((fDataSet==20100||fDataSet==2011) && type ==0 &&pid==1){//If this is Pb+Pb and full acceptance with pid
816             Int_t width = 5;
817             if(fNCentBins<21) width = 10;
818             for(Int_t i=0;i<fNCentBins;i++){
819               snprintf(histoname,200,"Reco%s%sAcceptance%s%sCB%i",et->Data(),acceptance->Data(),detector->Data(),partid->Data(),i);
820               snprintf(histotitle,200,"Reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s for centrality %i-%i",etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data(),i*width,(i+1)*width);
821               snprintf(xtitle,50,"Reconstructed %s",etstring->Data());
822               CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEt,maxEt);
823             }
824           }
825         }
826       }
827     }
828   }
829   CreateHisto1D("RecoHadEtFullAcceptanceTPCAssumingPion","Reconstructing E_{T}^{had} with full acceptance for p_{T}>0.15 GeV/c assuming pions","Reconstructed E_{T}^{had}","dN_{eve}/dE_{T}^{had}",nbinsEt*2,minEt,maxEt);
830   CreateHisto1D("RecoHadEtFullAcceptanceTPCAssumingProton","Reconstructing E_{T}^{had} with full acceptance for p_{T}>0.15 GeV/c assuming protons","Reconstructed E_{T}^{had}","dN_{eve}/dE_{T}^{had}",nbinsEt*2,minEt,maxEt);
831   CreateHisto1D("RecoHadEtFullAcceptanceTPCAssumingKaon","Reconstructing E_{T}^{had} with full acceptance for p_{T}>0.15 GeV/c assuming kaons","Reconstructed E_{T}^{had}","dN_{eve}/dE_{T}^{had}",nbinsEt*2,minEt,maxEt);
832   CreateHisto1D("RecoHadEtFullAcceptanceITSAssumingPion","Reconstructing E_{T}^{had} with full acceptance for p_{T}>0.10 GeV/c assuming pions","Reconstructed E_{T}^{had}","dN_{eve}/dE_{T}^{had}",nbinsEt*2,minEt,maxEt);
833   CreateHisto1D("RecoHadEtFullAcceptanceITSAssumingProton","Reconstructing E_{T}^{had} with full acceptance for p_{T}>0.10 GeV/c assuming protons","Reconstructed E_{T}^{had}","dN_{eve}/dE_{T}^{had}",nbinsEt*2,minEt,maxEt);
834   CreateHisto1D("RecoHadEtFullAcceptanceITSAssumingKaon","Reconstructing E_{T}^{had} with full acceptance for p_{T}>0.10 GeV/c assuming kaons","Reconstructed E_{T}^{had}","dN_{eve}/dE_{T}^{had}",nbinsEt*2,minEt,maxEt);
835
836   //Cross checks that corrections are applied correctly
837   if(fDataSet==20100 || fDataSet==2011){
838     CreateHisto2D("fbkgdVsCentralityBin","f_{bkgd} vs centrality bin","centrality bin","f_{bkgd}",21,-1.5,19.5,200,0.7,1.05);//
839     CreateHisto2D("feffPionVsCentralityBin","Pion efficiency vs centrality bin","centrality bin","pion efficiency",21,-1.5,19.5,200,0,1.2);//
840     CreateHisto2D("feffHadronVsCentralityBin","Hadron efficiency vs centrality bin","centrality bin","hadron efficiency",21,-1.5,19.5,200,0,1.2);//
841     CreateHisto2D("feffKaonVsCentralityBin","Kaon efficiency vs centrality bin","centrality bin","kaon efficiency",21,-1.5,19.5,200,0,1.2);//
842     CreateHisto2D("feffProtonVsCentralityBin","Proton efficiency vs centrality bin","centrality bin","proton efficiency",21,-1.5,19.5,200,0,1.2);//
843     CreateHisto2D("fnotIDVsCentralityBin","f_{notID} vs centrality bin","centrality bin","f_{notID}",21,-1.5,19.5,50,0.95,1.05);//
844     CreateHisto2D("fpTcutVsCentralityBin","f_{pTcut} vs centrality bin","centrality bin","f_{pTcut}",21,-1.5,19.5,50,0.95,1.05);
845     CreateHisto2D("fneutralVsCentralityBin","f_{neutral} vs centrality bin","centrality bin","f_{neutral}",21,-1.5,19.5,50,0.5,1.00);
846     CreateHisto2D("ConstantCorrectionsVsCentralityBin","constant corrections vs centrality bin","centrality bin","constant corrections",21,-1.5,19.5,50,0.5,1.00);
847   }
848
849   delete sTPC;
850   delete sITS;
851   delete sTPCpt;
852   delete sITSpt;
853   delete sPID;
854   delete sNoPID;
855   delete sNoPIDString;
856   delete sPiKPEt;
857   delete sHadEt;
858   delete sTotEt;
859   delete sTotEtString;
860   delete sHadEtString;
861   delete sPiKPEtString;
862   delete sFull;
863   delete sEMCAL;
864   delete sPHOS;
865
866 }