]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/totEt/AliAnalysisEtReconstructed.cxx
Implementing improved PHOS nonlinearity, changing geometry settings to read all 2011...
[u/mrichter/AliRoot.git] / PWGLF / totEt / AliAnalysisEtReconstructed.cxx
1 //_________________________________________________________________________
2 //  Utility Class for transverse energy studies
3 //  Base class for ESD analysis
4 //  - reconstruction output
5 //  implementation file
6 //
7 //*-- Authors: Oystein Djuvsland (Bergen), David Silvermyr (ORNL)
8 //_________________________________________________________________________
9
10 #include "AliAnalysisEtReconstructed.h"
11 #include "AliAnalysisEtCuts.h"
12 #include "AliESDtrack.h"
13 #include "AliEMCALTrack.h"
14 #include "AliESDCaloCluster.h"
15 #include "TVector3.h"
16 #include "TGeoGlobalMagField.h"
17 #include "AliMagF.h"
18 #include "AliVEvent.h"
19 #include "AliESDEvent.h"
20 #include "AliESDtrackCuts.h"
21 #include "AliVParticle.h"
22 #include "TDatabasePDG.h"
23 #include "TList.h"
24 #include "AliESDpid.h"
25 #include <iostream>
26 #include "TH3F.h"
27 #include "TH2F.h"
28 #include "TH2I.h"
29 #include "TH1I.h"
30 #include "TFile.h"
31 #include "AliAnalysisHadEtCorrections.h"
32 #include "AliAnalysisEtSelector.h"
33 #include "AliLog.h"
34 #include "AliCentrality.h"
35 #include "AliPHOSGeoUtils.h"
36 #include "AliPHOSGeometry.h"
37 #include "AliAnalysisEtRecEffCorrection.h"
38 #include "AliESDpid.h"
39
40
41 using namespace std;
42
43 ClassImp(AliAnalysisEtReconstructed);
44
45
46 AliAnalysisEtReconstructed::AliAnalysisEtReconstructed() :
47         AliAnalysisEt()
48         ,fCorrections(0)
49         ,fPidCut(0)
50         ,nChargedHadronsMeasured(0)
51         ,nChargedHadronsTotal(0)
52         ,fHistChargedPionEnergyDeposit(0)
53         ,fHistProtonEnergyDeposit(0)
54         ,fHistAntiProtonEnergyDeposit(0)
55         ,fHistChargedKaonEnergyDeposit(0)
56         ,fHistMuonEnergyDeposit(0)
57         ,fHistRemovedEnergy(0)
58         ,fGeomCorrection(1.0)
59         ,fEMinCorrection(1.0/0.687)
60         ,fRecEffCorrection(1.0)
61         ,fClusterPositionAccepted(0)
62         ,fClusterPositionAll(0)
63         ,fClusterPositionAcceptedEnergy(0)
64         ,fClusterPositionAllEnergy(0)
65         ,fClusterEnergy(0)
66         ,fClusterEnergyCent(0)
67         ,fClusterEnergyCentMatched(0)
68         ,fClusterEnergyCentNotMatched(0)
69         ,fClusterEt(0)
70         ,fHistChargedEnergyRemoved(0)
71         ,fHistNeutralEnergyRemoved(0)
72         ,fHistGammaEnergyAdded(0)
73         ,fHistMatchedTracksEvspTvsCent(0)
74         ,fHistMatchedTracksEvspTvsCentEffCorr(0)
75         ,fHistMatchedTracksEvspTvsCentEffTMCorr(0)
76         ,fHistPeripheralMatchedTracksEvspTvsCentEffTMCorr(0)
77         ,fHistMatchedTracksEvspTvsCentEffTMCorr500MeV(0)
78         ,fHistFoundHadronsvsCent(0)
79         ,fHistNotFoundHadronsvsCent(0)
80         ,fHistFoundHadronsEtvsCent(0)
81         ,fHistNotFoundHadronsEtvsCent(0)
82         ,fHistFoundHadronsvsCent500MeV(0)
83         ,fHistNotFoundHadronsvsCent500MeV(0)
84         ,fHistFoundHadronsEtvsCent500MeV(0)
85         ,fHistNotFoundHadronsEtvsCent500MeV(0)
86         ,fHistNominalRawEt(0)
87         ,fHistNominalNonLinHighEt(0)
88         ,fHistNominalNonLinLowEt(0)
89         ,fHistNominalEffHighEt(0)
90         ,fHistNominalEffLowEt(0)
91         ,fHistTotRawEtEffCorr(0)
92         ,fHistTotRawEt(0)
93         ,fHistTotRawEtEffCorr500MeV(0)
94         ,fHistTotAllRawEt(0)
95         ,fHistTotAllRawEtEffCorr(0)
96         ,fHistNClustersPhosVsEmcal(0)
97         ,fHistClusterSizeVsCent(0)
98         ,fHistMatchedClusterSizeVsCent(0)
99         ,fHistTotAllRawEtVsTotalPt(0)
100         ,fHistTotAllRawEtVsTotalPtVsCent(0)
101         ,fHistTotMatchedRawEtVsTotalPtVsCent(0)
102         ,fHistPIDProtonsTrackMatchedDepositedVsNch(0)
103         ,fHistPIDAntiProtonsTrackMatchedDepositedVsNch(0)
104         ,fHistPIDProtonsTrackMatchedDepositedVsNcl(0)
105         ,fHistPIDAntiProtonsTrackMatchedDepositedVsNcl(0)
106         ,fHistPiKPTrackMatchedDepositedVsNch(0)
107                                                       //,
108         ,fHistPIDProtonsTrackMatchedDepositedVsNchNoEff(0)
109         ,fHistPIDAntiProtonsTrackMatchedDepositedVsNchNoEff(0)
110         ,fHistPIDProtonsTrackMatchedDepositedVsNclNoEff(0)
111         ,fHistPIDAntiProtonsTrackMatchedDepositedVsNclNoEff(0)
112         ,fHistPiKPTrackMatchedDepositedVsNchNoEff(0)
113         ,fHistCentVsNchVsNclReco(0)
114         ,fHistRawSignalReco(0)
115         ,fHistEffCorrSignalReco(0)
116 {
117
118 }
119
120 AliAnalysisEtReconstructed::~AliAnalysisEtReconstructed()
121 {//destructor
122     delete fCorrections;
123     delete fHistChargedPionEnergyDeposit; /** Energy deposited in calorimeter by charged pions */
124     delete fHistProtonEnergyDeposit; /** Energy deposited in calorimeter by protons */
125     delete fHistAntiProtonEnergyDeposit; /** Energy deposited in calorimeter by anti-protons */
126     delete fHistChargedKaonEnergyDeposit; /** Energy deposited in calorimeter by charged kaons */
127     delete fHistMuonEnergyDeposit; /** Energy deposited in calorimeter by muons */
128
129     delete fHistRemovedEnergy; // removed energy
130     delete fClusterPositionAccepted;
131     delete fClusterPositionAll;
132     delete fClusterPositionAcceptedEnergy;
133     delete fClusterPositionAllEnergy;
134     delete fClusterEnergy;
135     delete fClusterEnergyCent;
136     delete fClusterEnergyCentMatched;
137     delete fClusterEnergyCentNotMatched;
138     delete fClusterEt;
139     delete fHistChargedEnergyRemoved;
140     delete fHistNeutralEnergyRemoved;
141     delete fHistGammaEnergyAdded;
142     delete fHistMatchedTracksEvspTvsCent;
143     delete fHistMatchedTracksEvspTvsCentEffCorr;
144     delete fHistMatchedTracksEvspTvsCentEffTMCorr;
145     delete fHistPeripheralMatchedTracksEvspTvsCentEffTMCorr;
146     delete fHistMatchedTracksEvspTvsCentEffTMCorr500MeV;
147     delete fHistFoundHadronsvsCent;
148     delete fHistNotFoundHadronsvsCent;
149     delete fHistFoundHadronsEtvsCent;
150     delete fHistNotFoundHadronsEtvsCent;
151     delete fHistFoundHadronsvsCent500MeV;
152     delete fHistNotFoundHadronsvsCent500MeV;
153     delete fHistFoundHadronsEtvsCent500MeV;
154     delete fHistNotFoundHadronsEtvsCent500MeV;
155     delete fHistNominalRawEt;
156     delete fHistNominalNonLinHighEt;
157     delete fHistNominalNonLinLowEt;
158     delete fHistNominalEffHighEt;
159     delete fHistNominalEffLowEt;
160     delete fHistTotRawEtEffCorr;
161     delete fHistTotRawEt;
162     delete fHistTotAllRawEt;
163     delete fHistTotAllRawEtEffCorr;
164     delete fHistTotRawEtEffCorr500MeV;
165     delete fHistNClustersPhosVsEmcal;
166     delete fHistClusterSizeVsCent;
167     delete fHistMatchedClusterSizeVsCent;
168     delete fHistTotAllRawEtVsTotalPt;
169     delete fHistTotAllRawEtVsTotalPtVsCent;
170     delete fHistTotMatchedRawEtVsTotalPtVsCent;
171     delete fHistPIDProtonsTrackMatchedDepositedVsNch;
172     delete fHistPIDAntiProtonsTrackMatchedDepositedVsNch;
173     delete fHistPIDProtonsTrackMatchedDepositedVsNcl;
174     delete fHistPIDAntiProtonsTrackMatchedDepositedVsNcl;
175     delete fHistPiKPTrackMatchedDepositedVsNch;
176     delete fHistPIDProtonsTrackMatchedDepositedVsNchNoEff;
177     delete fHistPIDAntiProtonsTrackMatchedDepositedVsNchNoEff;
178     delete fHistPIDProtonsTrackMatchedDepositedVsNclNoEff;
179     delete fHistPIDAntiProtonsTrackMatchedDepositedVsNclNoEff;
180     delete fHistPiKPTrackMatchedDepositedVsNchNoEff;
181     delete fHistCentVsNchVsNclReco;
182     delete fHistRawSignalReco;
183     delete fHistEffCorrSignalReco;
184 }
185
186 Int_t AliAnalysisEtReconstructed::AnalyseEvent(AliVEvent* ev)
187 {
188
189     //AliAnalysisEt::AnalyseEvent(ev);
190     // analyse ESD event
191     ResetEventValues();
192     if (!ev) {
193         AliFatal("ERROR: Event does not exist");
194         return 0;
195     }
196
197     AliESDEvent *event = dynamic_cast<AliESDEvent*>(ev);
198     if (!event) {
199         AliFatal("ERROR: ESD Event does not exist");
200         return 0;
201     }
202     if(!fSelector){
203         AliFatal("ERROR: fSelector does not exist");
204         return 0;
205     }
206     fSelector->SetEvent(event);
207     
208     Int_t cent = -1;
209     fCentrality = event->GetCentrality();
210     if (fCentrality && cent)
211     {
212         cent = fCentrality->GetCentralityClass5("V0M");
213         fCentClass = fCentrality->GetCentralityClass5("V0M");
214     }
215
216
217   //for PID
218   //AliESDpid *pID = new AliESDpid();
219   //pID->MakePID(event);
220   Float_t etPIDProtons = 0.0;
221   Float_t etPIDAntiProtons = 0.0;
222   Float_t etPiKPMatched = 0.0;
223   Float_t etPIDProtonsNoEff = 0.0;
224   Float_t etPIDAntiProtonsNoEff = 0.0;
225   Float_t etPiKPMatchedNoEff = 0.0;
226   Float_t multiplicity = fEsdtrackCutsTPC->GetReferenceMultiplicity(event,kTRUE);
227
228
229     Float_t totalMatchedPt = 0.0;
230     Float_t totalPt = 0.0;
231     TObjArray* list  = fEsdtrackCutsTPC->GetAcceptedTracks(event);
232     Int_t nGoodTracks = list->GetEntries();
233     for (Int_t iTrack = 0; iTrack < nGoodTracks; iTrack++){
234         AliESDtrack *track = dynamic_cast<AliESDtrack*> (list->At(iTrack));
235         if (!track)
236           {
237             Printf("ERROR: Could not get track %d", iTrack);
238             continue;
239           }
240         else{
241           totalPt +=track->Pt();
242           //pID->MakeITSPID(track);
243
244
245         }
246     }
247
248     //TRefArray *caloClusters = fSelector->GetClusters();//just gets the correct set of clusters - does not apply any cuts
249     //Float_t fClusterMult = caloClusters->GetEntries();
250
251     Float_t nominalRawEt = 0;
252     Float_t totEt500MeV = 0;
253     Float_t nonlinHighRawEt = 0;
254     Float_t nonlinLowRawEt = 0;
255     Float_t effHighRawEt = 0;
256     Float_t effLowRawEt = 0;
257     Float_t uncorrEt = 0;
258     Float_t rawSignal = 0;
259     Float_t effCorrSignal = 0;
260
261     nChargedHadronsMeasured = 0.0;
262     nChargedHadronsTotal = 0.0;
263     Float_t nChargedHadronsEtMeasured = 0.0;
264     Float_t nChargedHadronsEtTotal = 0.0;
265     Float_t nChargedHadronsMeasured500MeV = 0.0;
266     Float_t nChargedHadronsTotal500MeV = 0.0;
267     Float_t nChargedHadronsEtMeasured500MeV = 0.0;
268     Float_t nChargedHadronsEtTotal500MeV = 0.0;
269     Float_t fTotAllRawEt = 0.0;
270     Float_t fTotRawEt = 0.0;
271     Float_t fTotRawEtEffCorr = 0.0;
272     Float_t fTotAllRawEtEffCorr = 0.0;
273     Int_t nPhosClusters = 0;
274     Int_t nEmcalClusters = 0;
275
276
277     TRefArray *caloClusters = fSelector->GetClusters();
278     Int_t nCluster = caloClusters->GetEntries();
279
280     for (int iCluster = 0; iCluster < nCluster; iCluster++ )
281     {
282         AliESDCaloCluster* cluster = ( AliESDCaloCluster* )caloClusters->At( iCluster );
283         if (!cluster)
284         {
285             AliError(Form("ERROR: Could not get cluster %d", iCluster));
286             continue;
287         }
288         int x = 0;
289         fCutFlow->Fill(x++);
290         if(cluster->IsEMCAL()) nEmcalClusters++;
291         else nPhosClusters++;
292         if(!fSelector->IsDetectorCluster(*cluster)) continue;
293         fCutFlow->Fill(x++);
294         if(!fSelector->PassMinEnergyCut(*cluster)) continue;
295         fCutFlow->Fill(x++);
296         if (!fSelector->PassDistanceToBadChannelCut(*cluster)) continue;
297         fCutFlow->Fill(x++);
298         if (!fSelector->CutGeometricalAcceptance(*cluster)) continue;
299         //fCutFlow->Fill(x++);
300         Float_t pos[3];
301
302         cluster->GetPosition(pos);
303         TVector3 cp(pos);
304         fClusterPositionAll->Fill(cp.Phi(), cp.PseudoRapidity());
305         fClusterPositionAllEnergy->Fill(cp.Phi(), cp.PseudoRapidity(),GetCorrectionModification(*cluster,0,0,cent)*cluster->E());
306
307         //if(TMath::Abs(cp.Eta())> fCuts->fCuts->GetGeometryEmcalEtaAccCut() || cp.Phi() >  fCuts->GetGeometryEmcalPhiAccMaxCut()*TMath::Pi()/180. ||  cp.Phi() >  fCuts->GetGeometryEmcalPhiAccMinCut()*TMath::Pi()/180.) continue;//Do not accept if cluster is not in the acceptance
308         fTotAllRawEt += TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
309         fTotAllRawEtEffCorr +=GetCorrectionModification(*cluster,0,0,cent)* CorrectForReconstructionEfficiency(*cluster,cent);
310
311         fClusterEnergyCent->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(),cent);
312
313         Bool_t matched = kTRUE;//default to no track matched
314         Int_t trackMatchedIndex = cluster->GetTrackMatchedIndex();//find the index of the matched track
315         matched = !(fSelector->PassTrackMatchingCut(*cluster));//PassTrackMatchingCut is false if there is a matched track
316         if(matched){//if the track match is good (, is the track good?
317           if(trackMatchedIndex < 0) matched=kFALSE;//If the index is bad, don't count it
318           if(matched){
319             AliESDtrack *track = event->GetTrack(trackMatchedIndex);
320             //if this is a good track, accept track will return true.  The track matched is good, so not track matched is false
321             matched = fEsdtrackCutsTPC->AcceptTrack(track);//If the track is bad, don't count it
322           }
323         }
324
325
326         if (matched)
327         {
328           
329             if (cluster->GetNTracksMatched() > 0 && trackMatchedIndex>=0)
330             {
331                 AliVTrack *track = event->GetTrack(trackMatchedIndex);
332                 if (!track) {
333                     AliError("Error: track does not exist");
334                 }
335                 else {
336                   totalMatchedPt +=track->Pt();
337                   fClusterEnergyCentMatched->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(),cent);
338                   fHistMatchedClusterSizeVsCent->Fill(cluster->GetNCells(),cent);
339
340                   float eff = fTmCorrections->TrackMatchingEfficiency(track->Pt(),cent);
341                   if(TMath::Abs(eff)<1e-5) eff = 1.0;
342                   //cout<<"pt "<<track->Pt()<<" eff "<<eff<<" total "<<nChargedHadronsTotal<<endl;
343                   nChargedHadronsMeasured++;
344                   nChargedHadronsTotal += 1/eff;
345                   Double_t effCorrEt = GetCorrectionModification(*cluster,0,0,cent) * CorrectForReconstructionEfficiency(*cluster,cent);
346                   nChargedHadronsEtMeasured+= TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
347                   //One efficiency is the gamma efficiency and the other is the track matching efficiency.
348                   nChargedHadronsEtTotal+= 1/eff *TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
349                   //cout<<"nFound "<<1<<" nFoundTotal "<<1/eff<<" etMeas "<<TMath::Sin(cp.Theta())*cluster->E()<<" ET total "<< 1/eff *TMath::Sin(cp.Theta())*cluster->E()<<endl;
350
351                   Float_t nSigmaPion = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion); 
352                   Float_t nSigmaProton = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton); 
353                   bool isProton = (nSigmaPion>3.0 && nSigmaProton<3.0 && track->Pt()<0.9);
354                   //cout<<"NSigmaProton "<<nSigmaProton<<endl;
355                   etPiKPMatched += effCorrEt;
356                   etPiKPMatchedNoEff  +=TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
357                   if(isProton){
358                     if(track->Charge()>0){
359                       etPIDProtons += effCorrEt;
360                       etPIDProtonsNoEff +=TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
361                     }
362                     else{
363                       etPIDAntiProtonsNoEff +=TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
364                       etPIDAntiProtons += effCorrEt;
365                     }
366                   }
367                   if(TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E()>0.5){
368                     nChargedHadronsMeasured500MeV++;
369                     nChargedHadronsTotal500MeV += 1/eff;
370                     nChargedHadronsEtMeasured500MeV+= TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
371                     nChargedHadronsEtTotal500MeV+= 1/eff *TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
372                   }
373                   fHistMatchedTracksEvspTvsCent->Fill(track->P(),TMath::Sin(cp.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E(),cent);
374                   fHistMatchedTracksEvspTvsCentEffCorr->Fill(track->P(),effCorrEt,cent);
375                   //Weighed by the number of tracks we didn't find
376                   fHistMatchedTracksEvspTvsCentEffTMCorr->Fill(track->P(), effCorrEt,cent, (1/eff-1) );
377                   if(cent<16 && cent>11){//centralities 60-80% where false track matches are low
378                     for(int cbtest = 0; cbtest<20; cbtest++){//then we calculate the deposit matched to hadrons with different centrality bins' efficiencies
379                       float efftest = fTmCorrections->TrackMatchingEfficiency(track->Pt(),cbtest);
380                       if(TMath::Abs(efftest)<1e-5) efftest = 1.0;
381                       Double_t effCorrEttest = GetCorrectionModification(*cluster,0,0,cent)*CorrectForReconstructionEfficiency(*cluster,cbtest);
382                       fHistPeripheralMatchedTracksEvspTvsCentEffTMCorr->Fill(track->P(), effCorrEttest,cbtest, (1/efftest-1) );
383                     }
384                   }
385                   cluster->GetPosition(pos);      
386                   TVector3 p2(pos);
387                   uncorrEt += TMath::Sin(p2.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
388                   if(uncorrEt>=0.5) fHistMatchedTracksEvspTvsCentEffTMCorr500MeV->Fill(track->P(), effCorrEt,cent, (1/eff-1) );
389                     const Double_t *pidWeights = track->PID();
390
391                     Double_t maxpidweight = 0;
392                     Int_t maxpid = 0;
393
394                     if (pidWeights)
395                     {
396                         for (Int_t p =0; p < AliPID::kSPECIES; p++)
397                         {
398                             if (pidWeights[p] > maxpidweight)
399                             {
400                                 maxpidweight = pidWeights[p];
401                                 maxpid = p;
402                             }
403                         }
404                         if (fCuts->GetHistMakeTreeDeposit() && fDepositTree)
405                         {
406                             fEnergyDeposited =GetCorrectionModification(*cluster,0,0,cent)* cluster->E();
407                             fMomentumTPC = track->P();
408                             fCharge = track->Charge();
409                             fParticlePid = maxpid;
410                             fPidProb = maxpidweight;
411                             AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
412                             if (!esdTrack) {
413                                 AliError("Error: track does not exist");
414                             }
415                             else {
416                                 if (esdTrack) fTrackPassedCut = fEsdtrackCutsTPC->AcceptTrack(esdTrack);
417                                 fDepositTree->Fill();
418                             }
419                         }
420
421                         if (maxpidweight > fPidCut)
422                         {
423                             //Float_t dist = TMath::Sqrt(pos[0]*pos[0] + pos[1]*pos[1]);
424
425                             //Float_t theta = TMath::ATan(pos[2]/dist)+TMath::Pi()/2;
426
427                             //Float_t et = cluster->E() * TMath::Sin(theta);
428                             if (maxpid == AliPID::kProton)
429                             {
430
431                                 if (track->Charge() == 1)
432                                 {
433                                     fHistProtonEnergyDeposit->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(), track->E());
434                                 }
435                                 else if (track->Charge() == -1)
436                                 {
437                                     fHistAntiProtonEnergyDeposit->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(), track->E());
438                                 }
439                             }
440                             else if (maxpid == AliPID::kPion)
441                             {
442                                 fHistChargedPionEnergyDeposit->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(), track->E());
443                             }
444                             else if (maxpid == AliPID::kKaon)
445                             {
446                                 fHistChargedKaonEnergyDeposit->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(), track->E());
447                             }
448                             else if (maxpid == AliPID::kMuon)
449                             {
450                                 fHistMuonEnergyDeposit->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(), track->E());
451                             }
452                         }
453                     }
454                 }
455             }
456             //continue;
457         } // distance
458         else{//these are clusters which were not track matched
459           fCutFlow->Fill(x++);
460           //std::cout << x++ << std::endl;
461           
462           //if (cluster->E() >  fSingleCellEnergyCut && cluster->GetNCells() == fCuts->GetCommonSingleCell()) continue;
463           //if (cluster->E() < fClusterEnergyCut) continue;
464           cluster->GetPosition(pos);
465           
466             TVector3 p2(pos);
467             
468             fClusterPositionAccepted->Fill(p2.Phi(), p2.PseudoRapidity());
469             fClusterPositionAcceptedEnergy->Fill(p2.Phi(), p2.PseudoRapidity(),GetCorrectionModification(*cluster,0,0,cent)*cluster->E());
470             fClusterEnergy->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E());
471             fClusterEnergyCentNotMatched->Fill(GetCorrectionModification(*cluster,0,0,cent)*cluster->E(),cent);
472             fHistClusterSizeVsCent->Fill(cluster->GetNCells(),cent);
473             fClusterEt->Fill(TMath::Sin(p2.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E());
474             uncorrEt += TMath::Sin(p2.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
475             float myuncorrEt = TMath::Sin(p2.Theta())*GetCorrectionModification(*cluster,0,0,cent)*cluster->E();
476             fTotRawEt += myuncorrEt;
477
478             Double_t effCorrEt = CorrectForReconstructionEfficiency(*cluster,cent)*GetCorrectionModification(*cluster,0,0,cent);
479             rawSignal += myuncorrEt;
480             effCorrSignal +=effCorrEt;
481             //cout<<"cluster energy "<<cluster->E()<<" eff corr Et "<<effCorrEt<<endl;
482             fTotRawEtEffCorr += effCorrEt;
483             fTotNeutralEt += effCorrEt;
484             nominalRawEt += effCorrEt;
485             if(myuncorrEt>=0.5){
486               totEt500MeV += effCorrEt;
487               //cout<<"test "<<myuncorrEt<<"> 0.5"<<endl;
488             }
489             else{
490               //cout<<"test "<<myuncorrEt<<"< 0.5"<<endl;
491             }
492             nonlinHighRawEt += effCorrEt*GetCorrectionModification(*cluster,1,0,cent);
493             nonlinLowRawEt += effCorrEt*GetCorrectionModification(*cluster,-1,0,cent);
494             effHighRawEt += effCorrEt*GetCorrectionModification(*cluster,0,1,cent);
495             effLowRawEt += effCorrEt*GetCorrectionModification(*cluster,0,-1,cent);
496             fNeutralMultiplicity++;
497         }
498         fMultiplicity++;
499     }
500     
501
502     fHistRawSignalReco->Fill(rawSignal);
503     fHistEffCorrSignalReco->Fill(effCorrSignal);
504
505     fHistNClustersPhosVsEmcal->Fill(nPhosClusters,nEmcalClusters,cent);
506     fChargedEnergyRemoved = GetChargedContribution(fNeutralMultiplicity);
507     fNeutralEnergyRemoved = GetNeutralContribution(fNeutralMultiplicity);
508     fHistChargedEnergyRemoved->Fill(fChargedEnergyRemoved, fNeutralMultiplicity);
509     fHistNeutralEnergyRemoved->Fill(fNeutralEnergyRemoved, fNeutralMultiplicity);
510     
511     fGammaEnergyAdded = GetGammaContribution(fNeutralMultiplicity);
512     fHistGammaEnergyAdded->Fill(fGammaEnergyAdded, fNeutralMultiplicity);
513
514     Double_t removedEnergy = GetChargedContribution(fNeutralMultiplicity) + GetNeutralContribution(fNeutralMultiplicity) + GetGammaContribution(fNeutralMultiplicity) + GetSecondaryContribution(fNeutralMultiplicity);
515     fHistRemovedEnergy->Fill(removedEnergy);
516     
517     fTotNeutralEtAcc = fTotNeutralEt;
518     //fHistTotRawEtEffCorr->Fill(fTotNeutralEt,cent);
519     fHistTotRawEtEffCorr->Fill(fTotRawEtEffCorr,cent);
520     fHistTotRawEt->Fill(fTotRawEt,cent);
521     fHistTotAllRawEt->Fill(fTotAllRawEt,cent);
522     fHistTotAllRawEtVsTotalPt->Fill(fTotAllRawEt,totalPt);
523     fHistTotAllRawEtVsTotalPtVsCent->Fill(fTotAllRawEt,totalPt,cent);
524     fHistTotMatchedRawEtVsTotalPtVsCent->Fill(fTotAllRawEt,totalMatchedPt,cent);
525     fHistTotAllRawEtEffCorr->Fill(fTotAllRawEtEffCorr,cent);
526     //cout<<"fTotAllRawEtEffCorr "<<fTotAllRawEtEffCorr<<" fTotAllRawEt "<<fTotAllRawEt<<" fTotRawEtEffCorr "<<fTotRawEtEffCorr<<"("<<fTotNeutralEt<<")"<<" fTotRawEt "<<fTotRawEt<<endl;
527     //cout<<"uncorr "<<uncorrEt<<" raw "<<nominalRawEt<<" tot raw "<<fTotNeutralEt;
528     fTotNeutralEt = fGeomCorrection * fEMinCorrection * (fTotNeutralEt - removedEnergy);
529     //cout<<" tot corr "<<fTotNeutralEt<<endl;
530     fTotEt = fTotChargedEt + fTotNeutralEt;
531 // Fill the histograms...0
532     FillHistograms();
533     //std::cout << "fTotNeutralEt: " << fTotNeutralEt << ", Contribution from non-removed charged: " << GetChargedContribution(fNeutralMultiplicity) << ", neutral: " << GetNeutralContribution(fNeutralMultiplicity) << ", gammas: " << GetGammaContribution(fNeutralMultiplicity) << ", multiplicity: " << fNeutralMultiplicity<< std::endl;
534     //cout<<"cent "<<cent<<" cluster mult "<<fClusterMult<<" fTotNeutralEt "<<fTotNeutralEt<<" nominalRawEt "<<nominalRawEt<<endl;
535     fHistNominalRawEt->Fill(nominalRawEt,cent);
536     fHistTotRawEtEffCorr500MeV->Fill(totEt500MeV,cent);
537     fHistNominalNonLinHighEt->Fill(nonlinHighRawEt,cent);
538     fHistNominalNonLinLowEt->Fill(nonlinLowRawEt,cent);
539     fHistNominalEffHighEt->Fill(effHighRawEt,cent);
540     fHistNominalEffLowEt->Fill(effLowRawEt,cent);
541     fHistFoundHadronsvsCent->Fill(nChargedHadronsMeasured,cent);
542     fHistNotFoundHadronsvsCent->Fill(nChargedHadronsTotal-nChargedHadronsMeasured,cent);
543     fHistFoundHadronsEtvsCent->Fill(nChargedHadronsEtMeasured,cent);
544     fHistNotFoundHadronsEtvsCent->Fill(nChargedHadronsEtTotal-nChargedHadronsEtMeasured,cent);
545     //cout<<"found "<<nChargedHadronsMeasured<<" total "<<nChargedHadronsTotal<<" not found "<<nChargedHadronsTotal-nChargedHadronsMeasured<<" found "<< nChargedHadronsMeasured500MeV<<" not found "<< nChargedHadronsTotal500MeV-nChargedHadronsMeasured500MeV <<" total "<<nChargedHadronsTotal500MeV<<endl;
546     fHistFoundHadronsvsCent500MeV->Fill(nChargedHadronsMeasured500MeV,cent);
547     fHistNotFoundHadronsvsCent500MeV->Fill(nChargedHadronsTotal500MeV-nChargedHadronsMeasured500MeV,cent);
548     fHistFoundHadronsEtvsCent500MeV->Fill(nChargedHadronsEtMeasured500MeV,cent);
549     fHistNotFoundHadronsEtvsCent500MeV->Fill(nChargedHadronsEtTotal500MeV-nChargedHadronsEtMeasured500MeV,cent);
550 //     cout<<"Number of hadrons measured:  "<<nChargedHadronsMeasured<<" Estimated total number of hadrons "<<nChargedHadronsTotal<<" ET in track matched hadrons "<<
551 //       nChargedHadronsEtMeasured;
552 //     if(nChargedHadronsMeasured>0)cout<<" ("<<nChargedHadronsEtMeasured/nChargedHadronsMeasured<<") ";
553 //     cout<<" ET in all hadrons ";
554 //     cout<<nChargedHadronsEtTotal;
555 //     if(nChargedHadronsTotal>0) cout<<" ("<<nChargedHadronsEtTotal/nChargedHadronsTotal<<") ";
556 //     cout<<endl;
557     fHistPIDProtonsTrackMatchedDepositedVsNch->Fill(etPIDProtons,multiplicity);
558     fHistPIDAntiProtonsTrackMatchedDepositedVsNch->Fill(etPIDAntiProtons,multiplicity);
559     fHistPIDProtonsTrackMatchedDepositedVsNcl->Fill(etPIDProtons,nCluster);
560     fHistPIDAntiProtonsTrackMatchedDepositedVsNcl->Fill(etPIDAntiProtons,nCluster);
561     fHistPIDProtonsTrackMatchedDepositedVsNchNoEff->Fill(etPIDProtonsNoEff,multiplicity);
562     fHistPIDAntiProtonsTrackMatchedDepositedVsNchNoEff->Fill(etPIDAntiProtonsNoEff,multiplicity);
563     fHistPIDProtonsTrackMatchedDepositedVsNclNoEff->Fill(etPIDProtonsNoEff,nCluster);
564     fHistPIDAntiProtonsTrackMatchedDepositedVsNclNoEff->Fill(etPIDAntiProtonsNoEff,nCluster);
565     fHistCentVsNchVsNclReco->Fill(cent,multiplicity,nCluster);
566     fHistPiKPTrackMatchedDepositedVsNch->Fill(etPiKPMatched,multiplicity);
567     fHistPiKPTrackMatchedDepositedVsNchNoEff->Fill(etPiKPMatchedNoEff,multiplicity);
568     //delete pID;
569     return 0;
570 }
571
572 bool AliAnalysisEtReconstructed::CheckGoodVertex(AliVParticle* track)
573 { // check vertex
574
575     Float_t bxy = 999.;
576     Float_t bz = 999.;
577     if (!track) {
578         AliError("ERROR: no track");
579         return kFALSE;
580     }
581     AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
582     if (!esdTrack) {
583         AliError("ERROR: no track");
584         return kFALSE;
585     }
586     esdTrack->GetImpactParametersTPC(bxy,bz);
587
588
589     bool status = (TMath::Abs(track->Xv()) < fCuts->GetReconstructedVertexXCut()) &&
590                   (TMath::Abs(track->Yv()) < fCuts->GetReconstructedVertexYCut()) &&
591                   (TMath::Abs(track->Zv()) < fCuts->GetReconstructedVertexZCut()) &&
592                   (TMath::Abs(bxy) < fCuts->GetReconstructedIPxyCut()) &&
593                   (TMath::Abs(bz) < fCuts->GetReconstructedIPzCut());
594
595     return status;
596 }
597
598 void AliAnalysisEtReconstructed::Init()
599 { // Init
600     AliAnalysisEt::Init();
601     fPidCut = fCuts->GetReconstructedPidCut();
602     TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 1., 1., AliMagF::k5kG));
603     if (!fCorrections) {
604         cout<<"Warning!  You have not set corrections.  Your code will crash.  You have to set the corrections."<<endl;
605     }
606 }
607
608 bool AliAnalysisEtReconstructed::TrackHitsCalorimeter(AliVParticle* track, Double_t magField)
609 { // propagate track to detector radius
610     if (!track) {
611         cout<<"Warning: track empty"<<endl;
612         return kFALSE;
613     }
614     AliESDtrack *esdTrack= dynamic_cast<AliESDtrack*>(track);
615     if (!esdTrack) {
616         AliError("ERROR: no ESD track");
617         return kFALSE;
618     }
619     // Printf("Propagating track: eta: %f, phi: %f, pt: %f", esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt());
620
621     Bool_t prop = esdTrack->PropagateTo(fDetectorRadius, magField);
622
623     // if (prop) Printf("Track propagated, eta: %f, phi: %f, pt: %f", esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt());
624     return prop && fSelector->CutGeometricalAcceptance(*esdTrack);
625 }
626
627 void AliAnalysisEtReconstructed::FillOutputList(TList* list)
628 { // add some extra histograms to the ones from base class
629     AliAnalysisEt::FillOutputList(list);
630
631     list->Add(fHistChargedPionEnergyDeposit);
632     list->Add(fHistProtonEnergyDeposit);
633     list->Add(fHistAntiProtonEnergyDeposit);
634     list->Add(fHistChargedKaonEnergyDeposit);
635     list->Add(fHistMuonEnergyDeposit);
636
637     list->Add(fHistRemovedEnergy);
638     list->Add(fClusterPositionAccepted);
639     list->Add(fClusterPositionAll);
640     list->Add(fClusterPositionAcceptedEnergy);
641     list->Add(fClusterPositionAllEnergy);
642     list->Add(fClusterEnergy);
643     list->Add(fClusterEnergyCent);
644     list->Add(fClusterEnergyCentMatched);
645     list->Add(fClusterEnergyCentNotMatched);
646     list->Add(fClusterEt);
647     
648     list->Add(fHistChargedEnergyRemoved);
649     list->Add(fHistNeutralEnergyRemoved);
650     list->Add(fHistGammaEnergyAdded);
651     list->Add(fHistMatchedTracksEvspTvsCent);
652     list->Add(fHistMatchedTracksEvspTvsCentEffCorr);
653     list->Add(fHistMatchedTracksEvspTvsCentEffTMCorr);
654     list->Add(fHistPeripheralMatchedTracksEvspTvsCentEffTMCorr);
655     list->Add(fHistMatchedTracksEvspTvsCentEffTMCorr500MeV);
656     list->Add(fHistFoundHadronsvsCent);
657     list->Add(fHistNotFoundHadronsvsCent);
658     list->Add(fHistFoundHadronsEtvsCent);
659     list->Add(fHistNotFoundHadronsEtvsCent);
660     list->Add(fHistFoundHadronsvsCent500MeV);
661     list->Add(fHistNotFoundHadronsvsCent500MeV);
662     list->Add(fHistFoundHadronsEtvsCent500MeV);
663     list->Add(fHistNotFoundHadronsEtvsCent500MeV);
664     list->Add(fHistNominalRawEt);
665     list->Add(fHistNominalNonLinHighEt);
666     list->Add(fHistNominalNonLinLowEt);
667     list->Add(fHistNominalEffHighEt);
668     list->Add(fHistNominalEffLowEt);
669     list->Add(fHistTotRawEtEffCorr);
670     list->Add(fHistTotRawEtEffCorr500MeV);
671     list->Add(fHistTotAllRawEtEffCorr);
672     list->Add(fHistTotRawEt);
673     list->Add(fHistTotAllRawEt);
674     list->Add(fHistNClustersPhosVsEmcal);
675     list->Add(fHistClusterSizeVsCent);
676     list->Add(fHistMatchedClusterSizeVsCent);
677     list->Add(fHistTotAllRawEtVsTotalPt);
678     list->Add(fHistTotAllRawEtVsTotalPtVsCent);
679     list->Add(fHistTotMatchedRawEtVsTotalPtVsCent);
680     list->Add(fHistPIDProtonsTrackMatchedDepositedVsNch);
681     list->Add(fHistPIDAntiProtonsTrackMatchedDepositedVsNch);
682     list->Add(fHistPIDProtonsTrackMatchedDepositedVsNcl);
683     list->Add(fHistPIDAntiProtonsTrackMatchedDepositedVsNcl);
684     list->Add(fHistPiKPTrackMatchedDepositedVsNch);
685     list->Add(fHistPIDProtonsTrackMatchedDepositedVsNchNoEff);
686     list->Add(fHistPIDAntiProtonsTrackMatchedDepositedVsNchNoEff);
687     list->Add(fHistPIDProtonsTrackMatchedDepositedVsNclNoEff);
688     list->Add(fHistPIDAntiProtonsTrackMatchedDepositedVsNclNoEff);
689     list->Add(fHistPiKPTrackMatchedDepositedVsNchNoEff);
690     list->Add(fHistCentVsNchVsNclReco);
691     list->Add(fHistRawSignalReco);
692     list->Add(fHistEffCorrSignalReco);
693 }
694
695 void AliAnalysisEtReconstructed::CreateHistograms()
696 { // add some extra histograms to the ones from base class
697     AliAnalysisEt::CreateHistograms();
698
699     Int_t nbinsEt = 1000;
700     Double_t minEt = 0;
701     Double_t maxEt = 10;
702
703     // possibly change histogram limits
704 //     if (fCuts) {
705 //         nbinsEt = fCuts->GetHistNbinsParticleEt();
706 //         minEt = fCuts->GetHistMinParticleEt();
707 //         maxEt = fCuts->GetHistMaxParticleEt();
708 //     }
709
710     TString histname;
711     histname = "fHistChargedPionEnergyDeposit" + fHistogramNameSuffix;
712     fHistChargedPionEnergyDeposit = new TH2F(histname.Data(), "Energy deposited by #pi^{+/-}", nbinsEt, minEt, maxEt, nbinsEt, minEt, maxEt);
713     fHistChargedPionEnergyDeposit->SetXTitle("Energy deposited in calorimeter");
714     fHistChargedPionEnergyDeposit->SetYTitle("Energy of track");
715
716     histname = "fHistProtonEnergyDeposit" + fHistogramNameSuffix;
717     fHistProtonEnergyDeposit = new TH2F(histname.Data(), "Energy deposited by protons", nbinsEt, minEt, maxEt, nbinsEt, minEt, maxEt);
718     fHistProtonEnergyDeposit->SetXTitle("Energy deposited in calorimeter");
719     fHistProtonEnergyDeposit->SetYTitle("Energy of track");
720
721     histname = "fHistAntiProtonEnergyDeposit" + fHistogramNameSuffix;
722     fHistAntiProtonEnergyDeposit = new TH2F(histname.Data(), "Energy deposited by anti-protons", nbinsEt, minEt, maxEt, nbinsEt, minEt, maxEt);
723     fHistAntiProtonEnergyDeposit->SetXTitle("Energy deposited in calorimeter");
724     fHistAntiProtonEnergyDeposit->SetYTitle("Energy of track");
725
726     histname = "fHistChargedKaonEnergyDeposit" + fHistogramNameSuffix;
727     fHistChargedKaonEnergyDeposit = new TH2F(histname.Data(), "Energy deposited by K^{+/-}", nbinsEt, minEt, maxEt, nbinsEt, minEt, maxEt);
728     fHistChargedKaonEnergyDeposit->SetXTitle("Energy deposited in calorimeter");
729     fHistChargedKaonEnergyDeposit->SetYTitle("Energy of track");
730
731     histname = "fHistMuonEnergyDeposit" + fHistogramNameSuffix;
732     fHistMuonEnergyDeposit = new TH2F(histname.Data(), "Energy deposited by #mu^{+/-}", nbinsEt, minEt, maxEt, nbinsEt, minEt, maxEt);
733     fHistMuonEnergyDeposit->SetXTitle("Energy deposited in calorimeter");
734     fHistMuonEnergyDeposit->SetYTitle("Energy of track");
735
736     histname = "fHistRemovedEnergy" + fHistogramNameSuffix;
737     fHistRemovedEnergy = new TH1F(histname.Data(), histname.Data(), 1000, 0, 20);
738     //fHistMuonEnergyDeposit->SetXTitle("Energy deposited in calorimeter");
739     //fHistMuonEnergyDeposit->SetYTitle("Energy of track");
740
741     histname = "fClusterPositionAccepted" + fHistogramNameSuffix;
742     fClusterPositionAccepted = new TH2D(histname.Data(), "Position of accepted neutral clusters",300, -TMath::Pi(),TMath::Pi(), 100, -0.7 , 0.7);
743     fClusterPositionAccepted->SetXTitle("#phi");
744     fClusterPositionAccepted->SetYTitle("#eta");
745
746     histname = "fClusterPositionAll" + fHistogramNameSuffix;
747     fClusterPositionAll = new TH2D(histname.Data(), "Position of accepted neutral clusters",300, -TMath::Pi(),TMath::Pi(), 100, -0.7 , 0.7);
748     fClusterPositionAll->SetXTitle("#phi");
749     fClusterPositionAll->SetYTitle("#eta");
750
751     histname = "fClusterPositionAcceptedEnergy" + fHistogramNameSuffix;
752     fClusterPositionAcceptedEnergy = new TH2D(histname.Data(), "Position of accepted neutral clusters",300, -TMath::Pi(),TMath::Pi(), 100, -0.7 , 0.7);
753     fClusterPositionAcceptedEnergy->SetXTitle("#phi");
754     fClusterPositionAcceptedEnergy->SetYTitle("#eta");
755
756     histname = "fClusterPositionAllEnergy" + fHistogramNameSuffix;
757     fClusterPositionAllEnergy = new TH2D(histname.Data(), "Position of accepted neutral clusters",300, -TMath::Pi(),TMath::Pi(), 100, -0.7 , 0.7);
758     fClusterPositionAllEnergy->SetXTitle("#phi");
759     fClusterPositionAllEnergy->SetYTitle("#eta");
760
761     histname = "fClusterEnergy" + fHistogramNameSuffix;
762     fClusterEnergy = new TH1F(histname.Data(), histname.Data(), 100, 0, 5);
763     fClusterEnergy->SetYTitle("Number of clusters");
764     fClusterEnergy->SetXTitle("Energy of cluster");
765
766     histname = "fClusterEnergyCent" + fHistogramNameSuffix;
767     fClusterEnergyCent = new TH2F(histname.Data(), histname.Data(), 100, 0, 5,20,-0.5,19.5);
768     fClusterEnergyCent->SetXTitle("Energy of cluster");
769     fClusterEnergyCent->SetYTitle("Centrality Bin");
770     fClusterEnergyCent->SetZTitle("Number of clusters");
771
772     histname = "fClusterEnergyCentMatched" + fHistogramNameSuffix;
773     fClusterEnergyCentMatched = new TH2F(histname.Data(), histname.Data(), 100, 0, 5,20,-0.5,19.5);
774     fClusterEnergyCentMatched->SetXTitle("Energy of cluster");
775     fClusterEnergyCentMatched->SetYTitle("Centrality Bin");
776     fClusterEnergyCentMatched->SetZTitle("Number of Clusters");
777
778     histname = "fClusterEnergyCentNotMatched" + fHistogramNameSuffix;
779     fClusterEnergyCentNotMatched = new TH2F(histname.Data(), histname.Data(), 100, 0, 5,20,-0.5,19.5);
780     fClusterEnergyCentNotMatched->SetXTitle("Energy of cluster");
781     fClusterEnergyCentNotMatched->SetYTitle("Centrality Bin");
782     fClusterEnergyCentNotMatched->SetZTitle("Number of clusters");
783
784     histname = "fClusterEt" + fHistogramNameSuffix;
785     fClusterEt = new TH1F(histname.Data(), histname.Data(), 100, 0, 5);
786     fClusterEt->SetXTitle("Number of clusters");
787     fClusterEt->SetYTitle("E_{T} of cluster");
788
789     histname = "fHistChargedEnergyRemoved" + fHistogramNameSuffix;
790     fHistChargedEnergyRemoved = new TH2D(histname.Data(), histname.Data(), 1000, .0, 30, 100, -0.5 , 99.5);
791
792     histname = "fHistNeutralEnergyRemoved" + fHistogramNameSuffix;
793     fHistNeutralEnergyRemoved = new TH2D(histname.Data(), histname.Data(), 1000, .0, 30, 100, -0.5 , 99.5);
794
795     histname = "fHistGammaEnergyAdded" + fHistogramNameSuffix;
796     fHistGammaEnergyAdded = new TH2D(histname.Data(), histname.Data(), 1000, .0, 30, 100, -0.5 , 99.5);
797
798     fHistMatchedTracksEvspTvsCent = new TH3F("fHistMatchedTracksEvspTvsCent", "fHistMatchedTracksEvspTvsCent",100, 0, 3,100,0,3,20,-0.5,19.5);
799     fHistMatchedTracksEvspTvsCentEffCorr = new TH3F("fHistMatchedTracksEvspTvsCentEffCorr", "fHistMatchedTracksEvspTvsCentEffCorr",100, 0, 3,100,0,3,20,-0.5,19.5);
800     fHistMatchedTracksEvspTvsCentEffTMCorr = new TH3F("fHistMatchedTracksEvspTvsCentEffTMCorr", "fHistMatchedTracksEvspTvsCentEffTMCorr",100, 0, 3,100,0,3,20,-0.5,19.5);
801     fHistPeripheralMatchedTracksEvspTvsCentEffTMCorr = new TH3F("fHistPeripheralMatchedTracksEvspTvsCentEffTMCorr", "fHistPeripheralMatchedTracksEvspTvsCentEffTMCorr",100, 0, 3,100,0,3,20,-0.5,19.5);
802     fHistMatchedTracksEvspTvsCentEffTMCorr500MeV = new TH3F("fHistMatchedTracksEvspTvsCentEffTMCorr500MeV", "fHistMatchedTracksEvspTvsCentEffTMCorr500MeV",100, 0, 3,100,0,3,20,-0.5,19.5);
803
804     float max = 200;
805     if(fHistogramNameSuffix.Contains("P")){max = 100;}
806     fHistFoundHadronsvsCent = new TH2F("fHistFoundHadronsvsCent","fHistFoundHadronsvsCent",100,0,max,20,-0.5,19.5);
807        fHistNotFoundHadronsvsCent = new TH2F("fHistNotFoundHadronsvsCent","fHistNotFoundHadronsvsCent",100,0,max,20,-0.5,19.5);
808     fHistFoundHadronsEtvsCent = new TH2F("fHistFoundHadronsEtvsCent","fHistFoundHadronsEtvsCent",100,0,max,20,-0.5,19.5);
809        fHistNotFoundHadronsEtvsCent = new TH2F("fHistNotFoundHadronsEtvsCent","fHistNotFoundHadronsEtvsCent",100,0,max,20,-0.5,19.5);
810     fHistFoundHadronsvsCent500MeV = new TH2F("fHistFoundHadronsvsCent500MeV","fHistFoundHadronsvsCent500MeV",100,0,max,20,-0.5,19.5);
811     fHistNotFoundHadronsvsCent500MeV = new TH2F("fHistNotFoundHadronsvsCent500MeV","fHistNotFoundHadronsvsCent500MeV",100,0,max,20,-0.5,19.5);
812     fHistFoundHadronsEtvsCent500MeV = new TH2F("fHistFoundHadronsEtvsCent500MeV","fHistFoundHadronsEtvsCent500MeV",100,0,max,20,-0.5,19.5);
813     fHistNotFoundHadronsEtvsCent500MeV = new TH2F("fHistNotFoundHadronsEtvsCent500MeV","fHistNotFoundHadronsEtvsCent500MeV",100,0,max,20,-0.5,19.5);
814
815     fHistTotRawEtEffCorr = new TH2F("fHistTotRawEtEffCorr","fHistTotRawEtEffCorr",250,0,250,20,-0.5,19.5);
816     fHistTotRawEt = new TH2F("fHistTotRawEt","fHistTotRawEt",250,0,250,20,-0.5,19.5);
817     fHistTotRawEtEffCorr500MeV = new TH2F("fHistTotRawEtEffCorr500MeV","fHistTotRawEtEffCorr500MeV",250,0,250,20,-0.5,19.5);
818     fHistTotAllRawEt = new TH2F("fHistTotAllRawEt","fHistTotAllRawEt",250,0,250,20,-0.5,19.5);
819     fHistTotAllRawEtEffCorr = new TH2F("fHistTotAllRawEtEffCorr","fHistTotAllRawEtEffCorr",250,0,250,20,-0.5,19.5);
820     fHistNClustersPhosVsEmcal = new TH3F("fHistNClustersPhosVsEmcal","fHistNClustersPhosVsEmcal",50,0,50,250,0,250,20,-0.5,19);
821     fHistClusterSizeVsCent = new TH2F("fHistClusterSizeVsCent","fHistClusterSizeVsCent",10,0.5,10.5,20,-0.5,19.5);
822     fHistMatchedClusterSizeVsCent = new TH2F("fHistMatchedClusterSizeVsCent","fHistMatchedClusterSizeVsCent",10,0.5,10.5,20,-0.5,19.5);
823     fHistTotAllRawEtVsTotalPt = new TH2F("fHistTotAllRawEtVsTotalPt","fHistTotAllRawEtVsTotalPt",125,0,250,200,0,2000);
824     fHistTotAllRawEtVsTotalPtVsCent = new TH3F("fHistTotAllRawEtVsTotalPtVsCent","fHistTotAllRawEtVsTotalPtVsCent",125,0,250,200,0,2000,20,-0.5,19.5);
825     fHistTotMatchedRawEtVsTotalPtVsCent = new TH3F("fHistTotMatchedRawEtVsTotalPtVsCent","fHistTotMatchedRawEtVsTotalPtVsCent",250,0,250,100,0,200,20,-0.5,19.5);
826     
827     maxEt = 500;
828     histname = "fHistNominalRawEt" + fHistogramNameSuffix;
829     fHistNominalRawEt = new TH2D(histname.Data(), histname.Data(),nbinsEt,minEt,maxEt,20,-0.5,19.5);
830     histname = "fHistNominalNonLinHighEt" + fHistogramNameSuffix;
831     fHistNominalNonLinHighEt = new TH2D(histname.Data(), histname.Data(),nbinsEt,minEt,maxEt,20,-0.5,19.5);
832     histname = "fHistNominalNonLinLowEt" + fHistogramNameSuffix;
833     fHistNominalNonLinLowEt = new TH2D(histname.Data(), histname.Data(),nbinsEt,minEt,maxEt,20,-0.5,19.5);
834     histname = "fHistNominalEffHighEt" + fHistogramNameSuffix;
835     fHistNominalEffHighEt = new TH2D(histname.Data(), histname.Data(),nbinsEt,minEt,maxEt,20,-0.5,19.5);
836     histname = "fHistNominalEffLowEt" + fHistogramNameSuffix;
837     fHistNominalEffLowEt = new TH2D(histname.Data(), histname.Data(),nbinsEt,minEt,maxEt,20,-0.5,19.5);
838
839       Float_t maxEtRange = 25;
840       Float_t maxEtRangeHigh = 125;
841       Float_t minEtRange = 0;
842       Int_t nbinsMult = 100;
843       Float_t maxMult = 3000;
844       Float_t minMult = 0;
845       Int_t nbinsCl = 250;
846       Float_t maxCl = 500;
847       Float_t minCl = 0;
848     fHistPIDProtonsTrackMatchedDepositedVsNch = new TH2F("fHistPIDProtonsTrackMatchedDepositedVsNch","PID'd protons deposited in calorimeter vs multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsMult,minMult,maxMult);
849     fHistPIDAntiProtonsTrackMatchedDepositedVsNch = new TH2F("fHistPIDAntiProtonsTrackMatchedDepositedVsNch","PID'd #bar{p} E_{T} deposited in calorimeter vs multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsMult,minMult,maxMult);
850     fHistPIDProtonsTrackMatchedDepositedVsNcl = new TH2F("fHistPIDProtonsTrackMatchedDepositedVsNcl","PID'd protons deposited in calorimeter vs cluster multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsCl,minCl,maxCl);
851     fHistPIDAntiProtonsTrackMatchedDepositedVsNcl = new TH2F("fHistPIDAntiProtonsTrackMatchedDepositedVsNcl","PID'd #bar{p} E_{T} deposited in calorimeter vs cluster multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsCl,minCl,maxCl);
852     fHistPiKPTrackMatchedDepositedVsNch = new TH2F("fHistPiKPTrackMatchedDepositedVsNch","PiKP track matched",nbinsEt,minEtRange,maxEtRangeHigh,nbinsMult,minMult,maxMult);
853
854     fHistPIDProtonsTrackMatchedDepositedVsNchNoEff = new TH2F("fHistPIDProtonsTrackMatchedDepositedVsNchNoEff","PID'd protons deposited in calorimeter vs multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsMult,minMult,maxMult);
855     fHistPIDAntiProtonsTrackMatchedDepositedVsNchNoEff = new TH2F("fHistPIDAntiProtonsTrackMatchedDepositedVsNchNoEff","PID'd #bar{p} E_{T} deposited in calorimeter vs multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsMult,minMult,maxMult);
856     fHistPIDProtonsTrackMatchedDepositedVsNclNoEff = new TH2F("fHistPIDProtonsTrackMatchedDepositedVsNclNoEff","PID'd protons deposited in calorimeter vs cluster multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsCl,minCl,maxCl);
857     fHistPIDAntiProtonsTrackMatchedDepositedVsNclNoEff = new TH2F("fHistPIDAntiProtonsTrackMatchedDepositedVsNclNoEff","PID'd #bar{p} E_{T} deposited in calorimeter vs cluster multiplicity",nbinsEt,minEtRange,maxEtRange,nbinsCl,minCl,maxCl);
858     fHistPiKPTrackMatchedDepositedVsNchNoEff = new TH2F("fHistPiKPTrackMatchedDepositedVsNchNoEff","PiKP track matched",nbinsEt,minEtRange,maxEtRangeHigh,nbinsMult,minMult,maxMult);
859
860
861     fHistCentVsNchVsNclReco = new TH3F("fHistCentVsNchVsNclReco","Cent bin vs Nch Vs NCl",20,-0.5,19.5,nbinsMult,minMult,maxMult,nbinsCl,minCl,maxCl);
862
863    fHistRawSignalReco = new TH1F("fHistRawSignalReco","fHistRawSignalReco",20,-0.5,19.5);
864    fHistEffCorrSignalReco = new TH1F("fHistEffCorrSignalReco","fHistEffCorrSignalReco",20,-0.5,19.5);
865
866 }
867 Double_t AliAnalysisEtReconstructed::ApplyModifiedCorrections(const AliESDCaloCluster& cluster,Int_t nonLinCorr, Int_t effCorr, Int_t cent)
868 {
869   Float_t pos[3];
870   cluster.GetPosition(pos);
871   TVector3 cp(pos);
872   Double_t corrEnergy = fReCorrections->CorrectedEnergy(cluster.E(),cent);
873   
874   Double_t factorNonLin = GetCorrectionModification(cluster, nonLinCorr,effCorr,cent);
875
876     cout<<"Warning:  This function should not get called!"<<endl;
877   //std::cout << "Original energy: " << cluster.E() << ", corrected energy: " << corrEnergy << std::endl;
878   return TMath::Sin(cp.Theta())*corrEnergy*factorNonLin;
879 }
880
881 Double_t AliAnalysisEtReconstructed::GetCorrectionModification(const AliESDCaloCluster& cluster,Int_t nonLinCorr, Int_t effCorr, Int_t cent){//nonLinCorr 0 = nominal 1 = high -1 = low, effCorr  0 = nominal 1 = high -1 = low
882   if(nonLinCorr==0){
883     cout<<"Warning:  This function should not get called!"<<endl;//this statement is basically here to avoid a compilation warning
884   }
885   if(effCorr==0){
886     cout<<"Warning:  This function should not get called!"<<endl;//this statement is basically here to avoid a compilation warning
887   }
888   return cluster.E()*cent;
889 }