]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Tasks/AliAnalysisTaskJetFlowMC.h
add options for on-the-fly analysis of toy mc jet v2 events
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / AliAnalysisTaskJetFlowMC.h
1 #ifndef AliAnalysisTaskJetFlowMC_H
2 #define AliAnalysisTaskJetFlowMC_H
3
4 // root includes
5 #include "TF1.h"
6 #include "TH1F.h"
7 #include "TH2F.h" 
8 #include "TRandom.h"
9 // aliroot includes
10 #include "AliAnalysisTaskSE.h"
11 // forward declarations
12 class TList;
13 class TClonesArray;
14 class TArrayI;
15
16 class AliAnalysisTaskJetFlowMC : public AliAnalysisTaskSE 
17 {
18     public:
19         // enumerators
20         enum detectorType       {kVZEROA, kVZEROC, kVZEROComb, kFixedEP};  // detector that was used
21         // constructors, destructor
22         AliAnalysisTaskJetFlowMC();
23         AliAnalysisTaskJetFlowMC(const char *name, Int_t seed = 0);
24         virtual ~AliAnalysisTaskJetFlowMC();
25         void    UserCreateOutputObjects();
26         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);
27         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);
28
29         void    UserExec(Option_t *option);
30         void    SetDebugMode(Bool_t d)                          { fDebug = d;}
31         void    SetTracksInName(const char *name)               { fTracksInName     = name; }
32         void    SetTracksOutName(const char *name)              { fTracksOutName    = name; }
33         // additional setters
34         void    SetCentralityClasses(TArrayI* c)                { fCentralityClasses = c; }
35         void    SetReferenceDetector(detectorType type)         { fDetectorType = type; }
36         void    SetDifferentialV2(TF1* v2, Int_t c = 0)         { fFuncDiffV2[c] = v2; }
37         void    SetDifferentialV3(TF1* v3, Int_t c = 0)         { fFuncDiffV3[c] = v3; }
38         void    SetDifferentialV2(TH1* v2, Int_t c = 0)         { fHistDiffV2[c] = v2; }
39         void    SetDifferentialV3(TH1* v3, Int_t c = 0)         { fHistDiffV3[c] = v3; }
40         void    SetIntegratedV2(TH1* v2)                        { fHistIntV2 = v2; }
41         void    SetIntegratedV3(TH1* v3)                        { fHistIntV3 = v3; }
42         void    SetTrackSpectrum(TF1* ts)                       { fTrackSpectrum = ts; }
43         void    SetRandomizeEta(Bool_t b)                       { fRandomizeEta = b; }
44         void    SetMultiplicity(Int_t m)                        { fMult = m; }
45         void    SetReuseTracks(Bool_t r)                        { fReuseTracks = r; }
46         void    SetSingleFragmentationJetSpectrum(TF1* js)      { fJetSpectrumSF = js; }
47         void    SetNoOfSFJets(Int_t n)                          { fNoOfSFJets = n; }
48         // additional methods
49         void    V2AfterBurner(Double_t& phi, Double_t& eta, Double_t& pt) const;
50         void    V3AfterBurner(Double_t& phi, Double_t& eta, Double_t& pt) const;
51         void    InjectSingleFragmentationJetSpectrum(Int_t nacc);
52         void    CalculateEventPlane();
53         // inlined helper calculations
54         Double_t        GetTrackPt()       const                { return fTrackSpectrum->GetRandom();}
55         Double_t        GetTrackEta()       const               { return gRandom->Uniform(-.9, .9); }
56         /* inline */    Double_t GetV2(Double_t pt) const { 
57             return (fFuncDiffV2[fCenBin]) ? fFuncDiffV2[fCenBin]->Eval(pt) :
58             fHistDiffV2[fCenBin]->GetBinContent(fHistDiffV2[fCenBin]->GetXaxis()->FindBin(pt));
59         }
60         /* inline */    Double_t GetV3(Double_t pt) const { 
61             return (fFuncDiffV3[fCenBin]) ? fFuncDiffV3[fCenBin]->Eval(pt) : 
62             fHistDiffV3[fCenBin]->GetBinContent(fHistDiffV3[fCenBin]->GetXaxis()->FindBin(pt));
63         }
64         /* inline */    void GetFlowFluctuation(Double_t& vn) const {
65             vn += TMath::Sqrt(2*(vn*.25)*(vn*.25))*TMath::ErfInverse(2*(gRandom->Uniform(0, fFlowFluctuations))-1); 
66         }
67         /* inline */    Double_t PhaseShift(Double_t x) const {  
68             while (x>=TMath::TwoPi())x-=TMath::TwoPi();
69             while (x<0.)x+=TMath::TwoPi();
70         return x; }
71         /* inline */    Double_t PhaseShift(Double_t x, Double_t n) const {
72             x = PhaseShift(x);
73             if(TMath::Nint(n)==2) while (x>TMath::Pi()) x-=TMath::Pi();
74             if(TMath::Nint(n)==3) {
75                 if(x>2.*TMath::TwoPi()/n) x = TMath::TwoPi() - x;
76                 if(x>TMath::TwoPi()/n) x = TMath::TwoPi()-(x+TMath::TwoPi()/n);
77             }
78         return x; }
79         /* inline */    void SampleVnFromTF1(Double_t &phi) const {
80         phi = (fFuncVn) ? fFuncVn->GetRandom(0., TMath::TwoPi()) : 0; }
81         /* inline */    void FillHistogramsOriginalData(Double_t& pt, Double_t& eta, Double_t& phi) const {
82             fHistOriginalSpectrum[fCenBin]->Fill(pt);    fHistOriginalEtaPhi[fCenBin]->Fill(eta, phi);
83             fHistOriginalDeltaPhi[fCenBin]->Fill(PhaseShift(phi-fPsi2, 2));
84         }
85         /* inline */    void FillHistogramsToyData(Double_t& pt, Double_t& eta, Double_t& phi, Double_t& vn) const {
86             fHistToySpectrum[fCenBin]->Fill(pt);         fHistToyEtaPhi[fCenBin]->Fill(eta, phi);
87             fHistToyDeltaPhi[fCenBin]->Fill(PhaseShift(phi-fPsi2, 2));  fHistToyVn[fCenBin]->Fill(pt, vn);
88         }
89         void            Terminate(Option_t* option);
90         void            PrintInfo() const;
91     protected:
92         TString         fTracksOutName;         // name of output track array
93         TString         fTracksInName;          // name of input track array
94         TClonesArray   *fTracksIn;              //! track array in
95         TClonesArray   *fTracksOut;             //! track array out
96         Bool_t          fReuseTracks;           // use original event as template
97         Int_t           fMult;                  // multiplicity of new event
98         Int_t           fCenBin;                //! centrality bin
99         TArrayI*        fCentralityClasses;     // centrality classes (max 10) 
100         TF1*            fFuncVn;                //! vn function
101         TList*          fOutputList;            // output list
102         TF1*            fTrackSpectrum;         // track pt spectrum
103         Bool_t          fRandomizeEta;          // randomize eta
104         TF1*            fJetSpectrumSF;         // single fragmentation spectrum of jets
105         Int_t           fNoOfSFJets;            // number of single fragmentation jets that will be added
106         TF1*            fFuncDiffV2[10];        // differential v2 of charged tracks
107         TF1*            fFuncDiffV3[10];        // differential v3 of charged tracks
108         TH1*            fHistDiffV2[10];        // differential v2 of charged tracks
109         TH1*            fHistDiffV3[10];        // differential v3 of charged tracks
110         TH1*            fHistIntV2;             // integrated v2 of charged tracks
111         TH1*            fHistIntV3;             // integrated v3 of charged tracks
112         Float_t         fFlowFluctuations;      // introduce gaussian flow fluctuations of this magnitude
113         Int_t           fMaxNumberOfIterations; // max number of iterations for afterburner
114         Double_t        fPsi2;                  //! 2nd order event plane orientation
115         Double_t        fPsi3;                  //! 3rd order event plane orientation
116         Double_t        fPrecisionPhi;          // afterburner precision
117         detectorType    fDetectorType;          // type of detector from which the EP is taken
118         // output histograms
119         TH1F*           fHistOriginalSpectrum[10];      //! original pt spectrum of accepted tracks
120         TH2F*           fHistOriginalEtaPhi[10];        //! original eta phi spectrum of accepted tracks
121         TH1F*           fHistToySpectrum[10];           //! spectrum of toy (generated) tracks
122         TH2F*           fHistToyEtaPhi[10];             //! eta phi spectrum of toy (generated) tracks
123         TH1F*           fHistOriginalDeltaPhi[10];      //! original delta phi spectrum
124         TH1F*           fHistToyDeltaPhi[10];           //! delta phi spectrum of toy (generated) tracks
125         TH2F*           fHistToyVn[10];                 //! generated differential vn values (should equal the differential spectrum)
126         TH1F*           fHistSFJetSpectrum;             //! spectrum of generated sf jets
127         TH2F*           fHistSFJetEtaPhi;               //! eta phi of generated sf jets
128     private:
129         AliAnalysisTaskJetFlowMC(const AliAnalysisTaskJetFlowMC&);            // not implemented
130         AliAnalysisTaskJetFlowMC &operator=(const AliAnalysisTaskJetFlowMC&); // not implemented
131
132         ClassDef(AliAnalysisTaskJetFlowMC, 2); // Task to generate toy mc PicoTracks based on real events
133 };
134 #endif