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