]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonAnalysisBase.h
Refining the kRatio PID mode
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliProtonAnalysisBase.h
1 #ifndef ALIPROTONANALYSISBASE_H
2 #define ALIPROTONANALYSISBASE_H
3
4 /*  See cxx source for full Copyright notice */
5
6
7 /* $Id: AliProtonAnalysisBase.h 31056 2009-02-16 14:31:41Z pchrist $ */
8
9 //-------------------------------------------------------------------------
10 //                       Class AliProtonAnalysisBase
11 //   This is the base class for the baryon (proton) analysis
12 //
13 //    Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch
14 //-------------------------------------------------------------------------
15
16 #include "TObject.h"
17 #include "TString.h"
18 class TF1;
19 class TCanvas;
20 class TList;
21
22 #include "AliPhysicsSelection.h"
23 #include "AliBackgroundSelection.h"
24 #include "AliPID.h"
25 class AliESDEvent;
26 class AliESDtrack;
27 class AliESDVertex;
28
29 class AliProtonAnalysisBase : public TObject {
30  public:
31   enum TriggerMode { kMB1 = 0, kMB2, kSPDFASTOR };
32   enum AnalysisMode { kInvalid = -1, kTPC = 0, kHybrid, kGlobal };
33   enum PIDMode { kBayesian = 0, kRatio, kSigma};
34
35   AliProtonAnalysisBase();
36   virtual ~AliProtonAnalysisBase();
37
38   void SetAnalysisLevel(const char* type) {fProtonAnalysisLevel = type;}
39   void SetAnalysisMode(AnalysisMode analysismode) {fProtonAnalysisMode = analysismode;}
40   void SetEtaMode() {fAnalysisEtaMode = kTRUE;}
41   void SetTriggerMode(TriggerMode triggermode) {
42     fAnalysisMC = kTRUE; fTriggerMode = triggermode;}
43   void SetPIDMode(PIDMode pidmode) {fProtonPIDMode = pidmode;}
44
45   const char *GetAnalysisLevel() {return fProtonAnalysisLevel.Data();}
46   AnalysisMode GetAnalysisMode() const {return fProtonAnalysisMode;}
47   Bool_t GetEtaMode() const {return fAnalysisEtaMode;}
48   TriggerMode GetTriggerMode() const {return fTriggerMode;}
49   PIDMode GetPIDMode() const {return fProtonPIDMode;}
50   Bool_t GetMCAnalysisMode() {return fAnalysisMC;}
51
52   const  AliESDVertex *GetVertex(AliESDEvent *esd,
53                                  AnalysisMode mode,
54                                  Double_t gVx = 100.,
55                                  Double_t gVy = 100.,
56                                  Double_t gVz = 100.);
57   void SetAcceptedVertexDiamond(Double_t gVx, Double_t gVy, Double_t gVz) {
58     fVxMax = gVx; fVyMax = gVy; fVzMax = gVz;}
59   Double_t GetVxMax() const {return fVxMax;}
60   Double_t GetVyMax() const {return fVyMax;}
61   Double_t GetVzMax() const {return fVzMax;}
62   void SetMinNumOfContributors(Int_t nContributors) {
63     fMinNumOfContributors = nContributors;}
64   Int_t GetMinNumOfContributors() {return fMinNumOfContributors;}
65
66   void SetPhaseSpace(Int_t nBinsX, Double_t gXmin, Double_t gXmax,
67                      Int_t nBinsY, Double_t gYmin, Double_t gYmax) {
68     fNBinsX = nBinsX; fMinX = gXmin; fMaxX = gXmax;
69     fNBinsY = nBinsY; fMinY = gYmin; fMaxY = gYmax;
70   }
71   Int_t GetNBinsX() const {return fNBinsX;}
72   Int_t GetNBinsY() const {return fNBinsY;}
73   Double_t GetMinX() const {return fMinX;}
74   Double_t GetMinY() const {return fMinY;}
75   Double_t GetMaxX() const {return fMaxX;}
76   Double_t GetMaxY() const {return fMaxY;}
77
78   //Trigger
79   Bool_t IsOnlineTriggerUsed() {return kUseOnlineTrigger;}
80   void UseOnlineTrigger() {kUseOnlineTrigger = kTRUE;}
81   Bool_t IsEventTriggered(const AliESDEvent *esd,
82                           TriggerMode trigger = kMB2);
83   void OfflineTriggerInit() {
84     kUseOfflineTrigger = kTRUE;
85     fPhysicsSelection = new AliPhysicsSelection();
86     fPhysicsSelection->AddBackgroundIdentification(new AliBackgroundSelection());
87     fPhysicsSelection->SetAnalyzeMC(fAnalysisMC);
88   }
89   Bool_t IsOfflineTriggerUsed() {return kUseOfflineTrigger;}
90   AliPhysicsSelection *GetPhysicsSelectionObject() {return fPhysicsSelection;}
91
92   Bool_t IsPrimary(AliESDEvent *esd,
93                    const AliESDVertex *vertex, 
94                    AliESDtrack *track);
95   Bool_t IsAccepted(AliESDtrack *track);
96   Bool_t IsInPhaseSpace(AliESDtrack *track);
97
98   Float_t GetSigmaToVertex(AliESDtrack* esdTrack) const; 
99   Double_t Rapidity(Double_t Px, Double_t Py, Double_t Pz) const;
100   
101   //Cut functions
102   void    SetPointOnITSLayer1() {fPointOnITSLayer1Flag = kTRUE;}
103   void    SetPointOnITSLayer2() {fPointOnITSLayer2Flag = kTRUE;}
104   void    SetPointOnITSLayer3() {fPointOnITSLayer3Flag = kTRUE;}
105   void    SetPointOnITSLayer4() {fPointOnITSLayer4Flag = kTRUE;}
106   void    SetPointOnITSLayer5() {fPointOnITSLayer5Flag = kTRUE;}
107   void    SetPointOnITSLayer6() {fPointOnITSLayer6Flag = kTRUE;}
108   Bool_t  IsUsedPointOnITSLayer1() const {return fPointOnITSLayer1Flag;}
109   Bool_t  IsUsedPointOnITSLayer2() const {return fPointOnITSLayer2Flag;}
110   Bool_t  IsUsedPointOnITSLayer3() const {return fPointOnITSLayer3Flag;}
111   Bool_t  IsUsedPointOnITSLayer4() const {return fPointOnITSLayer4Flag;}
112   Bool_t  IsUsedPointOnITSLayer5() const {return fPointOnITSLayer5Flag;}
113   Bool_t  IsUsedPointOnITSLayer6() const {return fPointOnITSLayer6Flag;}
114   void    SetMinITSClusters(Int_t minITSClusters) {
115     fMinITSClusters = minITSClusters;
116     fMinITSClustersFlag = kTRUE;
117   }
118   Int_t   GetMinITSClusters() const {return fMinITSClusters;}
119   Bool_t  IsUsedMinITSClusters() const {return fMinITSClustersFlag;}
120
121   void    SetMaxChi2PerITSCluster(Double_t maxChi2PerITSCluster) {
122     fMaxChi2PerITSCluster = maxChi2PerITSCluster;
123     fMaxChi2PerITSClusterFlag = kTRUE;
124   }
125   Bool_t  IsUsedMaxChi2PerITSCluster() const {return fMaxChi2PerITSClusterFlag;}
126   Double_t   GetMaxChi2PerITSCluster() const {return fMaxChi2PerITSCluster;}
127
128   void    SetMinTPCClusters(Int_t minTPCClusters) {
129     fMinTPCClusters = minTPCClusters;
130     fMinTPCClustersFlag = kTRUE;
131   }
132   Bool_t  IsUsedMinTPCClusters() const {return fMinTPCClustersFlag;}
133   Int_t   GetMinTPCClusters() const {return fMinTPCClusters;}
134
135   void    SetMaxChi2PerTPCCluster(Double_t maxChi2PerTPCCluster) {
136     fMaxChi2PerTPCCluster = maxChi2PerTPCCluster;
137     fMaxChi2PerTPCClusterFlag = kTRUE;
138   }
139   Bool_t  IsUsedMaxChi2PerTPCCluster() const {return fMaxChi2PerTPCClusterFlag;}
140   Double_t   GetMaxChi2PerTPCCluster() const {return fMaxChi2PerTPCCluster;}
141
142   void    SetMaxCov11(Double_t maxCov11) {
143     fMaxCov11 = maxCov11; fMaxCov11Flag = kTRUE;}
144   void    SetMaxCov22(Double_t maxCov22) {
145     fMaxCov22 = maxCov22; fMaxCov22Flag = kTRUE;}
146   void    SetMaxCov33(Double_t maxCov33) {
147     fMaxCov33 = maxCov33; fMaxCov33Flag = kTRUE;}
148   void    SetMaxCov44(Double_t maxCov44) {
149     fMaxCov44 = maxCov44; fMaxCov44Flag = kTRUE;}
150   void    SetMaxCov55(Double_t maxCov55) {
151     fMaxCov55 = maxCov55; fMaxCov55Flag = kTRUE;}
152   Bool_t  IsUsedMaxCov11() const {return fMaxCov11Flag;}
153   Bool_t  IsUsedMaxCov22() const {return fMaxCov22Flag;}
154   Bool_t  IsUsedMaxCov33() const {return fMaxCov33Flag;}
155   Bool_t  IsUsedMaxCov44() const {return fMaxCov44Flag;}
156   Bool_t  IsUsedMaxCov55() const {return fMaxCov55Flag;}
157   Double_t   GetMaxCov11() const {return fMaxCov11;}
158   Double_t   GetMaxCov22() const {return fMaxCov22;}
159   Double_t   GetMaxCov33() const {return fMaxCov33;}
160   Double_t   GetMaxCov44() const {return fMaxCov44;}
161   Double_t   GetMaxCov55() const {return fMaxCov55;}
162
163   void    SetMaxSigmaToVertex(Double_t maxSigmaToVertex) {
164     fMaxSigmaToVertex = maxSigmaToVertex;
165     fMaxSigmaToVertexFlag = kTRUE;
166   }
167   Bool_t  IsUsedMaxSigmaToVertex() const {return fMaxSigmaToVertexFlag;}
168   Double_t   GetMaxSigmaToVertex() const {return fMaxSigmaToVertex;}
169
170   void    SetMaxSigmaToVertexTPC(Double_t maxSigmaToVertex) {
171     fMaxSigmaToVertexTPC = maxSigmaToVertex;
172     fMaxSigmaToVertexTPCFlag = kTRUE;
173   }
174   Bool_t  IsUsedMaxSigmaToVertexTPC() const {return fMaxSigmaToVertexTPCFlag;}
175   Double_t   GetMaxSigmaToVertexTPC() const {return fMaxSigmaToVertexTPC;}
176
177   void    SetMaxDCAXY(Double_t maxDCAXY) {
178     fMaxDCAXY = maxDCAXY;
179     fMaxDCAXYFlag = kTRUE;
180   }
181   Bool_t  IsUsedMaxDCAXY() const {return fMaxDCAXYFlag;}
182   Double_t   GetMaxDCAXY() const {return fMaxDCAXY;}
183
184   void    SetMaxDCAXYTPC(Double_t maxDCAXY) {
185     fMaxDCAXYTPC = maxDCAXY;
186     fMaxDCAXYTPCFlag = kTRUE;
187   }
188   Bool_t  IsUsedMaxDCAXYTPC() const {return fMaxDCAXYTPCFlag;}
189   Double_t   GetMaxDCAXYTPC() const {return fMaxDCAXYTPC;}
190
191   void    SetMaxDCAZ(Double_t maxDCAZ) {
192     fMaxDCAZ = maxDCAZ;
193     fMaxDCAZFlag = kTRUE;
194   }
195   Bool_t  IsUsedMaxDCAZ() const {return fMaxDCAZFlag;}
196   Double_t   GetMaxDCAZ() const {return fMaxDCAZ;}
197
198   void    SetMaxDCAZTPC(Double_t maxDCAZ) {
199     fMaxDCAZTPC = maxDCAZ;
200     fMaxDCAZTPCFlag = kTRUE;
201   }
202   Bool_t  IsUsedMaxDCAZTPC() const {return fMaxDCAZTPCFlag;}
203   Double_t   GetMaxDCAZTPC() const {return fMaxDCAZTPC;}
204
205   void    SetMaxDCA3D(Double_t maxDCA3D) {
206     fMaxDCA3D = maxDCA3D;
207     fMaxDCA3DFlag = kTRUE;
208   }
209   Bool_t  IsUsedMaxDCA3D() const {return fMaxDCA3DFlag;}
210   Double_t   GetMaxDCA3D() const {return fMaxDCA3D;}
211
212   void    SetMaxDCA3DTPC(Double_t maxDCA3D) {
213     fMaxDCA3DTPC = maxDCA3D;
214     fMaxDCA3DTPCFlag = kTRUE;
215   }
216   Bool_t  IsUsedMaxDCA3DTPC() const {return fMaxDCA3DTPCFlag;}
217   Double_t   GetMaxDCA3DTPC() const {return fMaxDCA3DTPC;}
218
219   void    SetMaxConstrainChi2(Double_t maxConstrainChi2) {
220     fMaxConstrainChi2 = maxConstrainChi2;
221     fMaxConstrainChi2Flag = kTRUE;
222   }
223   Bool_t  IsUsedMaxConstrainChi2() const {return fMaxConstrainChi2Flag;}
224   Double_t   GetMaxConstrainChi2() const {return fMaxConstrainChi2;}
225
226   void    SetMinTPCdEdxPoints(Int_t mindEdxpoints) {
227     fMinTPCdEdxPoints = mindEdxpoints;
228     fMinTPCdEdxPointsFlag = kTRUE;
229   }
230   Bool_t  IsUsedMinTPCdEdxPoints() const {return fMinTPCdEdxPointsFlag;}
231   Int_t   GetMinTPCdEdxPoints() const {return fMinTPCdEdxPoints;}
232   
233   void    SetITSRefit() {fITSRefitFlag = kTRUE;}
234   Bool_t  IsUsedITSRefit() const {return fITSRefitFlag;}
235   void    SetTPCRefit() {fTPCRefitFlag = kTRUE;}
236   Bool_t  IsUsedTPCRefit() const {return fTPCRefitFlag;}
237   void    SetESDpid() {fESDpidFlag = kTRUE;}
238   Bool_t  IsUsedESDpid() const {return fESDpidFlag;}
239   void    SetTPCpid() {fTPCpidFlag = kTRUE;}
240   Bool_t  IsUsedTPCpid() const {return fTPCpidFlag;}
241   void    SetTOFpid() {fTOFpidFlag = kTRUE;}
242   Bool_t  IsUsedTOFpid() const {return fTOFpidFlag;}
243
244   TCanvas *GetListOfCuts();
245
246   //PID related functions
247   Bool_t IsProton(AliESDtrack *track);
248   void SetNSigma(Int_t nsigma) {fNSigma = nsigma;}  
249   Int_t GetNSigma() const {return fNSigma;}
250   void SetRatio(Double_t ratio) {fNRatio = ratio;}
251   Double_t GetRatio() {return fNRatio;}
252   void SetPriorProbabilities(Double_t * const partFrac) {
253     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) fPartFrac[i] = partFrac[i];} 
254   void SetPriorProbabilityFunctions(TF1 *const felectron, 
255                                     TF1 *const fmuon, 
256                                     TF1 *const fpion, 
257                                     TF1 *const fkaon, 
258                                     TF1 *const fproton) {
259     fFunctionProbabilityFlag = kTRUE;
260     fElectronFunction = felectron; fMuonFunction = fmuon; 
261     fPionFunction = fpion; fKaonFunction = fkaon; fProtonFunction = fproton;
262   }
263   Bool_t IsPriorProbabilityFunctionUsed() const {return fFunctionProbabilityFlag;}
264   Double_t GetParticleFraction(Int_t i, Double_t p);
265   //Double_t Bethe(Double_t bg) const;
266
267   void SetDebugMode() {fDebugMode = kTRUE;}
268   Bool_t GetDebugMode() const {return fDebugMode;}
269
270   TList *GetVertexQAList() {return fListVertexQA;}
271
272  private:
273   AliProtonAnalysisBase(const AliProtonAnalysisBase&); // Not implemented
274   AliProtonAnalysisBase& operator=(const AliProtonAnalysisBase&); // Not implemented
275
276   TString fProtonAnalysisLevel;//"ESD", "AOD" or "MC"
277   Bool_t fAnalysisMC; //kTRUE if MC analysis while reading the ESDs
278   TriggerMode fTriggerMode; //Trigger mode
279   Bool_t kUseOnlineTrigger; //use the online trigger or not
280   Bool_t kUseOfflineTrigger; //use the offline trigger or not
281   AliPhysicsSelection *fPhysicsSelection; //Trigger selection: offline
282   AnalysisMode fProtonAnalysisMode; //Analysis mode: TPC-Hybrid-Global
283   PIDMode fProtonPIDMode; //PID mode: Bayesian-dE/dx ratio-Nsigma areas
284   Bool_t fAnalysisEtaMode; //run the analysis in eta or y
285
286   Double_t fVxMax, fVyMax, fVzMax; //vertex diamond constrain 
287   Int_t fMinNumOfContributors;//min number of contributors
288
289   Int_t fNBinsX; //number of bins in y or eta
290   Double_t fMinX, fMaxX; //min & max value of y or eta
291   Int_t fNBinsY;  //number of bins in pT
292   Double_t fMinY, fMaxY; //min & max value of pT
293   
294   //cuts
295   Int_t fMinTPCClusters, fMinITSClusters; //min TPC & ITS clusters
296   Double_t fMaxChi2PerTPCCluster, fMaxChi2PerITSCluster; //max chi2 per TPC & ITS cluster
297   Double_t fMaxCov11, fMaxCov22, fMaxCov33, fMaxCov44, fMaxCov55; //max values of cov. matrix
298   Double_t fMaxSigmaToVertex; //max sigma to vertex cut
299   Double_t fMaxSigmaToVertexTPC; //max sigma to vertex cut
300   Double_t fMaxDCAXY, fMaxDCAXYTPC; //max DCA xy
301   Double_t fMaxDCAZ, fMaxDCAZTPC; //max DCA z
302   Double_t fMaxDCA3D, fMaxDCA3DTPC; //max DCA 3D
303   Double_t fMaxConstrainChi2; //max constrain chi2 - vertex
304   Int_t  fMinTPCdEdxPoints;//min number of TPC points used for the dE/dx
305   Bool_t fMinTPCClustersFlag, fMinITSClustersFlag; //shows if this cut is used or not
306   Bool_t fMaxChi2PerTPCClusterFlag, fMaxChi2PerITSClusterFlag; //shows if this cut is used or not
307   Bool_t fMaxCov11Flag, fMaxCov22Flag, fMaxCov33Flag, fMaxCov44Flag, fMaxCov55Flag; //shows if this cut is used or not
308   Bool_t fMaxSigmaToVertexFlag; //shows if this cut is used or not
309   Bool_t fMaxSigmaToVertexTPCFlag; //shows if this cut is used or not
310   Bool_t fMaxDCAXYFlag, fMaxDCAXYTPCFlag; //shows if this cut is used or not
311   Bool_t fMaxDCAZFlag, fMaxDCAZTPCFlag; //shows if this cut is used or not
312   Bool_t fMaxDCA3DFlag, fMaxDCA3DTPCFlag; //shows if this cut is used or not
313   Bool_t fMaxConstrainChi2Flag; //shows if this cut is used or not
314   Bool_t fITSRefitFlag, fTPCRefitFlag; //shows if this cut is used or not
315   Bool_t fESDpidFlag, fTPCpidFlag, fTOFpidFlag; //shows if this cut is used or not
316   Bool_t fPointOnITSLayer1Flag, fPointOnITSLayer2Flag; //shows if this cut is used or not
317   Bool_t fPointOnITSLayer3Flag, fPointOnITSLayer4Flag; //shows if this cut is used or not
318   Bool_t fPointOnITSLayer5Flag, fPointOnITSLayer6Flag; //shows if this cut is used or not
319   Bool_t fMinTPCdEdxPointsFlag; //shows if this cut is used or not
320
321   //pid
322   Bool_t fFunctionProbabilityFlag; //flag: kTRUE if functions used
323   Int_t fNSigma; //N-sigma cut in the dE/dx band
324   Double_t fNRatio; //min value of the ratio of the measured dE/dx vs the expected
325   Double_t fPartFrac[10]; //prior probabilities
326   TF1  *fElectronFunction; //momentum dependence of the prior probs
327   TF1  *fMuonFunction; //momentum dependence of the prior probs
328   TF1  *fPionFunction; //momentum dependence of the prior probs
329   TF1  *fKaonFunction; //momentum dependence of the prior probs
330   TF1  *fProtonFunction; //momentum dependence of the prior probs
331
332   //Debug
333   Bool_t fDebugMode; //Enable the debug mode
334
335   //QA list
336   TList *fListVertexQA; //vertex QA list
337
338   ClassDef(AliProtonAnalysisBase,1);
339 };
340
341 #endif