Charged jets (pPb): Fixes and improvements
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskChargedJetsPA.h
CommitLineData
8628b70c 1#ifndef ALIANALYSISTASKCHARGEDJETSPA_H
2#define ALIANALYSISTASKCHARGEDJETSPA_H
3
12eb4ac1 4//#define DEBUGMODE
8628b70c 5
8628b70c 6class TList;
8628b70c 7class TClonesArray;
8class TString;
9class AliEmcalJet;
10class AliRhoParameter;
11class AliVParticle;
12class AliLog;
3fa9cde0 13class AliAnalysisUtils;
b95d0245 14class TRandom3;
013103f5 15class AliESDtrack;
16
17#include "AliESDtrackCuts.h"
18#include "THn.h"
19
0cf2a402 20const int kMaxMatch=5;
565f94c4 21const double kMaxChi2 = 200;
0cf2a402 22
013103f5 23// Class for the hybrid track cuts
24class AliESDHybridTrackcuts {
25 public:
26 AliESDHybridTrackcuts() : fMainCuts(0), fAdditionalCuts(0) {};
27 AliESDHybridTrackcuts(const AliESDHybridTrackcuts& pd) : fMainCuts(0), fAdditionalCuts(0) {((AliESDHybridTrackcuts &) pd).Copy(*this);};
28 virtual ~AliESDHybridTrackcuts() {delete fAdditionalCuts; delete fMainCuts;};
29
30 virtual void Copy(AliESDHybridTrackcuts &c) const
31 {
32 AliESDHybridTrackcuts& target = (AliESDHybridTrackcuts &) c;
33 target.fAdditionalCuts = fAdditionalCuts;
34 target.fMainCuts = fMainCuts;
35 };
36
37 // Meta function to accept hybrid tracks
38 Int_t AcceptTrack (const AliESDtrack* esdTrack) {
39 if (AcceptNormalTrack(esdTrack))
40 return 1;
41 else if (AcceptAdditionalTrack(esdTrack))
42 return 2;
43 else
44 return 0;
45 };
46
47 Bool_t AcceptNormalTrack (const AliESDtrack* esdTrack) {if(fMainCuts) return fMainCuts->AcceptTrack(esdTrack); else return kFALSE;};
48 Bool_t AcceptAdditionalTrack (const AliESDtrack* esdTrack) {if(fAdditionalCuts) return fAdditionalCuts->AcceptTrack(esdTrack); else return kFALSE;};
49 void SetMainCuts (AliESDtrackCuts* trackCuts) {fMainCuts = trackCuts;};
50 void SetAdditionalCuts (AliESDtrackCuts* trackCuts) {fAdditionalCuts = trackCuts;};
51 AliESDtrackCuts* GetAdditionalCuts () {return fAdditionalCuts;};
52 AliESDtrackCuts* GetMainCuts () {return fMainCuts;};
53
54 AliESDHybridTrackcuts &operator=(const AliESDHybridTrackcuts &c) {if (this != &c) ((AliESDHybridTrackcuts &) c).Copy(*this); return *this;};
55 protected:
56 AliESDtrackCuts* fMainCuts; // trackcut object for the global tracks
57 AliESDtrackCuts* fAdditionalCuts; // trackcut object for the complementary tracks
58
59// ClassDef(AliESDHybridTrackcuts, 2);
60};
8628b70c 61
8628b70c 62class AliAnalysisTaskChargedJetsPA : public AliAnalysisTaskSE {
63 public:
12eb4ac1 64 // ######### CONTRUCTORS/DESTRUCTORS AND STD FUNCTIONS
0cf2a402 65 AliAnalysisTaskChargedJetsPA() : AliAnalysisTaskSE(), fOutputLists(), fCurrentOutputList(0), fDoJetAnalysis(1), fAnalyzeJetProfile(0), fAnalyzeTrackcuts(0), fParticleLevel(0), fUseDefaultVertexCut(1), fUsePileUpCut(1), fSetCentralityToOne(0), fNoExternalBackground(0), fBackgroundForJetProfile(0), fPartialAnalysisNParts(1), fPartialAnalysisIndex(0), fJetArray(0), fTrackArray(0), fBackgroundJetArray(0), fJetArrayName(), fTrackArrayName(), fBackgroundJetArrayName(), fRhoTaskName(), fRandConeRadius(0.4), fSignalJetRadius(0.4), fBackgroundJetRadius(0.4), fNumberExcludedJets(-1), fMinEta(-0.9), fMaxEta(0.9), fMinJetEta(-0.5), fMaxJetEta(0.5), fMinTrackPt(0.150), fMinJetPt(5.0), fMinJetArea(0.5), fMinBackgroundJetPt(0.0), fMinNCrossedRows(70), fUsePtDepCrossedRowsCut(0), fNumberOfCentralityBins(20), fCentralityType("V0A"), fMatchTr(), fMatchChi(), fPrimaryVertex(0), fFirstLeadingJet(0), fSecondLeadingJet(0), fFirstLeadingKTJet(0), fSecondLeadingKTJet(0), fNumberSignalJets(0), fNumberSignalJetsAbove5GeV(0), fRandom(0), fHelperClass(0), fInitialized(0), fTaskInstanceCounter(0), fIsDEBUG(0), fIsPA(1), fNoTerminate(1), fEventCounter(0), fHybridESDtrackCuts(0), fHybridESDtrackCuts_variedPtDep(0), fHybridESDtrackCuts_variedPtDep2(0)
b95d0245 66 {
013103f5 67 // dummy
b95d0245 68 }
0983dd5b 69
013103f5 70 AliAnalysisTaskChargedJetsPA(const char *name, const char* trackArrayName, const char* jetArrayName, const char* backgroundJetArrayName, Bool_t analyzeJetProfile, Bool_t analyzeTrackcuts);
8628b70c 71 virtual ~AliAnalysisTaskChargedJetsPA();
72 virtual void UserCreateOutputObjects();
73 virtual void UserExec(Option_t *option);
392aa819 74 virtual Bool_t UserNotify();
8628b70c 75 virtual void Terminate(Option_t *);
efb9b161 76
12eb4ac1 77 // ######### SETTERS/GETTERS
013103f5 78 void SetDoJetAnalysis(Bool_t val) {fDoJetAnalysis = val;}
2a82f637 79 void SetAnalyzeJetProfile(Bool_t val) {fAnalyzeJetProfile = val;}
013103f5 80 void SetAnalyzeTrackcuts(Bool_t val) {fAnalyzeTrackcuts = val;}
c2b0976c 81 void SetAnalyzePartialEvents(Int_t nParts, Int_t index) {fPartialAnalysisNParts = nParts; fPartialAnalysisIndex = index;}
2a82f637 82 void SetUseDefaultVertexCut (Bool_t val) {fUseDefaultVertexCut = val;}
392aa819 83 void SetUsePileUpCut (Bool_t val) {fUsePileUpCut = val;}
0779c72f 84 void SetNoTerminate (Bool_t val) {fNoTerminate = val;}
013103f5 85 void SetIsPA (Bool_t val) {fIsPA = val;}
9f1e4f53 86 void SetCentralityToOne (Bool_t val) {fSetCentralityToOne = val;}
4bb1bca6 87 void SetNoExternalBackground (Bool_t val) {fNoExternalBackground = val;}
3dff28bc 88 void SetBackgroundForJetProfile (Bool_t val) {fBackgroundForJetProfile = val;}
2d6ed1a3 89 void SetMinNCrossedRows(Int_t val) {fMinNCrossedRows = val;}
e3ed0600 90 void SetUsePtDepCrossedRowsCut(Bool_t val) {fUsePtDepCrossedRowsCut = val;}
91
fa866fc8 92 void SetNumberOfCentralityBins(Int_t val) {fNumberOfCentralityBins = val;}
12eb4ac1 93 void SetTrackMinPt(Double_t minPt) {fMinJetPt = minPt;}
94 void SetSignalJetMinPt(Double_t minPt) {fMinJetPt = minPt;}
95 void SetSignalJetMinArea(Double_t minArea) {fMinJetArea = minArea;}
96 void SetBackgroundJetMinPt(Double_t minPt) {fMinBackgroundJetPt = minPt;}
12eb4ac1 97 void SetRandConeRadius(Double_t radius) {fRandConeRadius = radius;}
98 void SetSignalJetRadius(Double_t radius) {fSignalJetRadius = radius;}
99 void SetBackgroundJetRadius(Double_t radius) {fBackgroundJetRadius = radius;}
12eb4ac1 100 void SetCentralityType(const char* type) {fCentralityType = type;}
06b41974 101 void SetExternalRhoTaskName(const char* name) {fRhoTaskName = name;}
b836a932 102 void SetAcceptanceEta(Double_t minEta, Double_t maxEta) {fMinEta = minEta; fMaxEta = maxEta;}
103 void SetAcceptanceJetEta(Double_t minEta, Double_t maxEta) {fMinJetEta = minEta; fMaxJetEta = maxEta;}
12eb4ac1 104 Int_t GetInstanceCounter() {return fTaskInstanceCounter;}
013103f5 105 void SetCurrentOutputList(Int_t i)
106 {
107 if(i==0)
108 {
109 fCurrentOutputList = fOutputLists[0];
110 }
111 else if(i==1)
112 {
113 if(fAnalyzeJetProfile)
114 fCurrentOutputList = fOutputLists[1];
115 else
116 AliError("Non-existing output list demanded!");
117 }
118 else if(i==2)
119 {
120 if(!fAnalyzeJetProfile && fAnalyzeTrackcuts)
121 fCurrentOutputList = fOutputLists[1];
122 else if(fAnalyzeJetProfile && fAnalyzeTrackcuts)
123 fCurrentOutputList = fOutputLists[2];
124 else
125 AliError("Non-existing output list demanded!");
126 }
127 }
8628b70c 128
129 private:
12eb4ac1 130
131 // ######### MAIN CALCULATION FUNCTIONS
013103f5 132 void InitializeTrackcuts();
133 void GetLeadingJets();
e8df4140 134 Double_t GetCorrectedJetPt(AliEmcalJet* jet, Double_t background);
c2b0976c 135 Double_t GetDeltaPt(Double_t rho, Double_t leadingJetExclusionProbability = 0);
0cb49d99 136
137 void GetKTBackgroundDensityAll(Int_t numberExcludeLeadingJets, Double_t& rhoPbPb, Double_t& rhoPbPbWithGhosts, Double_t& rhoCMS, Double_t& rhoImprovedCMS, Double_t& rhoMean, Double_t& rhoTrackLike);
b95d0245 138 void GetTRBackgroundDensity(Int_t numberExcludeLeadingJets, Double_t& rhoNoExclusion, Double_t& rhoConeExclusion02, Double_t& rhoConeExclusion04, Double_t& rhoConeExclusion06, Double_t& rhoConeExclusion08, Double_t& rhoExactExclusion);
3dff28bc 139 void GetPPBackgroundDensity(Double_t& background);
013103f5 140
12eb4ac1 141 Double_t GetConePt(Double_t eta, Double_t phi, Double_t radius);
271cbc5d 142 Double_t GetCorrectedConePt(Double_t eta, Double_t phi, Double_t radius, Double_t background);
06b41974 143 Double_t GetExternalRho();
013103f5 144 void CreateJetProfilePlots(Double_t bgrd);
145 void CreateCutHistograms();
0cf2a402 146 void CreateITSTPCMatchingHistograms();
12eb4ac1 147 void GetPerpendicularCone(Double_t vecPhi, Double_t vecTheta, Double_t& conePt);
148
149 // ######### CHECK FUNCTIONS
150 Bool_t IsTrackInAcceptance(AliVParticle* track);
151 Bool_t IsTrackInCone(AliVTrack* track, Double_t eta, Double_t phi, Double_t radius);
b95d0245 152 Bool_t IsTrackInJet(AliEmcalJet* jet, Int_t trackIndex);
153 Bool_t IsJetOverlapping(AliEmcalJet* jet1, AliEmcalJet* jet2);
12eb4ac1 154
0cb49d99 155 Bool_t IsEventInAcceptance(AliVEvent* event);
12eb4ac1 156 Bool_t IsBackgroundJetInAcceptance(AliEmcalJet* jet);
ec676623 157 Bool_t IsSignalJetInAcceptance(AliEmcalJet* jet, Bool_t usePtCut = kFALSE);
8628b70c 158
12eb4ac1 159 // ######### HELPER FUNCTIONS
160 Double_t EtaToTheta(Double_t arg);
161 Double_t ThetaToEta(Double_t arg);
162 Double_t GetDeltaPhi(Double_t phi1, Double_t phi2);
163 Double_t MCGetOverlapCircleRectancle(Double_t cPosX, Double_t cPosY, Double_t cRadius, Double_t rPosXmin, Double_t rPosXmax, Double_t rPosYmin, Double_t rPosYmax);
b95d0245 164 Double_t MCGetOverlapMultipleCirclesRectancle(Int_t numCircles, std::vector<Double_t> cPosX, std::vector<Double_t> cPosY, Double_t cRadius, Double_t rPosXmin, Double_t rPosXmax, Double_t rPosYmin, Double_t rPosYmax);
0cf2a402 165 void Match(AliESDtrack* tr0, AliESDtrack* tr1, Int_t& nmatch, Bool_t excludeMom = kFALSE, Double_t rotate=0);
12eb4ac1 166
167 // ######### HISTOGRAM FUNCTIONS
168 void FillHistogram(const char * key, Double_t x);
169 void FillHistogram(const char * key, Double_t x, Double_t y);
170 void FillHistogram(const char * key, Double_t x, Double_t y, Double_t add);
013103f5 171 void FillCutHistogram(const char * key, Double_t cut, Double_t pT, Double_t eta, Double_t phi, Int_t isAdditionalTrack);
172
8628b70c 173 const char* GetHistoName(const char* name)
174 {
013103f5 175 if (fParticleLevel)
7e413f22 176 return Form("%s_MC", name);
177 return Form("%s", name);
8628b70c 178 }
8628b70c 179 template <class T> T* AddHistogram1D(const char* name = "CustomHistogram", const char* title = "NO_TITLE", const char* options = "", Int_t xBins = 100, Double_t xMin = 0.0, Double_t xMax = 20.0, const char* xTitle = "x axis", const char* yTitle = "y axis");
8628b70c 180 template <class T> T* AddHistogram2D(const char* name = "CustomHistogram", const char* title = "NO_TITLE", const char* options = "", Int_t xBins = 100, Double_t xMin = 0.0, Double_t xMax = 20.0, Int_t yBins = 100, Double_t yMin = 0.0, Double_t yMax = 20.0, const char* xTitle = "x axis", const char* yTitle = "y axis", const char* zTitle = "z axis");
013103f5 181 THnF* AddCutHistogram(const char* name, const char* title, const char* cutName, Int_t nBins, Double_t xMin, Double_t xMax);
182 void BinLogAxis(const THn *h, Int_t axisNumber);
8628b70c 183
12eb4ac1 184 // ######### STANDARD FUNCTIONS
8628b70c 185 void Calculate(AliVEvent* event);
186 void ExecOnce();
187 void Init ();
188
013103f5 189 std::vector<TList*> fOutputLists; //! Output lists
190 TList* fCurrentOutputList; //! Currently selected list where the histograms will be saved to
12eb4ac1 191 // ########## USAGE TRIGGERS
013103f5 192 Bool_t fDoJetAnalysis; // trigger if jets/tracks etc. should be analyzed
2a82f637 193 Bool_t fAnalyzeJetProfile; // trigger if jet profile should be analyzed
013103f5 194 Bool_t fAnalyzeTrackcuts; // trigger if trackcuts should be analyzed
195 Bool_t fParticleLevel; // trigger if data is kinematics only (for naming reasons)
2a82f637 196 Bool_t fUseDefaultVertexCut; // trigger if automatic vertex cut from helper class should be done
392aa819 197 Bool_t fUsePileUpCut; // trigger if pileup cut should be done
9f1e4f53 198 Bool_t fSetCentralityToOne; // trigger if centrality val. should be set to one for every event (failsafe)
4bb1bca6 199 Bool_t fNoExternalBackground; // External background is set to 0 (e.g. for PP)
3dff28bc 200 Int_t fBackgroundForJetProfile; // Which background will be subtracted for the profile calculation (0=External,1=Improved CMS,2=CMS,3=PP,4=TR,5=None)
c2b0976c 201 Int_t fPartialAnalysisNParts; // take only every Nth event
202 Int_t fPartialAnalysisIndex; // using e.g. only every 5th event, this specifies which one
203
12eb4ac1 204
8628b70c 205 // ########## SOURCE INFORMATION
206 TClonesArray* fJetArray; //! object containing the jets
207 TClonesArray* fTrackArray; //! object containing the tracks
8628b70c 208 TClonesArray* fBackgroundJetArray; //! object containing background jets
013103f5 209 TString fJetArrayName; // name of object containing the jets
210 TString fTrackArrayName; // name of object containing the tracks
211 TString fBackgroundJetArrayName;// name of object containing event wise bckgrds
06b41974 212 TString fRhoTaskName; // name of rho task for this analysis
8628b70c 213 // ########## JET/DIJET/RC PROPERTIES
214 Double_t fRandConeRadius; // Radius for the random cones
215 Double_t fSignalJetRadius; // Radius for the signal jets
216 Double_t fBackgroundJetRadius; // Radius for the KT background jets
8628b70c 217 Int_t fNumberExcludedJets; // Number of jets to be excluded from backgrounds
8628b70c 218 // ########## CUTS
b836a932 219 Double_t fMinEta; // min eta of tracks
220 Double_t fMaxEta; // max eta of tracks
221 Double_t fMinJetEta; // min eta of jets
222 Double_t fMaxJetEta; // max eta of jets
8628b70c 223 Double_t fMinTrackPt; // Min track pt to be accepted
8628b70c 224 Double_t fMinJetPt; // Min jet pt to be accepted
225 Double_t fMinJetArea; // Min jet area to be accepted
226 Double_t fMinBackgroundJetPt; // Min jet pt to be accepted as background jet
2d6ed1a3 227 Int_t fMinNCrossedRows; // Min number of crossed TPC rows for trackcut analysis
e3ed0600 228 Bool_t fUsePtDepCrossedRowsCut;// Trigger if linear pT dep. for crossed rows cut should be applied
b95d0245 229 Int_t fNumberOfCentralityBins;// Number of centrality bins used for histograms
12eb4ac1 230 TString fCentralityType; // Used centrality estimate (V0A, V0C, V0M, ...)
8628b70c 231
565f94c4 232 AliESDtrack* fMatchTr[kMaxMatch]; //! Helper variables track matching
233 Double_t fMatchChi[kMaxMatch]; //! Helper variables track matching
0cf2a402 234
235
8628b70c 236 // ########## EVENT PROPERTIES
565f94c4 237 const AliVVertex* fPrimaryVertex; //! Vertex found per event
8628b70c 238 AliEmcalJet* fFirstLeadingJet; //! leading jet in event
239 AliEmcalJet* fSecondLeadingJet; //! next to leading jet in event
013103f5 240 AliEmcalJet* fFirstLeadingKTJet; //! leading kT jet in event
241 AliEmcalJet* fSecondLeadingKTJet; //! next to leading kT jet in event
242 Int_t fNumberSignalJets; // Number of signal jets in event
243 Int_t fNumberSignalJetsAbove5GeV; // Number of signal jets in event > 5GeV
8628b70c 244 // ########## GENERAL VARS
245 TRandom3* fRandom; //! A random number
3fa9cde0 246 AliAnalysisUtils* fHelperClass; //! Vertex selection helper
013103f5 247 Bool_t fInitialized; // trigger if tracks/jets are loaded
8628b70c 248 Int_t fTaskInstanceCounter; // for naming reasons
b95d0245 249 Bool_t fIsDEBUG; // Debug trigger
013103f5 250 Bool_t fIsPA; // pPb trigger
0779c72f 251 Bool_t fNoTerminate; // don't use terminate routines
c2b0976c 252 ULong_t fEventCounter; // Internal event counter
013103f5 253 AliESDHybridTrackcuts* fHybridESDtrackCuts; //! these trackcuts are applied
e3ed0600 254 AliESDHybridTrackcuts* fHybridESDtrackCuts_variedPtDep; //! these trackcuts are applied
255 AliESDHybridTrackcuts* fHybridESDtrackCuts_variedPtDep2; //! these trackcuts are applied
013103f5 256
12eb4ac1 257 AliAnalysisTaskChargedJetsPA(const AliAnalysisTaskChargedJetsPA&);
258 AliAnalysisTaskChargedJetsPA& operator=(const AliAnalysisTaskChargedJetsPA&);
8628b70c 259
013103f5 260 ClassDef(AliAnalysisTaskChargedJetsPA, 3); // Charged jet analysis for pA
8628b70c 261
262};
263#endif