]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetMatching.h
matching constituents within matched jets (from Redmer)
[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, kGeoEtaPhiArea, kGeoRArea, kDeepMatching};
24         enum duplicateRecovery  {kDoNothing, kTraceDuplicates, kRemoveDuplicates}; 
25         enum sourceBKG          {kNoSourceBKG, kSourceRho, kSourceLocalRho};
26         enum targetBKG          {kNoTargetBKG, kTargetRho, kTargetLocalRho};
27         // constructors, destructor
28                                 AliAnalysisTaskJetMatching();
29                                 AliAnalysisTaskJetMatching(const char *name);
30         virtual                 ~AliAnalysisTaskJetMatching();
31         // setting up the task and technical aspects
32         void                    ExecOnce();
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 //            printf("dEta %.2f \t dPhi %.2f \n", a->Eta()-b->Eta(), a->Phi()-b->Phi());
51             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; }
52
53         // setters - setup how to run
54         void                    SetDebugMode(Int_t d)                           {fDebug = d;}
55         void                    SetMatchingScheme(matchingSceme m)              {fMatchingScheme = m;}
56         void                    SetDuplicateRecoveryScheme(duplicateRecovery d) {fDuplicateJetRecoveryMode = d;}
57         void                    SetUseEmcalBaseJetCuts(Bool_t b)                {fUseEmcalBaseJetCuts = b;}
58         void                    SetSourceBKG(sourceBKG b)                       {fSourceBKG = b;}
59         void                    SetTargetBKG(targetBKG b)                       {fTargetBKG = b;}
60         void                    SetSourceJetsName(const char* n)                {fSourceJetsName = n;}
61         void                    SetTargetJetsName(const char* n)                {fTargetJetsName = n; }
62         void                    SetMatchedJetsName(const char* n)               {fMatchedJetsName = n;}
63         void                    SetMatchEta(Float_t f)                          {fMatchEta = f;}
64         void                    SetMatchPhi(Float_t f)                          {fMatchPhi = f;}
65         void                    SetMatchR(Float_t f)                            {fMatchR = f;}
66         void                    SetMatchRelArea(Float_t f)                      {fMatchArea = f;}
67         void                    SetMaxRelEnergyDiff(Float_t f)                  {fMaxRelEnergyDiff = f;}
68         void                    SetMaxAbsEnergyDiff(Float_t f)                  {fMaxAbsEnergyDiff = f;}
69         // methods
70         void                    DoGeometricMatchingEtaPhi(Bool_t pairCuts = kFALSE);
71         void                    DoGeometricMatchingR(Bool_t pairCuts = kFALSE);
72         void                    DoDeepMatching();
73         void                    DuplicateJetRecovery();
74         void                    PostMatchedJets();
75         // fill histogrmas
76         void                    FillAnalysisSummaryHistogram() const;
77         void                    FillMatchedJetHistograms() const;
78         // setters - analysis details
79         /* inline */    Bool_t PassesCuts(const AliVTrack* track) const {
80             if(!track) return kFALSE;
81             return (track->Pt() < fTrackPtCut || track->Eta() < fTrackMinEta || track->Eta() > fTrackMaxEta || track->Phi() < fTrackMinPhi || track->Phi() > fTrackMaxPhi) ? kFALSE : kTRUE; }
82         /* inline */    Bool_t PassesCuts(AliEmcalJet* jet) const {
83             if(!jet) return kFALSE;
84             return (fUseEmcalBaseJetCuts) ? AliAnalysisTaskEmcalJet::AcceptJet(jet) : kTRUE; }
85         /* inline */    Bool_t PassesCuts(AliEmcalJet* a, AliEmcalJet* b) const {
86             if (fMatchArea > 0) { return (TMath::Abs(a->Area()/b->Area()) < fMatchArea) ? kTRUE : kFALSE; }
87             if (fMaxRelEnergyDiff > 0) { return (TMath::Abs(a->E()/b->E()) > fMaxRelEnergyDiff) ? kTRUE : kFALSE; }
88             if (fMaxAbsEnergyDiff > 0) { return (TMath::Abs(a->E()-b->E()) > fMaxAbsEnergyDiff) ? kTRUE : kFALSE; }
89             return kTRUE; }
90         /* inline */    void ClearMatchedJetsCache() {
91             for (Int_t i(0); i < fNoMatchedJets; i++) {
92                 fMatchedJetContainer[i][0] = 0x0; fMatchedJetContainer[i][1] = 0x0; }
93             fNoMatchedJets = 0;
94         }
95         void                    PrintInfo() const;
96         virtual void            Terminate(Option_t* option);
97
98     private: 
99         Int_t                   fDebug;                 // debug level (0 none, 1 fcn calls, 2 verbose)
100         TClonesArray*           fSourceJets;            //! array with source jets
101         TString                 fSourceJetsName;        // name of array with source jets
102         TClonesArray*           fTargetJets;            //! array with target jets
103         TString                 fTargetJetsName;        // name of array with target jets
104         TClonesArray*           fMatchedJets;           //! final list of matched jets which is added to event
105         TString                 fMatchedJetsName;       // name of list of matched jets
106         Bool_t                  fUseScaledRho;          // use scaled rho
107         matchingSceme           fMatchingScheme;        // select your favorite matching algorithm
108         duplicateRecovery       fDuplicateJetRecoveryMode;      // what to do with duplicate matches
109         Bool_t                  fUseEmcalBaseJetCuts;   // use the emcal jet base class for jet cuts
110         sourceBKG               fSourceBKG;             // subtracted background of source jets
111         targetBKG               fTargetBKG;             // subtracted background of target jets
112         // additional jet cuts (most are inherited)
113         Float_t                 fLocalJetMinEta;        // local eta cut for jets
114         Float_t                 fLocalJetMaxEta;        // local eta cut for jets
115         Float_t                 fLocalJetMinPhi;        // local phi cut for jets
116         Float_t                 fLocalJetMaxPhi;        // local phi cut for jets
117         // transient object pointers
118         TList*                  fOutputList;            //! output list
119         TH1F*                   fHistUnsortedCorrelation;       //! dphi correlation of unsorted jets
120         TH1F*                   fHistMatchedCorrelation;        //! dphi correlation of matched jets
121         TH1F*                   fHistSourceJetPt;       //! pt of source jets
122         TH1F*                   fHistTargetJetPt;       //! pt of target jets
123         TH1F*                   fHistMatchedJetPt;      //! pt of matched jets
124         TH1F*                   fHistNoConstSourceJet;  //! number of constituents of source jet
125         TH1F*                   fHistNoConstTargetJet;  //! number of constituents of target jet
126         TH1F*                   fHistNoConstMatchJet;   //! number of constituents of matched jets
127         TProfile*               fProfFracPtMatched;     //! sum pt fraction for matched tracks / jet
128         TProfile*               fProfFracPtJets;        //! sum pt fraction for matched jets
129         TProfile*               fProfFracNoMatched;     //! no of constituents fraction found / jet
130         TProfile*               fProfFracNoJets;        //! no of consstituents fraction jet / jet
131         TH1F*                   fHistAnalysisSummary;   //! flags
132         TProfile*               fProfQAMatched;         //! QA spreads of matched jets
133         TProfile*               fProfQA;                //! QA spreads of source and target jets
134         Int_t                   fNoMatchedJets;         //! number of matched jets
135         AliEmcalJet*            fMatchedJetContainer[100][2];   //! pointers to matched jets
136         // geometric matching parameters
137         Float_t                 fMatchEta;              // max eta distance between centers of matched jets
138         Float_t                 fMatchPhi;              // max phi distance between centers of matched jets
139         Float_t                 fMatchR;                // max distance between matched jets
140         Float_t                 fMatchArea;             // max relative area mismatch between matched jets
141         Float_t                 fMaxRelEnergyDiff;      // max relative energy difference between matched jets
142         Float_t                 fMaxAbsEnergyDiff;      // max absolute energy difference between matched jets
143
144         AliAnalysisTaskJetMatching(const AliAnalysisTaskJetMatching&);                  // not implemented
145         AliAnalysisTaskJetMatching& operator=(const AliAnalysisTaskJetMatching&);       // not implemented
146
147         ClassDef(AliAnalysisTaskJetMatching, 2);
148 };
149
150 #endif