AliPhysics  v5-07-18-02 (20ec537)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskEmcal.h
Go to the documentation of this file.
1 #ifndef ALIANALYSISTASKEMCAL_H
2 #define ALIANALYSISTASKEMCAL_H
3 
4 class TClonesArray;
5 class TString;
6 class TList;
7 class AliEmcalParticle;
8 class AliMCParticle;
9 class AliVCluster;
10 class AliVTrack;
11 class AliVParticle;
12 class AliVCaloCells;
13 class TH1;
14 class TProfile;
15 class AliEMCALGeometry;
18 class AliGenPythiaEventHeader;
19 class AliVCaloTrigger;
20 class AliAnalysisUtils;
21 class AliEmcalTriggerPatchInfo;
22 
23 #include "Rtypes.h"
24 
25 #include "AliAnalysisTaskSE.h"
26 
27 class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
28  public:
29 
30  enum BeamType {
31  kNA = -1,
32  kpp = 0,
33  kAA = 1,
34  kpA = 2
35  };
36 
37  enum TriggerType {
38  kND = -1,
39  kJ1 = 0,
40  kJ2 = 1,
41  kG1 = 2,
42  kG2 = 3,
43  kL0 = 4
44  };
45 
46  enum TriggerCategory { // Online trigger categories
50  kTriggerRecalcJet = 3, // Recalculated max trigger patch; does not need to be above trigger threshold
52  };
53 
55  kNoSpecialTreatment, // No special treatment for EMCal triggers
56  kOverlapWithLowThreshold // The overlap between low and high threshold trigger is assigned to the lower threshold only
57  };
58 
60  AliAnalysisTaskEmcal(const char *name, Bool_t histo=kFALSE);
61  virtual ~AliAnalysisTaskEmcal();
62 
66  AliClusterContainer *GetClusterContainer(Int_t i=0) const;
67  AliParticleContainer *GetParticleContainer(const char* name) const;
68  AliClusterContainer *GetClusterContainer(const char* name) const;
69  void RemoveParticleContainer(Int_t i=0) { fParticleCollArray.RemoveAt(i) ; }
70  void RemoveClusterContainer(Int_t i=0) { fClusterCollArray.RemoveAt(i) ; }
71  void SetCaloCellsName(const char *n) { fCaloCellsName = n ; }
73  void SetCaloTriggersName(const char *n) { fCaloTriggersName = n ; }
74  void SetCentRange(Double_t min, Double_t max) { fMinCent = min ; fMaxCent = max ; }
75  void SetCentralityEstimator(const char *c) { fCentEst = c ; }
76  void SetClusName(const char *n) { AddClusterContainer(n) ; }
77  void SetClusPtCut(Double_t cut, Int_t c=0);
78  void SetClusTimeCut(Double_t min, Double_t max, Int_t c=0);
79  void SetEventPlaneVsEmcal(Double_t ep) { fEventPlaneVsEmcal = ep ; }
81  void SetHistoBins(Int_t nbins, Double_t min, Double_t max) { fNbins = nbins; fMinBinPt = min; fMaxBinPt = max ; }
82  void SetIsEmbedded(Bool_t i) { fIsEmbedded = i ; }
83  void SetIsPythia(Bool_t i) { fIsPythia = i ; }
85  void SetMCLabelShift(Int_t s) { fMCLabelShift = s ; }
86  void SetMinMCLabel(Int_t s) { fMinMCLabel = s ; }
87  void SetMinNTrack(Int_t min) { fMinNTrack = min ; }
88  void SetMinPtTrackInEmcal(Double_t min) { fMinPtTrackInEmcal = min ; }
89  void SetNCentBins(Int_t n) { fNcentBins = n ; }
90  void SetNeedEmcalGeom(Bool_t n) { fNeedEmcalGeom = n ; }
91  void SetOffTrigger(UInt_t t) { fOffTrigger = t ; }
92  void SetTrackEtaLimits(Double_t min, Double_t max, Int_t c=0);
93  void SetTrackPhiLimits(Double_t min, Double_t max, Int_t c=0);
94  void SetTrackPtCut(Double_t cut, Int_t c=0);
95  void SetTracksName(const char *n) { AddParticleContainer(n) ; }
96  void SetTrigClass(const char *n) { fTrigClass = n ; }
98  void SetUseAliAnaUtils(Bool_t b, Bool_t bRejPilup = kTRUE) { fUseAliAnaUtils = b ; fRejectPileup = bRejPilup ; }
99  void SetVzRange(Double_t min, Double_t max) { fMinVz = min ; fMaxVz = max ; }
103 
104  protected:
105  void SetRejectionReasonLabels(TAxis* axis);
106  Bool_t AcceptCluster(AliVCluster *clus, Int_t c = 0) const;
107  Bool_t AcceptTrack(AliVParticle *track, Int_t c = 0) const;
108  void AddObjectToEvent(TObject *obj);
109  AliVParticle *GetAcceptParticleFromArray(Int_t p, Int_t c=0) const;
110  AliVCluster *GetAcceptClusterFromArray(Int_t cl, Int_t c=0) const;
111  TClonesArray *GetArrayFromEvent(const char *name, const char *clname=0);
113  TClonesArray *GetParticleArray(Int_t i=0) const;
114  TClonesArray *GetClusterArray(Int_t i=0) const;
115  Int_t GetNParticles(Int_t i=0) const;
116  Int_t GetNClusters(Int_t i=0) const;
117  AliEmcalTriggerPatchInfo *GetMainTriggerPatch(TriggerCategory triggersel = kTriggerLevel1Jet, Bool_t doOfflinSimple = kFALSE);
118  Bool_t HasTriggerType(TriggerType triggersel);
119  ULong_t GetTriggerList();
120  Bool_t PythiaInfoFromFile(const char* currFile, Float_t &fXsec, Float_t &fTrials, Int_t &pthard);
121 
122  // Overloaded AliAnalysisTaskSE methods
124  void UserExec(Option_t *option);
125  Bool_t UserNotify();
126 
127  // Virtual functions, to be overloaded in derived classes
128  virtual void ExecOnce();
129  virtual Bool_t FillGeneralHistograms();
130  virtual Bool_t IsEventSelected();
131  virtual Bool_t RetrieveEventObjects();
132  virtual Bool_t FillHistograms() { return kTRUE ; }
133  virtual Bool_t Run() { return kTRUE ; }
134 
135  // Static utilities
136  static Double_t DeltaPhi(Double_t phia, Double_t phib, Double_t rMin = -TMath::Pi()/2, Double_t rMax = 3*TMath::Pi()/2);
137  static Double_t* GenerateFixedBinArray(Int_t n, Double_t min, Double_t max);
138  static void GenerateFixedBinArray(Int_t n, Double_t min, Double_t max, Double_t* array);
139  static Double_t GetParallelFraction(AliVParticle* part1, AliVParticle* part2);
140  static Double_t GetParallelFraction(const TVector3& vect1, AliVParticle* part2);
141 
142  static Double_t fgkEMCalDCalPhiDivide; // phi value used to distinguish between DCal and EMCal
143 
144  // Task configuration
145  BeamType fForceBeamType; // forced beam type
146  Bool_t fGeneralHistograms; // whether or not it should fill some general histograms
147  Bool_t fInitialized; // whether or not the task has been already initialized
148  Bool_t fCreateHisto; // whether or not create histograms
149  TString fCaloCellsName; // name of calo cell collection
150  TString fCaloTriggersName; // name of calo triggers collection
151  TString fCaloTriggerPatchInfoName; // trigger patch info array name
152  Double_t fMinCent; // min centrality for event selection
153  Double_t fMaxCent; // max centrality for event selection
154  Double_t fMinVz; // min vertex for event selection
155  Double_t fMaxVz; // max vertex for event selection
156  Double_t fTrackPtCut; // cut on track pt in event selection
157  Int_t fMinNTrack; // minimum nr of tracks in event with pT>fTrackPtCut
158  Bool_t fUseAliAnaUtils; // used for LHC13* data: z-vtx, Ncontributors, z-vtx resolution cuts
159  Bool_t fRejectPileup; // Reject pilup using function AliAnalysisUtils::IsPileUpEvent()
160  Bool_t fTklVsClusSPDCut; // Apply tracklet-vs-cluster SPD cut to reject background events in pp
161  UInt_t fOffTrigger; // offline trigger for event selection
162  TString fTrigClass; // trigger class name for event selection
163  TriggerType fTriggerTypeSel; // trigger type to select based on trigger patches
164  Int_t fNbins; // no. of pt bins
165  Double_t fMinBinPt; // min pt in histograms
166  Double_t fMaxBinPt; // max pt in histograms
167  Double_t fMinPtTrackInEmcal; // min pt track in emcal
168  Double_t fEventPlaneVsEmcal; // select events which have a certain event plane wrt the emcal
169  Double_t fMinEventPlane; // minimum event plane value
170  Double_t fMaxEventPlane; // maximum event plane value
171  TString fCentEst; // name of V0 centrality estimator
172  Bool_t fIsEmbedded; // trigger, embedded signal
173  Bool_t fIsPythia; // trigger, if it is a PYTHIA production
174  Int_t fSelectPtHardBin; // select one pt hard bin for analysis
175  Int_t fMinMCLabel; // minimum MC label value for the tracks/clusters being considered MC particles
176  Int_t fMCLabelShift; // if MC label > fMCLabelShift, MC label -= fMCLabelShift
177  Int_t fNcentBins; // how many centrality bins
178  Bool_t fNeedEmcalGeom; // whether or not the task needs the emcal geometry
179  TObjArray fParticleCollArray; // particle/track collection array
180  TObjArray fClusterCollArray; // cluster collection array
181  ULong_t fTriggers; // list of fired triggers
182  EMCalTriggerMode_t fEMCalTriggerMode; // EMCal trigger selection mode
183  Bool_t fUseNewCentralityEstimation; // Use new centrality estimation (for 2015 data)
184 
185  // Service fields
186  AliAnalysisUtils *fAliAnalysisUtils;
187  Bool_t fIsEsd;
188  AliEMCALGeometry *fGeom;
189  TClonesArray *fTracks;
190  TClonesArray *fCaloClusters;
191  AliVCaloCells *fCaloCells;
192  AliVCaloTrigger *fCaloTriggers;
193  TClonesArray *fTriggerPatchInfo;
194  Double_t fCent;
195  Int_t fCentBin;
196  Double_t fEPV0;
197  Double_t fEPV0A;
198  Double_t fEPV0C;
199  Double_t fVertex[3];
200  Int_t fNVertCont;
202  AliGenPythiaEventHeader *fPythiaHeader;
203  Double_t fPtHard;
204  Int_t fPtHardBin;
205  Int_t fNTrials;
206  Float_t fXsection;
207 
208  // Output
209  TList *fOutput;
214  TH1 *fHistTrials;
215  TH1 *fHistEvents;
216  TProfile *fHistXsection;
217  TH1 *fHistPtHard;
223 
224  private:
225  AliAnalysisTaskEmcal(const AliAnalysisTaskEmcal&); // not implemented
226  AliAnalysisTaskEmcal &operator=(const AliAnalysisTaskEmcal&); // not implemented
227 
228  ClassDef(AliAnalysisTaskEmcal, 12) // EMCAL base analysis task
229 };
230 
231 //________________________________________________________________________
232 inline Double_t AliAnalysisTaskEmcal::DeltaPhi(Double_t phia, Double_t phib, Double_t rangeMin, Double_t rangeMax)
233 {
234  // Calculate Delta Phi.
235 
236  Double_t dphi = -999;
237  const Double_t tpi = TMath::TwoPi();
238 
239  if (phia < 0) phia += tpi;
240  else if (phia > tpi) phia -= tpi;
241  if (phib < 0) phib += tpi;
242  else if (phib > tpi) phib -= tpi;
243  dphi = phib - phia;
244  if (dphi < rangeMin) dphi += tpi;
245  else if (dphi > rangeMax) dphi -= tpi;
246 
247  return dphi;
248 }
249 
250 //________________________________________________________________________
251 inline void AliAnalysisTaskEmcal::GenerateFixedBinArray(Int_t n, Double_t min, Double_t max, Double_t* array)
252 {
253  Double_t binWidth = (max-min)/n;
254  array[0] = min;
255  for (Int_t i = 1; i <= n; i++) {
256  array[i] = array[i-1]+binWidth;
257  }
258 }
259 
260 //________________________________________________________________________
261 inline Double_t* AliAnalysisTaskEmcal::GenerateFixedBinArray(Int_t n, Double_t min, Double_t max)
262 {
263  Double_t *array = new Double_t[n+1];
264  GenerateFixedBinArray(n, min, max, array);
265  return array;
266 }
267 
268 #endif
void SetCentRange(Double_t min, Double_t max)
TH1 * fHistTrials
x section from pythia header
static Double_t DeltaPhi(Double_t phia, Double_t phib, Double_t rMin=-TMath::Pi()/2, Double_t rMax=3 *TMath::Pi()/2)
Bool_t AcceptTrack(AliVParticle *track, Int_t c=0) const
Bool_t HasTriggerType(TriggerType triggersel)
Int_t fNTrials
event pt hard bin
void SetMinNTrack(Int_t min)
void SetUseAliAnaUtils(Bool_t b, Bool_t bRejPilup=kTRUE)
AliEmcalTriggerPatchInfo * GetMainTriggerPatch(TriggerCategory triggersel=kTriggerLevel1Jet, Bool_t doOfflinSimple=kFALSE)
void SetUseSPDTrackletVsClusterBG(Bool_t b)
Double_t fPtHard
event Pythia header
void SetTrackPtCut(Double_t cut, Int_t c=0)
Double_t fEPV0
event centrality bin
void SetUseNewCentralityEstimation(Bool_t b)
Bool_t AcceptCluster(AliVCluster *clus, Int_t c=0) const
AliAnalysisTaskEmcal & operator=(const AliAnalysisTaskEmcal &)
void AddObjectToEvent(TObject *obj)
Int_t fCentBin
event centrality
TH1 * fHistEventsAfterSel
total number of trials per pt hard bin after selection
void SetTriggerTypeSel(TriggerType t)
void SetVzRange(Double_t min, Double_t max)
TH1 * fHistEventPlane
z vertex position
TList * fOutput
x-section from pythia header
void SetTracksName(const char *n)
TH1 * fHistEvents
trials from pyxsec.root
void SetClusPtCut(Double_t cut, Int_t c=0)
AliClusterContainer * AddClusterContainer(const char *n)
Double_t fEPV0C
event plane V0A
TH1 * fHistCentrality
pt hard distribution
void SetCaloTriggerPatchInfoName(const char *n)
void SetTrackEtaLimits(Double_t min, Double_t max, Int_t c=0)
AliParticleContainer * GetParticleContainer(Int_t i=0) const
void SetEMCalTriggerMode(EMCalTriggerMode_t m)
TProfile * fHistXsectionAfterSel
total number of events per pt hard bin after selection
EMCalTriggerMode_t fEMCalTriggerMode
virtual Bool_t FillHistograms()
void SetForceBeamType(BeamType f)
Int_t GetNParticles(Int_t i=0) const
TClonesArray * fCaloClusters
tracks
TH1 * fHistTriggerClasses
book keep reasons for rejecting event
AliEMCALGeometry * fGeom
whether it's an ESD analysis
AliGenPythiaEventHeader * fPythiaHeader
event beam type
void SetTrackPhiLimits(Double_t min, Double_t max, Int_t c=0)
AliParticleContainer * AddParticleContainer(const char *n)
AliAnalysisUtils * fAliAnalysisUtils
AliClusterContainer * GetClusterContainer(Int_t i=0) const
virtual Bool_t FillGeneralHistograms()
TClonesArray * GetParticleArray(Int_t i=0) const
BeamType fBeamType
event vertex number of contributors
Double_t fCent
trigger patch info array
Int_t GetNClusters(Int_t i=0) const
Int_t fNVertCont
event vertex
void SetClusName(const char *n)
void RemoveClusterContainer(Int_t i=0)
static Double_t GetParallelFraction(AliVParticle *part1, AliVParticle *part2)
virtual Bool_t RetrieveEventObjects()
void RemoveParticleContainer(Int_t i=0)
TProfile * fHistXsection
total number of events per pt hard bin
Bool_t PythiaInfoFromFile(const char *currFile, Float_t &fXsec, Float_t &fTrials, Int_t &pthard)
void UserExec(Option_t *option)
AliVCaloCells * fCaloCells
clusters
void SetTrigClass(const char *n)
void SetIsEmbedded(Bool_t i)
TClonesArray * GetArrayFromEvent(const char *name, const char *clname=0)
virtual Bool_t IsEventSelected()
TH1 * fHistPtHard
x section from pyxsec.root
static Double_t * GenerateFixedBinArray(Int_t n, Double_t min, Double_t max)
Int_t fPtHardBin
event pt hard
void SetHistoBins(Int_t nbins, Double_t min, Double_t max)
TClonesArray * fTracks
emcal geometry
TH1 * fHistTrialsAfterSel
incoming and selected events
Bool_t fIsEsd
vertex selection (optional)
Double_t fVertex[3]
event plane V0C
TH1 * fHistEventRejection
event plane distribution
void SetMakeGeneralHistograms(Bool_t g)
TClonesArray * fTriggerPatchInfo
calo triggers
TClonesArray * GetClusterArray(Int_t i=0) const
void SetNeedEmcalGeom(Bool_t n)
Double_t fEPV0A
event plane V0
void SetEventPlaneVsEmcal(Double_t ep)
void SetCaloTriggersName(const char *n)
AliVCaloTrigger * fCaloTriggers
cells
void SetRejectionReasonLabels(TAxis *axis)
TH1 * fHistZVertex
event centrality distribution
const Int_t nbins
void SetClusTimeCut(Double_t min, Double_t max, Int_t c=0)
Float_t fXsection
event trials
void SetCaloCellsName(const char *n)
void SetCentralityEstimator(const char *c)
TH1 * fHistEventCount
output list
void SetMinPtTrackInEmcal(Double_t min)
AliVParticle * GetAcceptParticleFromArray(Int_t p, Int_t c=0) const
AliVCluster * GetAcceptClusterFromArray(Int_t cl, Int_t c=0) const
void SetOffTrigger(UInt_t t)
static Double_t fgkEMCalDCalPhiDivide