]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/AliEmcalJetTask.h
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliEmcalJetTask.h
1 #ifndef ALIEMCALJETTASK_H
2 #define ALIEMCALJETTASK_H
3
4 class TClonesArray;
5 class AliVEvent;
6 class AliRhoParameter;
7
8 namespace fastjet {
9   class PseudoJet;
10 }
11
12 #include "AliLog.h"
13 #include "AliAnalysisTaskSE.h"
14 #include "AliFJWrapper.h"
15 #include "AliAODMCParticle.h"
16 #include "AliEmcalJet.h"
17
18 class AliEmcalJetTask : public AliAnalysisTaskSE {
19  public:
20
21   enum JetType {
22     kNone=0,
23     kKT=1<<0,
24     kAKT=1<<1,
25     kFullJet=1<<2,
26     kChargedJet=1<<3,
27     kNeutralJet=1<<4,
28     kR020Jet=1<<5,
29     kR030Jet=1<<6,
30     kR040Jet=1<<7,
31     kRX1Jet=1<<8,  // user defined radii, use SetRadius(Double_t)
32     kRX2Jet=1<<9,
33     kRX3Jet=1<<10
34   };
35
36   AliEmcalJetTask();
37   AliEmcalJetTask(const char *name);
38   virtual ~AliEmcalJetTask();
39
40   void                   UserCreateOutputObjects();
41   void                   UserExec(Option_t *option);
42   void                   Terminate(Option_t *option);
43  
44   Bool_t                 IsLocked()                       { if(fLocked) {AliFatal("Jet finder task is locked! Changing properties is not allowed."); return kTRUE;} else return kFALSE;};
45   void                   SetLocked()                      { fLocked = kTRUE;}
46   void                   SelectConstituents(UInt_t constSel, UInt_t MCconstSel)  { fConstSel = constSel; fMCConstSel = MCconstSel; };
47   void                   SetAlgo(Int_t a)                 { if(IsLocked()) return; if (a==0) fJetType |= kKT; else fJetType |= kAKT; }  // for backward compatibility only
48   void                   SetClusName(const char *n)       { if(IsLocked()) return; fCaloName      = n     ; }
49   void                   SetJetsName(const char *n)       { if(IsLocked()) return; fJetsName      = n     ; }
50   void                   SetJetsSubName(const char *n)    { fJetsSubName   = n     ; }
51   void                   SetTracksSubName(const char *n)  { fTracksSubName = n     ; }
52   void                   SetClusSubName(const char *n)    { fClusSubName   = n     ; }
53   void                   SetJetType(UInt_t t)             { if(IsLocked()) return; fJetType       = t     ; }
54   void                   SetMarkConstituents(UInt_t m)    { if(IsLocked()) return; fMarkConst     = m     ; }
55   void                   SetMinJetArea(Double_t a)        { if(IsLocked()) return; fMinJetArea    = a     ; }
56   void                   SetMinJetClusPt(Double_t min)    { if(IsLocked()) return; fMinJetClusPt  = min   ; }
57   void                   SetMinJetPt(Double_t j)          { if(IsLocked()) return; fMinJetPt      = j     ; }
58   void                   SetMinJetTrackPt(Double_t min)   { if(IsLocked()) return; fMinJetTrackPt = min   ; }
59   void                   SetRadius(Double_t r)            { if(IsLocked()) return; fRadius        = r     ; if ((fJetType & (kRX1Jet|kRX2Jet|kRX3Jet)) == 0) AliWarning("Radius value will be ignored if jet type is not set to a user defined radius (kRX1Jet,kRX2Jet,kRX3Jet)."); }
60   void                   SetTrackEfficiency(Double_t t)   { if(IsLocked()) return; fTrackEfficiency = t   ; }
61   void                   SetTracksName(const char *n)     { if(IsLocked()) return; fTracksName    = n     ; }
62   void                   SetType(Int_t t)                 { if(IsLocked()) return; 
63                                                             if (t==0) fJetType |= kFullJet; 
64                                                             else if (t==1) fJetType |= kChargedJet; 
65                                                             else if (t==2) fJetType |= kNeutralJet; } // for backward compatibility only
66   void                   SetEtaRange(Double_t emi, Double_t ema) {if(IsLocked()) return; fEtaMin = emi; fEtaMax = ema; }
67   void                   SetPhiRange(Double_t pmi, Double_t pma) {if(IsLocked()) return; fPhiMin = pmi; fPhiMax = pma; }
68   void                   SetJetEtaRange(Double_t emi, Double_t ema) {if(IsLocked()) return; fJetEtaMin = emi; fJetEtaMax = ema; }
69   void                   SetJetPhiRange(Double_t pmi, Double_t pma) {if(IsLocked()) return; fJetPhiMin = pmi; fJetPhiMax = pma; }
70   void                   SetGhostArea(Double_t gharea)    { if(IsLocked()) return; fGhostArea      = gharea;  }
71   void                   SetMinMCLabel(Int_t s)           { if(IsLocked()) return; fMinMCLabel     = s     ;  }
72   void                   SetRecombScheme(Int_t scheme)    { if(IsLocked()) return; fRecombScheme   = scheme;  }
73   void                   SelectCollisionCandidates(UInt_t offlineTriggerMask = AliVEvent::kMB)
74   {
75     if(!fIsPSelSet)
76     {
77       fIsPSelSet = kTRUE;
78       fOfflineTriggerMask = offlineTriggerMask;
79     }
80     else
81     {
82       AliWarning("Manually setting the event selection for jet finders is not allowed! Using trigger=old_trigger | your_trigger");  
83       fOfflineTriggerMask = fOfflineTriggerMask | offlineTriggerMask;
84     }
85   }
86   void                   SetLegacyMode(Bool_t mode)           { if(IsLocked()) return; fLegacyMode = mode; }
87   void                   SetMCFlag(UInt_t m)                  { if(IsLocked()) return; fMCFlag     = m   ; }
88   void                   SelectHIJING(Bool_t s)               { if(IsLocked()) return; if (s) fGeneratorIndex = 0; else fGeneratorIndex = -1; }
89   void                   SetGeneratorIndex(Short_t i)         { if(IsLocked()) return; fGeneratorIndex = i; }
90   void                   SelectPhysicalPrimaries(Bool_t s)    { if(IsLocked()) return; 
91                                                                 if (s) fMCFlag |=  AliAODMCParticle::kPhysicalPrim ; 
92                                                                 else   fMCFlag &= ~AliAODMCParticle::kPhysicalPrim ; }
93
94   void                   SetCodeDebug(Bool_t val)               { fCodeDebug    = val          ; }
95   void                   SetForceIsMcPart(Bool_t b)             { fIsMcPart     = b            ; }
96   void                   SetPionMassForClusters(Bool_t b)       { fPionMassClusters = b        ; }
97
98   void                   SetRhoName(const char *n)              { fRhoName      = n            ; }
99   void                   SetRhomName(const char *n)             { fRhomName     = n            ; }
100   void                   SetGenericSubtractionJetMass(Bool_t b) { fDoGenericSubtractionJetMass = b; }
101   void                   SetGenericSubtractionGR(Bool_t b, Double_t rmax = 2., Double_t dr = 0.04, Double_t ptmin = 0.) { fDoGenericSubtractionGR = b; fRMax=rmax; fDRStep=dr; fPtMinGR=ptmin;}
102   void                   SetConstituentSubtraction(Bool_t b)    { fDoConstituentSubtraction = b; }
103   void                   SetGenericSubtractionExtraJetShapes(Bool_t b)            { fDoGenericSubtractionExtraJetShapes =b;}
104   void                   SetUseExternalBkg(Bool_t b, Double_t rho, Double_t rhom) { fUseExternalBkg = b; fRho = rho; fRhom = rhom;}
105
106   UInt_t                 GetJetType()                     { return fJetType; }
107   Bool_t                 GetLegacyMode()                  { return fLegacyMode; }
108   TString                GetJetsSubName()                 { return fJetsSubName; }
109
110   const char*            GetJetsName()                    { return fJetsName.Data(); }
111   Double_t               GetRadius()                      { return fRadius; }
112   const char*            GetTracksName()                  { return fTracksName.Data(); }
113   const char*            GetClusName()                    { return fCaloName.Data(); }
114   const char*            GetRhoName()                     { return fRhoName.Data(); }
115   UInt_t                 GetMarkConstituents()            { return fMarkConst; }
116   Double_t               GetMinJetArea()                  { return fMinJetArea; }
117   Double_t               GetMinJetClusPt()                { return fMinJetClusPt; }
118   Double_t               GetMinJetPt()                    { return fMinJetPt; }
119   Double_t               GetMinJetTrackPt()               { return fMinJetTrackPt; }
120   Double_t               GetTrackEfficiency()             { return fTrackEfficiency; }
121   Double_t               GetGhostArea()                   { return fGhostArea; }
122   Int_t                  GetMinMCLabel()                  { return fMinMCLabel; }
123   Int_t                  GetRecombScheme()                { return fRecombScheme; }
124   Double_t               GetEtaMin()                      { return fEtaMin; }
125   Double_t               GetEtaMax()                      { return fEtaMax; }
126   Double_t               GetPhiMin()                      { return fPhiMin; }
127   Double_t               GetPhiMax()                      { return fPhiMax; }
128   Double_t               GetJetEtaMin()                   { return fJetEtaMin; }
129   Double_t               GetJetEtaMax()                   { return fJetEtaMax; }
130   Double_t               GetJetPhiMin()                   { return fJetPhiMin; }
131   Double_t               GetJetPhiMax()                   { return fJetPhiMax; }
132
133   AliVEvent*             GetEvent()                       { return fEvent;}
134   TClonesArray*          GetClusters()                    { return fClus;}
135   TClonesArray*          GetTracks()                      { return fTracks;}
136   TClonesArray*          GetJets()                        { return fJets;}
137
138  protected:
139   void                   FindJets();
140   Bool_t                 DoInit();
141   Bool_t                 GetSortedArray(Int_t indexes[], std::vector<fastjet::PseudoJet> array) const;
142
143    void                   FillJetConstituents(std::vector<fastjet::PseudoJet>& constituents,AliEmcalJet *jet,Double_t vertex[3],UInt_t jetCount,Int_t& nt,Int_t& nc,Double_t& maxCh,Double_t& maxNe,Int_t& ncharged,Int_t& nneutral,Double_t& neutralE,Double_t& mcpt,Int_t& cemc,Double_t& emcpt,Int_t& gall,Int_t& gemc,std::vector<fastjet::PseudoJet>& constituentsunsub,Int_t flag); 
144   Int_t                  GetIndexSub(Double_t phisub,std::vector<fastjet::PseudoJet>& constituentsunsub);
145
146   TString                fTracksName;             // name of track collection
147   TString                fCaloName;               // name of calo cluster collection
148   TString                fJetsName;               // name of jet collection
149   TString                fJetsSubName;            // name of subtracted jet collection
150   TString                fTracksSubName;          // name of subtracted track collection
151   TString                fClusSubName;            // name of subtracted clusters collection
152   UInt_t                 fJetType;                // jet type (algorithm, radius, constituents)
153   UInt_t                 fConstSel;               // select constituents from a previous jet finding
154   UInt_t                 fMCConstSel;             // select MC constituents (label!=0) from a previous jet finding
155   UInt_t                 fMarkConst;              // constituents are marked (via TObject::SetBit) as belonging to the # leading jets
156   Double_t               fRadius;                 // jet radius
157   Double_t               fMinJetTrackPt;          // min jet track momentum   (applied before clustering)
158   Double_t               fMinJetClusPt;           // min jet cluster momentum (applied before clustering)
159   Double_t               fPhiMin;                 // minimum phi for constituents (applied before clustering)
160   Double_t               fPhiMax;                 // maximum phi for constituents (applied before clustering)
161   Double_t               fEtaMin;                 // minimum eta for constituents (applied before clustering)
162   Double_t               fEtaMax;                 // maximum eta for constituents (applied before clustering)
163   Double_t               fMinJetArea;             // min area to keep jet in output
164   Double_t               fMinJetPt;               // min jet pt to keep jet in output
165   Double_t               fJetPhiMin;              // minimum phi to keep jet in output
166   Double_t               fJetPhiMax;              // maximum phi to keep jet in output
167   Double_t               fJetEtaMin;              // minimum eta to keep jet in output
168   Double_t               fJetEtaMax;              // maximum eta to keep jet in output
169   Double_t               fGhostArea;              // ghost area
170   Int_t                  fMinMCLabel;             // minimum MC label value for the tracks/clusters being considered MC particles
171   Int_t                  fRecombScheme;           // recombination scheme used by fastjet
172   Double_t               fTrackEfficiency;        // artificial tracking inefficiency (0...1)
173   UInt_t                 fMCFlag;                 // select MC particles with flags
174   Short_t                fGeneratorIndex;         // select MC particles with generator index (default = -1 = switch off selection)
175   Bool_t                 fIsInit;                 //!=true if already initialized
176   Bool_t                 fLocked;                 // true if lock is set
177   Bool_t                 fIsPSelSet;              //!=true if physics selection was set
178   Bool_t                 fIsMcPart;               //!=true if MC particles are given as input
179   Bool_t                 fIsEmcPart;              //!=true if emcal particles are given as input (for clusters)
180   Bool_t                 fIsPicoTrack;            //!=true if pico tracks are given as input
181   Bool_t                 fIsEsdClus;              //!=true if AliESDCaloCluster is given as input
182   Bool_t                 fLegacyMode;             //! if true, enable FJ 2.x behavior
183   Bool_t                 fCodeDebug;              // use nontested code changes 
184   Bool_t                 fPionMassClusters;       // assume pion mass for clusters
185   Bool_t                 fDoGenericSubtractionJetMass;        // calculate generic subtraction
186   Bool_t                 fDoGenericSubtractionGR;             // calculate generic subtraction for angular structure function GR
187   Bool_t                 fDoGenericSubtractionExtraJetShapes; // calculate generic subtraction for other jet shapes like radialmoment,pTD etc
188   Bool_t                 fDoConstituentSubtraction;           // calculate constituent subtraction
189   Bool_t                 fUseExternalBkg;                     // use external background for generic subtractor
190   TString                fRhoName;                            // name of rho
191   TString                fRhomName;                           // name of rhom
192   Double_t               fRho;                                // pT background density
193   Double_t               fRhom;                               // mT background density
194   Double_t               fRMax;                               // R max for GR calculation
195   Double_t               fDRStep;                             // step width for GR calculation
196   Double_t               fPtMinGR;                            // min pT for GR calculation
197  
198
199   TClonesArray          *fJets;                   //!jet collection
200   TClonesArray          *fJetsSub;                //!subtracted jet collection
201   TClonesArray          *fTracksSub;              //!subtracted track collection
202   TClonesArray          *fClusSub;                //!subtracted cluster collection
203   AliVEvent             *fEvent;                  //!current event
204   TClonesArray          *fTracks;                 //!tracks collection
205   TClonesArray          *fClus;                   //!cluster collection
206   AliRhoParameter       *fRhoParam;               //!event rho
207   AliRhoParameter       *fRhomParam;              //!event rhom
208
209  private:
210   AliEmcalJetTask(const AliEmcalJetTask&);            // not implemented
211   AliEmcalJetTask &operator=(const AliEmcalJetTask&); // not implemented
212
213   ClassDef(AliEmcalJetTask, 17) // Jet producing task
214 };
215 #endif