]> 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 TObjArray;
6 class AliVEvent;
7 class AliEMCALGeometry;
8 class AliEmcalJetUtility;
9 class AliFJWrapper;
10
11 namespace fastjet {
12   class PseudoJet;
13 }
14
15 #include "AliLog.h"
16 #include "AliAnalysisTaskSE.h"
17 #include "AliFJWrapper.h"
18 #include "AliAODMCParticle.h"
19 #include "AliEmcalJet.h"
20
21 class AliEmcalJetTask : public AliAnalysisTaskSE {
22  public:
23
24   enum JetType {
25     kNone=0,
26     kKT=1<<0,
27     kAKT=1<<1,
28     kFullJet=1<<2,
29     kChargedJet=1<<3,
30     kNeutralJet=1<<4,
31     kR020Jet=1<<5,
32     kR030Jet=1<<6,
33     kR040Jet=1<<7,
34     kRX1Jet=1<<8,  // user defined radii, use SetRadius(Double_t)
35     kRX2Jet=1<<9,
36     kRX3Jet=1<<10
37   };
38
39   AliEmcalJetTask();
40   AliEmcalJetTask(const char *name);
41   virtual ~AliEmcalJetTask();
42
43   void UserCreateOutputObjects();
44   void UserExec(Option_t* option);
45   void Terminate(Option_t* /*option*/) {;}
46
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                   SetClusLabelRange(Int_t min, Int_t max)    { if (IsLocked()) return; fMinLabelClusters = min   ; fMaxLabelClusters = max; }
50   void                   SetEtaRange(Double_t emi, Double_t ema)    { if (IsLocked()) return; fEtaMin           = emi   ; fEtaMax = ema   ; }
51   void                   SetGhostArea(Double_t gharea)              { if (IsLocked()) return; fGhostArea        = gharea; }
52   void                   SetJetsName(const char *n)                 { if (IsLocked()) return; fJetsName         = n     ; }
53   void                   SetJetEtaRange(Double_t emi, Double_t ema) { if (IsLocked()) return; fJetEtaMin        = emi   ; fJetEtaMax = ema; }
54   void                   SetJetPhiRange(Double_t pmi, Double_t pma) { if (IsLocked()) return; fJetPhiMin        = pmi   ; fJetPhiMax = pma; }
55   void                   SetJetType(UInt_t t)                       { if (IsLocked()) return; fJetType          = t     ; }
56   void                   SetLocked()                                { fLocked = kTRUE;}
57   void                   SetMinJetArea(Double_t a)                  { if (IsLocked()) return; fMinJetArea       = a     ; }
58   void                   SetMinJetClusPt(Double_t min)              { if (IsLocked()) return; fMinJetClusPt     = min   ; }
59   void                   SetMinJetPt(Double_t j)                    { if (IsLocked()) return; fMinJetPt         = j     ; }
60   void                   SetMinJetTrackPt(Double_t min)             { if (IsLocked()) return; fMinJetTrackPt    = min   ; }
61   void                   SetMinMCLabel(Int_t s)                     { if (IsLocked()) return; fMinMCLabel       = s     ; }
62   void                   SetPhiRange(Double_t pmi, Double_t pma)    { if (IsLocked()) return; fPhiMin           = pmi   ; fPhiMax = pma; }
63   void                   SetRecombScheme(Int_t scheme)              { if (IsLocked()) return; fRecombScheme     = scheme; }
64   void                   SetTracksName(const char *n)               { if (IsLocked()) return; fTracksName       = n     ; }
65   void                   SetTrackEfficiency(Double_t t)             { if (IsLocked()) return; fTrackEfficiency  = t     ; }
66   void                   SetTrackLabelRange(Int_t min, Int_t max)   { if (IsLocked()) return; fMinLabelTracks   = min   ; fMaxLabelTracks = max; }
67   void                   SetLegacyMode(Bool_t mode)                 { if (IsLocked()) return; fLegacyMode       = mode  ; }
68   void                   SetMCFlag(UInt_t m)                        { if (IsLocked()) return; fMCFlag           = m     ; }
69   void                   SelectHIJING(Bool_t s)                     { if (IsLocked()) return; if (s) fGeneratorIndex = 0; else fGeneratorIndex = -1; }
70   void                   SetGeneratorIndex(Short_t i)               { if (IsLocked()) return; fGeneratorIndex   = i     ; }
71
72   AliEmcalJetUtility*    AddUtility(AliEmcalJetUtility* utility);
73
74   const char*            GetClusName()                    { return fCaloName.Data()   ; }
75   Double_t               GetEtaMin()                      { return fEtaMin            ; }
76   Double_t               GetEtaMax()                      { return fEtaMax            ; }
77   Double_t               GetGhostArea()                   { return fGhostArea         ; }
78   const char*            GetJetsName()                    { return fJetsName.Data()   ; }
79   Double_t               GetJetEtaMin()                   { return fJetEtaMin         ; }
80   Double_t               GetJetEtaMax()                   { return fJetEtaMax         ; }
81   Double_t               GetJetPhiMin()                   { return fJetPhiMin         ; }
82   Double_t               GetJetPhiMax()                   { return fJetPhiMax         ; }
83   UInt_t                 GetJetType()                     { return fJetType           ; }
84   Bool_t                 GetLegacyMode()                  { return fLegacyMode        ; }
85   Double_t               GetMinJetArea()                  { return fMinJetArea        ; }
86   Double_t               GetMinJetClusPt()                { return fMinJetClusPt      ; }
87   Double_t               GetMinJetPt()                    { return fMinJetPt          ; }
88   Double_t               GetMinJetTrackPt()               { return fMinJetTrackPt     ; }
89   Int_t                  GetMinMCLabel()                  { return fMinMCLabel        ; }
90   Double_t               GetPhiMin()                      { return fPhiMin            ; }
91   Double_t               GetPhiMax()                      { return fPhiMax            ; }
92   Double_t               GetRadius()                      { return fRadius            ; }
93   Int_t                  GetRecombScheme()                { return fRecombScheme      ; }
94   const char*            GetTracksName()                  { return fTracksName.Data() ; }
95   Double_t               GetTrackEfficiency()             { return fTrackEfficiency   ; }
96
97   AliVEvent*             GetEvent()                       { return fEvent             ; }
98   TClonesArray*          GetClusters()                    { return fClus              ; }
99   TClonesArray*          GetTracks()                      { return fTracks            ; }
100   TClonesArray*          GetJets()                        { return fJets              ; }
101   TObjArray*             GetUtilities()                   { return fUtilities         ; }
102
103   void                   FillJetConstituents(AliEmcalJet *jet, std::vector<fastjet::PseudoJet>& constituents, TClonesArray *tracks, TClonesArray *clusters,
104                                              std::vector<fastjet::PseudoJet>& constituents_sub, Int_t flag = 0, TClonesArray *particles_sub = 0);
105
106   Int_t                  GetIndexSub(Double_t phi_sub, std::vector<fastjet::PseudoJet>& constituents_unsub);
107
108   Bool_t IsLocked() 
109   {
110     if (fLocked) {
111       AliFatal("Jet finder task is locked! Changing properties is not allowed."); 
112       return kTRUE;
113     } 
114     else {
115       return kFALSE;
116     }
117   }
118
119   void SelectCollisionCandidates(UInt_t offlineTriggerMask = AliVEvent::kMB)
120   {
121     if(!fIsPSelSet)
122     {
123       fIsPSelSet = kTRUE;
124       fOfflineTriggerMask = offlineTriggerMask;
125     }
126     else
127     {
128       AliWarning("Manually setting the event selection for jet finders is not allowed! Using trigger=old_trigger | your_trigger");  
129       fOfflineTriggerMask = fOfflineTriggerMask | offlineTriggerMask;
130     }
131   }
132
133   void SetRadius(Double_t r)            
134   { 
135     if (IsLocked()) return; 
136     fRadius = r; 
137     if ((fJetType & (kRX1Jet|kRX2Jet|kRX3Jet)) == 0) 
138       AliWarning("Radius value will be ignored if jet type is not set to a user defined radius (kRX1Jet,kRX2Jet,kRX3Jet)."); 
139   }
140
141   void SetType(Int_t t)                 
142   { 
143     if(IsLocked()) return; 
144     if (t==0) fJetType |= kFullJet; 
145     else if (t==1) fJetType |= kChargedJet; 
146     else if (t==2) fJetType |= kNeutralJet; 
147   } // for backward compatibility only
148
149   void SelectPhysicalPrimaries(Bool_t s)    
150   { 
151     if(IsLocked()) return; 
152     if (s) fMCFlag |=  AliAODMCParticle::kPhysicalPrim; 
153     else   fMCFlag &= ~AliAODMCParticle::kPhysicalPrim; 
154   }
155
156  protected:
157
158   void                   FindJets();
159   void                   FillJetBranch();
160   Bool_t                 DoInit();
161   void                   InitUtilities();
162   void                   PrepareUtilities();
163   void                   ExecuteUtilities(AliEmcalJet* jet, Int_t ij);
164   void                   TerminateUtilities();
165   Bool_t                 GetSortedArray(Int_t indexes[], std::vector<fastjet::PseudoJet> array) const;
166
167   TString                fTracksName;             // name of track collection
168   TString                fCaloName;               // name of calo cluster collection
169   TString                fJetsName;               // name of jet collection
170   UInt_t                 fJetType;                // jet type (algorithm, radius, constituents)
171   Int_t                  fMinLabelTracks;         // select track constituents with a minimum label index (track->GetLabel())
172   Int_t                  fMaxLabelTracks;         // select track constituents with a maximum label index (track->GetLabel())
173   Int_t                  fMinLabelClusters;       // select cluster constituents with a minimum label index (cluster->GetLabel())
174   Int_t                  fMaxLabelClusters;       // select cluster constituents with a maximum label index (cluster->GetLabel())
175   Int_t                  fMinMCLabel;             // minimum MC label value for the tracks/clusters being considered MC particles
176   Double_t               fRadius;                 // jet radius
177   Double_t               fMinJetTrackPt;          // min jet track momentum (applied before clustering)
178   Double_t               fMinJetClusPt;           // min jet cluster momentum (applied before clustering)
179   Double_t               fPhiMin;                 // minimum phi for constituents (applied before clustering)
180   Double_t               fPhiMax;                 // maximum phi for constituents (applied before clustering)
181   Double_t               fEtaMin;                 // minimum eta for constituents (applied before clustering)
182   Double_t               fEtaMax;                 // maximum eta for constituents (applied before clustering)
183   Double_t               fMinJetArea;             // min area to keep jet in output
184   Double_t               fMinJetPt;               // min jet pt to keep jet in output
185   Double_t               fJetPhiMin;              // minimum phi to keep jet in output
186   Double_t               fJetPhiMax;              // maximum phi to keep jet in output
187   Double_t               fJetEtaMin;              // minimum eta to keep jet in output
188   Double_t               fJetEtaMax;              // maximum eta to keep jet in output
189   Double_t               fGhostArea;              // ghost area
190   Int_t                  fRecombScheme;           // recombination scheme used by fastjet
191   Double_t               fTrackEfficiency;        // artificial tracking inefficiency (0...1)
192   UInt_t                 fMCFlag;                 // select MC particles with flags (e.g. to select physical primaries)
193   Short_t                fGeneratorIndex;         // select MC particles with generator index (default = -1 to switch off selection)
194   TObjArray             *fUtilities;              // jet utilities (gen subtractor, constituent subtractor etc.)
195   Bool_t                 fLocked;                 // true if lock is set
196  
197   Bool_t                 fIsInit;                 //!=true if already initialized
198   Bool_t                 fIsPSelSet;              //!=true if physics selection was set
199   Bool_t                 fIsEmcPart;              //!=true if emcal particles are given as input (for clusters)
200   Bool_t                 fLegacyMode;             //!=true to enable FJ 2.x behavior
201
202   Double_t               fVertex[3];              //!vertex of the current event
203   AliEMCALGeometry      *fGeom;                   //!emcal geometry object
204   TClonesArray          *fJets;                   //!jet collection
205   AliVEvent             *fEvent;                  //!current event
206   TClonesArray          *fTracks;                 //!tracks collection
207   TClonesArray          *fClus;                   //!cluster collection
208   AliFJWrapper           fFastJetWrapper;         //!fastjet wrapper
209
210  private:
211   AliEmcalJetTask(const AliEmcalJetTask&);            // not implemented
212   AliEmcalJetTask &operator=(const AliEmcalJetTask&); // not implemented
213
214   ClassDef(AliEmcalJetTask, 17) // Jet producing task
215 };
216 #endif