e1ed9e144f14111066c10e71d1b49d8d53d5ae1e
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskRhoVnModulation.h
1 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. */
2 /* See cxx source for full Copyright notice */
3 /* $Id$ */
4
5 #ifndef ALIANALYSISTASKRHOVNMODULATION_H
6 #define ALIANALYSISTASKRHOVNMODULATION_H
7
8 #include <AliAnalysisTaskEmcalJet.h>
9 #include <AliEmcalJet.h>
10 #include <AliVEvent.h>
11 #include <AliVTrack.h>
12 #include <AliVCluster.h>
13 #include <TClonesArray.h>
14 #include <TMath.h>
15 #include <TRandom3.h>
16
17 class TF1;
18 class THF1;
19 class THF2;
20 class TProfile;
21
22 class AliAnalysisTaskRhoVnModulation : public AliAnalysisTaskEmcalJet
23 {
24     public:
25          // enumerators
26         enum fitModulationType  { kNoFit, kV2, kV3, kCombined, kUser, kFourierSeries, kIntegratedFlow }; // fit type
27         enum runModeType        { kLocal, kGrid };                      // run mode type
28         enum dataType           { kESD, kAOD, kESDMC, kAODMC };         // data type
29         enum detectorType       { kTPC, kVZEROA, kVZEROC};    // detector that was used
30         // constructors, destructor
31                                 AliAnalysisTaskRhoVnModulation();
32                                 AliAnalysisTaskRhoVnModulation(const char *name, runModeType type);
33         virtual                 ~AliAnalysisTaskRhoVnModulation();
34        
35         // setting up the task and technical aspects
36         Bool_t                  InitializeAnalysis();
37         virtual void            UserCreateOutputObjects();
38         virtual Bool_t          Run();
39         TH1F*                   BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c = -1, Bool_t append = kTRUE);
40         TH2F*                   BookTH2F(const char* name, const char* x, const char* y, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t c = -1, Bool_t append = kTRUE);
41         /* inline */    Double_t PhaseShift(Double_t x) const {  
42             while (x>=TMath::TwoPi())x-=TMath::TwoPi();
43             while (x<0.)x+=TMath::TwoPi();
44             return x; }
45         /* inline */    Double_t PhaseShift(Double_t x, Double_t n) const {
46             x = PhaseShift(x);
47             if(TMath::Nint(n)==2) while (x>TMath::Pi()) x-=TMath::Pi();
48             if(TMath::Nint(n)==3) {
49                 if(x>2.*TMath::TwoPi()/n) x = TMath::TwoPi() - x;
50                 if(x>TMath::TwoPi()/n) x = TMath::TwoPi()-(x+TMath::TwoPi()/n);
51             }
52             return x; }
53         /* inline */    Double_t ChiSquarePDF(Int_t ndf, Double_t x) const {
54             Double_t n(ndf/2.), denom(TMath::Power(2, n)*TMath::Gamma(n));
55             if (denom!=0)  return ((1./denom)*TMath::Power(x, n-1)*TMath::Exp(-x/2.)); 
56             return -999; }
57         // note that the cdf of the chisquare distribution is the normalized lower incomplete gamma function
58         /* inline */    Double_t ChiSquareCDF(Int_t ndf, Double_t x) const { return TMath::Gamma(ndf/2., x/2.); }
59         /* inline */    Double_t RhoVal() const { return (fRho) ? fRho->GetVal(): -999.;}                 
60         /* inline */    Double_t RhoVal(Double_t phi, Double_t r, Double_t n) const {
61             if(!fFitModulation) return RhoVal(); // coverity
62             switch (fFitModulationType) {
63                 case kNoFit : return RhoVal();
64                 default : {
65                     Double_t denom(2*r*fFitModulation->GetParameter(0));
66                     return  (denom <= 0.) ? RhoVal() : n*(fFitModulation->Integral(phi-r, phi+r)/denom); 
67                 }
68             }
69         }
70         // setters - analysis setup
71         void                    SetDebugMode(Int_t d)                           {fDebug = d;}
72         void                    SetFillQAHistograms(Bool_t qa)                  {fFillQAHistograms = qa;}
73         void                    SetCentralityClasses(TArrayI* c)                {fCentralityClasses = c;}
74         void                    SetIntegratedFlow(TH1F* i, TH1F* j)             {fUserSuppliedV2 = i;
75                                                                                  fUserSuppliedV3 = j; }
76         void                    SetOnTheFlyResCorrection(TH1F* r2, TH1F* r3)    {fUserSuppliedR2 = r2;
77                                                                                  fUserSuppliedR3 = r3; }
78         void                    SetNameJetClones(const char* name)              {fNameJetClones = name; }
79         void                    SetNamePicoTrackClones(const char* name)        {fNamePicoTrackClones = name; }
80         void                    SetNameRho(const char* name)                    {fNameRho = name; }
81         void                    SetRandomSeed(TRandom3* r)                      {if (fRandom) delete fRandom; fRandom = r; }
82         void                    SetModulationFit(TF1* fit)                      {if (fFitModulation) delete fFitModulation;
83                                                                                  fFitModulation = fit; }
84         void                    SetModulationFitMinMaxP(Float_t m, Float_t n)   {fMinPvalue = m; fMaxPvalue = n; }
85         void                    SetModulationFitType(fitModulationType type)    {fFitModulationType = type; }
86         void                    SetModulationFitOptions(TString opt)            {fFitModulationOptions = opt; }
87         void                    SetReferenceDetector(detectorType type)         {fDetectorType = type; }
88         void                    SetUsePtWeight(Bool_t w)                        {fUsePtWeight = w; }
89         void                    SetRunModeType(runModeType type)                {fRunModeType = type; }
90         void                    SetAbsVertexZ(Float_t v)                        {fAbsVertexZ = v; }
91         void                    SetMinDistanceRctoLJ(Float_t m)                 {fMinDisanceRCtoLJ = m; }
92         void                    SetRandomConeRadius(Float_t r)                  {fRandomConeRadius = r; }
93         void                    SetMinLeadingHadronPt(Double_t m)               {fMinLeadingHadronPt = m; }
94         void                    SetForceAbsVnHarmonics(Bool_t f)                {fAbsVnHarmonics = f; }
95         void                    SetExcludeLeadingJetsFromFit(Float_t n)         {fExcludeLeadingJetsFromFit = n; }
96         void                    SetRebinSwapHistoOnTheFly(Bool_t r)             {fRebinSwapHistoOnTheFly = r; }
97         void                    SetSaveThisPercentageOfFits(Float_t p)          {fPercentageOfFits = p; }
98         void                    SetUseV0EventPlaneFromHeader(Bool_t h)          {fUseV0EventPlaneFromHeader = h;}
99         void                    SetSetPtSub(Bool_t s)                           {fSetPtSub = s; }
100         void                    SetExplicitOutlierCutForYear(Int_t y)           {fExplicitOutlierCut = y;}
101         // local cuts
102         void                    SetLocalJetMinMaxEta(Float_t min, Float_t max)  {fLocalJetMinEta = min; fLocalJetMaxEta = max;}
103         void                    SetLocalJetMinMaxEta(Float_t R)                 {fLocalJetMinEta = - 0.9 + R; fLocalJetMaxEta = 0.9 - R; }
104         void                    SetLocalJetMinMaxPhi(Float_t min, Float_t max)  {fLocalJetMinPhi = min; fLocalJetMaxEta = max;}
105         // 'trivial' helper calculations
106         void                    CalculateEventPlaneVZERO(Double_t vzero[2][2]) const;
107         void                    CalculateEventPlaneTPC(Double_t* tpc);
108         void                    CalculateEventPlaneResolution(Double_t vzero[2][2], Double_t* tpc) const;
109         void                    CalculateRandomCone(Float_t &pt, Float_t &eta, Float_t &phi, AliEmcalJet* jet = 0x0, Bool_t randomize = 0) const;
110         // analysis details
111         Bool_t                  CorrectRho(Double_t psi2, Double_t psi3);
112         // event and track selection
113         /* inline */    Bool_t PassesCuts(const AliVTrack* track) const {
114             if(!track) return kFALSE;
115             return (track->Pt() < fTrackPtCut || track->Eta() < fTrackMinEta || track->Eta() > fTrackMaxEta || track->Phi() < fTrackMinPhi || track->Phi() > fTrackMaxPhi) ? kFALSE : kTRUE; }
116         /* inline */    Bool_t PassesCuts(AliEmcalJet* jet) const {
117             if(!jet || fJetRadius <= 0) return kFALSE;
118             return (GetLeadingHadronPt(jet) < fMinLeadingHadronPt || jet->Pt() < fJetPtCut || jet->Area()/(fJetRadius*fJetRadius*TMath::Pi()) < fPercAreaCut || jet->Eta() < fJetMinEta || jet->Eta() > fJetMaxEta || jet->Phi() < fJetMinPhi || jet->Phi() > fJetMaxPhi) ? kFALSE : kTRUE; }
119         Bool_t                  PassesCuts(AliVEvent* event);
120         Bool_t                  PassesCuts(Int_t year);
121         Bool_t                  PassesCuts(const AliVCluster* track) const;
122         // filling histograms
123         void                    FillHistogramsAfterSubtraction(Double_t vzero[2][2], Double_t* tpc) const;
124         void                    FillTrackHistograms() const;
125         void                    FillClusterHistograms() const;
126         void                    FillCorrectedClusterHistograms() const;
127         void                    FillEventPlaneHistograms(Double_t vzero[2][2], Double_t* tpc) const;
128         void                    FillRhoHistograms() const;
129         void                    FillDeltaPtHistograms(Double_t psi2, Double_t psi3) const; 
130         void                    FillJetHistograms(Double_t vzero[2][2], Double_t* psi) const;
131         void                    FillDeltaPhiHistograms(Double_t vzero[2][2], Double_t* tpc) const;
132         void                    FillQAHistograms(AliVTrack* vtrack) const;
133         void                    FillQAHistograms(AliVEvent* vevent);
134         void                    FillAnalysisSummaryHistogram() const;
135         virtual void            Terminate(Option_t* option);
136         // interface methods for the output file
137         void                    SetOutputList(TList* l) {fOutputList = l;}
138         TH1F*                   GetResolutionFromOuptutFile(detectorType detector, Int_t h = 2, TArrayD* c = 0x0);
139         TH1F*                   CorrectForResolutionDiff(TH1F* v, detectorType detector, TArrayD* cen, Int_t c, Int_t h = 2);
140         TH1F*                   CorrectForResolutionInt(TH1F* v, detectorType detector, TArrayD* cen, Int_t h = 2);
141     private:
142         // analysis flags and settings
143         Int_t                   fDebug;                 // debug level (0 none, 1 fcn calls, 2 verbose)
144         Bool_t                  fInitialized;           //! is the analysis initialized?
145         Bool_t                  fFillQAHistograms;      // fill qa histograms
146         TArrayI*                fCentralityClasses;     //-> centrality classes (maximum 10)
147         TH1F*                   fUserSuppliedV2;        // histo with integrated v2
148         TH1F*                   fUserSuppliedV3;        // histo with integrated v3
149         TH1F*                   fUserSuppliedR2;        // correct the extracted v2 with this r
150         TH1F*                   fUserSuppliedR3;        // correct the extracted v3 with this r
151         // members
152         Int_t                   fNAcceptedTracks;       //! number of accepted tracks
153         fitModulationType       fFitModulationType;     // fit modulation type
154         Bool_t                  fUsePtWeight;           // use dptdphi instead of dndphi
155         detectorType            fDetectorType;          // type of detector used for modulation fit
156         TString                 fFitModulationOptions;  // fit options for modulation fit
157         runModeType             fRunModeType;           // run mode type 
158         dataType                fDataType;              // datatype 
159         TRandom3*               fRandom;                //-> dont use gRandom to not interfere with other tasks
160         Int_t                   fMappedRunNumber;       //! mapped runnumer (for QA)
161         Int_t                   fInCentralitySelection; //! centrality bin
162         TF1*                    fFitModulation;         //-> modulation fit for rho
163         Float_t                 fMinPvalue;             // minimum value of p
164         Float_t                 fMaxPvalue;             // maximum value of p
165         const char*             fNameJetClones;         //! collection of tclones array with jets
166         const char*             fNamePicoTrackClones;   //! collection of tclones with pico tracks
167         const char*             fNameRho;               //! name of rho
168         // additional jet cuts (most are inherited)
169         Float_t                 fLocalJetMinEta;        // local eta cut for jets
170         Float_t                 fLocalJetMaxEta;        // local eta cut for jets
171         Float_t                 fLocalJetMinPhi;        // local phi cut for jets
172         Float_t                 fLocalJetMaxPhi;        // local phi cut for jets
173         // event cuts
174         Float_t                 fAbsVertexZ;            // cut on zvertex
175         // general qa histograms
176         TH1F*                   fHistCentrality;        //! accepted centrality
177         TH1F*                   fHistVertexz;           //! accepted verte
178         TH2F*                   fHistRunnumbersPhi;     //! run numbers averaged phi
179         TH2F*                   fHistRunnumbersEta;     //! run numbers averaged eta
180         TH1F*                   fHistPvaluePDF;         //! pdf value of chisquare p
181         TH1F*                   fHistPvalueCDF;         //! cdf value of chisquare p
182         // general settings
183         Float_t                 fMinDisanceRCtoLJ;      // min distance between rc and leading jet
184         Float_t                 fRandomConeRadius;      // radius of random cone
185         Bool_t                  fAbsVnHarmonics;        // force postive local rho
186         Float_t                 fExcludeLeadingJetsFromFit;    // exclude n leading jets from fit
187         Bool_t                  fRebinSwapHistoOnTheFly;       // rebin swap histo on the fly
188         Float_t                 fPercentageOfFits;      // save this percentage of fits
189         Bool_t                  fUseV0EventPlaneFromHeader;    // use the vzero event plane from the header
190         Bool_t                  fSetPtSub;              // store the subtracted pt in the jet
191         Int_t                   fExplicitOutlierCut;    // cut on correlation of tpc and global multiplicity
192         Double_t                fMinLeadingHadronPt;    // minimum pt for leading hadron
193         // transient object pointers
194         TList*                  fOutputList;            //! output list
195         TList*                  fOutputListGood;        //! output list for local analysis
196         TList*                  fOutputListBad;         //! output list for local analysis
197         TH1F*                   fHistAnalysisSummary;   //! analysis summary
198         TH1F*                   fHistSwap;              //! swap histogram
199         TProfile*               fProfV2;                //! extracted v2
200         TProfile*               fProfV2Resolution[10];  //! resolution parameters for v2
201         TProfile*               fProfV3;                //! extracted v3
202         TProfile*               fProfV3Resolution[10];  //! resolution parameters for v3
203         // qa histograms for accepted pico tracks
204         TH1F*                   fHistPicoTrackPt[10];    //! pt of all charged tracks
205         TH2F*                   fHistPicoCat1[10];       //! pico tracks spd hit and refit
206         TH2F*                   fHistPicoCat2[10];       //! pico tracks wo spd hit w refit, constrained
207         TH2F*                   fHistPicoCat3[10];       //! pico tracks wo spd hit wo refit, constrained
208         // qa histograms for accepted emcal clusters
209         /* TH1F*                   fHistClusterPt[10];      //! pt uncorrected emcal clusters */
210         /* TH1F*                   fHistClusterPhi[10];     //! phi uncorrected emcal clusters */
211         /* TH1F*                   fHistClusterEta[10];     //! eta uncorrected emcal clusters */
212         // qa histograms for accepted emcal clusters aftehadronic correction
213         /* TH1F*                   fHistClusterCorrPt[10];  //! pt corrected emcal clusters */
214         /* TH1F*                   fHistClusterCorrPhi[10]; //! phi corrected emcal clusters */
215         /* TH1F*                   fHistClusterCorrEta[10]; //! eta corrected emcal clusters */
216         // qa event planes
217         TProfile*               fHistPsiControl;         //! event plane control histogram
218         TProfile*               fHistPsiSpread;          //! event plane spread histogram
219         TH1F*                   fHistPsiVZEROA;          //! psi 2 from vzero a
220         TH1F*                   fHistPsiVZEROC;          //! psi 2 from vzero c
221         TH1F*                   fHistPsiTPC;             //! psi 2 from tpc
222         // background
223         TH1F*                   fHistRhoPackage[10];     //! rho as estimated by emcal jet package
224         TH1F*                   fHistRho[10];            //! background
225         TH2F*                   fHistRhoVsMult;          //! rho versus multiplicity
226         TH2F*                   fHistRhoVsCent;          //! rho veruss centrality
227         TH2F*                   fHistRhoAVsMult;         //! rho * A vs multiplicity for all jets
228         TH2F*                   fHistRhoAVsCent;         //! rho * A vs centrality for all jets
229         // delta pt distributions
230         TH2F*                   fHistRCPhiEta[10];              //! random cone eta and phi
231         TH2F*                   fHistRhoVsRCPt[10];             //! rho * A vs rcpt
232         TH1F*                   fHistRCPt[10];                  //! rcpt
233         TH2F*                   fHistDeltaPtDeltaPhi2[10];      //! dpt vs dphi
234         TH2F*                   fHistDeltaPtDeltaPhi3[10];      //! dpt vs dphi
235         TH2F*                   fHistRCPhiEtaExLJ[10];          //! random cone eta and phi, excl leading jet
236         TH2F*                   fHistRhoVsRCPtExLJ[10];         //! rho * A vs rcpt, excl leading jet
237         TH1F*                   fHistRCPtExLJ[10];              //! rcpt, excl leading jet
238         TH2F*                   fHistDeltaPtDeltaPhi2ExLJ[10];  //! dpt vs dphi, excl leading jet
239         TH2F*                   fHistDeltaPtDeltaPhi3ExLJ[10];  //! dpt vs dphi, excl leading jet
240         /* TH2F*                   fHistRCPhiEtaRand[10];          //! random cone eta and phi, randomized */
241         /* TH2F*                   fHistRhoVsRCPtRand[10];         //! rho * A vs rcpt, randomized */
242         /* TH1F*                   fHistRCPtRand[10];              //! rcpt, randomized */ 
243         /* TH2F*                   fHistDeltaPtDeltaPhi2Rand[10];  //! dpt vs dphi, randomized */
244         /* TH2F*                   fHistDeltaPtDeltaPhi3Rand[10];  //! dpt vs dphi, randomized */
245         // jet histograms (after kinematic cuts)
246         TH1F*                   fHistJetPtRaw[10];              //! jet pt - no background subtraction
247         TH1F*                   fHistJetPt[10];                 //! pt of found jets (background subtracted)
248         TH2F*                   fHistJetEtaPhi[10];             //! eta and phi correlation
249         TH2F*                   fHistJetPtArea[10];             //! jet pt versus area
250         TH2F*                   fHistJetPtConstituents[10];     //! jet pt versus number of constituents
251         TH2F*                   fHistJetEtaRho[10];             //! jet eta versus jet rho
252         // in plane, out of plane jet spectra
253         TH2F*                   fHistJetPsiTPCPt[10];            //! psi tpc versus pt
254         TH2F*                   fHistJetPsiVZEROAPt[10];         //! psi vzeroa versus pt
255         TH2F*                   fHistJetPsiVZEROCPt[10];         //! psi vzeroc versus pt
256         // phi minus psi 
257         TH1F*                   fHistDeltaPhi2VZEROA[10];       //! phi minus psi_A
258         TH1F*                   fHistDeltaPhi2VZEROC[10];       //! phi minus psi_C
259         TH1F*                   fHistDeltaPhi2TPC[10];          //! phi minus psi_TPC
260         TH1F*                   fHistDeltaPhi3VZEROA[10];       //! phi minus psi_A
261         TH1F*                   fHistDeltaPhi3VZEROC[10];       //! phi minus psi_C
262         TH1F*                   fHistDeltaPhi3TPC[10];          //! phi minus psi_TPC
263
264         AliAnalysisTaskRhoVnModulation(const AliAnalysisTaskRhoVnModulation&);                  // not implemented
265         AliAnalysisTaskRhoVnModulation& operator=(const AliAnalysisTaskRhoVnModulation&);       // not implemented
266
267         ClassDef(AliAnalysisTaskRhoVnModulation, 11);
268 };
269
270 #endif