o First Version of TRDnSigma implementation (Xianguo) o still requires some catching...
[u/mrichter/AliRoot.git] / PWGLF / totEt / AliAnalysisHadEtMonteCarlo.cxx
1 //_________________________________________________________________________
2 //  Utility Class for transverse energy studies, charged hadrons
3 //  Base class for MC analysis
4 //  - MC output
5 // implementation file
6 //
7 //Created by Christine Nattrass, Rebecca Scott, Irakli Martashvili
8 //University of Tennessee at Knoxville
9 //_________________________________________________________________________
10 #include "AliAnalysisHadEtMonteCarlo.h"
11 #include "AliAnalysisEtCuts.h"
12
13 #include "AliStack.h"
14 #include "AliMCEvent.h"
15 #include "AliESDEvent.h"
16 #include "AliESDtrackCuts.h"
17 #include "AliESDpid.h"
18 #include "AliPID.h"
19 #include "AliESDtrack.h"
20 #include "AliVParticle.h"
21 #include "AliAnalysisTask.h"
22 #include "AliAnalysisManager.h"
23 #include "AliAnalysisHadEtReconstructed.h"
24 #include "AliAnalysisHadEtCorrections.h"
25 #include "AliAnalysisEtCuts.h"
26 #include <iostream>
27 #include "TRandom.h"
28 #include "AliAnalysisEtCommon.h"
29 #include "AliCentrality.h"
30 #include "AliLog.h"
31 #include "AliPWG0Helper.h"
32 #include "AliPIDResponse.h"
33 #include "AliTPCPIDResponse.h" 
34 #include "AliInputEventHandler.h"
35 #include "AliAnalysisManager.h"
36 #include "AliGenEventHeader.h"
37 #include "AliGenCocktailEventHeader.h"
38 #include "AliGenHijingEventHeader.h"
39 //class AliPWG0Helper;
40 //#include "$ALICE_ROOT/PWG0/AliPWG0Helper.h"
41
42 using namespace std;
43
44 ClassImp(AliAnalysisHadEtMonteCarlo);
45
46
47 Int_t AliAnalysisHadEtMonteCarlo::fgNumSmearWidths = 4;
48 Float_t AliAnalysisHadEtMonteCarlo::fgSmearWidths[4] = {0.005,0.006,0.007,0.008};
49
50 AliAnalysisHadEtMonteCarlo::AliAnalysisHadEtMonteCarlo():AliAnalysisHadEt()
51                                                         ,checkLabelForHIJING(kFALSE)
52                                                         ,fNMCProducedMin(0)
53                                                         ,fNMCProducedMax(0)
54                                                         ,fSimPiKPEt(0)
55                                                         ,fSimRawEtTPC(0)
56                                                         ,fSimRawEtITS(0)
57                                                         ,fSimHadEt(0)
58                                                         ,fSimTotEt(0) 
59                                                         ,fSimPiKPEtShouldBeReco(0)
60                                                         ,fSimPiKPEtShouldBeRecoPi(0)
61                                                         ,fSimPiKPEtShouldBeRecoK(0)
62                                                         ,fSimPiKPEtShouldBeRecoP(0)
63                                                         ,fRunLightweight(0)
64                                                         ,fInvestigateSmearing(0)
65                                                         ,fInvestigateFull(0)
66                                                         ,fInvestigateEMCal(0)
67                                                         ,fInvestigatePHOS(0)
68                                                         ,fInvestigatePiKP(0)
69                                                         ,fRequireITSHits(0)
70                                                         ,fBaryonEnhancement(0)
71                                                         ,fUseRecoPt(0)
72                                                         ,kIsOfflineV0AND(0)
73                                                         ,kIsOfflineMB(0)
74                                                         ,kDoTriggerChecks(0)
75                                                         ,kDoTriggerChecksOnly(0)
76                                                         ,fPtSmearer(0)
77                                                         ,fHadEtReco(0)
78 {
79 }
80 AliAnalysisHadEtMonteCarlo::~AliAnalysisHadEtMonteCarlo(){//destructor
81   if(fPtSmearer) delete fPtSmearer;
82 }
83
84 void AliAnalysisHadEtMonteCarlo::ResetEventValues(){//resetting event variables
85   AliAnalysisHadEt::ResetEventValues();
86     fSimHadEt=0.0;
87     fSimTotEt=0.0;
88     fSimPiKPEt=0.0;
89     fSimRawEtTPC=0.0;
90     fSimRawEtITS=0.0;
91 }
92 Int_t AliAnalysisHadEtMonteCarlo::AnalyseEvent(AliVEvent* ev,AliVEvent* ev2)
93 { // analyse MC and real event info
94   FillHisto1D("NEvents",0.5,1);
95   if(!ev || !ev2){
96     AliFatal("ERROR: Event does not exist");   
97     return 0;
98   }
99   AliMCEvent *mcEvent = dynamic_cast<AliMCEvent*>(ev);
100   AliESDEvent *realEvent = dynamic_cast<AliESDEvent*>(ev2);
101   if(!mcEvent || !realEvent){  
102     AliFatal("ERROR: mcEvent or realEvent does not exist");
103     return 0;
104   }
105   AliStack *stack = mcEvent->Stack();
106
107   if(checkLabelForHIJING) SetGeneratorMinMaxParticles(mcEvent);
108   fCentBin= -1;
109   fGoodEvent = kTRUE;//for p+p collisions if we made it this far we have a good event
110   if(fDataSet==20100 ||fDataSet==2011 ){//If this is Pb+Pb
111     AliCentrality *centrality = realEvent->GetCentrality();
112     if(fNCentBins<21) fCentBin= centrality->GetCentralityClass10(fCentralityMethod);
113     else{ fCentBin= centrality->GetCentralityClass5(fCentralityMethod);}
114     if(fCentBin ==-1) fGoodEvent = kFALSE;//but for Pb+Pb events we don't want to count events where we did not find a centrality
115   }
116   AnalyseEvent(ev);
117   if(kDoTriggerChecksOnly) return 1;//If we are only doing trigger checks, don't bother with all of the reconstructed stuff
118   //for PID
119   if(kDoTriggerChecks && (!kIsOfflineV0AND ||!kIsOfflineMB ) ){return 1;}//In this case we are just after trigger efficiencies and don't care about the ET reconstructed.
120   AliESDpid *pID = new AliESDpid();//This is identified as a memory leak in valgrind but I delete this object so I think it may be a problem with AliESDpid.
121
122   //=============================================
123
124   //Roughly following $ALICE_ROOT/PWG0/dNdEta/AlidNdEtaCorrectionTask
125
126   //=============================================TPC&&ITS=============================================
127   //for investigating momentum smearing 
128   Float_t pTtotalReco = 0.0;
129   Float_t pTtotalSim = 0.0;
130   Float_t eTtotalSimAll = 0.0;
131   Float_t eTtotalReco = 0.0;
132   Float_t eTtotalRecoEffCorr = 0.0;
133   Float_t eTtotalRecoEffBkgdCorr = 0.0;
134   Float_t eTtotalRecoBkgdCorr = 0.0;
135   Float_t eTtotalRecoUncorr = 0.0;
136   Float_t eTtotalRecoTotalUncorr = 0.0;
137   Float_t eTtotalRecoEffCorrPi = 0.0;
138   Float_t eTtotalRecoEffCorrK = 0.0;
139   Float_t eTtotalRecoEffCorrP = 0.0;
140   Float_t eTtotalRecoBkgd = 0.0;
141   Float_t eTtotalRecoPIDSmeared = 0.0;
142   Float_t eTtotalAsReconstructed = 0.0;
143   Float_t eTBkgdAsReconstructed = 0.0;
144   Float_t eTtotalAsReconstructedPi = 0.0;
145   Float_t eTtotalAsReconstructedP = 0.0;
146   Float_t eTtotalAsReconstructedK = 0.0;
147   Float_t eTtotalSim = 0.0;
148   Int_t nReco = 0;
149   TString *strTPC = new TString("TPC");
150   TString *strITS = new TString("ITS");
151   TString *strTPCITS = new TString("TPCITS");
152   Int_t lastcutset = 1;
153   if(fRequireITSHits) lastcutset = 2;
154   for(Int_t cutset=0;cutset<=lastcutset;cutset++){
155     TString *cutName = NULL;
156     TObjArray* list = NULL;
157     switch(cutset){
158     case 0:
159       cutName = strTPC;
160       list = fEsdtrackCutsTPC->GetAcceptedTracks(realEvent);
161       break;
162     case 1:
163       cutName = strITS;
164       list = fEsdtrackCutsITS->GetAcceptedTracks(realEvent);
165       break;
166     case 2:
167       cutName = strTPCITS;
168       list = fEsdtrackCutsITSTPC->GetAcceptedTracks(realEvent);
169       break;
170     default:
171       cerr<<"Error:  cannot fill histograms!"<<endl;
172       return -1;
173     }
174     Int_t nGoodTracks = list->GetEntries();
175     for (Int_t iTrack = 0; iTrack < nGoodTracks; iTrack++)
176       {
177         AliESDtrack *track = dynamic_cast<AliESDtrack*> (list->At(iTrack));
178         UInt_t label = (UInt_t)TMath::Abs(track->GetLabel());
179         //if(checkLabelForHIJING && !IsHIJINGLabel(label,mcEvent,stack) ){cout<<"I am rejecting this particle because it is not HIJING"<<endl;}
180         if(checkLabelForHIJING && !IsHIJINGLabel(label,mcEvent,stack) ) continue;
181         if (!track)
182           {
183             Printf("ERROR: Could not get track %d", iTrack);
184             continue;
185           }
186         else{
187           Float_t nSigmaPion,nSigmaProton,nSigmaKaon,nSigmaElectron;
188 //        pID->MakeTPCPID(track);
189 //        pID->MakeITSPID(track);
190           if(cutset!=1){
191             nSigmaPion = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion)); 
192             nSigmaProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton)); 
193             nSigmaKaon =TMath::Abs( fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon)); 
194             nSigmaElectron =TMath::Abs( fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron)); 
195 //          nSigmaPion = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kPion));
196 //          nSigmaProton = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kProton));
197 //          nSigmaKaon = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kKaon));
198 //          nSigmaElectron = TMath::Abs(pID->NumberOfSigmasTPC(track,AliPID::kElectron));
199           }
200           else{
201             nSigmaPion = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kPion)); 
202             nSigmaProton = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kProton)); 
203             nSigmaKaon = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kKaon)); 
204             nSigmaElectron = TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kElectron)); 
205 //          nSigmaPion = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kPion));
206 //          nSigmaProton = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kProton));
207 //          nSigmaKaon = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kKaon));
208 //          nSigmaElectron = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kElectron));
209           }
210 //        bool isPion = (nSigmaPion<3.0 && nSigmaProton>2.0 && nSigmaKaon>2.0);
211 //        bool isElectron = (nSigmaElectron<2.0 && nSigmaPion>4.0 && nSigmaProton>3.0 && nSigmaKaon>3.0);
212 //        bool isKaon = (nSigmaPion>3.0 && nSigmaProton>2.0 && nSigmaKaon<2.0);
213 //        bool isProton = (nSigmaPion>3.0 && nSigmaProton<2.0 && nSigmaKaon>2.0);
214           bool isPion = (nSigmaPion<3.0 && nSigmaProton>2.0 && nSigmaKaon>2.0);
215           bool isElectron = (nSigmaElectron<2.0 && nSigmaPion>4.0 && nSigmaProton>3.0 && nSigmaKaon>3.0);
216           bool isKaon = (nSigmaPion>3.0 && nSigmaProton>3.0 && nSigmaKaon<3.0 && track->Pt()<0.45);
217           bool isProton = (nSigmaPion>3.0 && nSigmaProton<3.0 && nSigmaKaon>3.0 && track->Pt()<0.9);
218
219           bool unidentified = (!isProton && !isKaon && !isElectron && !isPion);
220           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
221             unidentified = true;
222             isPion=false;
223             isElectron=false;
224             isKaon=false;
225             isProton=false;
226           }
227           Float_t dEdx = track->GetTPCsignal();
228           if(cutset==1) dEdx = track->GetITSsignal();
229
230           FillHisto2D(Form("dEdxAll%s",cutName->Data()),track->P(),dEdx,1.0);
231
232             TParticle  *simPart  = stack->Particle(label);
233           if(!simPart) {
234             Printf("no MC particle\n");                 
235             continue;           
236           }
237           else{//analysis
238             if(fInvestigateSmearing && cutset==2){
239               //calculates what we would measure for the pi/k/p et with background
240               eTtotalRecoTotalUncorr += Et(simPart);
241               if(isPion){
242                 eTtotalRecoEffBkgdCorr += Et(simPart) *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionPion(track->Pt(),fCentBin) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
243                 eTtotalRecoBkgdCorr += Et(simPart) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
244                 eTtotalRecoTotalUncorr += Et(simPart);
245               }
246               if(isProton){
247                 eTtotalRecoEffBkgdCorr += Et(simPart) *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionProton(track->Pt(),fCentBin) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
248                 eTtotalRecoBkgdCorr += Et(simPart) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
249               }
250               if(isKaon){
251                 eTtotalRecoEffBkgdCorr += Et(simPart) *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionKaon(track->Pt(),fCentBin) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
252                 eTtotalRecoBkgdCorr += Et(simPart) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
253               }
254               if(unidentified){
255                 eTtotalRecoEffBkgdCorr += Et(simPart) *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionHadron(track->Pt(),fCentBin) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
256                 eTtotalRecoBkgdCorr += Et(simPart) * fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
257               }
258               //for calculating et as it's done in the reconstructed data
259               Float_t corrBkgd=0.0;
260               Float_t corrNotID=0.0;
261               //Float_t corrNoID=0.0;// = fHadEtReco->GetCorrections()->GetNotIDCorrectionNoPID(track->Pt());
262               Float_t corrEff = 0.0;
263               //Float_t corrEffNoID = 0.0;
264               Float_t et = 0.0;
265               if(cutset==2){//TPC
266                 corrBkgd = fHadEtReco->GetCorrections()->GetBackgroundCorrectionTPC(track->Pt());
267                 //corrEffNoID = fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionHadron(track->Pt(),fCentBin);
268                 corrNotID = fHadEtReco->GetCorrections()->GetNotIDConstCorrectionTPC();
269                 //corrNoID = fHadEtReco->GetCorrections()->GetNotIDConstCorrectionTPCNoID();
270               }
271               if(cutset==1){//ITS
272                 corrBkgd = fHadEtReco->GetCorrections()->GetBackgroundCorrectionITS(track->Pt());
273                 //corrEffNoID = fHadEtReco->GetCorrections()->GetITSEfficiencyCorrectionHadron(track->Pt(),fCentBin);
274                 corrNotID = fHadEtReco->GetCorrections()->GetNotIDConstCorrectionITS();
275                 //corrNoID = fHadEtReco->GetCorrections()->GetNotIDConstCorrectionITSNoID();
276               }
277               
278               
279               bool isprimary = stack->IsPhysicalPrimary(label);
280               if (TMath::Abs(track->Eta()) < fHadEtReco->GetCorrections()->GetEtaCut()){
281                   if(isPion){
282                     et = Et(track->P(),track->Theta(),fgPiPlusCode,track->Charge());
283                     corrEff = fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionPion(track->Pt(),fCentBin);
284                     if(isprimary){
285                       eTtotalAsReconstructed += et*corrBkgd*corrEff*corrNotID;
286                     }
287                     else{
288                       eTBkgdAsReconstructed += et*corrBkgd*corrEff*corrNotID;
289                     }
290                   }
291                   if(isKaon){
292                     et = Et(track->P(),track->Theta(),fgKPlusCode,track->Charge());
293                     corrEff = fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionKaon(track->Pt(),fCentBin);
294                     if(isprimary){
295                       eTtotalAsReconstructed += et*corrBkgd*corrEff*corrNotID;
296                     }
297                     else{
298                       eTBkgdAsReconstructed += et*corrBkgd*corrEff*corrNotID;
299                     }
300                   }
301                   if(isProton){
302                     et = Et(track->P(),track->Theta(),fgProtonCode,track->Charge());
303                     corrEff = fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionProton(track->Pt(),fCentBin);
304                     if(isprimary){
305                       eTtotalAsReconstructed += et*corrBkgd*corrEff*corrNotID;
306                     }
307                     else{
308                       eTBkgdAsReconstructed += et*corrBkgd*corrEff*corrNotID;
309                     }
310                   }
311                   if(unidentified){
312                     et = Et(track->P(),track->Theta(),fgPiPlusCode,track->Charge());
313                     corrEff = fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionHadron(track->Pt(),fCentBin);
314                     if(isprimary){
315                       eTtotalAsReconstructed += et*corrBkgd*corrEff*corrNotID;
316                     }
317                     else{
318                       eTBkgdAsReconstructed += et*corrBkgd*corrEff*corrNotID;
319                     }
320                   }
321                   if(!isPion && !isProton && !isKaon && !unidentified){
322                       eTBkgdAsReconstructed += et*corrBkgd*corrEff*corrNotID;
323                   }
324                   TParticlePDG *pdg = simPart->GetPDG(0);
325                   if(pdg){
326                     Int_t pdgCode =  simPart->GetPDG(0)->PdgCode();
327                     if(pdgCode==fgPiPlusCode ||pdgCode==fgPiMinusCode){eTtotalAsReconstructedPi+=et*corrBkgd*corrEff*corrNotID;}
328                     if(pdgCode==fgKPlusCode ||pdgCode==fgKMinusCode){eTtotalAsReconstructedK+=et*corrBkgd*corrEff*corrNotID;}
329                     if(pdgCode==fgProtonCode ||pdgCode==fgAntiProtonCode){eTtotalAsReconstructedP+=et*corrBkgd*corrEff*corrNotID;}
330                   }
331                 }
332             }
333
334             if(cutset==2) eTtotalSimAll += Et(simPart);
335             if(stack->IsPhysicalPrimary(label)){
336               if (TMath::Abs(simPart->Eta()) < fHadEtReco->GetCorrections()->GetEtaCut()){
337                 TParticlePDG *pdg = simPart->GetPDG(0);
338                 if(!pdg) continue;
339                 Int_t pdgCode =  simPart->GetPDG(0)->PdgCode();
340                 Int_t mypid = 0;
341                 if(pdgCode==AliAnalysisHadEt::fgPiPlusCode) mypid = 1;
342                 if(pdgCode==fgProtonCode) mypid = 2;
343                 if(pdgCode==fgKPlusCode) mypid = 3;
344                 if(pdgCode==fgEPlusCode) mypid = 4;
345                 if(pdgCode==fgPiMinusCode) mypid = 1;
346                 if(pdgCode==fgAntiProtonCode) mypid = 2;
347                 if(pdgCode==fgKMinusCode) mypid = 3;
348                 if(pdgCode==fgEMinusCode) mypid = 4;
349                 //bool filled = false;      
350                 //for smearing investigations
351                 if(fInvestigateSmearing && cutset==2){
352                   pTtotalReco += simPart->Pt();
353                   pTtotalSim += track->Pt();
354                   eTtotalReco += Et(track->P(),track->Theta(),pdgCode,track->Charge());
355                   eTtotalSim += Et(simPart);
356                   nReco++;
357                 }
358                 //============Charged hadrons===================================
359                 float myefficiencyCorrEt = 0.0;
360                 //identified...
361                 if(isPion){
362                   if(pdgCode!=fgPiPlusCode && pdgCode!=fgPiMinusCode){
363                     FillHisto2D(Form("MisidentifiedPIDs%s",cutName->Data()),1,mypid,1);
364                   }
365                   float myEt = Et(simPart);
366                   if(fInvestigateSmearing && cutset==2){
367                     eTtotalRecoPIDSmeared +=myEt;
368                     eTtotalRecoEffCorr += myEt *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionPion(track->Pt(),fCentBin);
369                     myefficiencyCorrEt = myEt * fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionPion(track->Pt(),fCentBin) ;
370                   }
371                   if( !fRunLightweight){
372                     if(track->Charge()>0){ FillHisto2D(Form("EtReconstructed%sIdentifiedPiPlus",cutName->Data()),track->Pt(),track->Eta(),myEt);}
373                     else{ FillHisto2D(Form("EtReconstructed%sIdentifiedPiMinus",cutName->Data()),track->Pt(),track->Eta(),myEt);}
374                   }
375                   FillHisto2D(Form("dEdxPion%s",cutName->Data()),track->P(),dEdx,1.0);
376                 }
377                 if(isProton){
378                   if(pdgCode!=fgProtonCode && pdgCode!=fgAntiProtonCode){
379                     FillHisto2D(Form("MisidentifiedPIDs%s",cutName->Data()),2,mypid,1);
380                   }
381                   float myEt = Et(simPart);
382                   if(fInvestigateSmearing && cutset==2){
383                     eTtotalRecoPIDSmeared +=myEt;
384                     eTtotalRecoEffCorr += myEt *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionProton(track->Pt(),fCentBin);
385                     myefficiencyCorrEt = myEt * fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionProton(track->Pt(),fCentBin);
386                   }
387                   if( !fRunLightweight){
388                     if(track->Charge()>0){ FillHisto2D(Form("EtReconstructed%sIdentifiedProton",cutName->Data()),track->Pt(),track->Eta(),myEt);}
389                     else{ FillHisto2D(Form("EtReconstructed%sIdentifiedAntiProton",cutName->Data()),track->Pt(),track->Eta(),myEt);}
390                     if(fBaryonEnhancement){
391                       myEt = myEt*ProtonBaryonEnhancement(track->Pt());
392                       if(track->Charge()>0){ FillHisto2D(Form("EtReconstructed%sIdentifiedProtonEnhanced",cutName->Data()),track->Pt(),track->Eta(),myEt);}
393                       else{ FillHisto2D(Form("EtReconstructed%sIdentifiedAntiProtonEnhanced",cutName->Data()),track->Pt(),track->Eta(),myEt);}
394                     }
395                   }
396                   FillHisto2D(Form("dEdxProton%s",cutName->Data()),track->P(),dEdx,1.0);
397                 }
398                 if(isKaon){
399                   if(pdgCode!=fgKMinusCode && pdgCode!=fgKPlusCode){
400                     FillHisto2D(Form("MisidentifiedPIDs%s",cutName->Data()),3,mypid,1);
401                   }
402                   float myEt = Et(simPart);
403                   if(fInvestigateSmearing && cutset==2){
404                     eTtotalRecoPIDSmeared +=myEt;
405                     eTtotalRecoEffCorr += myEt *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionKaon(track->Pt(),fCentBin);
406                     myefficiencyCorrEt = myEt * fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionKaon(track->Pt(),fCentBin);
407                   }
408                   if( !fRunLightweight){
409                     if(track->Charge()>0){ FillHisto2D(Form("EtReconstructed%sIdentifiedKPlus",cutName->Data()),track->Pt(),track->Eta(),myEt);}
410                     else{ FillHisto2D(Form("EtReconstructed%sIdentifiedKMinus",cutName->Data()),track->Pt(),track->Eta(),myEt);}
411                   }
412                   FillHisto2D(Form("dEdxKaon%s",cutName->Data()),track->P(),dEdx,1.0);
413                 }
414                 if(isElectron){
415                   if(pdgCode!=fgEMinusCode && pdgCode!=fgEPlusCode){
416                     FillHisto2D(Form("MisidentifiedPIDs%s",cutName->Data()),4,mypid,1);
417                   }
418                   if( !fRunLightweight){
419                     float myEt = Et(simPart);
420                     if(track->Charge()>0){ FillHisto2D(Form("EtReconstructed%sIdentifiedEPlus",cutName->Data()),track->Pt(),track->Eta(),myEt);}
421                     else{ FillHisto2D(Form("EtReconstructed%sIdentifiedEMinus",cutName->Data()),track->Pt(),track->Eta(),myEt);}
422                   }
423                   FillHisto2D(Form("dEdxElectron%s",cutName->Data()),track->P(),dEdx,1.0);
424                 }
425                 if(unidentified){
426                   if(pdgCode!=fgEMinusCode && pdgCode!=fgEPlusCode){
427                     float myEtPi = Et(simPart,fgPionMass);
428                     float myEtP = Et(simPart,fgProtonMass);
429                     float myEtK = Et(simPart,fgKaonMass);
430                     float myEt = Et(simPart);
431                     if(fInvestigateSmearing && cutset==2){
432                       eTtotalRecoPIDSmeared +=myEtPi;
433                       eTtotalRecoEffCorr += myEt *fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionHadron(track->Pt(),fCentBin);
434                       myefficiencyCorrEt = myEt * fHadEtReco->GetCorrections()->GetTPCEfficiencyCorrectionHadron(track->Pt(),fCentBin);
435                     }
436                     if( !fRunLightweight){
437                       FillHisto2D(Form("EtReconstructed%sUnidentifiedAssumingPion",cutName->Data()),track->Pt(),track->Eta(),myEtPi);
438                       FillHisto2D(Form("EtReconstructed%sUnidentifiedAssumingProton",cutName->Data()),track->Pt(),track->Eta(),myEtP);
439                       FillHisto2D(Form("EtReconstructed%sUnidentifiedAssumingKaon",cutName->Data()),track->Pt(),track->Eta(),myEtK);
440                       FillHisto2D(Form("EtReconstructed%sUnidentified",cutName->Data()),track->Pt(),track->Eta(),myEt);
441                       FillHisto2D(Form("EtNReconstructed%sUnidentified",cutName->Data()),track->Pt(),track->Eta(),1.0);
442                       if(pdgCode == fgPiPlusCode||pdgCode == fgPiMinusCode){
443                         FillHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingPion",cutName->Data()),track->Pt(),track->Eta(),myEtPi);
444                         FillHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingProton",cutName->Data()),track->Pt(),track->Eta(),myEtP);
445                         FillHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingKaon",cutName->Data()),track->Pt(),track->Eta(),myEtK);
446                         FillHisto2D(Form("EtReconstructed%sUnidentifiedPion",cutName->Data()),track->Pt(),track->Eta(),myEt);
447                         FillHisto2D(Form("EtNReconstructed%sUnidentifiedPion",cutName->Data()),track->Pt(),track->Eta(),1.0);
448                       }
449                       if(pdgCode == fgKPlusCode||pdgCode == fgKMinusCode){
450                         FillHisto2D(Form("EtReconstructed%sUnidentifiedKaonAssumingPion",cutName->Data()),track->Pt(),track->Eta(),myEtPi);
451                         FillHisto2D(Form("EtReconstructed%sUnidentifiedKaonAssumingProton",cutName->Data()),track->Pt(),track->Eta(),myEtP);
452                         FillHisto2D(Form("EtReconstructed%sUnidentifiedKaonAssumingKaon",cutName->Data()),track->Pt(),track->Eta(),myEtK);
453                         FillHisto2D(Form("EtReconstructed%sUnidentifiedKaon",cutName->Data()),track->Pt(),track->Eta(),myEt);
454                         FillHisto2D(Form("EtNReconstructed%sUnidentifiedKaon",cutName->Data()),track->Pt(),track->Eta(),1.0);
455                       }
456                       if(pdgCode == fgProtonCode||pdgCode == fgAntiProtonCode){
457                         FillHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingPion",cutName->Data()),track->Pt(),track->Eta(),myEtPi);
458                         FillHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingProton",cutName->Data()),track->Pt(),track->Eta(),myEtP);
459                         FillHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingKaon",cutName->Data()),track->Pt(),track->Eta(),myEtK);
460                         FillHisto2D(Form("EtReconstructed%sUnidentifiedProton",cutName->Data()),track->Pt(),track->Eta(),myEt);
461                         FillHisto2D(Form("EtNReconstructed%sUnidentifiedProton",cutName->Data()),track->Pt(),track->Eta(),1.0);
462                         if(fBaryonEnhancement){
463                           myEt = myEt*ProtonBaryonEnhancement(track->Pt());
464                           FillHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingPionEnhanced",cutName->Data()),track->Pt(),track->Eta(),myEtPi);
465                           FillHisto2D(Form("EtReconstructed%sUnidentifiedProtonEnhanced",cutName->Data()),track->Pt(),track->Eta(),myEt);
466                           FillHisto2D(Form("EtNReconstructed%sUnidentifiedProtonEnhanced",cutName->Data()),track->Pt(),track->Eta(),1.0);
467                         }
468                       }
469                     }
470                   }
471                   FillHisto2D(Form("dEdxUnidentified%s",cutName->Data()),track->P(),dEdx,1.0);
472                   FillHisto1D(Form("UnidentifiedPIDs%s",cutName->Data()),mypid,1);
473                 }
474                 //...simulated
475                 float myEtSim = Et(simPart);
476                 float myEtReco = 0.0;
477                 if(pdgCode == fgPiPlusCode){            
478                   float myEt = Et(simPart);
479                   float myEtP = Et(simPart,fgProtonMass);
480                   float myEtK = Et(simPart,fgKaonMass);
481                   myEtReco = Et(track->P(),track->Theta(),fgPiPlusCode,track->Charge());
482                   float pT = simPart->Pt();
483                   float eta = simPart->Eta();
484                   if(fInvestigateSmearing && cutset==2){
485                     eTtotalRecoEffCorrPi+=myefficiencyCorrEt;
486                     eTtotalRecoUncorr +=myEt;
487                   }
488                   if(fUseRecoPt){//Then we switch the pT and the Et
489                     myEt = myEtReco;
490                     pT = track->Pt();
491                     eta = track->Eta();
492                   }
493                   if( !fRunLightweight){
494                     FillHisto2D(Form("EtReconstructed%sPiPlus",cutName->Data()),pT,eta,myEt);
495                     FillHisto2D(Form("EtReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
496                     FillHisto2D(Form("EtNReconstructed%sPiPlus",cutName->Data()),pT,eta,myEt);
497                     FillHisto2D(Form("EtNReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
498                     if(fCentBin>=0){//if a centrality bin was defined
499                       FillHisto2D(Form("EtNReconstructed%sPiPlusCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
500                       FillHisto2D(Form("EtNReconstructed%sChargedHadronCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
501                     }
502                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingPion",cutName->Data()),pT,eta,myEt);
503                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingProton",cutName->Data()),pT,eta,myEtP);
504                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingKaon",cutName->Data()),pT,eta,myEtK);
505                     FillHisto2D(Form("EtReconstructed%sPiPlusAssumingKaon",cutName->Data()),pT,eta,myEtK);
506                     FillHisto2D(Form("EtReconstructed%sPiPlusAssumingProton",cutName->Data()),pT,eta,myEtP);
507                   }
508                   //filled = true;
509                 }
510                 if(pdgCode == fgPiMinusCode){
511                   float myEt = Et(simPart);
512                   float myEtP = Et(simPart,fgProtonMass);
513                   float myEtK = Et(simPart,fgKaonMass);
514                   myEtReco = Et(track->P(),track->Theta(),fgPiMinusCode,track->Charge());
515                   float pT = simPart->Pt();
516                   float eta = simPart->Eta();
517                   if(fInvestigateSmearing && cutset==2){
518                     eTtotalRecoEffCorrPi+=myefficiencyCorrEt;
519                     eTtotalRecoUncorr +=myEt;
520                   }
521                   if(fUseRecoPt){//Then we switch the pT and the Et
522                     myEt = myEtReco;
523                     pT = track->Pt();
524                     eta = track->Eta();
525                   }
526                   if( !fRunLightweight){
527                     FillHisto2D(Form("EtReconstructed%sPiMinus",cutName->Data()),pT,eta,myEt);
528                     FillHisto2D(Form("EtReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
529                     FillHisto2D(Form("EtNReconstructed%sPiMinus",cutName->Data()),pT,eta,myEt);
530                     FillHisto2D(Form("EtNReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
531                     if(fCentBin>=0){//if a centrality bin was defined
532                       FillHisto2D(Form("EtNReconstructed%sPiMinusCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
533                       FillHisto2D(Form("EtNReconstructed%sChargedHadronCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
534                     }
535                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingPion",cutName->Data()),pT,eta,myEt);
536                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingProton",cutName->Data()),pT,eta,myEtP);
537                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingKaon",cutName->Data()),pT,eta,myEtK);
538                     FillHisto2D(Form("EtReconstructed%sPiMinusAssumingKaon",cutName->Data()),pT,eta,myEtK);
539                     FillHisto2D(Form("EtReconstructed%sPiMinusAssumingProton",cutName->Data()),pT,eta,myEtP);
540                   }
541                   //filled = true;
542                 }
543                 if(pdgCode == fgKPlusCode){
544                   float myEt = Et(simPart);
545                   float myEtPi = Et(simPart,fgPionMass);
546                   float myEtP = Et(simPart,fgProtonMass);
547                   myEtReco = Et(track->P(),track->Theta(),fgKPlusCode,track->Charge());
548                   float pT = simPart->Pt();
549                   float eta = simPart->Eta();
550                   if(fUseRecoPt){//Then we switch the pT and the Et
551                     myEt = myEtReco;
552                     pT = track->Pt();
553                     eta = track->Eta();
554                   }
555                   if(fInvestigateSmearing && cutset==2){
556                     eTtotalRecoEffCorrK+=myefficiencyCorrEt;
557                     eTtotalRecoUncorr +=myEt;
558                   }
559                   if( !fRunLightweight){
560                     FillHisto2D(Form("EtReconstructed%sKPlus",cutName->Data()),pT,eta,myEt);
561                     FillHisto2D(Form("EtReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
562                     FillHisto2D(Form("EtNReconstructed%sKPlus",cutName->Data()),pT,eta,myEt);
563                     FillHisto2D(Form("EtNReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
564                     if(fCentBin>=0){//if a centrality bin was defined
565                       FillHisto2D(Form("EtNReconstructed%sKPlusCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
566                       FillHisto2D(Form("EtNReconstructed%sChargedHadronCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
567                     }
568                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingPion",cutName->Data()),pT,eta,myEtPi);
569                     FillHisto2D(Form("EtReconstructed%sKPlusAssumingPion",cutName->Data()),pT,eta,myEtPi);
570                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingKaon",cutName->Data()),pT,eta,myEt);
571                     FillHisto2D(Form("EtReconstructed%sKPlusAssumingKaon",cutName->Data()),pT,eta,myEt);
572                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingProton",cutName->Data()),pT,eta,myEtP);
573                     FillHisto2D(Form("EtReconstructed%sKPlusAssumingProton",cutName->Data()),pT,eta,myEtP);
574                   }
575                   //filled = true;
576                 }
577                 if(pdgCode == fgKMinusCode){
578                   float myEt = Et(simPart);
579                   float myEtPi = Et(simPart,fgPionMass);
580                   float myEtP = Et(simPart,fgProtonMass);
581                   myEtReco = Et(track->P(),track->Theta(),fgKMinusCode,track->Charge());
582                   float pT = simPart->Pt();
583                   float eta = simPart->Eta();
584                   if(fUseRecoPt){//Then we switch the pT and the Et
585                     myEt = myEtReco;
586                     pT = track->Pt();
587                     eta = track->Eta();
588                   }
589                   if(fInvestigateSmearing && cutset==2){
590                     eTtotalRecoEffCorrK+=myefficiencyCorrEt;
591                     eTtotalRecoUncorr +=myEt;
592                   }
593                   if( !fRunLightweight){
594                     FillHisto2D(Form("EtReconstructed%sKMinus",cutName->Data()),pT,eta,myEt);
595                     FillHisto2D(Form("EtReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
596                     FillHisto2D(Form("EtNReconstructed%sKMinus",cutName->Data()),pT,eta,myEt);
597                     FillHisto2D(Form("EtNReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
598                     if(fCentBin>=0){//if a centrality bin was defined
599                       FillHisto2D(Form("EtNReconstructed%sKMinusCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
600                       FillHisto2D(Form("EtNReconstructed%sChargedHadronCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
601                     }
602                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingPion",cutName->Data()),pT,eta,myEtPi);
603                     FillHisto2D(Form("EtReconstructed%sKMinusAssumingPion",cutName->Data()),pT,eta,myEtPi);
604                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingKaon",cutName->Data()),pT,eta,myEt);
605                     FillHisto2D(Form("EtReconstructed%sKMinusAssumingKaon",cutName->Data()),pT,eta,myEt);
606                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingProton",cutName->Data()),pT,eta,myEtP);
607                     FillHisto2D(Form("EtReconstructed%sKMinusAssumingProton",cutName->Data()),pT,eta,myEtP);
608                   }
609                   //filled = true;
610                 }
611                 if(pdgCode == fgProtonCode){
612                   float myEt = Et(simPart);
613                   float myEtPi = Et(simPart,fgPionMass);
614                   float myEtK = Et(simPart,fgKaonMass);
615                   myEtReco = Et(track->P(),track->Theta(),fgProtonCode,track->Charge());
616                   float pT = simPart->Pt();
617                   float eta = simPart->Eta();
618                   if(fUseRecoPt){//Then we switch the pT and the Et
619                     myEt = myEtReco;
620                     pT = track->Pt();
621                     eta = track->Eta();
622                   }
623                   if(fInvestigateSmearing && cutset==2){
624                     eTtotalRecoEffCorrP+=myefficiencyCorrEt;
625                     eTtotalRecoUncorr +=myEt;
626                   }
627                   if( !fRunLightweight){
628                     FillHisto2D(Form("EtReconstructed%sProton",cutName->Data()),pT,eta,myEt);
629                     FillHisto2D(Form("EtReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
630                     FillHisto2D(Form("EtNReconstructed%sProton",cutName->Data()),pT,eta,myEt);
631                     FillHisto2D(Form("EtNReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
632                     if(fCentBin>=0){//if a centrality bin was defined
633                       FillHisto2D(Form("EtNReconstructed%sProtonCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
634                       FillHisto2D(Form("EtNReconstructed%sChargedHadronCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
635                     }
636                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingPion",cutName->Data()),pT,eta,myEtPi);
637                     FillHisto2D(Form("EtReconstructed%sProtonAssumingPion",cutName->Data()),pT,eta,myEtPi);
638                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingKaon",cutName->Data()),pT,eta,myEtK);
639                     FillHisto2D(Form("EtReconstructed%sProtonAssumingKaon",cutName->Data()),pT,eta,myEtK);
640                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingProton",cutName->Data()),pT,eta,myEt);
641                     FillHisto2D(Form("EtReconstructed%sProtonAssumingProton",cutName->Data()),pT,eta,myEt);
642                   }
643                   //filled = true;
644
645                   if( !fRunLightweight){
646                     if(fBaryonEnhancement){
647                       float enhancement = ProtonBaryonEnhancement(track->Pt());
648                       FillHisto2D(Form("EtReconstructed%sProtonEnhanced",cutName->Data()),pT,eta,myEt*enhancement);
649                       FillHisto2D(Form("EtNReconstructed%sProtonEnhanced",cutName->Data()),pT,eta,myEt*enhancement);
650                       FillHisto2D(Form("EtReconstructed%sProtonAssumingPionEnhanced",cutName->Data()),pT,eta,myEtPi*enhancement);
651                     }
652                   }
653
654                 }
655                 if(pdgCode == fgAntiProtonCode){
656                   float myEt = Et(simPart);
657                   float myEtPi = Et(simPart,fgPionMass);
658                   float myEtK = Et(simPart,fgKaonMass);
659                   myEtReco = Et(track->P(),track->Theta(),fgAntiProtonCode,track->Charge());
660                   float pT = simPart->Pt();
661                   float eta = simPart->Eta();
662                   if(fUseRecoPt){//Then we switch the pT and the Et
663                     myEt = myEtReco;
664                     pT = track->Pt();
665                     eta = track->Eta();
666                   }
667                   if(fInvestigateSmearing && cutset==2){
668                     eTtotalRecoEffCorrP+=myefficiencyCorrEt;
669                     eTtotalRecoUncorr +=myEt;
670                   }
671                   if( !fRunLightweight){
672                     FillHisto2D(Form("EtReconstructed%sAntiProton",cutName->Data()),pT,eta,myEt);
673                     FillHisto2D(Form("EtReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
674                     FillHisto2D(Form("EtNReconstructed%sAntiProton",cutName->Data()),pT,eta,myEt);
675                     FillHisto2D(Form("EtNReconstructed%sChargedHadron",cutName->Data()),pT,eta,myEt);
676                     if(fCentBin>=0){//if a centrality bin was defined
677                       FillHisto2D(Form("EtNReconstructed%sAntiProtonCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
678                       FillHisto2D(Form("EtNReconstructed%sChargedHadronCB%i",cutName->Data(),fCentBin),pT,eta,myEt);
679                     }
680                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingPion",cutName->Data()),pT,eta,myEtPi);
681                     FillHisto2D(Form("EtReconstructed%sAntiProtonAssumingPion",cutName->Data()),pT,eta,myEtPi);
682                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingKaon",cutName->Data()),pT,eta,myEtK);
683                     FillHisto2D(Form("EtReconstructed%sAntiProtonAssumingKaon",cutName->Data()),pT,eta,myEtK);
684                     FillHisto2D(Form("EtReconstructed%sChargedHadronAssumingProton",cutName->Data()),pT,eta,myEt);
685                     FillHisto2D(Form("EtReconstructed%sAntiProtonAssumingProton",cutName->Data()),pT,eta,myEt);
686                   }
687                   //filled = true;
688                   if( !fRunLightweight){
689                     if(fBaryonEnhancement){
690                       float enhancement = ProtonBaryonEnhancement(track->Pt());
691                       FillHisto2D(Form("EtReconstructed%sAntiProtonEnhanced",cutName->Data()),pT,eta,myEt*enhancement);
692                       FillHisto2D(Form("EtNReconstructed%sAntiProtonEnhanced",cutName->Data()),pT,eta,myEt*enhancement);
693                       FillHisto2D(Form("EtReconstructed%sAntiProtonAssumingPionEnhanced",cutName->Data()),pT,eta,myEtPi*enhancement);
694                     }
695                   }
696                 }
697                 if(pdgCode == fgEPlusCode){
698                   if( !fRunLightweight){
699                     float myEt = Et(simPart);
700                     FillHisto2D(Form("EtReconstructed%sEPlus",cutName->Data()),simPart->Pt(),simPart->Eta(),myEt);
701                     if(!isElectron || unidentified){
702                       float myEtPi = Et(simPart,fgPionMass);
703                       FillHisto2D(Form("EtReconstructed%sMisidentifiedElectrons",cutName->Data()),track->Pt(),track->Eta(),myEtPi);
704                     }
705                   }
706                   //filled = true;
707                 }
708                 if(pdgCode == fgEMinusCode){
709                   if( !fRunLightweight){
710                     if(!isElectron || unidentified){
711                       float myEtPi = Et(simPart,fgPionMass);
712                       FillHisto2D(Form("EtReconstructed%sMisidentifiedElectrons",cutName->Data()),track->Pt(),track->Eta(),myEtPi);
713                     }
714                     float myEt = Et(simPart);
715                     FillHisto2D(Form("EtReconstructed%sEMinus",cutName->Data()),simPart->Pt(),simPart->Eta(),myEt);
716                   }
717                   //filled = true;
718                 }
719                 if( !fRunLightweight){
720                   if(myEtReco>0.0){FillHisto2D(Form("ETresolution%s",cutName->Data()),myEtReco,(myEtSim-myEtReco)/myEtReco,1.0);}
721                   if(track->Pt()>0.0){FillHisto2D(Form("pTresolution%s",cutName->Data()),track->Pt(),(simPart->Pt() - track->Pt())/track->Pt(),1.0);}
722                   if(track->P()>0.0){FillHisto2D(Form("presolution%s",cutName->Data()),track->P(),(simPart->P() - track->P())/track->P(),1.0);}
723                   FillHisto1D(Form("pTsim%s",cutName->Data()),simPart->Pt(),1.0);
724                   FillHisto1D(Form("pTrec%s",cutName->Data()),track->Pt(),1.0);
725                   if(fCentBin!=-1){
726                     FillHisto1D(Form("pTsim%sCB%i",cutName->Data(),fCentBin),simPart->Pt(),1.0);
727                     FillHisto1D(Form("pTrec%sCB%i",cutName->Data(),fCentBin),track->Pt(),1.0);
728                   }
729                 }
730               }
731             }
732             else{//not a primary - we're after V0 daughters!
733               bool written = false;
734               //now, what is the et we would measure for this?  Since this is the relevant et.
735               float myrecoEt = 0;
736               if(isPion || unidentified) myrecoEt = Et(track->P(),track->Theta(),fgPiPlusCode,track->Charge());
737               if(isProton) myrecoEt = Et(track->P(),track->Theta(),fgProtonCode,track->Charge());
738               if(isKaon) myrecoEt = Et(track->P(),track->Theta(),fgKPlusCode,track->Charge());
739               if (TMath::Abs(simPart->Eta()) < fHadEtReco->GetCorrections()->GetEtaCut()){
740                 TParticle *mom = NULL;
741                 if(simPart->GetFirstMother()>=0) mom= stack->Particle(simPart->GetFirstMother());
742                 if(mom){
743                   TParticlePDG *pc = mom->GetPDG(0);
744                   if(pc){
745                     Int_t pdgCode =  mom->GetPDG(0)->PdgCode();
746                     if(pdgCode == fgLambdaCode){
747                       written = true;
748                       float myEt = Et(simPart);
749                       float pT = simPart->Pt();
750                       float eta = simPart->Eta();
751                       TParticlePDG *simpdg = simPart->GetPDG(0);
752                       if(!simpdg) continue;
753                       eTtotalRecoBkgd+=myEt;
754                       if(fUseRecoPt){//Then we switch the pT and the Et
755                         myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
756                         pT = track->Pt();
757                         eta = track->Eta();
758                       }
759                       if( !fRunLightweight){
760                         FillHisto2D(Form("EtReconstructed%sLambdaDaughters",cutName->Data()),pT,eta,myrecoEt);
761                         Float_t weight = LambdaWeight(mom->Pt());
762                         if(fBaryonEnhancement){
763                           float enhancement = ProtonBaryonEnhancement(track->Pt());
764                           weight = weight*enhancement;
765                         }
766                         FillHisto2D(Form("EtReconstructed%sLambdaDaughtersReweighted",cutName->Data()),pT,eta,myrecoEt*weight);
767                       }
768                     }
769                     if(pdgCode == fgAntiLambdaCode){
770                       written = true;
771                       float myEt = Et(simPart);
772                       float pT = simPart->Pt();
773                       float eta = simPart->Eta();
774                       eTtotalRecoBkgd+=myEt;
775                       TParticlePDG *simpdg = simPart->GetPDG(0);
776                       if(!simpdg) continue;
777                       if(fUseRecoPt){//Then we switch the pT and the Et
778                         myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
779                         pT = track->Pt();
780                         eta = track->Eta();
781                       }
782                       if( !fRunLightweight){
783                         FillHisto2D(Form("EtReconstructed%sAntiLambdaDaughters",cutName->Data()),pT,eta,myrecoEt);
784                         Float_t weight = AntiLambdaWeight(mom->Pt());
785                         if(fBaryonEnhancement){
786                           float enhancement = ProtonBaryonEnhancement(track->Pt());
787                           weight = weight*enhancement;
788                         }
789                         FillHisto2D(Form("EtReconstructed%sAntiLambdaDaughtersReweighted",cutName->Data()),pT,eta,myrecoEt*weight);
790                       }
791                     }
792                     if(pdgCode == fgK0SCode || pdgCode == fgK0LCode || pdgCode == fgKPlusCode || pdgCode == fgKMinusCode){//actually get all kaon daughters
793                       written = true;
794                       float myEt = Et(simPart);
795                       float pT = simPart->Pt();
796                       float eta = simPart->Eta();
797                       eTtotalRecoBkgd+=myEt;
798                       TParticlePDG *simpdg = simPart->GetPDG(0);
799                       if(!simpdg) continue;
800                       if(fUseRecoPt){//Then we switch the pT and the Et
801                         myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
802                         pT = track->Pt();
803                         eta = track->Eta();
804                       }
805                       if( !fRunLightweight){
806                         FillHisto2D(Form("EtReconstructed%sK0SDaughters",cutName->Data()),pT,eta,myEt);
807                         Float_t weight = K0Weight(mom->Pt());
808                         FillHisto2D(Form("EtReconstructed%sK0SDaughtersReweighted",cutName->Data()),pT,eta,myrecoEt*weight);
809                       }
810                     }
811                     if(pdgCode == fgXiCode){
812                       written = true;
813                       float myEt = Et(simPart);
814                       float pT = simPart->Pt();
815                       float eta = simPart->Eta();
816                       eTtotalRecoBkgd+=myEt;
817                       TParticlePDG *simpdg = simPart->GetPDG(0);
818                       if(!simpdg) continue;
819                       if(fUseRecoPt){//Then we switch the pT and the Et
820                         myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
821                         pT = track->Pt();
822                         eta = track->Eta();
823                       }
824                       if( !fRunLightweight){
825                         FillHisto2D(Form("EtReconstructed%sXiDaughters",cutName->Data()),pT,eta,myrecoEt);
826                       }
827                     }
828                     if(pdgCode == fgAntiXiCode){
829                       written = true;
830                       float myEt = Et(simPart);
831                       float pT = simPart->Pt();
832                       float eta = simPart->Eta();
833                       eTtotalRecoBkgd+=myEt;
834                       TParticlePDG *simpdg = simPart->GetPDG(0);
835                       if(!simpdg) continue;
836                       if(fUseRecoPt){//Then we switch the pT and the Et
837                         myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
838                         pT = track->Pt();
839                         eta = track->Eta();
840                       }
841                       if( !fRunLightweight){
842                         FillHisto2D(Form("EtReconstructed%sAntiXiDaughters",cutName->Data()),pT,eta,myrecoEt);
843                       }
844                     }
845                     if(pdgCode == fgOmegaCode){
846                       written = true;
847                       float myEt = Et(simPart);
848                       float pT = simPart->Pt();
849                       float eta = simPart->Eta();
850                       eTtotalRecoBkgd+=myEt;
851                       TParticlePDG *simpdg = simPart->GetPDG(0);
852                       if(!simpdg) continue;
853                       if(fUseRecoPt){//Then we switch the pT and the Et
854                         myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
855                         pT = track->Pt();
856                         eta = track->Eta();
857                       }
858                       if( !fRunLightweight){
859                         FillHisto2D(Form("EtReconstructed%sOmegaDaughters",cutName->Data()),pT,eta,myrecoEt);
860                       }
861                     }
862                     if(pdgCode == fgXiCode){
863                       written = true;
864                       float myEt = Et(simPart);
865                       float pT = simPart->Pt();
866                       float eta = simPart->Eta();
867                       eTtotalRecoBkgd+=myEt;
868                       TParticlePDG *simpdg = simPart->GetPDG(0);
869                       if(!simpdg) continue;
870                       if(fUseRecoPt){//Then we switch the pT and the Et
871                         myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
872                         pT = track->Pt();
873                         eta = track->Eta();
874                       }
875                       if( !fRunLightweight){
876                         FillHisto2D(Form("EtReconstructed%sAntiOmegaDaughters",cutName->Data()),pT,eta,myrecoEt);
877                       }
878                     }
879
880                     if(mom->GetFirstMother()>0){
881                       TParticle *grandma = NULL;
882                       if(mom->GetFirstMother()>=0) stack->Particle(mom->GetFirstMother());
883                       if(grandma){
884                         TParticlePDG *mompdg = mom->GetPDG(0);
885                         if(!mompdg) continue;
886                         Int_t pdgCodeMom =  mom->GetPDG(0)->PdgCode();
887                         if(pdgCodeMom==fgPiPlusCode || pdgCodeMom==fgPiMinusCode || pdgCodeMom==fgProtonCode ||pdgCodeMom==fgAntiProtonCode || pdgCodeMom==fgKPlusCode || pdgCode==fgKMinusCode){
888                           TParticlePDG *grandmapdg = grandma->GetPDG(0);
889                           if(!grandmapdg) continue;
890                           Int_t pdgCodeGrandma =  grandma->GetPDG(0)->PdgCode();
891                       
892                           if(pdgCodeGrandma == fgXiCode){
893                             written = true;
894                             float myEt = Et(simPart);
895                             float pT = simPart->Pt();
896                             float eta = simPart->Eta();
897                             eTtotalRecoBkgd+=myEt;
898                             if(fUseRecoPt){//Then we switch the pT and the Et
899                               myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
900                               pT = track->Pt();
901                               eta = track->Eta();
902                             }
903                             if( !fRunLightweight){
904                               FillHisto2D(Form("EtReconstructed%sXiDaughters",cutName->Data()),pT,eta,myrecoEt);
905                             }
906                           }
907                           if(pdgCodeGrandma == fgAntiXiCode){
908                             written = true;
909                             float myEt = Et(simPart);
910                             float pT = simPart->Pt();
911                             float eta = simPart->Eta();
912                             eTtotalRecoBkgd+=myEt;
913                             if(fUseRecoPt){//Then we switch the pT and the Et
914                               myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
915                               pT = track->Pt();
916                               eta = track->Eta();
917                             }
918                             if( !fRunLightweight){
919                               FillHisto2D(Form("EtReconstructed%sAntiXiDaughters",cutName->Data()),pT,eta,myrecoEt);
920                             }
921                           }
922                           if(pdgCodeGrandma == fgOmegaCode){
923                             written = true;
924                             float myEt = Et(simPart);
925                             float pT = simPart->Pt();
926                             float eta = simPart->Eta();
927                             eTtotalRecoBkgd+=myEt;
928                             if(fUseRecoPt){//Then we switch the pT and the Et
929                               myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
930                               pT = track->Pt();
931                               eta = track->Eta();
932                             }
933                             if( !fRunLightweight){
934                               FillHisto2D(Form("EtReconstructed%sOmegaDaughters",cutName->Data()),pT,eta,myrecoEt);
935                             }
936                           }
937                           if(pdgCodeGrandma == fgXiCode){
938                             written = true;
939                             float myEt = Et(simPart);
940                             float pT = simPart->Pt();
941                             float eta = simPart->Eta();
942                             eTtotalRecoBkgd+=myEt;
943                             if(fUseRecoPt){//Then we switch the pT and the Et
944                               myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
945                               pT = track->Pt();
946                               eta = track->Eta();
947                             }
948                             if( !fRunLightweight){
949                               FillHisto2D(Form("EtReconstructed%sAntiOmegaDaughters",cutName->Data()),pT,eta,myrecoEt);
950                             }
951                           }
952
953                         }
954                       }
955                     }
956                     if(!written){
957                       int mycode = simPart->GetPDG(0)->PdgCode();
958                       if(!mycode) continue;
959                       if( (pdgCode == fgGammaCode || pdgCode == fgPi0Code) && (mycode==fgEPlusCode||mycode==fgEMinusCode)){
960                         written = true;
961                         float myEt = Et(simPart);
962                         float pT = simPart->Pt();
963                         float eta = simPart->Eta();
964                         eTtotalRecoBkgd+=myEt;
965                         if(fUseRecoPt){//Then we switch the pT and the Et
966                           myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
967                           pT = track->Pt();
968                           eta = track->Eta();
969                         }
970                         if( !fRunLightweight){
971                           FillHisto2D(Form("EtReconstructed%sConversionElectrons",cutName->Data()),pT,eta,myrecoEt);
972                         }
973                       }
974                       if(mycode==fgMuPlusCode || mycode==fgMuMinusCode){
975                         written = true;
976                         float myEt = Et(simPart);
977                         float pT = simPart->Pt();
978                         float eta = simPart->Eta();
979                         eTtotalRecoBkgd+=myEt;
980                         if(fUseRecoPt){//Then we switch the pT and the Et
981                           myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
982                           pT = track->Pt();
983                           eta = track->Eta();
984                         }
985                         if( !fRunLightweight){
986                           FillHisto2D(Form("EtReconstructed%sSecondaryMuons",cutName->Data()),pT,eta,myrecoEt);
987                         }
988                       }
989                       if(mycode==fgPiPlusCode || mycode==fgPiMinusCode){
990                         written = true;
991                         float myEt = Et(simPart);
992                         float pT = simPart->Pt();
993                         float eta = simPart->Eta();
994                         eTtotalRecoBkgd+=myEt;
995                         if(fUseRecoPt){//Then we switch the pT and the Et
996                           myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
997                           pT = track->Pt();
998                           eta = track->Eta();
999                         }
1000                         if( !fRunLightweight){
1001                           FillHisto2D(Form("EtReconstructed%sSecondaryPions",cutName->Data()),pT,eta,myrecoEt);
1002                         }
1003                       }
1004                       if(mycode==fgAntiProtonCode || mycode==fgProtonCode){
1005                         written = true;
1006                         float myEt = Et(simPart);
1007                         float pT = simPart->Pt();
1008                         float eta = simPart->Eta();
1009                         eTtotalRecoBkgd+=myEt;
1010                         if(fUseRecoPt){//Then we switch the pT and the Et
1011                           myEt = Et(track->P(),track->Theta(),simPart->GetPDG(0)->PdgCode(),track->Charge());
1012                           pT = track->Pt();
1013                           eta = track->Eta();
1014                         }
1015                         if( !fRunLightweight){
1016                           FillHisto2D(Form("EtReconstructed%sSecondaryProtons",cutName->Data()),pT,eta,myrecoEt);
1017                         }
1018                       }
1019                       //if(!written) cout<<"I was not counted in the background and I am a "<<simPart->GetName()<<" and my mother is a "<<mom->GetName()<<endl;
1020                     }
1021                   }
1022                   else{cout<<"No particle code!! 657"<<endl;}
1023                 }
1024                 else{cout<<"No mother particle!! 658"<<endl;}
1025               }
1026             }
1027           }
1028
1029         }
1030       }
1031     delete list;
1032   }
1033   if(fInvestigateSmearing && !fRunLightweight){
1034     if(fSimPiKPEtShouldBeReco>0.0) FillHisto2D("SimPiKPEtMinusSimEffCorrRecoOnly",fSimPiKPEtShouldBeReco,(fSimPiKPEtShouldBeReco-eTtotalRecoEffCorr)/fSimPiKPEtShouldBeReco,1.0);
1035     if(fSimPiKPEtShouldBeReco>0.0) FillHisto2D("SimPiKPEtMinusSimEffBkgdCorrRecoOnly",fSimPiKPEtShouldBeReco,(fSimPiKPEtShouldBeReco-eTtotalRecoEffBkgdCorr)/fSimPiKPEtShouldBeReco,1.0);
1036     if(fSimPiKPEtShouldBeRecoPi>0.0) FillHisto2D("SimPiKPEtMinusSimEffCorrRecoPiOnly",fSimPiKPEtShouldBeRecoPi,(fSimPiKPEtShouldBeRecoPi-eTtotalRecoEffCorrPi)/fSimPiKPEtShouldBeRecoPi,1.0);
1037     if(fSimPiKPEtShouldBeRecoP>0.0) FillHisto2D("SimPiKPEtMinusSimEffCorrRecoPOnly",fSimPiKPEtShouldBeRecoP,(fSimPiKPEtShouldBeRecoP-eTtotalRecoEffCorrP)/fSimPiKPEtShouldBeRecoP,1.0);
1038     if(fSimPiKPEtShouldBeRecoK>0.0) FillHisto2D("SimPiKPEtMinusSimEffCorrRecoKOnly",fSimPiKPEtShouldBeRecoK,(fSimPiKPEtShouldBeRecoK-eTtotalRecoEffCorrK)/fSimPiKPEtShouldBeRecoK,1.0);
1039     if(eTtotalSim>0.0) FillHisto2D("SimPiKPEtMinusSimAllCorrSmearedRecoOnly",eTtotalSim,(eTtotalSim-eTtotalSimAll+eTtotalRecoBkgd)/eTtotalSim,1.0);
1040     if(eTtotalRecoTotalUncorr>0.0) FillHisto2D("SimPiKPEtMeasMinusEtRealPiKP",eTtotalRecoTotalUncorr,(eTtotalRecoTotalUncorr-eTtotalRecoUncorr)/eTtotalRecoTotalUncorr,1.0);
1041     if(eTtotalSim>0.0) FillHisto2D("SimPiKPEtMinusSimAllSmearedRecoOnly",eTtotalSim,(eTtotalSim-eTtotalSimAll)/eTtotalSim,1.0);
1042     if(eTtotalSim>0.0) FillHisto2D("SimPiKPEtMinusSimPIDSmearedRecoOnly",eTtotalSim,(eTtotalSim-eTtotalRecoPIDSmeared*1.01)/eTtotalSim,1.0);
1043     if(eTtotalSim>0.0) FillHisto2D("SimPiKPEtMinusSimSmearedRecoOnly",eTtotalSim,(eTtotalSim-eTtotalReco)/eTtotalSim,1.0);
1044     if(pTtotalSim>0.0) FillHisto2D("SimPiKPPtMinusSimSmearedRecoOnly",pTtotalSim,(pTtotalSim-pTtotalReco)/pTtotalSim,1.0);
1045     if(eTtotalSim>0.0) FillHisto2D("SimPiKPEtMinusSimSmearedMultRecoOnly",nReco,(eTtotalSim-eTtotalReco)/eTtotalSim,1.0);
1046     if(pTtotalSim>0.0) FillHisto2D("SimPiKPPtMinusSimSmearedMultRecoOnly",nReco,(pTtotalSim-pTtotalReco)/pTtotalSim,1.0);
1047   }
1048   delete pID;
1049   delete strTPC;
1050   delete strITS;
1051   delete strTPCITS;
1052   return 1;
1053 }
1054 Int_t AliAnalysisHadEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
1055 { // analyse MC event
1056      ResetEventValues();
1057      if(!ev){
1058             AliFatal("ERROR: Event does not exist");   
1059             return 0;
1060      }
1061      
1062     // Get us an mc event
1063     AliMCEvent *mcEvent = dynamic_cast<AliMCEvent*>(ev);
1064     if(!mcEvent){  
1065       AliFatal("ERROR: MC Event does not exist");
1066       return 0;
1067     }
1068
1069     // Let's play with the stack!
1070     AliStack *stack = mcEvent->Stack();
1071
1072
1073     Int_t nPrim = stack->GetNtrack();
1074
1075     Float_t fSimPiKPEtPtSmeared = 0;
1076     Float_t fSimPiKPEtEfficiencySmeared = 0;
1077     Float_t fSimPiKPEtPtCutSmearedTPC = 0;
1078     Float_t fSimPiKPEtPtCutSmearedITS = 0;
1079     Float_t fSimPiKPEtPIDSmeared = 0;
1080     Float_t fSimPiKPEtPIDSmearedNoID = 0;
1081     fSimPiKPEtShouldBeReco = 0;
1082     fSimPiKPEtShouldBeRecoPi = 0;
1083     fSimPiKPEtShouldBeRecoK = 0;
1084     fSimPiKPEtShouldBeRecoP = 0;
1085     //=================Tracks which may or may not have been reconstructed=================
1086
1087     for (Int_t iPart = 0; iPart < nPrim; iPart++)
1088     {
1089
1090       TParticle *part = stack->Particle(iPart);//This line is identified as a loss of memory by valgrind, however, the pointer still belongs to the stack, so it's the stack's problem
1091
1092         if(checkLabelForHIJING && !IsHIJINGLabel(iPart,mcEvent,stack) ) continue;
1093
1094         if (!part)
1095           {
1096             Printf("ERROR: Could not get particle %d", iPart);
1097             continue;
1098           }
1099         // Check if it is a primary particle
1100         if (stack->IsPhysicalPrimary(iPart)){//primaries
1101
1102           if (TMath::Abs(part->Eta()) < fHadEtReco->GetCorrections()->GetEtaCut())          {
1103             TParticlePDG *pdg = part->GetPDG(0);
1104             if(!pdg) continue;
1105             Int_t pdgCode =  part->GetPDG(0)->PdgCode();
1106             bool filled = false;
1107             //Investigating smearing...
1108             //Numbers are realistic correction factors from previous studies
1109             if(fInvestigateSmearing){
1110               if(pdgCode==fgPiPlusCode ||pdgCode==fgPiMinusCode ||pdgCode==fgKPlusCode ||pdgCode==fgKMinusCode ||pdgCode==fgProtonCode ||pdgCode==fgAntiProtonCode){
1111                 //To investigate Smearing...
1112                 Float_t myet = Et(part);
1113                 fSimPiKPEt += myet;
1114                 if(part->Pt()>0.150) fSimRawEtTPC += myet;
1115                 if(part->Pt()>0.100) fSimRawEtITS += myet;
1116                 Float_t theta = part->Theta();
1117                 Short_t charge = 1;
1118                 Float_t momentum = part->P();
1119                 //pt smearing
1120                 Float_t pSmeared = momentum *  fPtSmearer->Gaus(1,0.005);//Gaussian centered around 1
1121                 fSimPiKPEtPtSmeared += Et(pSmeared,theta,pdgCode,charge);
1122                 //Efficiency smearing
1123                 //to mock up the difference between TPC only tracks in p+p (~90% efficiency at high pT) and TPC+ITS tracks in Pb+Pb (about 70% efficiency at high pT) a factor of 7/9 was added in front
1124                 float efficiency = 7.0/9.0*2.26545*TMath::Exp(-TMath::Power(9.99977e-01/part->Pt(),7.85488e-02));//simple rough efficiency from fitting curve
1125                 if(fPtSmearer->Binomial(1,efficiency) ==1){
1126                   fSimPiKPEtEfficiencySmeared += (1.0/efficiency)*myet;
1127                 }
1128                 //pT cut smeared
1129                 if(part->Pt()>0.10){fSimPiKPEtPtCutSmearedITS +=1.00988*myet;}
1130                 if(part->Pt()>0.15){fSimPiKPEtPtCutSmearedTPC +=1.02994*myet;}
1131                 //PID smearing
1132                 fSimPiKPEtPIDSmearedNoID += 1.03018015790601458*Et(momentum,theta,fgPiPlusCode,charge);
1133                 if(part->P()<1.0){//then the particle would have been ID'd
1134                   fSimPiKPEtPIDSmeared += 1.00918051514628582*myet;
1135                 }
1136                 else{//Then it would have been assumed to be a pion
1137                   fSimPiKPEtPIDSmeared += 1.00918051514628582*Et(momentum,theta,fgPiPlusCode,charge);
1138                 }
1139               }
1140             }
1141
1142             //============Charged hadrons===================================
1143             if(pdgCode == fgPiPlusCode){
1144               float myEt = Et(part);
1145               float myEtP = Et(part,fgProtonMass);
1146               float myEtK = Et(part,fgKaonMass);
1147               if(part->Pt()>0.15) fSimPiKPEtShouldBeReco += myEt;
1148               if(part->Pt()>0.15) fSimPiKPEtShouldBeRecoPi += myEt;
1149
1150               fSimHadEt += myEt;
1151               fSimTotEt += myEt;
1152
1153
1154               if( !fRunLightweight){
1155                 FillHisto2D("EtSimulatedPiPlus",part->Pt(),part->Eta(),myEt);
1156                 FillHisto2D("EtNSimulatedPiPlus",part->Pt(),part->Eta(),1.0);
1157                 FillHisto2D("EtSimulatedChargedHadron",part->Pt(),part->Eta(),myEt);
1158                 FillHisto2D("EtNSimulatedChargedHadron",part->Pt(),part->Eta(),1.0);
1159                 if(fCentBin>=0){//if a centrality bin was defined
1160                   FillHisto2D(Form("EtNSimulatedPiPlusCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1161                   FillHisto2D(Form("EtNSimulatedChargedHadronCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1162                 }
1163                 FillHisto2D("EtSimulatedChargedHadronAssumingPion",part->Pt(),part->Eta(),myEt);
1164                 FillHisto2D("EtSimulatedChargedHadronAssumingProton",part->Pt(),part->Eta(),myEtP);
1165                 FillHisto2D("EtSimulatedPiPlusAssumingProton",part->Pt(),part->Eta(),myEtP);
1166                 FillHisto2D("EtSimulatedChargedHadronAssumingKaon",part->Pt(),part->Eta(),myEtK);
1167                 FillHisto2D("EtSimulatedPiPlusAssumingKaon",part->Pt(),part->Eta(),myEtK);
1168                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1169                 Short_t charge = 1;
1170                 Float_t myEtLow = Et(0.0,part->Theta(),pdgCode,charge);
1171                 Float_t myEtITS = Et(0.10/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1172                 Float_t myEtTPC = Et(0.15/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1173                 FillHisto2D("EtSimulatedChargedHadronAssumingNoPt",part->Pt(),part->Eta(),myEtLow);
1174                 FillHisto2D("EtSimulatedChargedHadronAssumingPtTPCCut",part->Pt(),part->Eta(),myEtTPC);
1175                 FillHisto2D("EtSimulatedChargedHadronAssumingPtITSCut",part->Pt(),part->Eta(),myEtITS);
1176               }
1177               filled = true;
1178             }
1179             if(pdgCode == fgPiMinusCode){
1180               float myEt = Et(part);
1181               float myEtP = Et(part,fgProtonMass);
1182               float myEtK = Et(part,fgKaonMass);
1183               if(part->Pt()>0.15) fSimPiKPEtShouldBeReco += myEt;
1184               if(part->Pt()>0.15) fSimPiKPEtShouldBeRecoPi += myEt;
1185               fSimHadEt += myEt;
1186               fSimTotEt += myEt;
1187               if( !fRunLightweight){
1188                 FillHisto2D("EtSimulatedPiMinus",part->Pt(),part->Eta(),myEt);
1189                 FillHisto2D("EtNSimulatedPiMinus",part->Pt(),part->Eta(),1.0);
1190                 FillHisto2D("EtSimulatedChargedHadron",part->Pt(),part->Eta(),myEt);
1191                 FillHisto2D("EtNSimulatedChargedHadron",part->Pt(),part->Eta(),1.0);
1192                 if(fCentBin>=0){//if a centrality bin was defined
1193                   FillHisto2D(Form("EtNSimulatedPiMinusCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1194                   FillHisto2D(Form("EtNSimulatedChargedHadronCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1195                 }
1196                 FillHisto2D("EtSimulatedChargedHadronAssumingPion",part->Pt(),part->Eta(),myEt);
1197                 FillHisto2D("EtSimulatedChargedHadronAssumingProton",part->Pt(),part->Eta(),myEtP);
1198                 FillHisto2D("EtSimulatedPiMinusAssumingProton",part->Pt(),part->Eta(),myEtP);
1199                 FillHisto2D("EtSimulatedChargedHadronAssumingKaon",part->Pt(),part->Eta(),myEtK);
1200                 FillHisto2D("EtSimulatedPiMinusAssumingKaon",part->Pt(),part->Eta(),myEtK);
1201                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1202                 Short_t charge = -1;
1203                 Float_t myEtLow = Et(0.0,part->Theta(),pdgCode,charge);
1204                 Float_t myEtITS = Et(0.10/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1205                 Float_t myEtTPC = Et(0.15/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1206                 FillHisto2D("EtSimulatedChargedHadronAssumingNoPt",part->Pt(),part->Eta(),myEtLow);
1207                 FillHisto2D("EtSimulatedChargedHadronAssumingPtTPCCut",part->Pt(),part->Eta(),myEtTPC);
1208                 FillHisto2D("EtSimulatedChargedHadronAssumingPtITSCut",part->Pt(),part->Eta(),myEtITS);
1209               }
1210               filled = true;
1211             }
1212             if(pdgCode == fgKPlusCode){
1213               float myEt = Et(part);
1214               float myEtPi = Et(part,fgPionMass);
1215               float myEtP = Et(part,fgProtonMass);
1216               if(part->Pt()>0.15) fSimPiKPEtShouldBeReco += myEt;
1217               if(part->Pt()>0.15) fSimPiKPEtShouldBeRecoK += myEt;
1218               fSimHadEt += myEt;
1219               fSimTotEt += myEt;
1220               if( !fRunLightweight){
1221                 FillHisto2D("EtSimulatedKPlus",part->Pt(),part->Eta(),myEt);
1222                 FillHisto2D("EtNSimulatedKPlus",part->Pt(),part->Eta(),1.0);
1223                 FillHisto2D("EtSimulatedChargedHadron",part->Pt(),part->Eta(),myEt);
1224                 FillHisto2D("EtNSimulatedChargedHadron",part->Pt(),part->Eta(),1.0);
1225                 if(fCentBin>=0){//if a centrality bin was defined
1226                   FillHisto2D(Form("EtNSimulatedKPlusCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1227                   FillHisto2D(Form("EtNSimulatedChargedHadronCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1228                 }
1229                 FillHisto2D("EtSimulatedChargedHadronAssumingPion",part->Pt(),part->Eta(),myEtPi);
1230                 FillHisto2D("EtSimulatedKPlusAssumingPion",part->Pt(),part->Eta(),myEtPi);
1231                 FillHisto2D("EtSimulatedChargedHadronAssumingProton",part->Pt(),part->Eta(),myEtP);
1232                 FillHisto2D("EtSimulatedKPlusAssumingProton",part->Pt(),part->Eta(),myEtP);
1233                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1234                 Short_t charge = 1;
1235                 Float_t myEtLow = Et(0.0,part->Theta(),pdgCode,charge);
1236                 Float_t myEtITS = Et(0.10/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1237                 Float_t myEtTPC = Et(0.15/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1238                 FillHisto2D("EtSimulatedChargedHadronAssumingNoPt",part->Pt(),part->Eta(),myEtLow);
1239                 FillHisto2D("EtSimulatedChargedHadronAssumingPtTPCCut",part->Pt(),part->Eta(),myEtTPC);
1240                 FillHisto2D("EtSimulatedChargedHadronAssumingPtITSCut",part->Pt(),part->Eta(),myEtITS);
1241               }
1242               filled = true;
1243             }
1244             if(pdgCode == fgKMinusCode){
1245               float myEt = Et(part);
1246               float myEtPi = Et(part,fgPionMass);
1247               float myEtP = Et(part,fgProtonMass);
1248               if(part->Pt()>0.15) fSimPiKPEtShouldBeReco += myEt;
1249               if(part->Pt()>0.15) fSimPiKPEtShouldBeRecoK += myEt;
1250               fSimHadEt += myEt;
1251               fSimTotEt += myEt;
1252               if( !fRunLightweight){
1253                 FillHisto2D("EtSimulatedKMinus",part->Pt(),part->Eta(),myEt);
1254                 FillHisto2D("EtNSimulatedKMinus",part->Pt(),part->Eta(),1.0);
1255                 FillHisto2D("EtSimulatedChargedHadron",part->Pt(),part->Eta(),myEt);
1256                 FillHisto2D("EtNSimulatedChargedHadron",part->Pt(),part->Eta(),1.0);
1257                 if(fCentBin>=0){//if a centrality bin was defined
1258                   FillHisto2D(Form("EtNSimulatedKMinusCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1259                   FillHisto2D(Form("EtNSimulatedChargedHadronCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1260                 }
1261                 FillHisto2D("EtSimulatedChargedHadronAssumingPion",part->Pt(),part->Eta(),myEtPi);
1262                 FillHisto2D("EtSimulatedKMinusAssumingPion",part->Pt(),part->Eta(),myEtPi);
1263                 FillHisto2D("EtSimulatedChargedHadronAssumingProton",part->Pt(),part->Eta(),myEtP);
1264                 FillHisto2D("EtSimulatedKMinusAssumingProton",part->Pt(),part->Eta(),myEtP);
1265                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1266                 Short_t charge = -1;
1267                 Float_t myEtLow = Et(0.0,part->Theta(),pdgCode,charge);
1268                 Float_t myEtITS = Et(0.10/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1269                 Float_t myEtTPC = Et(0.15/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1270                 FillHisto2D("EtSimulatedChargedHadronAssumingNoPt",part->Pt(),part->Eta(),myEtLow);
1271                 FillHisto2D("EtSimulatedChargedHadronAssumingPtTPCCut",part->Pt(),part->Eta(),myEtTPC);
1272                 FillHisto2D("EtSimulatedChargedHadronAssumingPtITSCut",part->Pt(),part->Eta(),myEtITS);
1273               }
1274               filled = true;
1275             }
1276             if(pdgCode == fgProtonCode){
1277               float myEt = Et(part);
1278               float myEtPi = Et(part,fgPionMass);
1279               float myEtK = Et(part,fgKaonMass);
1280               if(part->Pt()>0.15) fSimPiKPEtShouldBeReco += myEt;
1281               if(part->Pt()>0.15) fSimPiKPEtShouldBeRecoP += myEt;
1282               fSimHadEt += myEt;
1283               fSimTotEt += myEt;
1284               if( !fRunLightweight){
1285                 FillHisto2D("EtSimulatedProton",part->Pt(),part->Eta(),myEt);
1286                 FillHisto2D("EtNSimulatedProton",part->Pt(),part->Eta(),1.0);
1287                 FillHisto2D("EtSimulatedChargedHadron",part->Pt(),part->Eta(),myEt);
1288                 FillHisto2D("EtNSimulatedChargedHadron",part->Pt(),part->Eta(),1.0);
1289                 if(fCentBin>=0){//if a centrality bin was defined
1290                   FillHisto2D(Form("EtNSimulatedProtonCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1291                   FillHisto2D(Form("EtNSimulatedChargedHadronCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1292                 }
1293                 FillHisto2D("EtSimulatedChargedHadronAssumingPion",part->Pt(),part->Eta(),myEtPi);
1294                 FillHisto2D("EtSimulatedProtonAssumingPion",part->Pt(),part->Eta(),myEtPi);
1295                 FillHisto2D("EtSimulatedChargedHadronAssumingKaon",part->Pt(),part->Eta(),myEtK);
1296                 FillHisto2D("EtSimulatedProtonAssumingKaon",part->Pt(),part->Eta(),myEtK);
1297                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1298                 Short_t charge = 1;
1299                 Float_t myEtLow = Et(0.0,part->Theta(),pdgCode,charge);
1300                 Float_t myEtITS = Et(0.10/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1301                 Float_t myEtTPC = Et(0.15/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1302                 FillHisto2D("EtSimulatedChargedHadronAssumingNoPt",part->Pt(),part->Eta(),myEtLow);
1303                 FillHisto2D("EtSimulatedChargedHadronAssumingPtTPCCut",part->Pt(),part->Eta(),myEtTPC);
1304                 FillHisto2D("EtSimulatedChargedHadronAssumingPtITSCut",part->Pt(),part->Eta(),myEtITS);
1305               }
1306               filled = true;
1307               if( !fRunLightweight){
1308                 if(fBaryonEnhancement){
1309                   float enhancement = ProtonBaryonEnhancement(part->Pt());
1310                   FillHisto2D("EtSimulatedProtonEnhanced",part->Pt(),part->Eta(),myEt*enhancement);
1311                   FillHisto2D("EtNSimulatedProtonEnhanced",part->Pt(),part->Eta(),1.0*enhancement);
1312                   FillHisto2D("EtSimulatedProtonAssumingPionEnhanced",part->Pt(),part->Eta(),myEtPi*enhancement);
1313                 }
1314               }
1315             }
1316             if(pdgCode == fgAntiProtonCode){
1317               float myEt = Et(part);
1318               float myEtPi = Et(part,fgPionMass);
1319               float myEtK = Et(part,fgKaonMass);
1320               if(part->Pt()>0.15) fSimPiKPEtShouldBeReco += myEt;
1321               if(part->Pt()>0.15) fSimPiKPEtShouldBeRecoP += myEt;
1322               fSimHadEt += myEt;
1323               fSimTotEt += myEt;
1324               if( !fRunLightweight){
1325                 FillHisto2D("EtSimulatedAntiProton",part->Pt(),part->Eta(),myEt);
1326                 FillHisto2D("EtNSimulatedAntiProton",part->Pt(),part->Eta(),1.0);
1327                 FillHisto2D("EtSimulatedChargedHadron",part->Pt(),part->Eta(),myEt);
1328                 FillHisto2D("EtNSimulatedChargedHadron",part->Pt(),part->Eta(),1.0);
1329                 if(fCentBin>=0){//if a centrality bin was defined
1330                   FillHisto2D(Form("EtNSimulatedAntiProtonCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1331                   FillHisto2D(Form("EtNSimulatedChargedHadronCB%i",fCentBin),part->Pt(),part->Eta(),1.0);
1332                 }
1333                 FillHisto2D("EtSimulatedChargedHadronAssumingPion",part->Pt(),part->Eta(),myEtPi);
1334                 FillHisto2D("EtSimulatedAntiProtonAssumingPion",part->Pt(),part->Eta(),myEtPi);
1335                 FillHisto2D("EtSimulatedChargedHadronAssumingKaon",part->Pt(),part->Eta(),myEtK);
1336                 FillHisto2D("EtSimulatedAntiProtonAssumingKaon",part->Pt(),part->Eta(),myEtK);
1337                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1338                 Short_t charge = -1;
1339                 Float_t myEtLow = Et(0.0,part->Theta(),pdgCode,charge);
1340                 Float_t myEtITS = Et(0.10/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1341                 Float_t myEtTPC = Et(0.15/TMath::Sin(part->Theta()),part->Theta(),pdgCode,charge);
1342                 FillHisto2D("EtSimulatedChargedHadronAssumingNoPt",part->Pt(),part->Eta(),myEtLow);
1343                 FillHisto2D("EtSimulatedChargedHadronAssumingPtTPCCut",part->Pt(),part->Eta(),myEtTPC);
1344                 FillHisto2D("EtSimulatedChargedHadronAssumingPtITSCut",part->Pt(),part->Eta(),myEtITS);
1345               }
1346               filled = true;
1347               if( !fRunLightweight){
1348                 if(fBaryonEnhancement){
1349                   float enhancement = ProtonBaryonEnhancement(part->Pt());
1350                   FillHisto2D("EtSimulatedAntiProtonEnhanced",part->Pt(),part->Eta(),myEt*enhancement);
1351                   FillHisto2D("EtNSimulatedAntiProtonEnhanced",part->Pt(),part->Eta(),1.0*enhancement);
1352                   FillHisto2D("EtSimulatedAntiProtonAssumingPionEnhanced",part->Pt(),part->Eta(),myEtPi*enhancement);
1353                 }
1354               }
1355             }
1356             //============Other hadrons===================================
1357
1358             if(pdgCode == fgNeutronCode){
1359               float myEt = Et(part);
1360               fSimHadEt += myEt;
1361               fSimTotEt += myEt;
1362               if( !fRunLightweight){
1363                 FillHisto2D("EtSimulatedNeutron",part->Pt(),part->Eta(),myEt);
1364                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1365               }
1366               filled = true;
1367             }
1368             if(pdgCode == fgAntiNeutronCode){
1369               float myEt = Et(part);
1370               fSimHadEt += myEt;
1371               fSimTotEt += myEt;
1372               if( !fRunLightweight){
1373                 FillHisto2D("EtSimulatedAntiNeutron",part->Pt(),part->Eta(),myEt);
1374                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1375               }
1376               filled = true;
1377             }
1378             if(pdgCode == fgLambdaCode){
1379               float myEt = Et(part);
1380               fSimHadEt += myEt;
1381               fSimTotEt += myEt;
1382               if( !fRunLightweight){
1383                 FillHisto2D("EtSimulatedLambda",part->Pt(),part->Eta(),myEt);
1384                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1385                 Float_t weight = LambdaWeight(part->Pt());
1386                 if(fBaryonEnhancement){
1387                   float enhancement = ProtonBaryonEnhancement(part->Pt());
1388                   weight = weight*enhancement;
1389                 }
1390                 FillHisto2D("EtSimulatedLambdaReweighted",part->Pt(),part->Eta(),myEt*weight);
1391                 Int_t ndaughters = part->GetNDaughters();
1392                 for(Int_t idaughter = 0;idaughter<ndaughters;idaughter++){
1393                   Int_t daughterindex = part->GetDaughter(idaughter);
1394                   if(daughterindex<0 || daughterindex>1e5) continue;
1395                   TParticle *daughter = stack->ParticleFromTreeK(daughterindex);
1396                   if(daughter){
1397                     if(daughter->GetPDG(0)){
1398                       Int_t daughtercode = daughter->GetPDG(0)->PdgCode();
1399                       if(daughtercode==fgPiMinusCode || daughtercode==fgProtonCode){
1400                         myEt = Et(daughter);
1401                         FillHisto2D("EtSimulatedLambdaDaughters",daughter->Pt(),daughter->Eta(),myEt);
1402                         FillHisto2D("EtSimulatedLambdaDaughtersReweighted",daughter->Pt(),daughter->Eta(),myEt*weight);
1403                       }
1404                     }
1405                     else{
1406                     }
1407                   }
1408                 }
1409               }
1410               filled = true;
1411             }
1412             if(pdgCode == fgAntiLambdaCode){
1413               float myEt = Et(part);
1414               fSimHadEt += myEt;
1415               fSimTotEt += myEt;
1416               if( !fRunLightweight){
1417                 FillHisto2D("EtSimulatedAntiLambda",part->Pt(),part->Eta(),myEt);
1418                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1419                 Float_t weight = AntiLambdaWeight(part->Pt());
1420                 if(fBaryonEnhancement){
1421                   float enhancement = ProtonBaryonEnhancement(part->Pt());
1422                   weight = weight*enhancement;
1423                 }
1424                 FillHisto2D("EtSimulatedAntiLambdaReweighted",part->Pt(),part->Eta(),myEt*weight);
1425                 Int_t ndaughters = part->GetNDaughters();
1426                 for(Int_t idaughter = 0;idaughter<ndaughters;idaughter++){
1427                   Int_t daughterindex = part->GetDaughter(idaughter);
1428                   if(daughterindex<0 || daughterindex>1e5) continue;
1429                   TParticle *daughter = stack->ParticleFromTreeK(daughterindex);
1430                   if(daughter){
1431                     if(daughter->GetPDG(0)){
1432                       Int_t daughtercode = daughter->GetPDG(0)->PdgCode();
1433                       if(daughtercode==fgPiPlusCode || daughtercode==fgAntiProtonCode){
1434                         myEt = Et(daughter);
1435                         FillHisto2D("EtSimulatedAntiLambdaDaughters",daughter->Pt(),daughter->Eta(),myEt);
1436                         FillHisto2D("EtSimulatedAntiLambdaDaughtersReweighted",daughter->Pt(),daughter->Eta(),myEt*weight);
1437                       }
1438                     }
1439                   }
1440                 }
1441               }
1442               filled = true;
1443             }
1444             if(pdgCode == fgK0SCode){
1445               float myEt = Et(part);
1446               fSimHadEt += myEt;
1447               fSimTotEt += myEt;
1448               if( !fRunLightweight){
1449                 FillHisto2D("EtSimulatedK0S",part->Pt(),part->Eta(),myEt);
1450                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1451                 Float_t weight = K0Weight(part->Pt());
1452                 FillHisto2D("EtSimulatedK0SReweighted",part->Pt(),part->Eta(),myEt*weight);
1453                 Int_t ndaughters = part->GetNDaughters();
1454                 for(Int_t idaughter = 0;idaughter<ndaughters;idaughter++){
1455                   Int_t daughterindex = part->GetDaughter(idaughter);
1456                   if(daughterindex<0 || daughterindex>1e5) continue;
1457                   TParticle *daughter = stack->ParticleFromTreeK(daughterindex);
1458                   if(daughter){
1459                     if(daughter->GetPDG(0)){
1460                       
1461                       Int_t daughtercode = daughter->GetPDG(0)->PdgCode();
1462                       if(daughtercode==fgPiMinusCode || daughtercode==fgPiPlusCode){
1463                         myEt = Et(daughter);
1464                         FillHisto2D("EtSimulatedK0SDaughters",daughter->Pt(),daughter->Eta(),myEt);
1465                         FillHisto2D("EtSimulatedK0SDaughtersReweighted",daughter->Pt(),daughter->Eta(),myEt*weight);
1466                       }
1467                     }
1468                   }
1469                 }
1470               }
1471               filled = true;
1472             }
1473             if(pdgCode == fgK0LCode){
1474               float myEt = Et(part);
1475               fSimHadEt += myEt;
1476               fSimTotEt += myEt;
1477               if( !fRunLightweight){
1478                 FillHisto2D("EtSimulatedK0L",part->Pt(),part->Eta(),myEt);
1479                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1480                 Float_t weight = K0Weight(part->Pt());
1481                 FillHisto2D("EtSimulatedK0LReweighted",part->Pt(),part->Eta(),myEt*weight);
1482               }
1483               filled = true;
1484             }
1485             if(pdgCode == fgOmegaCode){
1486               float myEt = Et(part);
1487               fSimHadEt += myEt;
1488               fSimTotEt += myEt;
1489               if( !fRunLightweight){
1490                 FillHisto2D("EtSimulatedOmega",part->Pt(),part->Eta(),myEt);
1491                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1492                 Int_t ndaughters = part->GetNDaughters();
1493                 for(Int_t idaughter = 0;idaughter<ndaughters;idaughter++){
1494                   Int_t daughterindex = part->GetDaughter(idaughter);
1495                   if(daughterindex<0 || daughterindex>1e5) continue;
1496                   TParticle *daughter = stack->Particle(daughterindex);
1497                   if(daughter){
1498                     if(daughter->GetPDG(0)){
1499                       
1500                       Int_t daughtercode = daughter->GetPDG(0)->PdgCode();
1501                       if(daughtercode==fgPiPlusCode || daughtercode==fgProtonCode || daughtercode==fgKMinusCode){
1502                         myEt = Et(daughter);
1503                         FillHisto2D("EtSimulatedOmegaDaughters",daughter->Pt(),daughter->Eta(),myEt);
1504                       }
1505                     }
1506                   }
1507                 }
1508               }
1509               filled = true;
1510             }
1511             if(pdgCode == fgAntiOmegaCode){
1512               float myEt = Et(part);
1513               fSimHadEt += myEt;
1514               fSimTotEt += myEt;
1515               if( !fRunLightweight){
1516                 FillHisto2D("EtSimulatedOmega",part->Pt(),part->Eta(),myEt);
1517                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1518                 Int_t ndaughters = part->GetNDaughters();
1519                 for(Int_t idaughter = 0;idaughter<ndaughters;idaughter++){
1520                   Int_t daughterindex = part->GetDaughter(idaughter);
1521                   if(daughterindex<0 || daughterindex>1e5) continue;
1522                   TParticle *daughter = stack->ParticleFromTreeK(daughterindex);
1523                   if(daughter){
1524                     if(daughter->GetPDG(0)){
1525                       Int_t daughtercode = daughter->GetPDG(0)->PdgCode();
1526                       if(daughtercode==fgPiMinusCode || daughtercode==fgAntiProtonCode || daughtercode==fgKPlusCode){
1527                         myEt = Et(daughter);
1528                         FillHisto2D("EtSimulatedAntiOmegaDaughters",daughter->Pt(),daughter->Eta(),myEt);
1529                       }
1530                     }
1531                   }
1532                 }
1533               }
1534               filled = true;
1535             }
1536             //There are two codes for Sigmas
1537             if(pdgCode == fgSigmaCode || pdgCode == -3222){
1538               float myEt = Et(part);
1539               fSimHadEt += myEt;
1540               fSimTotEt += myEt;
1541               if( !fRunLightweight){
1542                 FillHisto2D("EtSimulatedSigma",part->Pt(),part->Eta(),myEt);
1543                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1544               }
1545               filled = true;
1546             }
1547             if(pdgCode == fgAntiSigmaCode || pdgCode == 3222){
1548               float myEt = Et(part);
1549               fSimHadEt += myEt;
1550               fSimTotEt += myEt;
1551               if( !fRunLightweight){
1552                 FillHisto2D("EtSimulatedAntiSigma",part->Pt(),part->Eta(),myEt);
1553                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1554               }
1555               filled = true;
1556             }
1557             if(pdgCode == fgXiCode){
1558               float myEt = Et(part);
1559               fSimHadEt += myEt;
1560               fSimTotEt += myEt;
1561               if( !fRunLightweight){
1562                 FillHisto2D("EtSimulatedXi",part->Pt(),part->Eta(),myEt);
1563                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1564                 Int_t ndaughters = part->GetNDaughters();
1565                 for(Int_t idaughter = 0;idaughter<ndaughters;idaughter++){
1566                   Int_t daughterindex = part->GetDaughter(idaughter);
1567                   if(daughterindex<0 || daughterindex>1e5 || daughterindex>1e5) continue;
1568                   TParticle *daughter = stack->ParticleFromTreeK(daughterindex);
1569                   if(daughter){
1570                     if(daughter->GetPDG(0)){
1571                       
1572                       Int_t daughtercode = daughter->GetPDG(0)->PdgCode();
1573                       if(daughtercode==fgPiPlusCode || daughtercode==fgProtonCode || daughtercode==fgPiMinusCode){
1574                         myEt = Et(daughter);
1575                         FillHisto2D("EtSimulatedXiDaughters",daughter->Pt(),daughter->Eta(),myEt);
1576                       }
1577                     }
1578                   }
1579                 }
1580               }
1581               filled = true;
1582             }
1583             if(pdgCode == fgAntiXiCode){
1584               float myEt = Et(part);
1585               fSimHadEt += myEt;
1586               fSimTotEt += myEt;
1587               if( !fRunLightweight){
1588                 FillHisto2D("EtSimulatedAntiXi",part->Pt(),part->Eta(),myEt);
1589                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1590                 Int_t ndaughters = part->GetNDaughters();
1591                 for(Int_t idaughter = 0;idaughter<ndaughters;idaughter++){
1592                   Int_t daughterindex = part->GetDaughter(idaughter);
1593                   if(daughterindex<0 || daughterindex>1e5) continue;
1594                   TParticle *daughter = stack->ParticleFromTreeK(daughterindex);
1595                   if(daughter){
1596                     if(daughter->GetPDG(0)){
1597                       Int_t daughtercode = daughter->GetPDG(0)->PdgCode();
1598                       if(daughtercode==fgPiPlusCode || daughtercode==fgAntiProtonCode || daughtercode==fgPiMinusCode){
1599                         myEt = Et(daughter);
1600                         FillHisto2D("EtSimulatedAntiXiDaughters",daughter->Pt(),daughter->Eta(),myEt);
1601                       }
1602                     }
1603                   }
1604                 }
1605               }
1606               filled = true;
1607             }
1608             if(pdgCode == fgXi0Code){
1609               float myEt = Et(part);
1610               fSimHadEt += myEt;
1611               fSimTotEt += myEt;
1612               if( !fRunLightweight){
1613                 FillHisto2D("EtSimulatedXi0",part->Pt(),part->Eta(),myEt);
1614                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1615               }
1616               filled = true;
1617             }
1618             if(pdgCode == fgAntiXi0Code){
1619               float myEt = Et(part);
1620               fSimHadEt += myEt;
1621               fSimTotEt += myEt;
1622               if( !fRunLightweight){
1623                 FillHisto2D("EtSimulatedAntiXi0",part->Pt(),part->Eta(),myEt);
1624                 FillHisto2D("EtSimulatedAllHadron",part->Pt(),part->Eta(),myEt);
1625               }
1626               filled = true;
1627             }
1628             //============electrons===================================
1629
1630             if(pdgCode == fgEPlusCode){
1631               float myEt = Et(part);
1632               fSimTotEt += myEt;
1633               if( !fRunLightweight){
1634                 FillHisto2D("EtSimulatedEPlus",part->Pt(),part->Eta(),myEt);
1635               }
1636               filled = true;
1637             }
1638             if(pdgCode == fgEMinusCode){
1639               float myEt = Et(part);
1640               fSimTotEt += myEt;
1641               if( !fRunLightweight){
1642                 FillHisto2D("EtSimulatedEMinus",part->Pt(),part->Eta(),myEt);
1643               }
1644               filled = true;
1645             }
1646             //============neutrals===================================
1647             if(pdgCode == fgGammaCode){
1648               TParticle *mom = NULL;
1649               Int_t pdgCodeMom = -99999999;
1650               float momEta = -30;
1651               float mompT = -5;
1652               if(part->GetFirstMother()>=0){
1653                 mom = stack->Particle(part->GetFirstMother());
1654                 if(mom->GetPDG(0)){
1655                   pdgCodeMom =  mom->GetPDG(0)->PdgCode();
1656                   momEta = mom->Eta();
1657                   mompT = mom->Pt();
1658                 }
1659               }
1660               //We want to separate the gammas by pi0, eta, omega0 but we don't want to double count energy so we get the et from the gamma daughter
1661               if(pdgCodeMom == fgEtaCode){
1662                 float myEt = Et(part);
1663                 fSimTotEt += myEt;
1664                 if( !fRunLightweight){
1665                   FillHisto2D("EtSimulatedEta",mompT,momEta,myEt);
1666                 }
1667                 filled = true;
1668               }
1669               if(pdgCodeMom == fgPi0Code){
1670                 float myEt = Et(part);
1671                 fSimTotEt += myEt;
1672                 if( !fRunLightweight){
1673                   FillHisto2D("EtSimulatedPi0",mompT,momEta,myEt);
1674                 }
1675                 filled = true;
1676               }
1677               if(pdgCodeMom == fgOmega0Code){
1678                 float myEt = Et(part);
1679                 fSimTotEt += myEt;
1680                 if( !fRunLightweight){
1681                   FillHisto2D("EtSimulatedOmega0",mompT,momEta,myEt);
1682                 }
1683                 filled = true;
1684               }
1685               if(!filled){
1686                 float myEt = Et(part);
1687                 fSimTotEt += myEt;
1688                 if( !fRunLightweight){
1689                   FillHisto2D("EtSimulatedGamma",part->Pt(),part->Eta(),myEt);
1690                 }
1691                 filled = true;
1692               }
1693             }
1694             if(pdgCode == fgEtaCode){
1695               float myEt = Et(part);
1696               fSimTotEt += myEt;
1697               if( !fRunLightweight){
1698                 FillHisto2D("EtSimulatedEta",part->Pt(),part->Eta(),myEt);
1699               }
1700               filled = true;
1701             }
1702             if(pdgCode == fgPi0Code){
1703               float myEt = Et(part);
1704               fSimTotEt += myEt;
1705               if( !fRunLightweight){
1706                 FillHisto2D("EtSimulatedPi0",part->Pt(),part->Eta(),myEt);
1707               }
1708               filled = true;
1709             }
1710             if(pdgCode == fgOmega0Code){
1711               float myEt = Et(part);
1712               fSimTotEt += myEt;
1713               if( !fRunLightweight){
1714                 FillHisto2D("EtSimulatedOmega0",part->Pt(),part->Eta(),myEt);
1715               }
1716               filled = true;
1717             }
1718           }
1719         }
1720     }
1721
1722     FillHisto1D("SimTotEt",fSimTotEt,1.0);
1723     FillHisto1D("SimHadEt",fSimHadEt,1.0);
1724     FillHisto1D("SimPiKPEt",fSimPiKPEt,1.0);
1725     FillHisto1D("SimRawEtTPC",fSimRawEtTPC,1.0);
1726     FillHisto1D("SimRawEtITS",fSimRawEtITS,1.0);
1727     if((fDataSet!=20100 || fDataSet==2011) && AliPWG0Helper::GetEventProcessType(mcEvent->Header()) == AliPWG0Helper::kND){
1728       FillHisto1D("SimHadEtND",fSimHadEt,1.0);
1729       FillHisto1D("SimTotEtND",fSimTotEt,1.0);
1730       FillHisto1D("NEventsND",0.5,1);
1731       FillHisto1D("SimPiKPEtND",fSimPiKPEt,1.0);
1732       FillHisto1D("SimRawEtNDTPC",fSimRawEtTPC,1.0);
1733       FillHisto1D("SimRawEtNDITS",fSimRawEtITS,1.0);
1734       if(kIsOfflineV0AND){
1735         FillHisto1D("SimHadEtNDV0AND",fSimHadEt,1.0);
1736         FillHisto1D("SimTotEtNDV0AND",fSimTotEt,1.0);
1737         FillHisto1D("NEventsNDV0AND",0.5,1);
1738         FillHisto1D("SimPiKPEtNDV0AND",fSimPiKPEt,1.0);
1739         FillHisto1D("SimRawEtNDV0ANDTPC",fSimRawEtTPC,1.0);
1740         FillHisto1D("SimRawEtNDV0ANDITS",fSimRawEtITS,1.0);
1741       }
1742       if(kIsOfflineMB){
1743         FillHisto1D("SimHadEtNDMB",fSimHadEt,1.0);
1744         FillHisto1D("SimTotEtNDMB",fSimTotEt,1.0);
1745         FillHisto1D("NEventsNDMB",0.5,1);
1746         FillHisto1D("SimPiKPEtNDMB",fSimPiKPEt,1.0);
1747         FillHisto1D("SimRawEtNDMBTPC",fSimRawEtTPC,1.0);
1748         FillHisto1D("SimRawEtNDMBITS",fSimRawEtITS,1.0);
1749       }
1750     }
1751     if((fDataSet!=20100||fDataSet==2011) && AliPWG0Helper::GetEventProcessType(mcEvent->Header()) == AliPWG0Helper::kSD){
1752       FillHisto1D("SimHadEtSD",fSimHadEt,1.0);
1753       FillHisto1D("SimTotEtSD",fSimTotEt,1.0);
1754       FillHisto1D("NEventsSD",0.5,1);
1755       FillHisto1D("SimPiKPEtSD",fSimPiKPEt,1.0);
1756       FillHisto1D("SimRawEtSDTPC",fSimRawEtTPC,1.0);
1757       FillHisto1D("SimRawEtSDITS",fSimRawEtITS,1.0);
1758       if(kIsOfflineV0AND){
1759         FillHisto1D("SimHadEtSDV0AND",fSimHadEt,1.0);
1760         FillHisto1D("SimTotEtSDV0AND",fSimTotEt,1.0);
1761         FillHisto1D("NEventsSDV0AND",0.5,1);
1762         FillHisto1D("SimPiKPEtSDV0AND",fSimPiKPEt,1.0);
1763         FillHisto1D("SimRawEtSDV0ANDTPC",fSimRawEtTPC,1.0);
1764         FillHisto1D("SimRawEtSDV0ANDITS",fSimRawEtITS,1.0);
1765       }
1766       if(kIsOfflineMB){
1767         FillHisto1D("SimHadEtSDMB",fSimHadEt,1.0);
1768         FillHisto1D("SimTotEtSDMB",fSimTotEt,1.0);
1769         FillHisto1D("NEventsSDMB",0.5,1);
1770         FillHisto1D("SimPiKPEtSDMB",fSimPiKPEt,1.0);
1771         FillHisto1D("SimRawEtSDMBTPC",fSimRawEtTPC,1.0);
1772         FillHisto1D("SimRawEtSDMBITS",fSimRawEtITS,1.0);
1773       }
1774     }
1775     if((fDataSet!=20100 || fDataSet==2011) && AliPWG0Helper::GetEventProcessType(mcEvent->Header()) == AliPWG0Helper::kDD){
1776       FillHisto1D("SimHadEtDD",fSimHadEt,1.0);
1777       FillHisto1D("SimTotEtDD",fSimTotEt,1.0);
1778       FillHisto1D("NEventsDD",0.5,1);
1779       FillHisto1D("SimPiKPEtDD",fSimPiKPEt,1.0);
1780       FillHisto1D("SimRawEtDDTPC",fSimRawEtTPC,1.0);
1781       if(kIsOfflineV0AND){
1782         FillHisto1D("SimHadEtDDV0AND",fSimHadEt,1.0);
1783         FillHisto1D("SimTotEtDDV0AND",fSimTotEt,1.0);
1784         FillHisto1D("NEventsDDV0AND",0.5,1);
1785         FillHisto1D("SimPiKPEtDDV0AND",fSimPiKPEt,1.0);
1786         FillHisto1D("SimRawEtDDV0ANDTPC",fSimRawEtTPC,1.0);
1787         FillHisto1D("SimRawEtDDV0ANDITS",fSimRawEtITS,1.0);
1788       }
1789       if(kIsOfflineMB){
1790         FillHisto1D("SimHadEtDDMB",fSimHadEt,1.0);
1791         FillHisto1D("SimTotEtDDMB",fSimTotEt,1.0);
1792         FillHisto1D("NEventsDDMB",0.5,1);
1793         FillHisto1D("SimPiKPEtDDMB",fSimPiKPEt,1.0);
1794         FillHisto1D("SimRawEtDDMBTPC",fSimRawEtTPC,1.0);
1795         FillHisto1D("SimRawEtDDMBITS",fSimRawEtITS,1.0);
1796       }
1797     }
1798     if(fCentBin != -1){//if we have Pb+Pb and a centrality bin was found
1799       if(fSimTotEt>0.0) FillHisto1D(Form("SimTotEtCB%i",fCentBin),fSimTotEt,1.0);
1800       if(fSimHadEt>0.0) FillHisto1D(Form("SimHadEtCB%i",fCentBin),fSimHadEt,1.0);
1801       if(fSimPiKPEt>0.0)FillHisto1D(Form("SimPiKPEtCB%i",fCentBin),fSimPiKPEt,1.0);
1802     }
1803
1804     if(fInvestigateSmearing && !fRunLightweight){
1805       //Smearing histograms
1806       if(fSimPiKPEt>0.0) FillHisto2D("SimPiKPEtMinusSimPtSmeared",fSimPiKPEt,(fSimPiKPEt-fSimPiKPEtPtSmeared)/fSimPiKPEt,1.0);
1807       FillHisto1D("SimPiKPEtPtSmeared",fSimPiKPEtPtSmeared,1.0);
1808       if(fSimPiKPEt>0.0) FillHisto2D("SimPiKPEtMinusSimEfficiencySmeared",fSimPiKPEt,(fSimPiKPEt-fSimPiKPEtEfficiencySmeared)/fSimPiKPEt,1.0);
1809       FillHisto1D("SimPiKPEtEfficiencySmeared",fSimPiKPEtEfficiencySmeared,1.0);
1810       if(fSimPiKPEt>0.0) FillHisto2D("SimPiKPEtMinusSimPtCutSmearedTPC",fSimPiKPEt,(fSimPiKPEt-fSimPiKPEtPtCutSmearedTPC)/fSimPiKPEt,1.0);
1811       FillHisto1D("SimPiKPEtPtCutSmearedTPC",fSimPiKPEtPtCutSmearedTPC,1.0);
1812       if(fSimPiKPEt>0.0) FillHisto2D("SimPiKPEtMinusSimPtCutSmearedITS",fSimPiKPEt,(fSimPiKPEt-fSimPiKPEtPtCutSmearedITS)/fSimPiKPEt,1.0);
1813       FillHisto1D("SimPiKPEtPtCutSmearedITS",fSimPiKPEtPtCutSmearedTPC,1.0);
1814       if(fSimPiKPEt>0.0) FillHisto2D("SimPiKPEtMinusSimPIDSmeared",fSimPiKPEt,(fSimPiKPEt-fSimPiKPEtPIDSmeared)/fSimPiKPEt,1.0);
1815       FillHisto1D("SimPiKPEtPIDSmeared",fSimPiKPEtPIDSmeared,1.0);
1816       if(fSimPiKPEt>0.0) FillHisto2D("SimPiKPEtMinusSimPIDSmearedNoID",fSimPiKPEt,(fSimPiKPEt-fSimPiKPEtPIDSmearedNoID)/fSimPiKPEt,1.0);
1817       FillHisto1D("SimPiKPEtPIDSmearedNoID",fSimPiKPEtPIDSmearedNoID,1.0);
1818     }
1819     return 1;
1820     
1821 }
1822
1823 void AliAnalysisHadEtMonteCarlo::Init()
1824 { // Init
1825     AliAnalysisHadEt::Init();
1826     if(!fPtSmearer) fPtSmearer = new TRandom();
1827 }
1828 void AliAnalysisHadEtMonteCarlo::CreateHistograms(){
1829   //for simulated Et only (no reconstruction)
1830
1831   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
1832   if (!man) {
1833     AliFatal("Analysis manager needed");
1834     return;
1835   }
1836   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
1837   if (!inputHandler) {
1838     AliFatal("Input handler needed");
1839     return;
1840   }
1841
1842   //pid response object
1843   fPIDResponse=inputHandler->GetPIDResponse();
1844   if (!fPIDResponse) AliError("PIDResponse object was not created");
1845
1846   if( !fRunLightweight){
1847     CreateEtaPtHisto2D(TString("EtSimulatedPiPlus"),TString("Simulated E_{T} from #pi^{+}"));
1848     CreateEtaPtHisto2D("EtSimulatedPiMinus","Simulated E_{T} from #pi^{-}");
1849     CreateEtaPtHisto2D("EtSimulatedKPlus","Simulated E_{T} from K^{+}");
1850     CreateEtaPtHisto2D("EtSimulatedKMinus","Simulated E_{T} from K^{-}");
1851     CreateEtaPtHisto2D("EtSimulatedProton","Simulated E_{T} from p");
1852     CreateEtaPtHisto2D("EtSimulatedAntiProton","Simulated E_{T} from #bar{p}");//Both baryon enhancement and strangeness rescaling
1853     if(fBaryonEnhancement){
1854       CreateEtaPtHisto2D("EtSimulatedProtonEnhanced","Simulated E_{T} from p");
1855       CreateEtaPtHisto2D("EtSimulatedAntiProtonEnhanced","Simulated E_{T} from #bar{p}");
1856     }
1857     CreateEtaPtHisto2D("EtSimulatedChargedHadron","Simulated E_{T} from charged hadrons");
1858     CreateEtaPtHisto2D("EtNSimulatedPiPlus","Number of Simulated #pi^{+}");
1859     CreateEtaPtHisto2D("EtNSimulatedPiMinus","Number of simulated #pi^{-}");
1860     CreateEtaPtHisto2D("EtNSimulatedKPlus","Number of simulated K^{+}");
1861     CreateEtaPtHisto2D("EtNSimulatedKMinus","Number of simulated K^{-}");
1862     CreateEtaPtHisto2D("EtNSimulatedProton","Number of simulated p");
1863     CreateEtaPtHisto2D("EtNSimulatedAntiProton","Number of simulated #bar{p}");
1864     if(fBaryonEnhancement){
1865       CreateEtaPtHisto2D("EtNSimulatedProtonEnhanced","Number of simulated p");
1866       CreateEtaPtHisto2D("EtNSimulatedAntiProtonEnhanced","Number of simulated #bar{p}");
1867     }
1868     CreateEtaPtHisto2D("EtNSimulatedChargedHadron","Number of simulated charged hadrons");
1869     if(fDataSet==20100 || fDataSet==2011){//If this is Pb+Pb
1870       Int_t width = 5;
1871       if(fNCentBins<21) width = 10;
1872       for(Int_t i=0;i<fNCentBins;i++){
1873         CreateEtaPtHisto2D(Form("EtNSimulatedPiPlusCB%i",i),Form("Number of Simulated #pi^{+} for %i-%i central",i*width,(i+1)*width));
1874         CreateEtaPtHisto2D(Form("EtNSimulatedPiMinusCB%i",i),Form("Number of simulated #pi^{-} for %i-%i central",i*width,(i+1)*width));
1875         CreateEtaPtHisto2D(Form("EtNSimulatedKPlusCB%i",i),Form("Number of simulated K^{+} for %i-%i central",i*width,(i+1)*width));
1876         CreateEtaPtHisto2D(Form("EtNSimulatedKMinusCB%i",i),Form("Number of simulated K^{-} for %i-%i central",i*width,(i+1)*width));
1877         CreateEtaPtHisto2D(Form("EtNSimulatedProtonCB%i",i),Form("Number of simulated p for %i-%i central",i*width,(i+1)*width));
1878         CreateEtaPtHisto2D(Form("EtNSimulatedAntiProtonCB%i",i),Form("Number of simulated #bar{p} for %i-%i central",i*width,(i+1)*width));
1879         CreateEtaPtHisto2D(Form("EtNSimulatedChargedHadronCB%i",i),Form("Number of simulated charged hadrons for %i-%i central",i*width,(i+1)*width));
1880       }
1881     }
1882     CreateEtaPtHisto2D("EtSimulatedChargedHadronAssumingNoPt","Simulated E_{T} from charged hadrons assuming p_{T}=0");
1883     CreateEtaPtHisto2D("EtSimulatedChargedHadronAssumingPtTPCCut","Simulated E_{T} from charged hadrons assuming p_{T}=0.15");
1884     CreateEtaPtHisto2D("EtSimulatedChargedHadronAssumingPtITSCut","Simulated E_{T} from charged hadrons assuming p_{T}=0.10");
1885
1886     CreateEtaPtHisto2D("EtSimulatedChargedHadronAssumingPion","Simulated E_{T} from charged hadrons assuming they are all pions");
1887     CreateEtaPtHisto2D("EtSimulatedChargedHadronAssumingProton","Simulated E_{T} from charged hadrons assuming they are all pions");
1888     CreateEtaPtHisto2D("EtSimulatedChargedHadronAssumingKaon","Simulated E_{T} from charged hadrons assuming they are all pions");
1889     CreateEtaPtHisto2D("EtSimulatedKPlusAssumingPion","Simulated E_{T} from K^{+} assuming #pi mass");
1890     CreateEtaPtHisto2D("EtSimulatedKMinusAssumingPion","Simulated E_{T} from K^{-} assuming #pi mass");
1891     CreateEtaPtHisto2D("EtSimulatedProtonAssumingPion","Simulated E_{T} from p assuming #pi mass");
1892     CreateEtaPtHisto2D("EtSimulatedAntiProtonAssumingPion","Simulated E_{T} from #bar{p} assuming #pi mass");
1893     CreateEtaPtHisto2D("EtSimulatedKPlusAssumingProton","Simulated E_{T} from K^{+} assuming #pi mass");
1894     CreateEtaPtHisto2D("EtSimulatedKMinusAssumingProton","Simulated E_{T} from K^{-} assuming #pi mass");
1895     CreateEtaPtHisto2D("EtSimulatedPiPlusAssumingProton","Simulated E_{T} from p assuming #pi mass");
1896     CreateEtaPtHisto2D("EtSimulatedPiMinusAssumingProton","Simulated E_{T} from #bar{p} assuming #pi mass");
1897     CreateEtaPtHisto2D("EtSimulatedPiPlusAssumingKaon","Simulated E_{T} from K^{+} assuming #pi mass");
1898     CreateEtaPtHisto2D("EtSimulatedPiMinusAssumingKaon","Simulated E_{T} from K^{-} assuming #pi mass");
1899     CreateEtaPtHisto2D("EtSimulatedProtonAssumingKaon","Simulated E_{T} from p assuming #pi mass");
1900     CreateEtaPtHisto2D("EtSimulatedAntiProtonAssumingKaon","Simulated E_{T} from #bar{p} assuming #pi mass");
1901     if(fBaryonEnhancement){
1902       CreateEtaPtHisto2D("EtSimulatedProtonAssumingPionEnhanced","Simulated E_{T} from p assuming #pi mass");
1903       CreateEtaPtHisto2D("EtSimulatedAntiProtonAssumingPionEnhanced","Simulated E_{T} from #bar{p} assuming #pi mass");
1904     }
1905
1906     CreateEtaPtHisto2D("EtSimulatedLambda","Simulated E_{T} from #Lambda");
1907     CreateEtaPtHisto2D("EtSimulatedAntiLambda","Simulated E_{T} from #bar{#Lambda}");
1908     CreateEtaPtHisto2D("EtSimulatedK0S","Simulated E_{T} from K^{0}_{S}");
1909     CreateEtaPtHisto2D("EtSimulatedK0L","Simulated E_{T} from K^{0}_{L}");
1910     CreateEtaPtHisto2D("EtSimulatedLambdaReweighted","Simulated E_{T} from #Lambda");//These will also be used for baryon enhancement
1911     CreateEtaPtHisto2D("EtSimulatedAntiLambdaReweighted","Simulated E_{T} from #bar{#Lambda}");
1912     CreateEtaPtHisto2D("EtSimulatedK0SReweighted","Simulated E_{T} from K^{0}_{S}");
1913     CreateEtaPtHisto2D("EtSimulatedK0LReweighted","Simulated E_{T} from K^{0}_{L}");
1914     CreateEtaPtHisto2D("EtSimulatedNeutron","Simulated E_{T} from neutrons");
1915     CreateEtaPtHisto2D("EtSimulatedAntiNeutron","Simulated E_{T} from #bar{n}");
1916     CreateEtaPtHisto2D("EtSimulatedEPlus","Simulated E_{T} from e^{+}");
1917     CreateEtaPtHisto2D("EtSimulatedEMinus","Simulated E_{T} from e^{-}");
1918     CreateEtaPtHisto2D("EtSimulatedOmega","Simulated E_{T} from #Omega^{-}");
1919     CreateEtaPtHisto2D("EtSimulatedAntiOmega","Simulated E_{T} from #Omega^{+}");
1920     CreateEtaPtHisto2D("EtSimulatedXi","Simulated E_{T} from #Xi^{-}");
1921     CreateEtaPtHisto2D("EtSimulatedAntiXi","Simulated E_{T} from #Xi^{+}");
1922     CreateEtaPtHisto2D("EtSimulatedSigma","Simulated E_{T} from #Xi^{-}");
1923     CreateEtaPtHisto2D("EtSimulatedAntiSigma","Simulated E_{T} from #Xi^{+}");
1924     CreateEtaPtHisto2D("EtSimulatedXi0","Simulated E_{T} from #Xi^{0}");
1925     CreateEtaPtHisto2D("EtSimulatedAntiXi0","Simulated E_{T} from #Xi^{0}");
1926     CreateEtaPtHisto2D("EtSimulatedAllHadron","Simulated E_{T} from all hadrons");
1927
1928
1929     CreateEtaPtHisto2D("EtSimulatedLambdaDaughters","Simulated E_{T} from #Lambda Daughters");
1930     CreateEtaPtHisto2D("EtSimulatedAntiLambdaDaughters","Simulated E_{T} from #bar{#Lambda} Daughters");
1931     CreateEtaPtHisto2D("EtSimulatedK0SDaughters","Simulated E_{T} from K^{0}_{S} Daughters");
1932     CreateEtaPtHisto2D("EtSimulatedLambdaDaughtersReweighted","Simulated E_{T} from #Lambda Daughters");
1933     CreateEtaPtHisto2D("EtSimulatedAntiLambdaDaughtersReweighted","Simulated E_{T} from #bar{#Lambda} Daughters");
1934     CreateEtaPtHisto2D("EtSimulatedK0SDaughtersReweighted","Simulated E_{T} from K^{0}_{S} Daughters");
1935     CreateEtaPtHisto2D("EtSimulatedOmegaDaughters","Simulated E_{T} from #Omega^{-} Daughters");
1936     CreateEtaPtHisto2D("EtSimulatedAntiOmegaDaughters","Simulated E_{T} from #Omega^{+} Daughters");
1937     CreateEtaPtHisto2D("EtSimulatedXiDaughters","Simulated E_{T} from #Xi^{-} Daughters");
1938     CreateEtaPtHisto2D("EtSimulatedAntiXiDaughters","Simulated E_{T} from #Xi^{+} Daughters");
1939
1940
1941     CreateEtaPtHisto2D("EtSimulatedGamma","Simulated E_{T} from #gamma");
1942     CreateEtaPtHisto2D("EtSimulatedEta","Simulated E_{T} from #eta");
1943     CreateEtaPtHisto2D("EtSimulatedPi0","Simulated E_{T} from #pi^{0}");
1944     CreateEtaPtHisto2D("EtSimulatedOmega0","Simulated E_{T} from #omega");
1945   }
1946   TString *strTPC = new TString("TPC");
1947   TString *strITS = new TString("ITS");
1948   TString *strTPCITS = new TString("TPCITS");
1949   Int_t lastcutset = 1;
1950   if(fRequireITSHits) lastcutset = 2;
1951   for(Int_t i=0;i<=lastcutset;i++){
1952     TString *cutName = NULL;
1953     Float_t maxPtdEdx = 10;
1954     Float_t mindEdx = 35;
1955     Float_t maxdEdx = 150.0;
1956     switch(i){
1957     case 0:
1958       cutName = strTPC;
1959       break;
1960     case 1:
1961       cutName = strITS;
1962       maxPtdEdx = 5;
1963       maxdEdx = 500.0;
1964       break;
1965     case 2:
1966       cutName = strTPCITS;
1967       break;
1968     default:
1969       cerr<<"Error:  cannot make histograms!"<<endl;
1970       return;
1971     }
1972
1973     if( !fRunLightweight){
1974       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedPiPlus",cutName->Data()),"Reconstructed E_{T} from identified #pi^{+}");
1975       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedPiMinus",cutName->Data()),"Reconstructed E_{T} from identified #pi^{-}");
1976       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedKPlus",cutName->Data()),"Reconstructed E_{T} from identified K^{+}");
1977       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedEMinus",cutName->Data()),"Reconstructed E_{T} from identified e^{-}");
1978       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedEPlus",cutName->Data()),"Reconstructed E_{T} from identified e^{+}");
1979       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedKMinus",cutName->Data()),"Reconstructed E_{T} from identified K^{-}");
1980       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedProton",cutName->Data()),"Reconstructed E_{T} from identified p");
1981       CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedAntiProton",cutName->Data()),"Reconstructed E_{T} from identified #bar{p}");
1982       if(fBaryonEnhancement){
1983         CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedProtonEnhanced",cutName->Data()),"Reconstructed E_{T} from identified p");
1984         CreateEtaPtHisto2D(Form("EtReconstructed%sIdentifiedAntiProtonEnhanced",cutName->Data()),"Reconstructed E_{T} from identified #bar{p}");
1985       }
1986       CreateEtaPtHisto2D(Form("EtNReconstructed%sUnidentified",cutName->Data()),"Number of Reconstructed unidentified particles");
1987       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedAssumingPion",cutName->Data()),"Reconstructed E_{T} from unidentified particles assuming pion mass");
1988       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedAssumingProton",cutName->Data()),"Reconstructed E_{T} from unidentified particles assuming pion mass");
1989       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedAssumingKaon",cutName->Data()),"Reconstructed E_{T} from unidentified particles assuming pion mass");
1990
1991       CreateEtaPtHisto2D(Form("EtNReconstructed%sUnidentifiedKaon",cutName->Data()),"Number of Reconstructed unidentified kaons particles");
1992       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedKaonAssumingPion",cutName->Data()),"Reconstructed E_{T} from unidentified kaons particles assuming pion mass");
1993       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedKaonAssumingProton",cutName->Data()),"Reconstructed E_{T} from unidentified kaons particles assuming pion mass");
1994       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedKaonAssumingKaon",cutName->Data()),"Reconstructed E_{T} from unidentified kaons particles assuming pion mass");
1995       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedKaon",cutName->Data()),"Reconstructed E_{T} from unidentified kaons particles assuming kaon mass");
1996       CreateEtaPtHisto2D(Form("EtNReconstructed%sUnidentifiedProton",cutName->Data()),"Number of Reconstructed unidentified proton particles");
1997       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingPion",cutName->Data()),"Reconstructed E_{T} from unidentified proton particles assuming pion mass");
1998       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingKaon",cutName->Data()),"Reconstructed E_{T} from unidentified proton particles assuming pion mass");
1999       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingKaon",cutName->Data()),"Reconstructed E_{T} from unidentified kaons particles assuming pion mass");
2000       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingKaon",cutName->Data()),"Reconstructed E_{T} from unidentified proton particles assuming pion mass");
2001       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingProton",cutName->Data()),"Reconstructed E_{T} from unidentified kaons particles assuming pion mass");
2002       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingProton",cutName->Data()),"Reconstructed E_{T} from unidentified proton particles assuming pion mass");
2003       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedProton",cutName->Data()),"Reconstructed E_{T} from unidentified proton particles assuming proton mass");
2004       if(fBaryonEnhancement){
2005         CreateEtaPtHisto2D(Form("EtNReconstructed%sUnidentifiedProtonEnhanced",cutName->Data()),"Number of Reconstructed unidentified proton particles");
2006         CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedProtonAssumingPionEnhanced",cutName->Data()),"Reconstructed E_{T} from unidentified proton particles assuming pion mass");
2007         CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedProtonEnhanced",cutName->Data()),"Reconstructed E_{T} from unidentified proton particles assuming proton mass");
2008       }
2009       CreateEtaPtHisto2D(Form("EtNReconstructed%sUnidentifiedPion",cutName->Data()),"Number of Reconstructed unidentified pions particles");
2010       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingPion",cutName->Data()),"Reconstructed E_{T} from unidentified pions particles assuming pion mass");
2011       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingKaon",cutName->Data()),"Reconstructed E_{T} from unidentified pions particles assuming pion mass");
2012       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedPionAssumingProton",cutName->Data()),"Reconstructed E_{T} from unidentified pions particles assuming pion mass");
2013       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentifiedPion",cutName->Data()),"Reconstructed E_{T} from unidentified pions particles assuming pion mass");
2014
2015       CreateEtaPtHisto2D(Form("EtReconstructed%sUnidentified",cutName->Data()),"Reconstructed E_{T} from unidentified particles using real mass");
2016       CreateEtaPtHisto2D(Form("EtReconstructed%sMisidentifiedElectrons",cutName->Data()),"Reconstructed E_{T} from misidentified electrons");
2017
2018
2019       CreateEtaPtHisto2D(Form("EtReconstructed%sPiPlus",cutName->Data()),"Reconstructed E_{T} from #pi^{+}");
2020       CreateEtaPtHisto2D(Form("EtReconstructed%sPiMinus",cutName->Data()),"Reconstructed E_{T} from #pi^{-}");
2021       CreateEtaPtHisto2D(Form("EtReconstructed%sKPlus",cutName->Data()),"Reconstructed E_{T} from K^{+}");
2022       CreateEtaPtHisto2D(Form("EtReconstructed%sKMinus",cutName->Data()),"Reconstructed E_{T} from K^{-}");
2023       CreateEtaPtHisto2D(Form("EtReconstructed%sProton",cutName->Data()),"Reconstructed E_{T} from p");
2024       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiProton",cutName->Data()),"Reconstructed E_{T} from #bar{p}");
2025       if(fBaryonEnhancement){
2026         CreateEtaPtHisto2D(Form("EtReconstructed%sProtonEnhanced",cutName->Data()),"Reconstructed E_{T} from p");
2027         CreateEtaPtHisto2D(Form("EtReconstructed%sAntiProtonEnhanced",cutName->Data()),"Reconstructed E_{T} from #bar{p}");
2028       }
2029       CreateEtaPtHisto2D(Form("EtReconstructed%sChargedHadron",cutName->Data()),"Reconstructed E_{T} from charged hadrons");
2030       CreateEtaPtHisto2D(Form("EtNReconstructed%sPiPlus",cutName->Data()),"Reconstructed E_{T} from #pi^{+}");
2031       CreateEtaPtHisto2D(Form("EtNReconstructed%sPiMinus",cutName->Data()),"Reconstructed E_{T} from #pi^{-}");
2032       CreateEtaPtHisto2D(Form("EtNReconstructed%sKPlus",cutName->Data()),"Reconstructed E_{T} from K^{+}");
2033       CreateEtaPtHisto2D(Form("EtNReconstructed%sKMinus",cutName->Data()),"Reconstructed E_{T} from K^{-}");
2034       CreateEtaPtHisto2D(Form("EtNReconstructed%sProton",cutName->Data()),"Reconstructed E_{T} from p");
2035       CreateEtaPtHisto2D(Form("EtNReconstructed%sAntiProton",cutName->Data()),"Reconstructed E_{T} from #bar{p}");
2036       if(fBaryonEnhancement){
2037         CreateEtaPtHisto2D(Form("EtNReconstructed%sProtonEnhanced",cutName->Data()),"Reconstructed E_{T} from p");
2038         CreateEtaPtHisto2D(Form("EtNReconstructed%sAntiProtonEnhanced",cutName->Data()),"Reconstructed E_{T} from #bar{p}");
2039       }
2040       CreateEtaPtHisto2D(Form("EtNReconstructed%sChargedHadron",cutName->Data()),"Reconstructed E_{T} from charged hadrons");
2041       if(fDataSet==20100||fDataSet==2011){//If this is Pb+Pb
2042         Int_t width = 5;
2043         if(fNCentBins<21) width = 10;
2044         for(Int_t j=0;j<fNCentBins;j++){
2045           CreateEtaPtHisto2D(Form("EtNReconstructed%sPiPlusCB%i",cutName->Data(),j),Form("Reconstructed E_{T} from #pi^{+} for %i-%i central",j*width,(j+1)*width));
2046           CreateEtaPtHisto2D(Form("EtNReconstructed%sPiMinusCB%i",cutName->Data(),j),Form("Reconstructed E_{T} from #pi^{-} for %i-%i central",j*width,(j+1)*width));
2047           CreateEtaPtHisto2D(Form("EtNReconstructed%sKPlusCB%i",cutName->Data(),j),Form("Reconstructed E_{T} from K^{+} for %i-%i central",j*width,(j+1)*width));
2048           CreateEtaPtHisto2D(Form("EtNReconstructed%sKMinusCB%i",cutName->Data(),j),Form("Reconstructed E_{T} from K^{-} for %i-%i central",j*width,(j+1)*width));
2049           CreateEtaPtHisto2D(Form("EtNReconstructed%sProtonCB%i",cutName->Data(),j),Form("Reconstructed E_{T} from p for %i-%i central",j*width,(j+1)*width));
2050           CreateEtaPtHisto2D(Form("EtNReconstructed%sAntiProtonCB%i",cutName->Data(),j),Form("Reconstructed E_{T} from #bar{p} for %i-%i central",j*width,(j+1)*width));
2051           CreateEtaPtHisto2D(Form("EtNReconstructed%sChargedHadronCB%i",cutName->Data(),j),Form("Reconstructed E_{T} from charged hadrons for %i-%i central",j*width,(j+1)*width));
2052         }
2053       }
2054
2055       CreateEtaPtHisto2D(Form("EtReconstructed%sChargedHadronAssumingPion",cutName->Data()),"Reconstructed E_{T} from charged hadrons assuming they are all pions");
2056       CreateEtaPtHisto2D(Form("EtReconstructed%sChargedHadronAssumingProton",cutName->Data()),"Reconstructed E_{T} from charged hadrons assuming they are all pions");
2057       CreateEtaPtHisto2D(Form("EtReconstructed%sChargedHadronAssumingKaon",cutName->Data()),"Reconstructed E_{T} from charged hadrons assuming they are all pions");
2058       CreateEtaPtHisto2D(Form("EtReconstructed%sKPlusAssumingPion",cutName->Data()),"Reconstructed E_{T} from K^{+} assuming #pi mass");
2059       CreateEtaPtHisto2D(Form("EtReconstructed%sKMinusAssumingPion",cutName->Data()),"Reconstructed E_{T} from K^{-} assuming #pi mass");
2060       CreateEtaPtHisto2D(Form("EtReconstructed%sProtonAssumingPion",cutName->Data()),"Reconstructed E_{T} from p assuming #pi mass");
2061       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiProtonAssumingPion",cutName->Data()),"Reconstructed E_{T} from #bar{p} assuming #pi mass");
2062       CreateEtaPtHisto2D(Form("EtReconstructed%sPiPlusAssumingKaon",cutName->Data()),"Reconstructed E_{T} from K^{+} assuming #pi mass");
2063       CreateEtaPtHisto2D(Form("EtReconstructed%sPiMinusAssumingKaon",cutName->Data()),"Reconstructed E_{T} from K^{-} assuming #pi mass");
2064       CreateEtaPtHisto2D(Form("EtReconstructed%sKPlusAssumingKaon",cutName->Data()),"Reconstructed E_{T} from K^{+} assuming #pi mass");
2065       CreateEtaPtHisto2D(Form("EtReconstructed%sKMinusAssumingKaon",cutName->Data()),"Reconstructed E_{T} from K^{-} assuming #pi mass");
2066       CreateEtaPtHisto2D(Form("EtReconstructed%sProtonAssumingKaon",cutName->Data()),"Reconstructed E_{T} from p assuming #pi mass");
2067       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiProtonAssumingKaon",cutName->Data()),"Reconstructed E_{T} from #bar{p} assuming #pi mass");
2068
2069       CreateEtaPtHisto2D(Form("EtReconstructed%sKPlusAssumingProton",cutName->Data()),"Reconstructed E_{T} from K^{+} assuming #pi mass");
2070       CreateEtaPtHisto2D(Form("EtReconstructed%sKMinusAssumingProton",cutName->Data()),"Reconstructed E_{T} from K^{-} assuming #pi mass");
2071       CreateEtaPtHisto2D(Form("EtReconstructed%sPiMinusAssumingProton",cutName->Data()),"Reconstructed E_{T} from p assuming #pi mass");
2072       CreateEtaPtHisto2D(Form("EtReconstructed%sPiPlusAssumingProton",cutName->Data()),"Reconstructed E_{T} from #bar{p} assuming #pi mass");
2073       CreateEtaPtHisto2D(Form("EtReconstructed%sProtonAssumingProton",cutName->Data()),"Reconstructed E_{T} from p assuming #pi mass");
2074       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiProtonAssumingProton",cutName->Data()),"Reconstructed E_{T} from #bar{p} assuming #pi mass");
2075
2076       if(fBaryonEnhancement){
2077         CreateEtaPtHisto2D(Form("EtReconstructed%sProtonAssumingPionEnhanced",cutName->Data()),"Reconstructed E_{T} from p assuming #pi mass");
2078         CreateEtaPtHisto2D(Form("EtReconstructed%sAntiProtonAssumingPionEnhanced",cutName->Data()),"Reconstructed E_{T} from #bar{p} assuming #pi mass");
2079       }
2080
2081       CreateEtaPtHisto2D(Form("EtReconstructed%sEPlus",cutName->Data()),"Reconstructed E_{T} from e^{+}");
2082       CreateEtaPtHisto2D(Form("EtReconstructed%sEMinus",cutName->Data()),"Reconstructed E_{T} from e^{-}");
2083
2084
2085
2086       CreateEtaPtHisto2D(Form("EtReconstructed%sLambdaDaughters",cutName->Data()),"Reconstructed E_{T} from #Lambda Daughters");
2087       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiLambdaDaughters",cutName->Data()),"Reconstructed E_{T} from #bar{#Lambda} Daughters");
2088       CreateEtaPtHisto2D(Form("EtReconstructed%sK0SDaughters",cutName->Data()),"Reconstructed E_{T} from K^{0}_{S} Daughters");
2089       CreateEtaPtHisto2D(Form("EtReconstructed%sLambdaDaughtersReweighted",cutName->Data()),"Reconstructed E_{T} from #Lambda Daughters");
2090       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiLambdaDaughtersReweighted",cutName->Data()),"Reconstructed E_{T} from #bar{#Lambda} Daughters");
2091       CreateEtaPtHisto2D(Form("EtReconstructed%sK0SDaughtersReweighted",cutName->Data()),"Reconstructed E_{T} from K^{0}_{S} Daughters");
2092       CreateEtaPtHisto2D(Form("EtReconstructed%sOmegaDaughters",cutName->Data()),"Reconstructed E_{T} from #Omega^{-} Daughters");
2093       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiOmegaDaughters",cutName->Data()),"Reconstructed E_{T} from #Omega^{+} Daughters");
2094       CreateEtaPtHisto2D(Form("EtReconstructed%sXiDaughters",cutName->Data()),"Reconstructed E_{T} from #Xi^{-} Daughters");
2095       CreateEtaPtHisto2D(Form("EtReconstructed%sAntiXiDaughters",cutName->Data()),"Reconstructed E_{T} from #Xi^{+} Daughters");
2096       CreateEtaPtHisto2D(Form("EtReconstructed%sConversionElectrons",cutName->Data()),"Reconstructed E_{T} from conversion electrons");
2097       CreateEtaPtHisto2D(Form("EtReconstructed%sSecondaryMuons",cutName->Data()),"Reconstructed E_{T} from secondary muons");//from pions
2098       CreateEtaPtHisto2D(Form("EtReconstructed%sSecondaryPions",cutName->Data()),"Reconstructed E_{T} from secondary pions");//from rescattering and sigma+-
2099       CreateEtaPtHisto2D(Form("EtReconstructed%sSecondaryProtons",cutName->Data()),"Reconstructed E_{T} from secondary protons");//from rescattering and sigma+-
2100     }
2101     CreateIntHisto1D(Form("UnidentifiedPIDs%s",cutName->Data()),"PIDs of unidentified particles", "PID", "Number of particles",9, -4,4);
2102     CreateHisto2D(Form("MisidentifiedPIDs%s",cutName->Data()),"PIDs of misidentified particles", "PID real","PID identified",5, -.5,4.5,5, -.5,4.5);
2103     CreateHisto2D(Form("dEdxAll%s",cutName->Data()),"dE/dx for all particles","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
2104     CreateHisto2D(Form("dEdxPion%s",cutName->Data()),"dE/dx for #pi^{#pm}","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
2105     CreateHisto2D(Form("dEdxKaon%s",cutName->Data()),"dE/dx for K^{#pm}","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
2106     CreateHisto2D(Form("dEdxProton%s",cutName->Data()),"dE/dx for p(#bar{p})","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
2107     CreateHisto2D(Form("dEdxElectron%s",cutName->Data()),"dE/dx for e^{#pm}","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
2108     CreateHisto2D(Form("dEdxUnidentified%s",cutName->Data()),"dE/dx for unidentified particles","momentum (GeV/c)","dE/dx",400,0.0,maxPtdEdx,200,mindEdx,maxdEdx);
2109   }
2110   delete strTPC;
2111   delete strITS;
2112   delete strTPCITS;
2113
2114   Float_t minEt = 0.0;
2115   Float_t maxEt = 100.0;
2116   Float_t minEtPiKP = 0.0;
2117   Float_t maxEtPiKP = 100.0;
2118   if(fDataSet==20100 || fDataSet==2011){
2119     maxEt=4000.0;
2120     maxEtPiKP = 2500;
2121   }
2122   if(fDataSet==2013){
2123     maxEt=100.0;
2124     maxEtPiKP = 100.0;
2125   }
2126   Int_t nbinsEt = 100;
2127   char histoname[200];
2128   char histotitle[200];
2129   char xtitle[50];
2130   char ytitle[50];
2131   TString *sTPC = new TString("TPC");
2132   TString *sITS = new TString("ITS");
2133   TString *sTPCpt = new TString("0.15");
2134   TString *sITSpt = new TString("0.10");
2135   TString *sPID = new TString("");
2136   TString *sNoPID = new TString("NoPID");
2137   TString *sNoPIDString = new TString(", No PID");
2138   TString *sHadEt = new TString("HadEt");
2139   TString *sTotEt = new TString("TotEt");
2140   TString *sPiKPEt =  new TString("PiKPEt");
2141   TString *sRawEt =  new TString("RawEt");
2142   TString *sTotEtString = new TString("total E_{T}");
2143   TString *sHadEtString = new TString("hadronic E_{T}");
2144   TString *sPiKPEtString = new TString("E_{T}^{#pi,K,p}");
2145   TString *sRawEtString = new TString("E_{T}^{raw}");
2146   TString *sFull = new TString("Full");
2147   TString *sEMCAL = new TString("EMCAL");
2148   TString *sPHOS = new TString("PHOS");
2149   float etDiff = 1.5;
2150   float etDiffLow = etDiff;
2151   if(fDataSet!=20100 && fDataSet!=2011){//If this is p+p
2152     etDiffLow = 2.5;
2153   }
2154
2155   for(int tpc = 0;tpc<lastcutset;tpc++){
2156     TString *detector = NULL;
2157     TString *ptstring = NULL;
2158     if(tpc==1) {detector = sTPC; ptstring = sTPCpt;}
2159     else{detector = sITS; ptstring = sITSpt;}
2160     for(int hadet = 0;hadet<2;hadet++){
2161       TString *et = NULL;
2162       TString *etstring = NULL;
2163       if(hadet==1) {et = sHadEt; etstring = sHadEtString;}
2164       else{et = sTotEt; etstring = sTotEtString;}
2165       for(int type = 0;type<3;type++){
2166         if(type==0 && !fInvestigateFull) continue;
2167         if(type==1 && !fInvestigateEMCal) continue;
2168         if(type==2 && !fInvestigatePHOS) continue;
2169         TString *acceptance = NULL;
2170         switch(type){
2171         case 0:
2172           acceptance = sFull;
2173           etDiff = 1.5;
2174           break;
2175         case 1:
2176           acceptance = sEMCAL;
2177           etDiff = 5;
2178           break;
2179         case 2:
2180           acceptance = sPHOS;
2181           etDiff = 5;
2182           break;
2183         default:
2184           acceptance = sFull;
2185         }
2186         for(int pid = 0;pid<2;pid++){
2187           TString *partid = NULL;
2188           TString *partidstring = NULL;
2189           if(pid==1){partid = sPID; partidstring = sPID;}
2190           else{partid = sNoPID; partidstring = sNoPIDString;}
2191
2192           snprintf(histoname,200,"Sim%sMinusReco%s%sAcceptance%s%s",et->Data(),et->Data(),acceptance->Data(),detector->Data(),partid->Data());
2193           snprintf(histotitle,200,"(Simulated %s - reconstructed %s)/(Simulated %s) with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),etstring->Data(),etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
2194           snprintf(ytitle,50,"(Simulated %s - reconstructed %s)/(Simulated %s)",etstring->Data(),etstring->Data(),etstring->Data());
2195           snprintf(xtitle,50,"Simulated %s",etstring->Data());
2196           CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiffLow,etDiff);
2197
2198           if(type==0){//only fill for full acceptance
2199             snprintf(histoname,200,"Sim%sVsReco%s%sAcceptance%s%s",et->Data(),et->Data(),acceptance->Data(),detector->Data(),partid->Data());
2200             snprintf(histotitle,200,"Simulated %s vs reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
2201             snprintf(ytitle,50,"Reconstructed %s",etstring->Data());
2202             snprintf(xtitle,50,"Simulated %s",etstring->Data());
2203             CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt*4,minEt,maxEt,nbinsEt*4,minEt,maxEt);
2204             if(hadet==1){//on top of that we want to create pikp histograms without adding a full option parallel to had and tot et - therefore we will just create these histos when we create the hadet histos
2205               snprintf(histoname,200,"Sim%sVsReco%s%sAcceptance%s%s",sPiKPEt->Data(),sPiKPEt->Data(),acceptance->Data(),detector->Data(),partid->Data());
2206               snprintf(histotitle,200,"Simulated %s vs reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s",sPiKPEtString->Data(),sPiKPEtString->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
2207               snprintf(ytitle,50,"Reconstructed %s",sPiKPEtString->Data());
2208               snprintf(xtitle,50,"Simulated %s",sPiKPEtString->Data());
2209               CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt*4,minEtPiKP,maxEtPiKP,nbinsEt*4,minEtPiKP,maxEtPiKP);
2210
2211               //And for the raw ET
2212               snprintf(histoname,200,"Sim%sVsReco%s%sAcceptance%s%s",sRawEt->Data(),sRawEt->Data(),acceptance->Data(),detector->Data(),partid->Data());
2213               snprintf(histotitle,200,"Simulated %s vs reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s",sRawEtString->Data(),sRawEtString->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
2214               snprintf(ytitle,50,"Reconstructed %s",sRawEtString->Data());
2215               snprintf(xtitle,50,"Simulated %s",sRawEtString->Data());
2216               CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt*4,minEtPiKP,maxEtPiKP,nbinsEt*4,minEtPiKP,maxEtPiKP);
2217             }
2218           }
2219
2220           if(hadet==0 && type==0 && fInvestigatePiKP){//we only want to do this once...  not the most elegant way of coding but hey...
2221             snprintf(histoname,200,"SimPiKPMinusRecoPiKP%sAcceptance%s%s",acceptance->Data(),detector->Data(),partid->Data());
2222             snprintf(histotitle,200,"(Sim PiKP - reco PiKP)/(Sim PiKP) with %s acceptance for p_{T}>%s GeV/c%s",acceptance->Data(),ptstring->Data(),partidstring->Data());
2223             snprintf(ytitle,50,"(Sim PiKP - reco PiKP)/(Sim PiKP)");
2224             snprintf(xtitle,50,"Simulated E_{T}^{#pi,K,p}");
2225             CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiffLow,etDiff);
2226           }
2227         }
2228       }
2229     }
2230   }
2231   CreateHisto1D("SimPiKPEt","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2232   CreateHisto1D("SimPiKPEtND","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2233   CreateHisto1D("SimPiKPEtDD","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2234   CreateHisto1D("SimPiKPEtSD","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2235   CreateHisto1D("SimPiKPEtNDV0AND","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2236   CreateHisto1D("SimPiKPEtDDV0AND","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2237   CreateHisto1D("SimPiKPEtSDV0AND","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2238   CreateHisto1D("SimPiKPEtNDMB","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2239   CreateHisto1D("SimPiKPEtDDMB","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2240   CreateHisto1D("SimPiKPEtSDMB","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2241   CreateHisto1D("SimRawEtTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2242   CreateHisto1D("SimRawEtNDTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2243   CreateHisto1D("SimRawEtDDTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2244   CreateHisto1D("SimRawEtSDTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2245   CreateHisto1D("SimRawEtNDV0ANDTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2246   CreateHisto1D("SimRawEtDDV0ANDTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2247   CreateHisto1D("SimRawEtSDV0ANDTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2248   CreateHisto1D("SimRawEtNDMBTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2249   CreateHisto1D("SimRawEtDDMBTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2250   CreateHisto1D("SimRawEtSDMBTPC","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2251   CreateHisto1D("SimRawEtITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2252   CreateHisto1D("SimRawEtNDITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2253   CreateHisto1D("SimRawEtDDITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2254   CreateHisto1D("SimRawEtSDITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2255   CreateHisto1D("SimRawEtNDV0ANDITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2256   CreateHisto1D("SimRawEtDDV0ANDITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2257   CreateHisto1D("SimRawEtSDV0ANDITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2258   CreateHisto1D("SimRawEtNDMBITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2259   CreateHisto1D("SimRawEtDDMBITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2260   CreateHisto1D("SimRawEtSDMBITS","Simulated #pi,K,p E_{T}","Simulated #pi,K,p E_{T}","Number of events",nbinsEt*4,minEtPiKP,maxEtPiKP);
2261   CreateHisto1D("SimTotEt","Simulated Total E_{T}","Simulated Total E_{T}","Number of events",nbinsEt*4,minEt,maxEt);
2262   CreateHisto1D("SimHadEt","Simulated Hadronic E_{T}","Simulated Hadronic E_{T}","Number of events",nbinsEt*4,minEt,maxEt);
2263   CreateHisto1D("SimTotEtND","Simulated Total E_{T}","Simulated Total E_{T} for non-diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2264   CreateHisto1D("SimHadEtND","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for non-diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2265   CreateHisto1D("SimTotEtNDV0AND","Simulated Total E_{T}","Simulated Total E_{T} for non-diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2266   CreateHisto1D("SimHadEtNDV0AND","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for non-diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2267   CreateHisto1D("SimTotEtNDMB","Simulated Total E_{T}","Simulated Total E_{T} for non-diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2268   CreateHisto1D("SimHadEtNDMB","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for non-diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2269   CreateHisto1D("SimTotEtSD","Simulated Total E_{T}","Simulated Total E_{T} for singly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2270   CreateHisto1D("SimHadEtSD","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for singly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2271   CreateHisto1D("SimTotEtSDV0AND","Simulated Total E_{T}","Simulated Total E_{T} for singly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2272   CreateHisto1D("SimHadEtSDV0AND","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for singly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2273   CreateHisto1D("SimTotEtSDMB","Simulated Total E_{T}","Simulated Total E_{T} for singly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2274   CreateHisto1D("SimHadEtSDMB","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for singly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2275   CreateHisto1D("SimTotEtDD","Simulated Total E_{T}","Simulated Total E_{T} for doubly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2276   CreateHisto1D("SimHadEtDD","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for doubly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2277   CreateHisto1D("SimTotEtDDV0AND","Simulated Total E_{T}","Simulated Total E_{T} for doubly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2278   CreateHisto1D("SimHadEtDDV0AND","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for doubly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2279   CreateHisto1D("SimTotEtDDMB","Simulated Total E_{T}","Simulated Total E_{T} for doubly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2280   CreateHisto1D("SimHadEtDDMB","Simulated Hadronic E_{T}","Simulated Hadronic E_{T} for doubly diffractive events","Number of events",nbinsEt*4,minEt,maxEt);
2281   if(fDataSet==20100||fDataSet==2011){
2282     Int_t width = 5;
2283     if(fNCentBins<21) width = 10;
2284     for(Int_t j=0;j<fNCentBins;j++){
2285       CreateHisto1D(Form("SimTotEtCB%i",j),Form("Simulated Total E_{T} for %i-%i central",j*width,(j+1)*width),"Simulated Total E_{T}","Number of events",nbinsEt*4,minEt,maxEt);
2286       CreateHisto1D(Form("SimHadEtCB%i",j),Form("Simulated Hadronic E_{T} for %i-%i central",j*width,(j+1)*width),"Simulated Hadronic E_{T}","Number of events",nbinsEt*4,minEt,maxEt);
2287       CreateHisto1D(Form("SimPiKPEtCB%i",j),Form("Simulated #pi,K,p E_{T} for %i-%i central",j*width,(j+1)*width),"Simulated #pi,K,p E_{T}","Number of events",nbinsEt,minEt,maxEt);
2288     }
2289   }
2290
2291   etDiff = 0.15;
2292
2293   if(fInvestigateSmearing && !fRunLightweight){
2294     //======================================================================
2295
2296     snprintf(histoname,200,"SimPiKPEtMeasMinusEtRealPiKP");
2297     snprintf(histotitle,200,"Simulated (all reconstructed - primaries)/all reconstructed for reconstructed tracks only");
2298     snprintf(ytitle,50,"(primary-all)/primary");
2299     snprintf(xtitle,50,"true p, K, p E_{T} for primary tracks");
2300     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff*5,etDiff*5);
2301
2302     snprintf(histoname,200,"SimPiKPEtMinusSimAllCorrSmearedRecoOnly");
2303     snprintf(histotitle,200,"Simulated (primary-all)/primary for reconstructed tracks only");
2304     snprintf(ytitle,50,"(primary-all)/primary");
2305     snprintf(xtitle,50,"true p, K, p E_{T} for primary tracks");
2306     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff*5,etDiff*5);
2307
2308     snprintf(histoname,200,"SimPiKPEtMinusSimEffCorrRecoOnly");
2309     snprintf(histotitle,200,"(sim-reco)/sim primary #pi,k,p for p_{T}>0.15");
2310     snprintf(ytitle,50,"(sim-reco)/sim");
2311     snprintf(xtitle,50,"true p, K, p E_{T} for primary tracks");
2312     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff*5,etDiff*5);
2313
2314     snprintf(histoname,200,"SimPiKPEtMinusSimEffBkgdCorrRecoOnly");
2315     snprintf(histotitle,200,"(sim-reco)/sim primary #pi,k,p for p_{T}>0.15 with background subtraction");
2316     snprintf(ytitle,50,"(sim-reco)/sim");
2317     snprintf(xtitle,50,"true p, K, p E_{T} for primary tracks");
2318     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff*5,etDiff*5);
2319
2320     snprintf(histoname,200,"SimPiKPEtMinusSimEffCorrRecoPiOnly");
2321     snprintf(histotitle,200,"(sim-reco)/sim primary #pi for p_{T}>0.15");
2322     snprintf(ytitle,50,"(sim-reco)/sim");
2323     snprintf(xtitle,50,"true #pi E_{T} for primary tracks");
2324     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt/2,nbinsEt,-etDiff*5,etDiff*5);
2325
2326     snprintf(histoname,200,"SimPiKPEtMinusSimEffCorrRecoKOnly");
2327     snprintf(histotitle,200,"(sim-reco)/sim primary K for p_{T}>0.15");
2328     snprintf(ytitle,50,"(sim-reco)/sim");
2329     snprintf(xtitle,50,"true K E_{T} for primary tracks");
2330     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt/6,nbinsEt,-etDiff*5,etDiff*5);
2331
2332     snprintf(histoname,200,"SimPiKPEtMinusSimEffCorrRecoPOnly");
2333     snprintf(histotitle,200,"(sim-reco)/sim primary p for p_{T}>0.15");
2334     snprintf(ytitle,50,"(sim-reco)/sim");
2335     snprintf(xtitle,50,"true p E_{T} for primary tracks");
2336     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt/6,nbinsEt,-etDiff*5,etDiff*5);
2337
2338     snprintf(histoname,200,"SimPiKPEtMinusSimAllSmearedRecoOnly");
2339     snprintf(histotitle,200,"Simulated (primary-all)/primary for reconstructed tracks only");
2340     snprintf(ytitle,50,"(primary-all)/primary");
2341     snprintf(xtitle,50,"true p, K, p E_{T} for primary tracks");
2342     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff*5,0.0);
2343
2344     snprintf(histoname,200,"SimPiKPEtMinusSimPIDSmearedRecoOnly");
2345     snprintf(histotitle,200,"Simulated (true-smeared)/true for reconstructed tracks only with PID smearing");
2346     snprintf(ytitle,50,"(true-smeared)/true");
2347     snprintf(xtitle,50,"true p, K, p E_{T}");
2348     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff,etDiff);
2349
2350     snprintf(histoname,200,"SimPiKPEtMinusSimSmearedRecoOnly");
2351     snprintf(histotitle,200,"Simulated (true-smeared)/true for reconstructed tracks only");
2352     snprintf(ytitle,50,"(true-smeared)/true");
2353     snprintf(xtitle,50,"true p, K, p E_{T}");
2354     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff/15,etDiff/15);
2355
2356     snprintf(histoname,200,"SimPiKPPtMinusSimSmearedRecoOnly");
2357     snprintf(histotitle,200,"Simulated (true-smeared)/true for reconstructed tracks only");
2358     snprintf(ytitle,50,"(true-smeared)/true");
2359     snprintf(xtitle,50,"true p, K, p p_{T}");
2360     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff/15,etDiff/15);
2361
2362     snprintf(histoname,200,"SimPiKPEtMinusSimSmearedMultRecoOnly");
2363     snprintf(histotitle,200,"Simulated (true-smeared)/true for reconstructed tracks only");
2364     snprintf(ytitle,50,"(true-smeared)/true");
2365     snprintf(xtitle,50,"number of reconstructed particles");
2366     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff/15,etDiff/15);
2367
2368     snprintf(histoname,200,"SimPiKPPtMinusSimSmearedMultRecoOnly");
2369     snprintf(histotitle,200,"Simulated (true-smeared)/true for reconstructed tracks only");
2370     snprintf(ytitle,50,"(true-smeared)/true");
2371     snprintf(xtitle,50,"number of reconstructed particles");
2372     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff/15,etDiff/15);
2373
2374     //======================================================================
2375
2376     snprintf(histoname,200,"SimPiKPEtMinusSimPtSmeared");
2377     snprintf(histotitle,200,"Simulated (true-smeared)/true for 0.5 percent momentum smearing");
2378     snprintf(ytitle,50,"(true-smeared)/true");
2379     snprintf(xtitle,50,"true p, K, p E_{T}");
2380     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff,etDiff);
2381     snprintf(histoname,200,"SimPiKPEtPtSmeared");
2382     snprintf(histotitle,200,"Simulated E_{T} for 0.5 percent momentum smearing");
2383     snprintf(ytitle,50,"Number of events");
2384     snprintf(xtitle,50,"p, K, p E_{T}");
2385     CreateHisto1D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt);
2386
2387     //======================================================================
2388
2389     snprintf(histoname,200,"SimPiKPEtMinusSimEfficiencySmeared");
2390     snprintf(histotitle,200,"Simulated (true-smeared)/true for efficiency smearing");
2391     snprintf(ytitle,50,"(true-smeared)/true");
2392     snprintf(xtitle,50,"true p, K, p E_{T}");
2393     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff*7,etDiff*7);
2394     snprintf(histoname,200,"SimPiKPEtEfficiencySmeared");
2395     snprintf(histotitle,200,"Simulated E_{T} for efficiency smearing");
2396     snprintf(ytitle,50,"Number of events");
2397     snprintf(xtitle,50,"p, K, p E_{T}");
2398     CreateHisto1D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt);
2399
2400     //======================================================================
2401
2402     snprintf(histoname,200,"SimPiKPEtMinusSimPtCutSmearedTPC");
2403     snprintf(histotitle,200,"Simulated (true-smeared)/true for p_{T}>0.15 GeV/c smearing");
2404     snprintf(ytitle,50,"(true-smeared)/true");
2405     snprintf(xtitle,50,"true p, K, p E_{T}");
2406     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff,etDiff);
2407     snprintf(histoname,200,"SimPiKPEtPtCutSmearedTPC");
2408     snprintf(histotitle,200,"Simulated E_{T} for p_{T}>0.15 GeV/c smearing");
2409     snprintf(ytitle,50,"Number of events");
2410     snprintf(xtitle,50,"p, K, p E_{T}");
2411     CreateHisto1D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt);
2412
2413
2414     //======================================================================
2415
2416     snprintf(histoname,200,"SimPiKPEtMinusSimPtCutSmearedITS");
2417     snprintf(histotitle,200,"Simulated (true-smeared)/true for p_{T}>0.10 GeV/c smearing");
2418     snprintf(ytitle,50,"(true-smeared)/true");
2419     snprintf(xtitle,50,"true p, K, p E_{T}");
2420     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff,etDiff);
2421     snprintf(histoname,200,"SimPiKPEtPtCutSmearedITS");
2422     snprintf(histotitle,200,"Simulated E_{T} for p_{T}>0.10 GeV/c smearing");
2423     snprintf(ytitle,50,"Number of events");
2424     snprintf(xtitle,50,"p, K, p E_{T}");
2425     CreateHisto1D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt);
2426
2427     //======================================================================
2428
2429     snprintf(histoname,200,"SimPiKPEtMinusSimPIDSmeared");
2430     snprintf(histotitle,200,"Simulated (true-smeared)/true for PID smearing");
2431     snprintf(ytitle,50,"(true-smeared)/true");
2432     snprintf(xtitle,50,"true p, K, p E_{T}");
2433     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff,etDiff);
2434     snprintf(histoname,200,"SimPiKPEtPIDSmeared");
2435     snprintf(histotitle,200,"Simulated E_{T} for PID smearing");
2436     snprintf(ytitle,50,"Number of events");
2437     snprintf(xtitle,50,"p, K, p E_{T}");
2438     CreateHisto1D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt);
2439
2440     //======================================================================
2441
2442     snprintf(histoname,200,"SimPiKPEtMinusSimPIDSmearedNoID");
2443     snprintf(histotitle,200,"Simulated (true-smeared)/true for PID smearing No ID");
2444     snprintf(ytitle,50,"(true-smeared)/true");
2445     snprintf(xtitle,50,"true p, K, p E_{T}");
2446     CreateHisto2D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt,nbinsEt,-etDiff,etDiff);
2447     snprintf(histoname,200,"SimPiKPEtPIDSmearedNoID");
2448     snprintf(histotitle,200,"Simulated E_{T} for PID smearing No ID");
2449     snprintf(ytitle,50,"Number of events");
2450     snprintf(xtitle,50,"p, K, p E_{T}");
2451     CreateHisto1D(histoname,histotitle,xtitle,ytitle,nbinsEt,minEt,maxEt);
2452   }
2453   delete sTPC;
2454   delete sITS;
2455   delete sTPCpt;
2456   delete sITSpt;
2457   delete sPID;
2458   delete sNoPID;
2459   delete sNoPIDString;
2460   delete sHadEt;
2461   delete sTotEt;
2462   delete sPiKPEt;
2463   delete sTotEtString;
2464   delete sHadEtString;
2465   delete sPiKPEtString;
2466   delete sFull;
2467   delete sEMCAL;
2468   delete sPHOS;
2469   CreateIntHisto1D("NEvents","Number of events","number of events","Number of events",1,0,1);
2470   CreateIntHisto1D("NEventsSD","Number of events","number of singly diffractive events","Number of events",1,0,1);
2471   CreateIntHisto1D("NEventsDD","Number of events","number of doubly diffractive events","Number of events",1,0,1);
2472   CreateIntHisto1D("NEventsND","Number of events","number of non-diffractive events","Number of events",1,0,1);
2473   CreateIntHisto1D("NEventsSDV0AND","Number of events","number of singly diffractive events","Number of events",1,0,1);
2474   CreateIntHisto1D("NEventsDDV0AND","Number of events","number of doubly diffractive events","Number of events",1,0,1);
2475   CreateIntHisto1D("NEventsNDV0AND","Number of events","number of non-diffractive events","Number of events",1,0,1);
2476   CreateIntHisto1D("NEventsSDMB","Number of events","number of singly diffractive events","Number of events",1,0,1);
2477   CreateIntHisto1D("NEventsDDMB","Number of events","number of doubly diffractive events","Number of events",1,0,1);
2478   CreateIntHisto1D("NEventsNDMB","Number of events","number of non-diffractive events","Number of events",1,0,1);
2479   if( !fRunLightweight){
2480     CreateResolutionPtHisto2D("presolutionTPC","p resolution","p^{rec}","(p^{sim}-p^{rec})/p^{rec}");
2481     CreateResolutionPtHisto2D("pTresolutionTPC","p_{T} resolution","p_{T}^{rec}","(p_{T}^{sim}-p_{T}^{rec})/p_{T}^{rec}");
2482     CreateResolutionPtHisto2D("ETresolutionTPC","E_{T} resolution","E_{T}^{rec}","(E_{T}^{sim}-E_{T}^{rec})/E_{T}^{rec}");
2483     CreateResolutionPtHisto2D("pTresolutionTPCITS","p_{T} resolution","p_{T}^{rec}","(p_{T}^{sim}-p_{T}^{rec})/p_{T}^{rec}");
2484     CreateResolutionPtHisto2D("ETresolutionTPCITS","E_{T} resolution","E_{T}^{rec}","(E_{T}^{sim}-E_{T}^{rec})/E_{T}^{rec}");
2485     CreateResolutionPtHisto2D("presolutionTPCITS","p resolution","p^{rec}","(p^{sim}-p^{rec})/p^{rec}");
2486     CreateResolutionPtHisto2D("pTresolutionITS","p_{T} resolution","p_{T}^{rec}","(p_{T}^{sim}-p_{T}^{rec})/p_{T}^{rec}");
2487     CreateResolutionPtHisto2D("ETresolutionITS","E_{T} resolution","E_{T}^{rec}","(E_{T}^{sim}-E_{T}^{rec})/E_{T}^{rec}");
2488     CreateResolutionPtHisto2D("presolutionITS","p resolution","p^{rec}","(p^{sim}-p^{rec})/p^{rec}");
2489     CreatePtHisto1D("pTsimITS","p_{T}^{sim}","p_{T}^{sim}","Number of particles");
2490     CreatePtHisto1D("pTsimTPC","p_{T}^{sim}","p_{T}^{sim}","Number of particles");
2491     CreatePtHisto1D("pTsimTPCITS","p_{T}^{sim}","p_{T}^{sim}","Number of particles");
2492     CreatePtHisto1D("pTrecITS","p_{T}^{rec}","p_{T}^{rec}","Number of particles");
2493     CreatePtHisto1D("pTrecTPC","p_{T}^{rec}","p_{T}^{rec}","Number of particles");
2494     CreatePtHisto1D("pTrecTPCITS","p_{T}^{rec}","p_{T}^{rec}","Number of particles");
2495     if(fDataSet==20100||fDataSet==2011){
2496       Int_t width = 5;
2497       if(fNCentBins<21) width = 10;
2498       for(Int_t j=0;j<fNCentBins;j++){
2499         CreatePtHisto1D(Form("pTsimITSCB%i",j),Form("p_{T}^{sim} for %i-%i central",j*width,(j+1)*width),"p_{T}^{sim}","Number of particles");
2500         CreatePtHisto1D(Form("pTsimTPCITSCB%i",j),Form("p_{T}^{sim} for %i-%i central",j*width,(j+1)*width),"p_{T}^{sim}","Number of particles");
2501         CreatePtHisto1D(Form("pTsimTPCCB%i",j),Form("p_{T}^{sim} for %i-%i central",j*width,(j+1)*width),"p_{T}^{sim}","Number of particles");
2502         CreatePtHisto1D(Form("pTrecITSCB%i",j),Form("p_{T}^{rec} for %i-%i central",j*width,(j+1)*width),"p_{T}^{rec}","Number of particles");
2503         CreatePtHisto1D(Form("pTrecTPCITSCB%i",j),Form("p_{T}^{rec} for %i-%i central",j*width,(j+1)*width),"p_{T}^{rec}","Number of particles");
2504         CreatePtHisto1D(Form("pTrecTPCCB%i",j),Form("p_{T}^{rec} for %i-%i central",j*width,(j+1)*width),"p_{T}^{rec}","Number of particles");
2505       }
2506     }
2507   }
2508
2509 }
2510
2511 void AliAnalysisHadEtMonteCarlo::SetGeneratorMinMaxParticles(AliMCEvent *eventMC){
2512   // In case of access only to hijing particles in cocktail
2513   // get the min and max labels
2514   // TODO: Check when generator is not the first one ...
2515   
2516   fNMCProducedMin = 0;
2517   fNMCProducedMax = 0;
2518   
2519   AliGenEventHeader * eventHeader = eventMC->GenEventHeader();
2520   
2521   AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
2522   
2523   if(!cocktail) return ;
2524     
2525   TList *genHeaders = cocktail->GetHeaders();
2526   
2527   Int_t nGenerators = genHeaders->GetEntries();
2528   //printf("N generators %d \n", nGenerators);
2529   
2530   for(Int_t igen = 0; igen < nGenerators; igen++)
2531     {
2532       AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
2533       TString name = eventHeader2->GetName();
2534       
2535       //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
2536       
2537       fNMCProducedMin = fNMCProducedMax;
2538       fNMCProducedMax+= eventHeader2->NProduced();
2539       
2540       if(name.Contains("Hijing",TString::kIgnoreCase)){
2541         //cout<<"Found HIJING event and set range "<<fNMCProducedMin<<"-"<<fNMCProducedMax<<endl;
2542         return ;
2543       }
2544     }
2545         
2546 }
2547 AliGenEventHeader* AliAnalysisHadEtMonteCarlo::GetGenEventHeader(AliMCEvent *eventMC) const
2548 {
2549   // Return pointer to Generated event header
2550   // If requested and cocktail, search for the hijing generator
2551   AliGenEventHeader * eventHeader = eventMC->GenEventHeader();
2552   AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
2553   
2554   if(!cocktail) return 0x0 ;
2555   
2556   TList *genHeaders = cocktail->GetHeaders();
2557   
2558   Int_t nGenerators = genHeaders->GetEntries();
2559   //printf("N generators %d \n", nGenerators);
2560   
2561   for(Int_t igen = 0; igen < nGenerators; igen++)
2562     {
2563       AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
2564       TString name = eventHeader2->GetName();
2565       
2566       //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
2567       
2568       if(name.Contains("Hijing",TString::kIgnoreCase)) return eventHeader2 ;
2569     }
2570   
2571   return 0x0;
2572   
2573 }
2574 Bool_t AliAnalysisHadEtMonteCarlo::IsHIJINGLabel(Int_t label,AliMCEvent *eventMC,AliStack *stack)
2575 {
2576  
2577   // Find if cluster/track was generated by HIJING
2578   
2579   AliGenHijingEventHeader*  hijingHeader =  dynamic_cast<AliGenHijingEventHeader *> (GetGenEventHeader(eventMC));
2580   
2581   //printf("header %p, label %d\n",hijingHeader,label);
2582   
2583   if(!hijingHeader || label < 0 ) return kFALSE;
2584   
2585   
2586   //printf("pass a), N produced %d\n",nproduced);
2587   
2588   if(label >= fNMCProducedMin && label < fNMCProducedMax)
2589   {
2590     //printf(" accept!, label is smaller than produced, N %d\n",nproduced);
2591
2592     return kTRUE;
2593   }
2594   
2595   if(!stack) return kFALSE;
2596   
2597   Int_t nprimaries = stack->GetNtrack();
2598   
2599   if(label > nprimaries) return kFALSE;
2600     
2601   TParticle * mom = stack->Particle(label);
2602     
2603   Int_t iMom = label;
2604   Int_t iParent = mom->GetFirstMother();
2605   while(iParent!=-1){
2606     if(iParent >= fNMCProducedMin && iParent < fNMCProducedMax){
2607       return kTRUE;
2608     }
2609       
2610     iMom = iParent;
2611     mom = stack->Particle(iMom);
2612     iParent = mom->GetFirstMother();
2613   }
2614     
2615   return kFALSE ;
2616     
2617 }
2618
2619
2620
2621