]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/ChargedHadrons/dNdPt/AlidNdPtAnalysisPbPbAOD.h
- fix for coverity 23140
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / ChargedHadrons / dNdPt / AlidNdPtAnalysisPbPbAOD.h
1 #ifndef AlidNdPtAnalysisPbPbAOD_H
2 #define AlidNdPtAnalysisPbPbAOD_H
3
4
5 //------------------------------------------------------------------------------
6 // AlidNdPtAnalysisPbPbAOD class used for dNdPt analysis in PbPb collision
7 // via AODs 
8 // 
9 // Author: P. Luettig, 15.05.2013
10 // last modified: 10.06.2014
11 //------------------------------------------------------------------------------
12
13
14
15 class iostream;
16
17 #include "AliAnalysisTaskSE.h"
18 #include "TObject.h"
19 #include "TList.h"
20 #include "TFile.h"
21 #include "TH1.h"
22 #include "TH2.h"
23 #include "TH3.h"
24 #include "THnSparse.h"
25 #include "THn.h"
26 #include "TClonesArray.h"
27 #include "TString.h"
28 #include "TProfile.h"
29
30 #include "TParticlePDG.h"
31 #include "TDatabasePDG.h"
32
33 #include "AliLog.h"
34 #include "AliCentrality.h"
35 #include "AliAODEvent.h"
36 #include "AliVEvent.h"
37
38 #include "AliInputEventHandler.h"
39 #include "AliAODInputHandler.h"
40 #include "AliAnalysisManager.h"
41 #include "AliMCEventHandler.h"
42 #include "AliAODMCHeader.h"
43 #include "AliAODMCParticle.h"
44 #include "AliGenHijingEventHeader.h"
45 #include "AliGenPythiaEventHeader.h"
46 #include "AliExternalTrackParam.h"
47 #include "AliESDtrack.h"
48 #include "AliEventplane.h"
49
50 #include "TSystem.h"
51 #include "TROOT.h"
52
53 class AlidNdPtAnalysisPbPbAOD : public AliAnalysisTaskSE {
54   public :
55     enum CheckQuantity { cqCrossedRows = 0, cqNcluster = 1, cqChi = 2, cqLength = 3, cqRowsOverFindable = 4 };
56     enum KinematicQuantity { kqPt = 0, kqEta = 1, kqPhi = 2 };
57     enum MaxCheckQuantity { cqMax = 5 };
58     enum MaxKinematicQuantity { kqMax = 3 };
59     
60     AlidNdPtAnalysisPbPbAOD(const char *name = "dNdPtPbPbAOD");
61     ~AlidNdPtAnalysisPbPbAOD();
62     
63     virtual void UserCreateOutputObjects();
64     virtual void UserExec(Option_t *option);
65     virtual void Terminate(Option_t *);
66     
67     // Set binning for Histograms (if not set default binning is used)
68     void SetBinsMult(Int_t nbins, Double_t* edges)                      { Printf("[I] Setting Mult Bins"); fMultNbins = nbins; fBinsMult = GetArrayClone(nbins,edges); }
69     void SetBinsPt(Int_t nbins, Double_t* edges)                        { Printf("[I] Setting pT Bins"); fPtNbins = nbins; fBinsPt = GetArrayClone(nbins,edges); }
70     void SetBinsPtCorr(Int_t nbins, Double_t* edges)            { Printf("[I] Setting pTcorr Bins"); fPtCorrNbins = nbins; fBinsPtCorr = GetArrayClone(nbins,edges); }
71     void SetBinsPtCheck(Int_t nbins, Double_t* edges)           { Printf("[I] Setting pTcheck Bins"); fPtCheckNbins = nbins; fBinsPtCheck = GetArrayClone(nbins,edges); }
72     void SetBinsEta(Int_t nbins, Double_t* edges)                       { Printf("[I] Setting Eta Bins"); fEtaNbins = nbins; fBinsEta = GetArrayClone(nbins,edges); }
73     void SetBinsEtaCheck(Int_t nbins, Double_t* edges)          { Printf("[I] Setting EtaCheck Bins"); fEtaCheckNbins = nbins; fBinsEtaCheck = GetArrayClone(nbins,edges); }
74     void SetBinsZv(Int_t nbins, Double_t* edges)                        { Printf("[I] Setting Zv Bins"); fZvNbins = nbins; fBinsZv= GetArrayClone(nbins,edges); }
75     void SetBinsCentrality(Int_t nbins, Double_t* edges)        { Printf("[I] Setting Cent Bins"); fCentralityNbins = nbins; fBinsCentrality = GetArrayClone(nbins,edges); }
76     void SetBinsPhi(Int_t nbins, Double_t* edges)                       { Printf("[I] Setting Phi Bins"); fPhiNbins = nbins; fBinsPhi = GetArrayClone(nbins,edges); }
77     
78     // set event cut variables
79     void SetCutMaxZVertex( Double_t d)                                      { fCutMaxZVertex = d; }
80     Double_t GetCutMaxZVertex()                                                 { return fCutMaxZVertex; }
81     
82     // set track kinematic cut parameters
83     void SetCutPtRange(Double_t ptmin, Double_t ptmax)          { fCutPtMin = ptmin; fCutPtMax = ptmax; }
84     Double_t GetCutPtMin()                                                          { return fCutPtMin; }
85     Double_t GetCutPtMax()                                                          { return fCutPtMax; }
86     
87     void SetCutEtaRange(Double_t etamin, Double_t etamax)       { fCutEtaMin = etamin; fCutEtaMax = etamax; }
88     Double_t GetCutEtaMin()                                                         { return fCutEtaMin; }
89     Double_t GetCutEtaMax()                                                         { return fCutEtaMax; }
90     
91     void EnableRelativeCuts()                                                           { Printf("[I] Relative Cuts enabled"); fUseRelativeCuts = kTRUE; }
92     Bool_t AreRelativeCutsEnabled()                                                     { return fUseRelativeCuts; }
93     
94     // setter and getter track quality cut parameters
95     void SetFilterBit(Int_t b)                                                          { fFilterBit = b; };
96     Int_t GetFilterBit()                                                                        { return fFilterBit; }
97     
98     void SetCutRequireTPCRefit(Bool_t *b)                                       { fCutRequireTPCRefit = b; } 
99     Bool_t IsTPCRefitRequired()                                                         { return fCutRequireTPCRefit; } 
100     
101     void SetCutRequireITSRefit(Bool_t *b)                                       { fCutRequireITSRefit = b; } 
102     Bool_t IsITSRefitRequired()                                                         { return fCutRequireITSRefit; } 
103     
104     void SetCutMinNClustersTPC(Double_t d)                                      { fCutMinNumberOfClusters = d; }
105     Double_t GetCutMinNClustersTPC()                                            { return fCutMinNumberOfClusters; }
106     
107     void SetCutPercMinNClustersTPC(Double_t d)                          { Printf("[I] Take only %.2f%% tracks with most clusters", d*100.); fCutPercMinNumberOfClusters = d; }
108     Double_t GetCutPercMinNClustersTPC()                                        { return fCutPercMinNumberOfClusters; }
109     
110     void SetCutMinNCrossedRowsTPC(Double_t d)                           { fCutMinNumberOfCrossedRows = d; }    
111     Double_t GetCutMinNCrossedRowsTPC()                                         { return fCutMinNumberOfCrossedRows; }
112     
113     void SetCutPercMinNCrossedRowsTPC(Double_t d)                       { Printf("[I] Take only %.2f%% tracks with most crossedRows", d*100.); fCutPercMinNumberOfCrossedRows = d; }    
114     Double_t GetCutPercMinNCrossedRowsTPC()                                     { return fCutPercMinNumberOfCrossedRows; }
115     
116     void SetCutMinRatioCrossedRowsOverFindableClustersTPC(Double_t d)   { fCutMinRatioCrossedRowsOverFindableClustersTPC = d; }
117     Double_t GetCutMinRatioCrossedRowsOverFindableClustersTPC()                 { return fCutMinRatioCrossedRowsOverFindableClustersTPC; }
118     
119     void SetCutLengthInTPCPtDependent(Bool_t b)                         { fCutLengthInTPCPtDependent = b; }
120     Bool_t DoCutLengthInTPCPtDependent()                                        { return fCutLengthInTPCPtDependent; }
121     
122     void SetPrefactorLengthInTPCPtDependent(Double_t d)         { fPrefactorLengthInTPCPtDependent = d; }
123     Double_t GetPrefactorLengthInTPCPtDependent()                       { return fPrefactorLengthInTPCPtDependent; }
124      
125     void SetCutMaxChi2PerClusterTPC(Double_t d)                         { fCutMaxChi2PerClusterTPC = d; }
126     void SetCutMaxFractionSharedTPCClusters(Double_t d)         { fCutMaxFractionSharedTPCClusters = d; }
127     void SetCutMaxDCAToVertexZ(Double_t d)                                      { fCutMaxDCAToVertexZ = d; }
128     void SetCutMaxDCAToVertexXY(Double_t d)                             { fCutMaxDCAToVertexXY = d; }
129     void SetCutMaxChi2PerClusterITS(Double_t d)                         { fCutMaxChi2PerClusterITS = d; }
130     void SetCutDCAToVertex2D(Bool_t *b)                                         { fCutDCAToVertex2D = b; } 
131     void SetCutRequireSigmaToVertex(Bool_t *b)                          { fCutRequireSigmaToVertex = b; } 
132     void SetCutMaxDCAToVertexXYPtDep(Double_t d0, Double_t d1, Double_t d2)
133     {
134       fCutMaxDCAToVertexXYPtDepPar0 = d0;
135       fCutMaxDCAToVertexXYPtDepPar1 = d1;
136       fCutMaxDCAToVertexXYPtDepPar2 = d2;
137     }
138     void SetCutAcceptKinkDaughters(Bool_t *b)                           { fCutAcceptKinkDaughters = b; } 
139     void SetCutMaxChi2TPCConstrainedGlobal(Double_t d)          { fCutMaxChi2TPCConstrainedGlobal = d; }
140        
141     // fill function for cross check histos
142     Bool_t FillDebugHisto(Double_t *dCrossCheckVar, Double_t *dKineVar, Double_t dCentrality, Bool_t bIsAccepted);
143     
144     // fill function for cut settings
145     void StoreCutSettingsToHistogram();
146     
147     // getter for DCA
148     Bool_t GetDCA(const AliAODTrack *track, AliAODEvent *evt, Double_t d0z0[2]);
149     
150     THnSparseF * GetHistZvPtEtaCent() const { return fZvPtEtaCent; }
151     TH1F * GetHistEventStatistics() const { return fEventStatistics; }
152     
153     const char * GetParticleName(Int_t pdg);
154     
155     AliGenHijingEventHeader* GetHijingEventHeader(AliAODMCHeader *header);
156     AliGenPythiaEventHeader* GetPythiaEventHeader(AliAODMCHeader *header);
157     
158         Double_t RotatePhi(Double_t phiTrack, Double_t phiEP);
159         Double_t MoveEventplane(Double_t dMCEP);
160     
161     Bool_t SetRelativeCuts(AliAODEvent *event);
162     
163     Bool_t IsTrackAccepted(AliAODTrack *tr, Double_t dCentrality, Double_t bMagZ);
164     Bool_t IsMCTrackAccepted(AliAODMCParticle *part);
165     
166     Bool_t IsHijingParticle(const AliAODMCParticle *part, AliGenHijingEventHeader* hijingGenHeader);
167     Bool_t IsPythiaParticle(const AliAODMCParticle *part, AliGenPythiaEventHeader* pythiaGenHeader);
168     
169     static Double_t* GetArrayClone(Int_t n, Double_t* source);
170         
171         void SetEventplaneSelector(char *c) { fEPselector = c; }
172         TString GetEventplaneSelector() { return fEPselector; }
173     
174   private :
175     
176     // Output List
177     TList               *fOutputList;
178     
179     // Histograms
180     TH1F            *fPt; // simple pT histogramm
181     TH1F            *fMCPt; // simple pT truth histogramm
182     THnSparseF  *fZvPtEtaCent; //-> Zv:Pt:Eta:Cent
183     THnSparseF  *fDeltaphiPtEtaCent; //-> Phi:Pt:Eta:Cent
184     THnSparseF  *fPtResptCent; //-> 1/pt:ResolutionPt:Cent
185     THnSparseF  *fMCRecPrimZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent
186     THnSparseF  *fMCGenZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent
187     THnSparseF  *fMCRecSecZvPtEtaCent; //-> MC Zv:Pt:Eta:Cent, only secondaries
188     THnSparseF  *fMCRecPrimDeltaphiPtEtaCent; //-> MC Phi:Pt:Eta:Cent
189     THnSparseF  *fMCGenDeltaphiPtEtaCent; //-> MC Phi:Pt:Eta:Cent
190     THnSparseF  *fMCRecSecDeltaphiPtEtaCent; //-> MC Phi:Pt:Eta:Cent, only secondaries
191     TH1F            *fEventStatistics; // contains statistics of number of events after each cut
192     TH1F        *fEventStatisticsCentrality; // contains number of events vs centrality, events need to have a track in kinematic range
193     TH1F            *fMCEventStatisticsCentrality; // contains MC number of events vs centrality, events need to have a track in kinematic range
194     TH1F            *fAllEventStatisticsCentrality; // contains number of events vs centrality, events need to be triggered
195     TH2F            *fEventStatisticsCentralityTrigger; // contains number of events vs centrality in 1% bins vs trigger
196     THnSparseF  *fZvMultCent; // Zv:Mult:Cent
197     TH1F            *fTriggerStatistics; // contains number of events per trigger
198     TH1F            *fCharge; // charge distribution in data
199     TH1F            *fMCCharge; // charge distribution in MC
200     THnSparseF  *fDCAPtAll; //control histo: DCAz:DCAxy:pT:eta:phi for all reconstructed tracks
201     THnSparseF  *fDCAPtAccepted; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco tracks
202     THnSparseF  *fMCDCAPtSecondary; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco track, which are secondaries (using MC info)
203     THnSparseF  *fMCDCAPtPrimary; //control histo: DCAz:DCAxy:pT:eta:phi for all accepted reco track, which are primaries (using MC info)
204     THnF            *fCrossCheckAll[5]; //control histo: {CrossedRows,Ncluster,Chi,Length,CrossedRows/Findable} vs pT,eta,phi,Centrality for all tracks
205     THnF            *fCrossCheckAcc[5]; //control histo: {CrossedRows,Ncluster,Chi,Length,CrossedRows/Findable} vs pT,eta,phi,Centrality after cuts
206     TH1F            *fCutPercClusters; // control histo: number of clusters, where the relative cut has been set e-by-e
207     TH1F            *fCutPercCrossed; // control histo: number of crossed rows, where the relative cut has been set e-by-e
208     TH2F            *fCrossCheckRowsLength; // control histo: number of crossed rows vs length in TPC
209     TH2F            *fCrossCheckClusterLength; // control histo: number of clusters vs length in TPC
210     TH2F            *fCrossCheckRowsLengthAcc; // control histo: number of crossed rows vs length in TPC for all accepted tracks
211     TH2F            *fCrossCheckClusterLengthAcc; // control histo: number of clusters vs length in TPC for all accepted tracks
212     TH1F        *fCutSettings; // control histo: cut settings
213     
214     TH1F                *fEventplaneDist; // event plane distribution in phi
215     TH1F                *fMCEventplaneDist; // MC event plane distribution in phi
216     TH2F                *fCorrelEventplaneMCDATA; // correlation between data and MC eventplane
217
218         // cross check for event plane resolution
219         TH2F            *fEPDistCent; // event plane distribution vs centrality
220         TH2F            *fPhiCent;      // particle phi distribution vs centrality
221         TProfile        *fPcosEPCent; // < cos 2 psi_ep > vs centrality
222         TProfile        *fPsinEPCent; // < sin 2 psi_ep > vs centrality
223         TProfile        *fPcosPhiCent; // < cos 2 phi > vs centrality
224         TProfile        *fPsinPhiCent; // < sin 2 phi > vs centrality
225
226         // global variables
227     Bool_t fIsMonteCarlo;
228         
229         TString fEPselector;
230     
231     // event cut variables
232     Double_t fCutMaxZVertex;
233     
234     // track kinematic cut variables
235     Double_t fCutPtMin;
236     Double_t fCutPtMax;
237     Double_t fCutEtaMin;
238     Double_t fCutEtaMax;
239     
240     // track quality cut variables
241     Int_t           fFilterBit;
242     Bool_t          fUseRelativeCuts;
243     Bool_t      fCutRequireTPCRefit;
244     Bool_t          fCutRequireITSRefit;
245     Double_t    fCutMinNumberOfClusters;
246     Double_t    fCutPercMinNumberOfClusters;
247     Double_t    fCutMinNumberOfCrossedRows;
248     Double_t    fCutPercMinNumberOfCrossedRows;
249     Double_t    fCutMinRatioCrossedRowsOverFindableClustersTPC;
250     Double_t    fCutMaxChi2PerClusterTPC;
251     Double_t    fCutMaxFractionSharedTPCClusters;
252     Double_t    fCutMaxDCAToVertexZ;
253     Double_t    fCutMaxDCAToVertexXY;
254     Double_t    fCutMaxChi2PerClusterITS;
255     Bool_t      fCutDCAToVertex2D;
256     Bool_t          fCutRequireSigmaToVertex;
257     Double_t    fCutMaxDCAToVertexXYPtDepPar0;
258     Double_t    fCutMaxDCAToVertexXYPtDepPar1;
259     Double_t    fCutMaxDCAToVertexXYPtDepPar2;
260     Bool_t          fCutAcceptKinkDaughters;
261     Double_t    fCutMaxChi2TPCConstrainedGlobal;
262     Bool_t          fCutLengthInTPCPtDependent;
263     Double_t    fPrefactorLengthInTPCPtDependent;
264     
265     //binning for THNsparse
266     Int_t       fMultNbins;
267     Int_t       fPtNbins;
268     Int_t       fPtCorrNbins;
269     Int_t       fPtCheckNbins;
270     Int_t       fEtaNbins;
271     Int_t       fEtaCheckNbins;
272     Int_t       fZvNbins;
273     Int_t       fCentralityNbins;
274     Int_t       fPhiNbins;
275     Double_t*   fBinsMult; //[fMultNbins]
276     Double_t*   fBinsPt; //[fPtNbins]
277     Double_t*   fBinsPtCorr; //[fPtCorrNbins]
278     Double_t*   fBinsPtCheck; //[fPtCheckNbins]
279     Double_t*   fBinsEta; //[fEtaNbins]
280     Double_t*   fBinsEtaCheck; //[fEtaCheckNbins]
281     Double_t*   fBinsZv; //[fZvNbins]
282     Double_t*   fBinsCentrality; //[fCentralityNbins]
283     Double_t*   fBinsPhi; //[fPhiNbins]
284     
285     AlidNdPtAnalysisPbPbAOD(const AlidNdPtAnalysisPbPbAOD&); // not implemented
286     AlidNdPtAnalysisPbPbAOD& operator=(const AlidNdPtAnalysisPbPbAOD&); // not implemented  
287     
288     ClassDef(AlidNdPtAnalysisPbPbAOD,8); // has to be at least 1, otherwise not streamable...
289 };
290
291 #endif