First update for AOD compatibility (distributions and efficiency), still missing...
[u/mrichter/AliRoot.git] / PWGCF / EBYE / NetParticle / AliAnalysisNetParticleHelper.h
1 //-*- Mode: C++ -*-
2
3 #ifndef ALIANALYSISNETPARTICLEHELPER_H
4 #define ALIANALYSISNETPARTICLEHELPER_H
5
6 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7  * See cxx source for full Copyright notice                               */
8  
9 // Helper Class for for NetParticle Distributions
10 // Authors: Jochen Thaeder <jochen@thaeder.de>
11
12 #include "THnSparse.h"
13 #include "TParticle.h"
14 #include "TH1F.h"
15 #include "TF1.h"
16
17 class AliESDtrack;
18 class AliMCEvent;
19 class AliStack;
20 class AliPIDResponse;
21 class AliESDInputHandler;
22 class AliAODInputHandler;
23 class AliAODEvent;
24 class AliAODTrack;
25 class AliAODMCParticle;
26
27 class AliAnalysisNetParticleHelper : public TNamed {
28
29  public:
30
31   /*
32    * ---------------------------------------------------------------------------------
33    *                            Constructor / Destructor
34    * ---------------------------------------------------------------------------------
35    */
36
37   AliAnalysisNetParticleHelper();
38   virtual ~AliAnalysisNetParticleHelper();
39
40   /*
41    * ---------------------------------------------------------------------------------
42    *                                    Setter
43    * ---------------------------------------------------------------------------------
44    */
45
46   void SetCentralityBinMax(Int_t d)                  {fCentralityBinMax    = d;}
47   void SetVertexZMax(Float_t f)                      {fVertexZMax          = f;}
48   void SetRapidityMax(Float_t f)                     {fRapidityMax         = f;}
49   void SetMinTrackLengthMC(Float_t f)                {fMinTrackLengthMC    = f;}
50   void SetNSigmaMaxCdd(Float_t f)                    {fNSigmaMaxCdd        = f;}
51   void SetNSigmaMaxCzz(Float_t f)                    {fNSigmaMaxCzz        = f;}
52
53   void SetParticleSpecies(AliPID::EParticleType pid) {fParticleSpecies     = pid;}
54   void SetControlParticleSpecies(Int_t pdgCode, Bool_t isNeutral, TString name) {
55     fControlParticleCode = pdgCode;
56     fControlParticleIsNeutral = isNeutral;
57     fControlParticleName = name;
58   }
59
60   void SetNSigmaMaxTPC(Float_t f)                    {fNSigmaMaxTPC        = f;}
61   void SetNSigmaMaxTOF(Float_t f)                    {fNSigmaMaxTOF        = f;}
62   void SetMinPtForTOFRequired(Float_t f)             {fMinPtForTOFRequired = f;}
63
64   /*
65    * ---------------------------------------------------------------------------------
66    *                                    Getter
67    * ---------------------------------------------------------------------------------
68    */
69   
70   AliPID::EParticleType GetParticleSpecies(){return fParticleSpecies;}
71
72   TH1F*    GetHEventStat0()                  {return fHEventStat0;}
73   TH1F*    GetHEventStat1()                  {return fHEventStat1;}
74   TH1F*    GetHTriggerStat()                 {return fHTriggerStat;}
75   TH1F*    GetHCentralityStat()              {return fHCentralityStat;}
76
77   Int_t    GetCentralityBin()                {return fCentralityBin;}
78   Float_t  GetCentralityPercentile()         {return fCentralityPercentile;}
79
80   Int_t    GetControlParticleCode()          {return fControlParticleCode;}
81   Bool_t   IsControlParticleNeutral()        {return fControlParticleIsNeutral;}
82   TString& GetControlParticleName()          {return fControlParticleName;}
83
84   /*
85    * ---------------------------------------------------------------------------------
86    *                                 Public Methods
87    * ---------------------------------------------------------------------------------
88    */
89
90   /** Initialize Helper */
91   Int_t Initialize(Bool_t isMC);
92
93   /** Setup Event */
94   Int_t SetupEvent(AliESDInputHandler *esdHandler, AliAODInputHandler *aodHandler, AliMCEvent *mcEvent);
95
96   /*
97    * ---------------------------------------------------------------------------------
98    *                         Event / Trigger Statistics
99    * ---------------------------------------------------------------------------------
100    */
101
102   /** Check if event is triggred */
103   Bool_t IsEventTriggered();
104
105   /** Fill event cut statistics */
106   Bool_t IsEventRejected();
107
108   /*
109    * ---------------------------------------------------------------------------------
110    *                         Accept Particle Methods - private
111    * ---------------------------------------------------------------------------------
112    */
113   
114   /** Check if charged MC particle is accepted for basic parameters */
115   /** NOT possible for AODs (AliAODMCParticle NOT from TParticle)*/
116   Bool_t IsParticleAcceptedBasicCharged(TParticle *particle, Int_t idxMC);
117   Bool_t IsParticleAcceptedBasicCharged(AliAODMCParticle *particle);
118
119   /** Check if neutral MC particle is accepted for basic parameters */
120   /** NOT possible for AODs (AliAODMCParticle NOT from TParticle)*/
121   Bool_t IsParticleAcceptedBasicNeutral(TParticle *particle, Int_t idxMC);
122   Bool_t IsParticleAcceptedBasicNeutral(AliAODMCParticle *particle);
123  
124   /** Check if MC particle is accepted for Rapidity */
125   Bool_t IsParticleAcceptedRapidity(TParticle *particle, Double_t &yP);
126
127   /** Check if MC particle is findable tracks */
128   Bool_t IsParticleFindable(Int_t label);
129     
130   /*
131    * ---------------------------------------------------------------------------------
132    *                            Accept Track Methods - public
133    * ---------------------------------------------------------------------------------
134    */
135   
136   /** Check if track is accepted for basic parameters */
137   /** NOT possible with AliVTrack (GetInnerParam returns NULL) */
138   Bool_t IsTrackAcceptedBasicCharged(AliESDtrack *track);
139   Bool_t IsTrackAcceptedBasicCharged(AliAODTrack *track);
140   
141   /** Check if track is accepted for Rapidity */
142   Bool_t IsTrackAcceptedRapidity(AliVTrack *track, Double_t &yP);
143
144   /** Check if track is accepted for DCA */
145   Bool_t IsTrackAcceptedDCA(AliESDtrack *track);
146
147   /** Check if track is accepted for PID */
148   Bool_t IsTrackAcceptedPID(AliVTrack *track, Double_t *pid);
149
150   /*
151    * ---------------------------------------------------------------------------------
152    *                         Helper Methods
153    * ---------------------------------------------------------------------------------
154    */
155
156   /** Update eta corrected TPC pid */
157   void  UpdateEtaCorrectedTPCPid();
158
159   /** Get efficiency correctionf of particle dependent on (eta, phi, pt, centrality) */
160   Double_t GetTrackbyTrackCorrectionFactor(Double_t *aTrack,  Int_t flag);
161   
162   /** Method for the correct logarithmic binning of histograms */
163   void BinLogAxis(const THnSparseF *h, Int_t axisNumber);
164
165   ///////////////////////////////////////////////////////////////////////////////////
166
167  private:
168
169   AliAnalysisNetParticleHelper(const AliAnalysisNetParticleHelper&); // not implemented
170   AliAnalysisNetParticleHelper& operator=(const AliAnalysisNetParticleHelper&); // not implemented
171
172   /*
173    * ---------------------------------------------------------------------------------
174    *                           Initialize - Private
175    * ---------------------------------------------------------------------------------
176    */
177
178   /**  Initialize event cut statistics */
179   void InitializeEventStats();
180
181   /**  Initialize trigger statistics */
182   void InitializeTriggerStats();
183
184   /**  Initialize centrality statistics */
185   void InitializeCentralityStats();
186
187   /** Initialize eta correction maps for TPC pid */
188   Int_t InitializeEtaCorrection(Bool_t isMC);
189
190   /** Initialize track by track correction matrices */
191   Int_t InitializeTrackbyTrackCorrection();
192
193   /*
194    * ---------------------------------------------------------------------------------
195    *                         Event / Trigger Statistics - private
196    * ---------------------------------------------------------------------------------
197    */
198   
199   /** Fill event cut statistics */
200   Bool_t FillEventStats(Int_t *aEventCuts);
201
202   /*
203    * ---------------------------------------------------------------------------------
204    *                             Members - private
205    * ---------------------------------------------------------------------------------
206    */
207
208   AliESDInputHandler   *fESDHandler;               //! Ptr to ESD handler 
209   AliPIDResponse       *fPIDResponse;              //! Ptr to PID response Object
210   AliESDEvent          *fESD;                      //! Ptr to ESD event
211   AliAODInputHandler   *fAODHandler;               //! Ptr to AOD handler 
212   AliAODEvent          *fAOD;                      //! Ptr to AOD event
213   AliMCEvent           *fMCEvent;                  //! Ptr to MC event
214   AliStack             *fStack;                    //! Ptr to stack
215
216   // =======================================================================
217
218   Int_t                 fCentralityBin;            //  Centrality bin of current event within max centrality bin
219   Float_t               fCentralityPercentile;     //  Centrality percentile of current event
220   // ----------------------------------------------------------------------
221   Int_t                 fCentralityBinMax;         //  Max centrality bin to be used
222   Float_t               fVertexZMax;               //  VertexZ cut
223   Float_t               fRapidityMax;              //  Rapidity cut
224   Float_t               fMinTrackLengthMC;         //  Min track length for MC tracks
225   Float_t               fNSigmaMaxCdd;             //  N Sigma for dcar / sqrt(cdd) - turn off with 0.
226   Float_t               fNSigmaMaxCzz;             //  N Sigma for dcaz / sqrt(czz) - turn off with 0.
227   // -----------------------------------------------------------------------
228   AliPID::EParticleType fParticleSpecies;          //  Particle species on basis of AliPID
229   Int_t                 fControlParticleCode;      //  PDG code control particle
230   Bool_t                fControlParticleIsNeutral; //  Is control particle neutral
231   TString               fControlParticleName;      //  Name of control particle
232   // -----------------------------------------------------------------------
233   Float_t               fNSigmaMaxTPC;             //  N Sigma for TPC PID
234   Float_t               fNSigmaMaxTOF;             //  N Sigma for TOF PID
235   Float_t               fMinPtForTOFRequired;      //  Min pt from where TOF is required
236
237   // =======================================================================
238
239   TH1F                 *fHEventStat0;              //  Event cut statistics
240   TH1F                 *fHEventStat1;              //  Event cut statistics - incremental
241   Int_t                 fHEventStatMax;            //  Max N cuts to be included in HEventStat
242   // -----------------------------------------------------------------------
243   TH1F                 *fHTriggerStat;             //  Trigger statistics
244   Int_t                 fNTriggers;                //  N triggers used
245   // -----------------------------------------------------------------------
246   TH1F                 *fHCentralityStat;          //  Centrality statistics
247   Int_t                 fNCentralityBins;          //  N centrality bins used
248
249   // =======================================================================
250
251   TF1                  *fEtaCorrFunc;              //! Eta correction function for TPC dE/dx  
252   THnSparseF         ***fCorr0;                    // Correction matrices for particle / anti-particle
253   THnSparseF         ***fCorr1;                    // Correction matrices [cross section corrected] matrices for particle/ anti-particle
254   // -----------------------------------------------------------------------
255
256   ClassDef(AliAnalysisNetParticleHelper, 1);
257 };
258
259 #endif