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