]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskChargedJetsPA.h
Charged jets (pPb): Allow arbitrary eta ranges
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskChargedJetsPA.h
1 #ifndef ALIANALYSISTASKCHARGEDJETSPA_H
2 #define ALIANALYSISTASKCHARGEDJETSPA_H
3
4 //#define DEBUGMODE
5
6 class TH1F;
7 class TH2F;
8 class TList;
9 class TClonesArray;
10 class TString;
11 class AliEmcalJet;
12 class AliRhoParameter;
13 class AliVParticle;
14 class AliLog;
15 class AliAnalysisUtils;
16 class TRandom3;
17
18 class AliAnalysisTaskChargedJetsPA : public AliAnalysisTaskSE {
19  public:
20   // ######### CONTRUCTORS/DESTRUCTORS AND STD FUNCTIONS
21   AliAnalysisTaskChargedJetsPA() : AliAnalysisTaskSE(), fOutputList(0), fAnalyzeJets(1), fAnalyzeJetProfile(1), fAnalyzeQA(1), fAnalyzeBackground(1), fAnalyzeDeprecatedBackgrounds(1), fAnalyzePythia(0), fAnalyzeMassCorrelation(0), fHasTracks(0), fHasJets(0), fHasBackgroundJets(0), fIsKinematics(0), fUseDefaultVertexCut(1), fUsePileUpCut(1), fSetCentralityToOne(0), fNoExternalBackground(0), fBackgroundForJetProfile(0), fPartialAnalysisNParts(1), fPartialAnalysisIndex(0), fJetArray(0), fTrackArray(0), fBackgroundJetArray(0), fJetArrayName(0), fTrackArrayName(0), fBackgroundJetArrayName(0), fNumPtHardBins(11), fUsePtHardBin(-1), fRhoTaskName(), fNcoll(6.88348), fRandConeRadius(0.4), fSignalJetRadius(0.4), fBackgroundJetRadius(0.4), fTRBackgroundConeRadius(0.6), fNumberRandCones(8), fNumberExcludedJets(-1), fDijetMaxAngleDeviation(10.0), fBackgroundJetEtaWindow(0.5), fMinEta(-0.9), fMaxEta(0.9), fMinJetEta(-0.5), fMaxJetEta(0.5), fMinTrackPt(0.150), fMinJetPt(0.15), fMinJetArea(0.5), fMinBackgroundJetPt(0.0), fMinDijetLeadingPt(10.0), fNumberOfCentralityBins(20), fCentralityType("V0A"), fFirstLeadingJet(0), fSecondLeadingJet(0), fNumberSignalJets(0), fCrossSection(0.0), fTrials(0.0),  fRandom(0), fHelperClass(0), fInitialized(0), fTaskInstanceCounter(0), fHistList(0), fHistCount(0), fIsDEBUG(0), fEventCounter(0)
22   {
23     for(Int_t i=0;i<1024;i++)
24       fSignalJets[i] = NULL;
25   }
26
27   AliAnalysisTaskChargedJetsPA(const char *name, const char* trackArrayName, const char* jetArrayName, const char* backgroundJetArrayName);
28   virtual ~AliAnalysisTaskChargedJetsPA();
29   virtual void     UserCreateOutputObjects();
30   virtual void     UserExec(Option_t *option);
31   virtual Bool_t   UserNotify();
32   virtual void     Terminate(Option_t *);
33
34   // ######### SETTERS/GETTERS
35   void        SetAnalyzeJets(Bool_t val) {fAnalyzeJets = val;}
36   void        SetAnalyzeJetProfile(Bool_t val) {fAnalyzeJetProfile = val;}
37   void        SetAnalyzeQA(Bool_t val) {fAnalyzeQA = val;}
38   void        SetAnalyzeBackground(Bool_t val) {fAnalyzeBackground = val;}
39   void        SetAnalyzeDeprecatedBackgrounds(Bool_t val) {fAnalyzeDeprecatedBackgrounds = val;}
40   void        SetAnalyzePythia(Bool_t val) {fAnalyzePythia = val;}
41   void        SetAnalyzeMassCorrelation(Bool_t val) {fAnalyzeMassCorrelation = val;}
42   void        SetAnalyzePartialEvents(Int_t nParts, Int_t index) {fPartialAnalysisNParts = nParts; fPartialAnalysisIndex = index;}
43   void        SetUseDefaultVertexCut (Bool_t val) {fUseDefaultVertexCut = val;}
44   void        SetUsePileUpCut (Bool_t val) {fUsePileUpCut = val;}
45   void        SetCentralityToOne (Bool_t val) {fSetCentralityToOne = val;}
46   void        SetNoExternalBackground (Bool_t val) {fNoExternalBackground = val;}
47   void        SetBackgroundForJetProfile (Bool_t val) {fBackgroundForJetProfile = val;}
48   void        SetNumberOfCentralityBins(Int_t val) {fNumberOfCentralityBins = val;} 
49   void        SetTrackMinPt(Double_t minPt) {fMinJetPt = minPt;}
50   void        SetSignalJetMinPt(Double_t minPt) {fMinJetPt = minPt;}
51   void        SetSignalJetMinArea(Double_t minArea) {fMinJetArea = minArea;}
52   void        SetBackgroundJetMinPt(Double_t minPt) {fMinBackgroundJetPt = minPt;}
53   void        SetDijetLeadingMinPt(Double_t minPt) {fMinDijetLeadingPt = minPt;}
54   void        SetNumberOfPtHardBins(Int_t count) {fNumPtHardBins = count;}
55   void        SetUsePtHardBin(Int_t number) {fUsePtHardBin = number;}
56   void        SetNumberOfRandConesPerEvent(Int_t count) {fNumberRandCones = count;}
57   void        SetRandConeRadius(Double_t radius) {fRandConeRadius = radius;}
58   void        SetSignalJetRadius(Double_t radius) {fSignalJetRadius = radius;}
59   void        SetBackgroundJetRadius(Double_t radius) {fBackgroundJetRadius = radius;}
60   void        SetTRBackgroundConeRadius(Double_t radius) {fTRBackgroundConeRadius = radius;}
61   void        SetCentralityType(const char* type) {fCentralityType = type;}
62   void        SetExternalRhoTaskName(const char* name) {fRhoTaskName = name;}
63   void        SetDijetMaxAngleDeviation(Double_t degrees) {fDijetMaxAngleDeviation = degrees/360.0 * TMath::TwoPi();} // degrees are more comfortable
64   void        SetAcceptanceEta(Double_t minEta, Double_t maxEta) {fMinEta = minEta; fMaxEta = maxEta;}
65   void        SetAcceptanceJetEta(Double_t minEta, Double_t maxEta) {fMinJetEta = minEta; fMaxJetEta = maxEta;}
66   Int_t       GetInstanceCounter() {return fTaskInstanceCounter;}
67
68  private:
69
70   // ######### MAIN CALCULATION FUNCTIONS
71   void        GetSignalJets();
72   Int_t       GetLeadingJets(TClonesArray* jetArray, Int_t* jetIDArray, Bool_t isSignalJets);
73   Double_t    GetCorrectedJetPt(AliEmcalJet* jet, Double_t background);
74   Double_t    GetDeltaPt(Double_t rho, Double_t leadingJetExclusionProbability = 0);
75
76   void        GetKTBackgroundDensityAll(Int_t numberExcludeLeadingJets, Double_t& rhoPbPb, Double_t& rhoPbPbWithGhosts, Double_t& rhoCMS, Double_t& rhoImprovedCMS, Double_t& rhoMean, Double_t& rhoTrackLike);
77   void        GetKTBackgroundDensity(Int_t numberExcludeLeadingJets, Double_t& rhoImprovedCMS);
78
79   void        GetTRBackgroundDensity(Int_t numberExcludeLeadingJets, Double_t& rhoNoExclusion, Double_t& rhoConeExclusion02, Double_t& rhoConeExclusion04, Double_t& rhoConeExclusion06, Double_t& rhoConeExclusion08, Double_t& rhoExactExclusion);
80   void        GetTRBackgroundDensity(Int_t numberExcludeLeadingJets, Double_t& rhoMean, Double_t& area, AliEmcalJet* excludeJet1, AliEmcalJet* excludeJet2, Bool_t doSearchPerpendicular);
81   void        GetPPBackgroundDensity(Double_t& background);
82   Double_t    GetConePt(Double_t eta, Double_t phi, Double_t radius);
83   Double_t    GetCorrectedConePt(Double_t eta, Double_t phi, Double_t radius, Double_t background);
84   Double_t    GetPtHard();
85   Double_t    GetPythiaTrials();
86   Int_t       GetPtHardBin();
87   Double_t    GetExternalRho();
88
89   void        GetPerpendicularCone(Double_t vecPhi, Double_t vecTheta, Double_t& conePt);
90
91   // ######### CHECK FUNCTIONS
92   Bool_t      IsTrackInAcceptance(AliVParticle* track);
93   Bool_t      IsTrackInCone(AliVTrack* track, Double_t eta, Double_t phi, Double_t radius);
94   Bool_t      IsTrackInJet(AliEmcalJet* jet, Int_t trackIndex);
95   Bool_t      IsJetOverlapping(AliEmcalJet* jet1, AliEmcalJet* jet2);
96
97   Bool_t      IsEventInAcceptance(AliVEvent* event);
98   Bool_t      IsBackgroundJetInAcceptance(AliEmcalJet* jet);
99   Bool_t      IsSignalJetInAcceptance(AliEmcalJet* jet);
100   Bool_t      IsDijet(AliEmcalJet* jet1, AliEmcalJet* jet2);
101   
102   // ######### HELPER FUNCTIONS
103   Double_t    EtaToTheta(Double_t arg);
104   Double_t    ThetaToEta(Double_t arg);
105   Double_t    GetDeltaPhi(Double_t phi1, Double_t phi2);
106   Double_t    MCGetOverlapCircleRectancle(Double_t cPosX, Double_t cPosY, Double_t cRadius, Double_t rPosXmin, Double_t rPosXmax, Double_t rPosYmin, Double_t rPosYmax);
107   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);
108
109
110   // ######### HISTOGRAM FUNCTIONS
111   void        FillHistogram(const char * key, Double_t x);
112   void        FillHistogram(const char * key, Double_t x, Double_t y);
113   void        FillHistogram(const char * key, Double_t x, Double_t y, Double_t add);
114   const char* GetHistoName(const char* name)
115   {
116     if (fIsKinematics)    
117       return Form("%s_MC", name);
118     return Form("%s", name);
119   }
120   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");
121   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");
122
123   // ######### STANDARD FUNCTIONS
124   void      Calculate(AliVEvent* event);
125   void      ExecOnce();
126   void      Init ();
127
128   TList*              fOutputList;            //! Output list
129   // ########## USAGE TRIGGERS 
130   Bool_t              fAnalyzeJets;           // trigger if jets should be processed
131   Bool_t              fAnalyzeJetProfile;     // trigger if jet profile should be analyzed
132   Bool_t              fAnalyzeQA;             // trigger if QA should be done
133   Bool_t              fAnalyzeBackground;     // trigger if background should be processed
134   Bool_t              fAnalyzeDeprecatedBackgrounds; // trigger if old background estimates should be processed
135   Bool_t              fAnalyzePythia;         // trigger if pythia properties should be processed
136   Bool_t              fAnalyzeMassCorrelation;// trigger if jet pt/constituent mass should be compared
137   Bool_t              fHasTracks;             // trigger if tracks are actually valid
138   Bool_t              fHasJets;               // trigger if jets are actually valid
139   Bool_t              fHasBackgroundJets;     // trigger if background is actually valid
140   Bool_t              fIsKinematics;          // trigger if data is kinematics only (for naming reasons)
141   Bool_t              fUseDefaultVertexCut;   // trigger if automatic vertex cut from helper class should be done
142   Bool_t              fUsePileUpCut;          // trigger if pileup cut should be done
143   Bool_t              fSetCentralityToOne;    // trigger if centrality val. should be set to one for every event (failsafe)
144   Bool_t              fNoExternalBackground;  // External background is set to 0 (e.g. for PP)
145   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)
146   Int_t               fPartialAnalysisNParts; // take only every Nth event
147   Int_t               fPartialAnalysisIndex;  // using e.g. only every 5th event, this specifies which one
148   
149
150   // ########## SOURCE INFORMATION
151   TClonesArray*       fJetArray;              //! object containing the jets
152   TClonesArray*       fTrackArray;            //! object containing the tracks
153   TClonesArray*       fBackgroundJetArray;    //! object containing background jets
154   TString*            fJetArrayName;          // name of object containing the jets
155   TString*            fTrackArrayName;        // name of object containing the tracks
156   TString*            fBackgroundJetArrayName;// name of object containing event wise bckgrds
157   Int_t               fNumPtHardBins;         // Number of used pt hard bins
158   Int_t               fUsePtHardBin;          // That pt hard bin will be analyzed when not -1
159   TString             fRhoTaskName;           // name of rho task for this analysis
160   // ########## JET/DIJET/RC PROPERTIES
161   Double_t            fNcoll;                 // Variable for Ncoll
162   Double_t            fRandConeRadius;        // Radius for the random cones
163   Double_t            fSignalJetRadius;       // Radius for the signal jets
164   Double_t            fBackgroundJetRadius;   // Radius for the KT background jets
165   Double_t            fTRBackgroundConeRadius;// Radius for the jets excluded in track background
166   Int_t               fNumberRandCones;       // Number of random cones to be put into one event
167   Int_t               fNumberExcludedJets;    // Number of jets to be excluded from backgrounds
168   Double_t            fDijetMaxAngleDeviation;// Max angle deviation from pi between two jets to be accept. as dijet
169   // ########## CUTS 
170   Double_t            fBackgroundJetEtaWindow;// +- window in eta for background jets
171   Double_t            fMinEta;                // min eta of tracks
172   Double_t            fMaxEta;                // max eta of tracks
173   Double_t            fMinJetEta;             // min eta of jets
174   Double_t            fMaxJetEta;             // max eta of jets
175   Double_t            fMinTrackPt;            // Min track pt to be accepted
176   Double_t            fMinJetPt;              // Min jet pt to be accepted
177   Double_t            fMinJetArea;            // Min jet area to be accepted
178   Double_t            fMinBackgroundJetPt;    // Min jet pt to be accepted as background jet
179   Double_t            fMinDijetLeadingPt;     // Min jet pt to be accepted as constituent of dijet 
180   Int_t               fNumberOfCentralityBins;// Number of centrality bins used for histograms
181   TString             fCentralityType;        // Used centrality estimate (V0A, V0C, V0M, ...)
182
183   // ########## EVENT PROPERTIES
184   AliEmcalJet*        fFirstLeadingJet;       //! leading jet in event
185   AliEmcalJet*        fSecondLeadingJet;      //! next to leading jet in event
186   Int_t               fNumberSignalJets;      //! Number of signal jets in event
187   AliEmcalJet*        fSignalJets[1024];      //! memory for signal jet pointers
188   Double_t            fCrossSection;          //! value is filled, if pythia header is accessible
189   Double_t            fTrials;                //! value is filled, if pythia header is accessible
190
191   // ########## GENERAL VARS
192   TRandom3*           fRandom;                //! A random number
193   AliAnalysisUtils*   fHelperClass;           //! Vertex selection helper
194   Bool_t              fInitialized;           //! trigger if tracks/jets are loaded
195   Int_t               fTaskInstanceCounter;   // for naming reasons
196   TList*              fHistList;              // Histogram list
197   Int_t               fHistCount;             // Histogram count
198   Bool_t              fIsDEBUG;               // Debug trigger
199   ULong_t             fEventCounter;          // Internal event counter
200   AliAnalysisTaskChargedJetsPA(const AliAnalysisTaskChargedJetsPA&);
201   AliAnalysisTaskChargedJetsPA& operator=(const AliAnalysisTaskChargedJetsPA&);
202
203   ClassDef(AliAnalysisTaskChargedJetsPA, 2); // Charged jet analysis for pA
204
205 };
206 #endif