bugfix
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliAnalysisTaskPi0v2.h
1 #ifndef AliAnalysisTaskPi0v2_cxx
2 #define AliAnalysisTaskPi0v2_cxx
3
4 #include "AliAnalysisTaskSE.h"
5 #include "TH1.h"
6 #include "TH2.h"
7 #include "TH3.h"
8 #include "THnSparse.h"
9 #include "AliLog.h"
10 #include "AliConversionSelection.h"
11 #include "AliConversionMesonCuts.h"
12 #include "AliV0ReaderV1.h"
13 #include "AliEventplane.h"
14 #include "TVector2.h"
15
16 #include "TProfile.h"
17 using namespace std;
18
19 class AliAnalysisTaskPi0v2 : public AliAnalysisTaskSE{
20
21 public:
22
23     enum EEventPlaneMethod{
24         kTPC=0,
25         kTPCEtaGap=1,
26         kV0A=2,
27         kV0C=3,
28         knEPMethod=4
29     };
30
31     enum EEventPlane{
32         kEPTPC=0,
33         kEPTPCEtaA,
34         kEPTPCEtaC,
35         kEPV0A,
36         kEPV0C,
37         knEP
38     };
39
40     enum EPDGCode{
41         kPi0=111,
42         kEta=221
43     };
44
45     static const Int_t knBinsPhi=6;
46     static const Int_t knCentMax=10;
47     static const Int_t knFlatPeriod=2;
48
49     AliAnalysisTaskPi0v2(const char *name="pi0v2",Int_t harmonic=2);
50     AliAnalysisTaskPi0v2(const AliAnalysisTaskPi0v2&); // not implemented
51     AliAnalysisTaskPi0v2& operator=(const AliAnalysisTaskPi0v2&); // not implemented
52     virtual ~AliAnalysisTaskPi0v2();
53
54     virtual void   UserCreateOutputObjects();
55     virtual void   UserExec(Option_t *option);
56     virtual void   Terminate(Option_t *);
57
58     void SetCentralityBins(Double_t *bins,Int_t nbins);
59
60     void SetMeson(EPDGCode meson){fMesonPDGCode=meson;}
61
62     void SetNBinsPhi(Int_t nbins){fNBinsPhi=nbins;}
63     void SetV0Reader(AliV0ReaderV1 *v0Reader){fV0Reader=v0Reader;}
64     void SetInvMassRange(Double_t range[2]){fInvMassRange[0]=range[0];fInvMassRange[1]=range[1];};
65     void SetEtaGap(Double_t gapsize){fEtaGap=gapsize;};
66
67     void SetCuts(AliConversionSelection **conversionselection,Int_t numberOfCuts);
68
69     void SetFillQA(Bool_t fill){fFillQA=fill;}
70
71     void SetEPSelectionMask(Int_t mask[knEPMethod]){for(Int_t ii=0;ii<knEPMethod;ii++)fEPSelectionMask[ii]=mask[ii];};
72
73     void SetFlatteningCoeff(EEventPlane ep,Int_t period,Int_t nCent,Double_t *cc2,Double_t *cs2,Double_t *cc4,Double_t *cs4);
74
75     Int_t GetPeriodIndex(TString period);
76     Int_t GetHarmonic(){return fHarmonic;};
77
78 private:
79     Bool_t InitEvent();
80
81     void ProcessGammas(Int_t iCut,EEventPlaneMethod iEP);
82     void ProcessPi0s(Int_t iCut,EEventPlaneMethod iEP);
83     void ProcessQA();
84
85     Double_t GetPhiwrtRP(Double_t dPhi);
86     Double_t GetPhotonPhiwrtRP(AliAODConversionPhoton *gamma,EEventPlaneMethod iEP,Bool_t bDoFlattening=kTRUE);
87     Double_t GetPi0PhiwrtRP(AliAODConversionMother *pi0,EEventPlaneMethod iEP,Bool_t bDoFlattening=kTRUE);
88     Double_t GetChargedPhiwrtRP(AliVTrack *charged,EEventPlaneMethod iEP,Bool_t bDoFlattening=kTRUE);
89     void GetPhotondNdPhi(Int_t *dNdPhi,Int_t iEP,Int_t iCut=0);
90     void GetChargeddNdPhi(Int_t *dNdPhi,Int_t &ntot,Int_t iEP);
91     Int_t GetPhiBin(Double_t phiwrt);
92     Int_t GetPhotonPhiBin(AliAODConversionPhoton *gamma,Int_t iEP);
93     Double_t GetMCPhotonPhiwrtRP(TParticle *gamma,EEventPlaneMethod iEP,Bool_t bDoFlattening=kTRUE);
94     TVector2 GetEPContribution(AliAODConversionPhoton *gamma);
95     Double_t GetEventPlaneAngle(EEventPlaneMethod EPmethod,Double_t eta=0,AliAODConversionPhoton *gamma0=NULL,AliAODConversionPhoton *gamma1=NULL,Bool_t bDoFlattening=kTRUE);
96     Double_t GetTPCSubEPEta(EEventPlane ep);
97     Double_t GetCorrectedTPCEPAngle(AliAODConversionPhoton *gamma0=NULL,AliAODConversionPhoton *gamma1=NULL,Bool_t bDoFlattening=kTRUE);
98     Bool_t SetCentrality();
99     void ProcessEventPlane();
100     Int_t GetRadialBin(Double_t radius);
101     Int_t GetRunIndex(Int_t run);
102     Double_t ApplyFlattening(Double_t phi,EEventPlane ep);
103     Bool_t GetTPCEventPlane();
104
105     void GetV0EP(AliVEvent * event,Double_t &rpv0a,Double_t &rpv0c);
106     void LoadVZEROCalibration(Int_t run);
107     void LoadTPCCalibration(Int_t run);
108     
109     Double_t GetWeight(TObject* track1);
110     Double_t GetPhiWeight(TObject* track1);
111     TH1F* SelectPhiDist(AliVTrack *track);
112
113     Double_t GetPsiInRange(Double_t phi);
114
115     TObjArray* GetEventPlaneTracks(Int_t &maxID);
116     TVector2 GetContributionEP(AliVTrack *track);
117     Int_t GetAODEPTrackFilterBit();
118
119     // Constants
120
121     enum Ebinsgamma{
122         kGammaPt=0,
123         kGammadPhi,
124         kGammaCent,
125         kGammaEPM,
126         knbinsGamma
127     };
128
129     enum Ebinspi0{
130         kPi0Pt=0,
131         kPi0Mass,
132         kPi0dPhi,
133         kPi0Cent,
134         kPi0EPM,
135         knbinsPi0
136     };
137
138     enum EEventSelection{
139         kEventIn=1,
140         kEventSelV0Reader,
141         kEventCentrality,
142         kEventRun,
143         kEventNoTPCEP,
144         kEventProcessEvent,
145         kEventSelected
146     };
147
148
149     static const Int_t knbinsGammaMult=3;
150   
151     static const Int_t kGCnYBinsSpectra = 80;
152     static const Double_t kGCfirstYBinSpectra = 0.;
153     static const Double_t kGClastYBinSpectra = 8.;
154
155     // Class variables and pointer
156
157     AliV0ReaderV1 *fV0Reader; // V0Reader
158     Int_t fNCuts; // Number of Photon Cuts for v2 analysis
159     AliConversionSelection **fConversionSelection; //[fNCuts] Selection of Particles for given Cut
160     TClonesArray *fConversionGammas; //Reconstructed Photons;
161     Int_t fNCentralityBins; // Number of Centrality Bins
162     Double_t fCentralityBins[knCentMax]; // CentralityBins for Analysis
163     Float_t fCentrality; //Event Centrality
164     Int_t fCentralityBin; // Event Centrality Bin
165     Int_t fNBinsPhi; // Number of Phi wrt RP bins
166     AliEventplane *fEP; // Event Plane Pointer
167     Bool_t fUseTPCOnlyTracks; // Use TPC Only Tracks for EP
168     Double_t fEtaMax; // Eta Max for analysis;
169     Double_t fEtaGap; // Eta Gap
170     Double_t fRPTPCEtaA; // TPCEtaA event plane
171     Double_t fRPTPCEtaC; // TPCEtaC event plane
172     Double_t fRPV0A; // V0A event plane
173     Double_t fRPV0C; // V0C event plane
174     Double_t fRPTPC; // TPC event plane
175     Double_t fRPTPCEtaABF; // TPCEtaA event plane before flattening
176     Double_t fRPTPCEtaCBF; // TPCEtaC event plane before flattening
177     Double_t fRPV0ABF;// V0A event plane before flattening
178     Double_t fRPV0CBF;// V0C event plane before flattening
179     Double_t fRPTPCBF;// TPC event plane before flattening
180     AliConversionCuts *fConversionCuts; // Cuts used by the V0Reader
181     TRandom3 *fRandomizer; // Randomizer for Event Plane Randomisation
182     TList *fOutputList; // List for Output (Histograms etc.)
183     EPDGCode fMesonPDGCode; // PDG Code of the processed Meson (for MC truth)
184     Double_t fInvMassRange[2]; // Inv Mass Range
185     Double_t fDeltaPsiRP; // Difference between subEventPlane angles
186     Int_t fRunNumber; // current run number
187     Int_t fRunIndex; // current internal run index
188     Int_t fNEPMethods; // number of EP methods
189     Bool_t fFillQA; // Fill QA Histograms
190     Int_t fHarmonic; // Harmonic to be analyzed (v2,v3,..)
191     Double_t fPsiMax; //Range for Psi
192     TString  fPeriod; //"LHC11h","LHC10h"
193     Bool_t fIsAOD; // Is AOD? else ESD
194     TH1F*        fPhiDist[4];                   // array of Phi distributions used to calculate phi weights
195     THnSparse *fSparseDist;               //! THn for eta-charge phi-weighting
196     TH1F *fHruns;                         // information about runwise statistics of phi-weights
197     Bool_t fDoEPFlattening; // Do flattening
198     Int_t fEPSelectionMask[knEPMethod]; // Which EP methods shall be applied
199     Double_t fFlatc2[knFlatPeriod][knEP][knCentMax];
200     Double_t fFlats2[knFlatPeriod][knEP][knCentMax];
201     Double_t fFlatc4[knFlatPeriod][knEP][knCentMax];
202     Double_t fFlats4[knFlatPeriod][knEP][knCentMax];
203     Int_t fPeriodIndex;
204
205     // Histograms
206
207     TH1F *hNEvents;
208     TH1F *hEventSelection;
209
210     // RP
211     TH2F *hRPTPC;
212     TH2F *hRPV0A;
213     TH2F *hRPV0C;
214     TH2F *hRPTPCAC;
215     TH2F *hRPV0ATPC;
216     TH2F *hRPV0CTPC;
217     TH2F *hRPV0AC;
218     TH2F *hCos2TPC;
219     TH2F *hCos2V0ATPC;
220     TH2F *hCos2V0CTPC;
221     TH2F *hCos2V0AC;
222     TH2F *hRPTPCEtaA;
223     TH2F *hRPTPCEtaC;
224     TH2F *hRPTPCEtaAC;
225     TH2F *hCos2TPCEta;
226     TH2F *hCos2V0ATPCEtaA;
227     TH2F *hCos2V0ATPCEtaC;
228     TH2F *hCos2V0CTPCEtaA;
229     TH2F *hCos2V0CTPCEtaC;
230     TH2F *hCos2SumWeights;
231     TH2F *hEtaTPCEP;
232
233     // Gamma
234     TH2F *hGammaMultCent;
235     TH2F **hGammaPhi;
236     TH2F *hMultChargedvsNGamma;
237     TH2F *hMultChargedvsVZERO;
238     TH2F *hMultChargedvsSPD;
239
240     THnSparseF *hGammadNdPhi;
241     THnSparseF *hGammaMultdPhiTRUE;
242     THnSparseF *hGammaMultdPhiRECOTRUE;
243     THnSparseF *hGammaMultTRUE;
244     THnSparseF *hGammaMultRECOTRUE;
245     THnSparseF **hGammaMultdPhi;
246     THnSparseF **hGammaMult;
247
248     THnSparseF **hGamma;
249     THnSparseF *hGammaFull;
250
251     THnSparseF *hCharged;
252
253     // Pi0
254     THnSparseF **hPi0;
255     THnSparseF **hPi0BG;
256
257     //V0 Calibration
258
259     static const Int_t nCentrBinV0 = 9; // # cenrality bins
260     TProfile *fMultV0;                  // object containing VZERO calibration information
261     Float_t fV0Cpol,fV0Apol;            // loaded by OADB
262     Float_t fMeanQ[nCentrBinV0][2][2];    // and recentering
263     Float_t fWidthQ[nCentrBinV0][2][2];   // ...
264
265     //Event Plane
266     //THnSparse *hEPVertex;
267     THnSparse *hEPQA;
268
269     ClassDef(AliAnalysisTaskPi0v2, 5); // example of analysis
270 };
271
272 #endif
273