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