]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/AliProtonAnalysisBase.h
Adding the possibility to check the background contribution - more QA plots to come...
[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, kSigma1, kSigma2 };
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(AliESDEvent *esd,
96                     const AliESDVertex *vertex, 
97                     AliESDtrack *track);
98   Bool_t IsInPhaseSpace(AliESDtrack *track);
99
100   Float_t GetSigmaToVertex(AliESDtrack* esdTrack) const; 
101   Double_t Rapidity(Double_t Px, Double_t Py, Double_t Pz) const;
102   
103   //Cut functions
104   void    SetPointOnITSLayer1() {fPointOnITSLayer1Flag = kTRUE;}
105   void    SetPointOnITSLayer2() {fPointOnITSLayer2Flag = kTRUE;}
106   void    SetPointOnITSLayer3() {fPointOnITSLayer3Flag = kTRUE;}
107   void    SetPointOnITSLayer4() {fPointOnITSLayer4Flag = kTRUE;}
108   void    SetPointOnITSLayer5() {fPointOnITSLayer5Flag = kTRUE;}
109   void    SetPointOnITSLayer6() {fPointOnITSLayer6Flag = kTRUE;}
110   Bool_t  IsUsedPointOnITSLayer1() const {return fPointOnITSLayer1Flag;}
111   Bool_t  IsUsedPointOnITSLayer2() const {return fPointOnITSLayer2Flag;}
112   Bool_t  IsUsedPointOnITSLayer3() const {return fPointOnITSLayer3Flag;}
113   Bool_t  IsUsedPointOnITSLayer4() const {return fPointOnITSLayer4Flag;}
114   Bool_t  IsUsedPointOnITSLayer5() const {return fPointOnITSLayer5Flag;}
115   Bool_t  IsUsedPointOnITSLayer6() const {return fPointOnITSLayer6Flag;}
116   void    SetMinITSClusters(Int_t minITSClusters) {
117     fMinITSClusters = minITSClusters;
118     fMinITSClustersFlag = kTRUE;
119   }
120   Int_t   GetMinITSClusters() const {return fMinITSClusters;}
121   Bool_t  IsUsedMinITSClusters() const {return fMinITSClustersFlag;}
122
123   void    SetMaxChi2PerITSCluster(Double_t maxChi2PerITSCluster) {
124     fMaxChi2PerITSCluster = maxChi2PerITSCluster;
125     fMaxChi2PerITSClusterFlag = kTRUE;
126   }
127   Bool_t  IsUsedMaxChi2PerITSCluster() const {return fMaxChi2PerITSClusterFlag;}
128   Double_t   GetMaxChi2PerITSCluster() const {return fMaxChi2PerITSCluster;}
129
130   void    SetMinTPCClusters(Int_t minTPCClusters) {
131     fMinTPCClusters = minTPCClusters;
132     fMinTPCClustersFlag = kTRUE;
133   }
134   Bool_t  IsUsedMinTPCClusters() const {return fMinTPCClustersFlag;}
135   Int_t   GetMinTPCClusters() const {return fMinTPCClusters;}
136
137   void    SetMaxChi2PerTPCCluster(Double_t maxChi2PerTPCCluster) {
138     fMaxChi2PerTPCCluster = maxChi2PerTPCCluster;
139     fMaxChi2PerTPCClusterFlag = kTRUE;
140   }
141   Bool_t  IsUsedMaxChi2PerTPCCluster() const {return fMaxChi2PerTPCClusterFlag;}
142   Double_t   GetMaxChi2PerTPCCluster() const {return fMaxChi2PerTPCCluster;}
143
144   void    SetMaxCov11(Double_t maxCov11) {
145     fMaxCov11 = maxCov11; fMaxCov11Flag = kTRUE;}
146   void    SetMaxCov22(Double_t maxCov22) {
147     fMaxCov22 = maxCov22; fMaxCov22Flag = kTRUE;}
148   void    SetMaxCov33(Double_t maxCov33) {
149     fMaxCov33 = maxCov33; fMaxCov33Flag = kTRUE;}
150   void    SetMaxCov44(Double_t maxCov44) {
151     fMaxCov44 = maxCov44; fMaxCov44Flag = kTRUE;}
152   void    SetMaxCov55(Double_t maxCov55) {
153     fMaxCov55 = maxCov55; fMaxCov55Flag = kTRUE;}
154   Bool_t  IsUsedMaxCov11() const {return fMaxCov11Flag;}
155   Bool_t  IsUsedMaxCov22() const {return fMaxCov22Flag;}
156   Bool_t  IsUsedMaxCov33() const {return fMaxCov33Flag;}
157   Bool_t  IsUsedMaxCov44() const {return fMaxCov44Flag;}
158   Bool_t  IsUsedMaxCov55() const {return fMaxCov55Flag;}
159   Double_t   GetMaxCov11() const {return fMaxCov11;}
160   Double_t   GetMaxCov22() const {return fMaxCov22;}
161   Double_t   GetMaxCov33() const {return fMaxCov33;}
162   Double_t   GetMaxCov44() const {return fMaxCov44;}
163   Double_t   GetMaxCov55() const {return fMaxCov55;}
164
165   void    SetMaxSigmaToVertex(Double_t maxSigmaToVertex) {
166     fMaxSigmaToVertex = maxSigmaToVertex;
167     fMaxSigmaToVertexFlag = kTRUE;
168   }
169   Bool_t  IsUsedMaxSigmaToVertex() const {return fMaxSigmaToVertexFlag;}
170   Double_t   GetMaxSigmaToVertex() const {return fMaxSigmaToVertex;}
171
172   void    SetMaxSigmaToVertexTPC(Double_t maxSigmaToVertex) {
173     fMaxSigmaToVertexTPC = maxSigmaToVertex;
174     fMaxSigmaToVertexTPCFlag = kTRUE;
175   }
176   Bool_t  IsUsedMaxSigmaToVertexTPC() const {return fMaxSigmaToVertexTPCFlag;}
177   Double_t   GetMaxSigmaToVertexTPC() const {return fMaxSigmaToVertexTPC;}
178
179   void    SetMaxDCAXY(Double_t maxDCAXY) {
180     fMaxDCAXY = maxDCAXY;
181     fMaxDCAXYFlag = kTRUE;
182   }
183   Bool_t  IsUsedMaxDCAXY() const {return fMaxDCAXYFlag;}
184   Double_t   GetMaxDCAXY() const {return fMaxDCAXY;}
185
186   void    SetMaxDCAXYTPC(Double_t maxDCAXY) {
187     fMaxDCAXYTPC = maxDCAXY;
188     fMaxDCAXYTPCFlag = kTRUE;
189   }
190   Bool_t  IsUsedMaxDCAXYTPC() const {return fMaxDCAXYTPCFlag;}
191   Double_t   GetMaxDCAXYTPC() const {return fMaxDCAXYTPC;}
192
193   void    SetMaxDCAZ(Double_t maxDCAZ) {
194     fMaxDCAZ = maxDCAZ;
195     fMaxDCAZFlag = kTRUE;
196   }
197   Bool_t  IsUsedMaxDCAZ() const {return fMaxDCAZFlag;}
198   Double_t   GetMaxDCAZ() const {return fMaxDCAZ;}
199
200   void    SetMaxDCAZTPC(Double_t maxDCAZ) {
201     fMaxDCAZTPC = maxDCAZ;
202     fMaxDCAZTPCFlag = kTRUE;
203   }
204   Bool_t  IsUsedMaxDCAZTPC() const {return fMaxDCAZTPCFlag;}
205   Double_t   GetMaxDCAZTPC() const {return fMaxDCAZTPC;}
206
207   void    SetMaxDCA3D(Double_t maxDCA3D) {
208     fMaxDCA3D = maxDCA3D;
209     fMaxDCA3DFlag = kTRUE;
210   }
211   Bool_t  IsUsedMaxDCA3D() const {return fMaxDCA3DFlag;}
212   Double_t   GetMaxDCA3D() const {return fMaxDCA3D;}
213
214   void    SetMaxDCA3DTPC(Double_t maxDCA3D) {
215     fMaxDCA3DTPC = maxDCA3D;
216     fMaxDCA3DTPCFlag = kTRUE;
217   }
218   Bool_t  IsUsedMaxDCA3DTPC() const {return fMaxDCA3DTPCFlag;}
219   Double_t   GetMaxDCA3DTPC() const {return fMaxDCA3DTPC;}
220
221   void    SetMaxConstrainChi2(Double_t maxConstrainChi2) {
222     fMaxConstrainChi2 = maxConstrainChi2;
223     fMaxConstrainChi2Flag = kTRUE;
224   }
225   Bool_t  IsUsedMaxConstrainChi2() const {return fMaxConstrainChi2Flag;}
226   Double_t   GetMaxConstrainChi2() const {return fMaxConstrainChi2;}
227
228   void    SetMinTPCdEdxPoints(Int_t mindEdxpoints) {
229     fMinTPCdEdxPoints = mindEdxpoints;
230     fMinTPCdEdxPointsFlag = kTRUE;
231   }
232   Bool_t  IsUsedMinTPCdEdxPoints() const {return fMinTPCdEdxPointsFlag;}
233   Int_t   GetMinTPCdEdxPoints() const {return fMinTPCdEdxPoints;}
234   
235   void    SetITSRefit() {fITSRefitFlag = kTRUE;}
236   Bool_t  IsUsedITSRefit() const {return fITSRefitFlag;}
237   void    SetTPCRefit() {fTPCRefitFlag = kTRUE;}
238   Bool_t  IsUsedTPCRefit() const {return fTPCRefitFlag;}
239   void    SetESDpid() {fESDpidFlag = kTRUE;}
240   Bool_t  IsUsedESDpid() const {return fESDpidFlag;}
241   void    SetTPCpid() {fTPCpidFlag = kTRUE;}
242   Bool_t  IsUsedTPCpid() const {return fTPCpidFlag;}
243   void    SetTOFpid() {fTOFpidFlag = kTRUE;}
244   Bool_t  IsUsedTOFpid() const {return fTOFpidFlag;}
245
246   TCanvas *GetListOfCuts();
247
248   //PID related functions
249   Bool_t IsProton(AliESDtrack *track);
250   void SetNSigma(Int_t nsigma) {fNSigma = nsigma;}  
251   Int_t GetNSigma() const {return fNSigma;}
252   void SetdEdxBandInfo(const char* filename);
253   void SetPriorProbabilities(Double_t * const partFrac) {
254     for(Int_t i = 0; i < AliPID::kSPECIESN; i++) fPartFrac[i] = partFrac[i];} 
255   void SetPriorProbabilityFunctions(TF1 *const felectron, 
256                                     TF1 *const fmuon, 
257                                     TF1 *const fpion, 
258                                     TF1 *const fkaon, 
259                                     TF1 *const fproton) {
260     fFunctionProbabilityFlag = kTRUE;
261     fElectronFunction = felectron; fMuonFunction = fmuon; 
262     fPionFunction = fpion; fKaonFunction = fkaon; fProtonFunction = fproton;
263   }
264   Bool_t IsPriorProbabilityFunctionUsed() const {return fFunctionProbabilityFlag;}
265   Double_t GetParticleFraction(Int_t i, Double_t p);
266   Double_t Bethe(Double_t bg) const;
267
268   void SetDebugMode() {fDebugMode = kTRUE;}
269   Bool_t GetDebugMode() const {return fDebugMode;}
270
271   TList *GetVertexQAList() {return fListVertexQA;}
272
273  private:
274   AliProtonAnalysisBase(const AliProtonAnalysisBase&); // Not implemented
275   AliProtonAnalysisBase& operator=(const AliProtonAnalysisBase&); // Not implemented
276
277   TString fProtonAnalysisLevel;//"ESD", "AOD" or "MC"
278   Bool_t fAnalysisMC; //kTRUE if MC analysis while reading the ESDs
279   TriggerMode fTriggerMode; //Trigger mode
280   Bool_t kUseOnlineTrigger; //use the online trigger or not
281   Bool_t kUseOfflineTrigger; //use the offline trigger or not
282   AliPhysicsSelection *fPhysicsSelection; //Trigger selection: offline
283   AnalysisMode fProtonAnalysisMode; //Analysis mode: TPC-Hybrid-Global
284   PIDMode fProtonPIDMode; //PID mode: Bayesian-dE/dx ratio-Nsigma areas
285   Bool_t fAnalysisEtaMode; //run the analysis in eta or y
286
287   Double_t fVxMax, fVyMax, fVzMax; //vertex diamond constrain 
288   Int_t fMinNumOfContributors;//min number of contributors
289
290   Int_t fNBinsX; //number of bins in y or eta
291   Double_t fMinX, fMaxX; //min & max value of y or eta
292   Int_t fNBinsY;  //number of bins in pT
293   Double_t fMinY, fMaxY; //min & max value of pT
294   
295   //cuts
296   Int_t fMinTPCClusters, fMinITSClusters; //min TPC & ITS clusters
297   Double_t fMaxChi2PerTPCCluster, fMaxChi2PerITSCluster; //max chi2 per TPC & ITS cluster
298   Double_t fMaxCov11, fMaxCov22, fMaxCov33, fMaxCov44, fMaxCov55; //max values of cov. matrix
299   Double_t fMaxSigmaToVertex; //max sigma to vertex cut
300   Double_t fMaxSigmaToVertexTPC; //max sigma to vertex cut
301   Double_t fMaxDCAXY, fMaxDCAXYTPC; //max DCA xy
302   Double_t fMaxDCAZ, fMaxDCAZTPC; //max DCA z
303   Double_t fMaxDCA3D, fMaxDCA3DTPC; //max DCA 3D
304   Double_t fMaxConstrainChi2; //max constrain chi2 - vertex
305   Int_t  fMinTPCdEdxPoints;//min number of TPC points used for the dE/dx
306   Bool_t fMinTPCClustersFlag, fMinITSClustersFlag; //shows if this cut is used or not
307   Bool_t fMaxChi2PerTPCClusterFlag, fMaxChi2PerITSClusterFlag; //shows if this cut is used or not
308   Bool_t fMaxCov11Flag, fMaxCov22Flag, fMaxCov33Flag, fMaxCov44Flag, fMaxCov55Flag; //shows if this cut is used or not
309   Bool_t fMaxSigmaToVertexFlag; //shows if this cut is used or not
310   Bool_t fMaxSigmaToVertexTPCFlag; //shows if this cut is used or not
311   Bool_t fMaxDCAXYFlag, fMaxDCAXYTPCFlag; //shows if this cut is used or not
312   Bool_t fMaxDCAZFlag, fMaxDCAZTPCFlag; //shows if this cut is used or not
313   Bool_t fMaxDCA3DFlag, fMaxDCA3DTPCFlag; //shows if this cut is used or not
314   Bool_t fMaxConstrainChi2Flag; //shows if this cut is used or not
315   Bool_t fITSRefitFlag, fTPCRefitFlag; //shows if this cut is used or not
316   Bool_t fESDpidFlag, fTPCpidFlag, fTOFpidFlag; //shows if this cut is used or not
317   Bool_t fPointOnITSLayer1Flag, fPointOnITSLayer2Flag; //shows if this cut is used or not
318   Bool_t fPointOnITSLayer3Flag, fPointOnITSLayer4Flag; //shows if this cut is used or not
319   Bool_t fPointOnITSLayer5Flag, fPointOnITSLayer6Flag; //shows if this cut is used or not
320   Bool_t fMinTPCdEdxPointsFlag; //shows if this cut is used or not
321
322   //pid
323   Bool_t fFunctionProbabilityFlag; //flag: kTRUE if functions used
324   Int_t fNSigma; //N-sigma cut in the dE/dx band
325   Double_t fdEdxMean[24]; //mean values of the dE/dx distributions for the proton band - P slices
326   Double_t fdEdxSigma[24]; //sigma values of the dE/dx distributions for the proton band - P slices
327   Double_t fPartFrac[10]; //prior probabilities
328   TF1  *fElectronFunction; //momentum dependence of the prior probs
329   TF1  *fMuonFunction; //momentum dependence of the prior probs
330   TF1  *fPionFunction; //momentum dependence of the prior probs
331   TF1  *fKaonFunction; //momentum dependence of the prior probs
332   TF1  *fProtonFunction; //momentum dependence of the prior probs
333
334   //Debug
335   Bool_t fDebugMode; //Enable the debug mode
336
337   //QA list
338   TList *fListVertexQA; //vertex QA list
339
340   ClassDef(AliProtonAnalysisBase,1);
341 };
342
343 #endif