]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetMatching.h
add bookkeeping of pythia ntrials and cross section for pt hard bins
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskJetMatching.h
1 #ifndef AliAnalysisTaskJetMatching_H
2 #define AliAnalysisTaskJetMatching_H
3
4 #include <AliAnalysisTaskEmcalJet.h>
5 #include <AliEmcalJet.h>
6 #include <AliVTrack.h>
7 #include <TClonesArray.h>
8 #include <TMath.h>
9 #include <TRandom3.h>
10
11 class TF1;
12 class THF1;
13 class THF2;
14 class TProfile;
15 class AliRhoParameter;
16 class AliLocalRhoParameter;
17 class TClonesArray;
18
19 class AliAnalysisTaskJetMatching : public AliAnalysisTaskEmcalJet
20 {
21     public:
22         // enumerators
23         enum matchingSceme      {kGeoEtaPhi, kGeoR};
24         enum sourceBKG          {kNoSourceBKG, kSourceRho, kSourceLocalRho};
25         enum targetBKG          {kNoTargetBKG, kTargetRho, kTargetLocalRho};
26         // constructors, destructor
27                                 AliAnalysisTaskJetMatching();
28                                 AliAnalysisTaskJetMatching(const char *name);
29         virtual                 ~AliAnalysisTaskJetMatching();
30         // setting up the task and technical aspects
31         void                    ExecOnce();
32         virtual Bool_t          Notify();
33         virtual void            UserCreateOutputObjects();
34         TH1F*                   BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Bool_t append = kTRUE);
35         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, Bool_t append = kTRUE);
36         virtual Bool_t          Run();
37         /* inline */    Double_t PhaseShift(Double_t x) const {  
38             while (x>=TMath::TwoPi())x-=TMath::TwoPi();
39             while (x<0.)x+=TMath::TwoPi();
40             return x; }
41         /* inline */    Double_t PhaseShift(Double_t x, Double_t n) const {
42             x = PhaseShift(x);
43             if(TMath::Nint(n)==2) while (x>TMath::Pi()) x-=TMath::Pi();
44             if(TMath::Nint(n)==3) {
45                 if(x>2.*TMath::TwoPi()/n) x = TMath::TwoPi() - x;
46                 if(x>TMath::TwoPi()/n) x = TMath::TwoPi()-(x+TMath::TwoPi()/n);
47             }
48             return x; }
49         /* inline */    Bool_t CompareTracks(AliVParticle* a, AliVParticle* b) const {
50             return (TMath::AreEqualAbs(a->Pt(), b->Pt(), 1e-2) && TMath::AreEqualAbs(a->Eta(), b->Eta(), 1e-2) && TMath::AreEqualAbs(a->Phi(), b->Phi(), 1e-2)) ? kTRUE : kFALSE; }
51         /* inline */    Double_t GetR(AliVParticle* a, AliVParticle* b) const {
52                if(!(a&&b)) return 999;
53                Double_t phiA(a->Phi()), phiB(b->Phi()), etaA(a->Eta()), etaB(b->Eta());
54                if(TMath::Abs(phiA-phiB) > TMath::Abs(phiA-phiB + TMath::TwoPi())) phiA+=TMath::TwoPi();
55                if(TMath::Abs(phiA-phiB) > TMath::Abs(phiA-phiB - TMath::TwoPi())) phiA-=TMath::TwoPi();
56                return TMath::Sqrt(TMath::Abs((etaA-etaB)*(etaA-etaB)+(phiA-phiB)*(phiA-phiB))); }
57
58         // setters - setup how to run
59         void                    SetDebugMode(Int_t d)                           {fDebug = d;}
60         void                    SetMatchingScheme(matchingSceme m)              {fMatchingScheme = m;}
61         void                    SetMatchConstituents(Bool_t m)                  {fMatchConstituents = m;}
62         void                    SetMinFracRecoveredConstituents(Float_t f)      {fMinFracRecoveredConstituents = f;}
63         void                    SetMinFracRecoveredConstituentPt(Float_t f)     {fMinFracRecoveredConstituentPt = f;}
64         void                    SetUseEmcalBaseJetCuts(Bool_t b)                {fUseEmcalBaseJetCuts = b;}
65         void                    SetGetBijection(Bool_t b)                       {fGetBijection = b;}
66         void                    SetSourceBKG(sourceBKG b)                       {fSourceBKG = b;}
67         void                    SetTargetBKG(targetBKG b)                       {fTargetBKG = b;}
68         void                    SetSourceJetsName(const char* n)                {fSourceJetsName = n;}
69         void                    SetTargetJetsName(const char* n)                {fTargetJetsName = n; }
70         void                    SetMatchedJetsName(const char* n)               {fMatchedJetsName = n;}
71         void                    SetSourceLocalRhoName(const char* n)            {fSourceRhoName = n;}
72         void                    SetTargetLocalRhoName(const char* n)            {fTargetRhoName = n;}
73         void                    SetSourceRadius(Float_t r)                      {fSourceRadius = r;}
74         void                    SetTargetRadius(Float_t r)                      {fTargetRadius = r;}
75         void                    SetMatchEta(Float_t f)                          {fMatchEta = f;}
76         void                    SetMatchPhi(Float_t f)                          {fMatchPhi = f;}
77         void                    SetMatchR(Float_t f)                            {fMatchR = f;}
78         void                    SetDoDetectorResponse(Bool_t d)                 {fDoDetectorResponse = d;}
79         // methods
80         void                    DoGeometricMatchingEtaPhi();
81         void                    DoGeometricMatchingR();
82         void                    DoConstituentMatching();
83         void                    GetBijection();
84         void                    PostMatchedJets();
85         // fill histogrmas
86         void                    FillAnalysisSummaryHistogram() const;
87         void                    FillMatchedJetHistograms();
88         // setters - analysis details
89         /* inline */    Bool_t PassesCuts(const AliVTrack* track) const {
90             return (!track || TMath::Abs(track->Eta()) > 0.9 || track->Phi() < 0 || track->Phi() > TMath::TwoPi()) ? kFALSE : kTRUE; }
91         /* inline */    Bool_t PassesCuts(AliEmcalJet* jet, Int_t c)  { if(!fUseEmcalBaseJetCuts) return (jet) ? kTRUE : kFALSE; 
92             else return AcceptJet(jet, c);}
93         /* inline */    void ClearMatchedJetsCache() {
94             for (Int_t i(0); i < fNoMatchedJets; i++) {
95                 fMatchedJetContainer[i][0] = 0x0; fMatchedJetContainer[i][1] = 0x0; }
96             fNoMatchedJets = 0;
97         }
98         void                    PrintInfo() const;
99         virtual void            Terminate(Option_t* option);
100
101     private: 
102         Int_t                   fDebug;                 // debug level (0 none, 1 fcn calls, 2 verbose)
103         TClonesArray*           fSourceJets;            //! array with source jets
104         TString                 fSourceJetsName;        // name of array with source jets
105         TClonesArray*           fTargetJets;            //! array with target jets
106         TString                 fTargetJetsName;        // name of array with target jets
107         TClonesArray*           fMatchedJets;           //! final list of matched jets which is added to event
108         TString                 fMatchedJetsName;       // name of list of matched jets
109         AliLocalRhoParameter*   fSourceRho;             //! source rho
110         TString                 fSourceRhoName;         // source rho  name
111         AliLocalRhoParameter*   fTargetRho;             //! target rho
112         TString                 fTargetRhoName;         // target rho name
113         Bool_t                  fUseScaledRho;          // use scaled rho
114         Float_t                 fSourceRadius;          // source radius 
115         Float_t                 fTargetRadius;          // target radius
116         matchingSceme           fMatchingScheme;        // select your favorite matching algorithm
117         Bool_t                  fUseEmcalBaseJetCuts;   // use the emcal jet base class for jet cuts
118         sourceBKG               fSourceBKG;             // subtracted background of source jets
119         targetBKG               fTargetBKG;             // subtracted background of target jets
120         // transient object pointers
121         TList*                  fOutputList;            //! output list
122         TH1F*                   fHistUnsortedCorrelation;       //! dphi correlation of unsorted jets
123         TH1F*                   fHistMatchedCorrelation;        //! dphi correlation of matched jets
124         TH1F*                   fHistSourceJetPt;       //! pt of source jets
125         TH1F*                   fHistMatchedSourceJetPt;//! pt of matched source jets
126         TH1F*                   fHistTargetJetPt;       //! pt of target jets
127         TH1F*                   fHistMatchedJetPt;      //! pt of matched jets
128         TH2F*                   fHistSourceMatchedJetPt;//! pt or source vs matched jets
129         TH2F*                   fHistDetectorResponseProb;      //! det prob
130         TH1F*                   fHistNoConstSourceJet;  //! number of constituents of source jet
131         TH1F*                   fHistNoConstTargetJet;  //! number of constituents of target jet
132         TH1F*                   fHistNoConstMatchJet;   //! number of constituents of matched jets
133         TProfile*               fProfFracPtMatched;     //! sum pt fraction for matched tracks / jet
134         TProfile*               fProfFracPtJets;        //! sum pt fraction for matched jets
135         TProfile*               fProfFracNoMatched;     //! no of constituents fraction found / jet
136         TProfile*               fProfFracNoJets;        //! no of consstituents fraction jet / jet
137         TH1F*                   fHistAnalysisSummary;   //! flags
138         TProfile*               fProfQAMatched;         //! QA spreads of matched jets
139         TProfile*               fProfQA;                //! QA spreads of source and target jets
140         Int_t                   fNoMatchedJets;         //! number of matched jets
141         AliEmcalJet*            fMatchedJetContainer[200][2];   //! pointers to matched jets
142         // geometric matching parameters
143         Float_t                 fMatchEta;              // max eta distance between centers of matched jets
144         Float_t                 fMatchPhi;              // max phi distance between centers of matched jets
145         Float_t                 fMatchR;                // max distance between matched jets
146         Bool_t                  fDoDetectorResponse;    // get detector response matrix (not normalized)
147         Bool_t                  fMatchConstituents;     // match constituents
148         Float_t                 fMinFracRecoveredConstituents;  // minimium fraction of constituents that needs to be found
149         Float_t                 fMinFracRecoveredConstituentPt; // minimium fraction of constituent pt that needs to be recovered
150         Bool_t                  fGetBijection;          // get bijection of source and matched jets
151         // pythia ntrials xsec bookkeeping
152         TH1F*                   fh1Trials;              //! sum of trails (in Notify)
153         TH1F*                   fh1AvgTrials;           //! average sum of trials (in Run)
154         TProfile*               fh1Xsec;                //! pythia cross section and trials
155         Float_t                 fAvgTrials;             // average number of trails per event
156
157         AliAnalysisTaskJetMatching(const AliAnalysisTaskJetMatching&);                  // not implemented
158         AliAnalysisTaskJetMatching& operator=(const AliAnalysisTaskJetMatching&);       // not implemented
159
160         ClassDef(AliAnalysisTaskJetMatching, 6);
161 };
162
163 #endif