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