Version number ++
[u/mrichter/AliRoot.git] / ANALYSIS / AliAODParticleBaseCut.h
1 #ifndef ALIAODPARTICLEBASECUT_H
2 #define ALIAODPARTICLEBASECUT_H
3 //__________________________________________________________________________
4 ////////////////////////////////////////////////////////////////////////////
5 //                                                                        //
6 // class AliAODParticleBaseCut                                            //
7 //                                                                        //
8 // Set of classes for performing cuts on particle properties of           //
9 // AliAODParticleBaseCut is a base class for "base                        //
10 // particle cuts". Further, there are implemented classes that performs   //
11 // cuts on the most common particle properties like pt, pseudo rapidity,  //
12 // angles, anergy, etc.                                                   //
13 //                                                                        //
14 // There are also implemeted base cuts that perform logical operations    //
15 // on results of base particle cuts: AliAODOrCut and  AliAODAndCut.       //
16 //                                                                        //
17 // Each base cut has a property, thet allows to distinguish them.         //
18 // This functionality is used by the interface methods of Particle Cut    //
19 // that allows easy update ranges.                                        //
20 //                                                                        //
21 // more info: http://aliweb.cern.ch/people/skowron/analyzer/index.html    //
22 // responsible: Piotr Skowronski@cern.ch                                  //
23 //                                                                        //
24 ////////////////////////////////////////////////////////////////////////////
25
26
27 #include <TObject.h>
28 #include "AliVAODParticle.h"
29
30
31 class AliAODParticleBaseCut: public TObject
32  {
33    //This class defines the range of some property - pure virtual
34    //Property is coded by AliAODCutTypes type
35    
36    public:
37
38      enum EAODCutProperty
39       {
40      //codes of particle properties
41        kAODP,  //Momentum
42        kAODPt, //Transverse momentum
43        kAODE,  //Energy
44        kAODRapidity, //
45        kAODPseudoRapidity,
46        kAODPx, //X coAnddinate of the momentum
47        kAODPy, //Y coAnddinate of the momentum
48        kAODPz, //Z coAnddinate of the momentum
49        kAODPhi,//angle
50        kAODTheta,//angle
51        kAODVx,  // vertex X coAnddinate
52        kAODVy,  // vertex Y coAnddinate
53        kAODVz,  // vertex Z coAnddinate
54        kAODPid, // vertex Z coAnddinate
55      //_____________________________
56        kAODNone
57       };
58
59      
60      AliAODParticleBaseCut(Double_t min = 0.0, Double_t max = 0.0,EAODCutProperty prop = kAODNone):
61                    fProperty(prop),fMin(min),fMax(max){}
62
63      virtual           ~AliAODParticleBaseCut(){}
64      
65      virtual Bool_t    Rejected(AliVAODParticle *p) const;
66      
67      void              SetRange(Double_t min, Double_t max){fMin = min; fMax = max;}
68
69      void              SetMinimum(Double_t min){fMin = min;}
70      void              SetMaximum(Double_t max){fMax = max;}
71      
72      Double_t          GetMinimum() const {return fMin;}
73      Double_t          GetMaximum() const {return fMax;}
74      
75      EAODCutProperty   GetProperty() const {return fProperty;}
76      virtual void Print(const Option_t * opt = "") const;
77      
78    protected:
79      virtual Double_t  GetValue(AliVAODParticle *) const = 0;
80
81      EAODCutProperty fProperty; //property that this cut describes
82      Double_t fMin;//minimum value
83      Double_t fMax;//maximum value
84      
85    private:
86      void PrintProperty(void) const;
87      ClassDef(AliAODParticleBaseCut,1)
88    
89  };
90
91 inline Bool_t
92 AliAODParticleBaseCut::Rejected(AliVAODParticle *p) const
93 {
94   //cjecks if particle property fits in range
95   if ( (GetValue(p) < fMin) || (GetValue(p) > fMax ) ) return kTRUE; //rejected
96   else return kFALSE; //accepted
97 }
98 /******************************************************************/
99 /******************************************************************/
100 /******************************************************************/
101
102  
103 class AliAODMomentumCut: public AliAODParticleBaseCut
104  {
105   public: 
106     AliAODMomentumCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODP){}
107     virtual ~AliAODMomentumCut(){}
108   protected:
109     Double_t  GetValue(AliVAODParticle * p)const{return p->P();}
110     ClassDef(AliAODMomentumCut,1)
111  };
112
113 class AliAODPtCut: public AliAODParticleBaseCut
114  {
115   public: 
116     AliAODPtCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODPt){}
117     virtual ~AliAODPtCut(){}
118   protected:
119     Double_t  GetValue(AliVAODParticle * p)const{return p->Pt();}
120     ClassDef(AliAODPtCut,1)
121  };
122
123
124 class AliAODEnergyCut: public AliAODParticleBaseCut
125  {
126   public: 
127     AliAODEnergyCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODE){}
128     virtual ~AliAODEnergyCut(){}
129   protected:
130     Double_t  GetValue(AliVAODParticle * p)const {return p->E();}
131     ClassDef(AliAODEnergyCut,1)
132  };
133
134 class AliAODRapidityCut: public AliAODParticleBaseCut
135  {
136   public: 
137     AliAODRapidityCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODRapidity){}
138     virtual ~AliAODRapidityCut(){}
139   protected:
140     Double_t  GetValue(AliVAODParticle * p)const{return p->Y();}
141     ClassDef(AliAODRapidityCut,1)
142  };
143
144 class AliAODPseudoRapidityCut: public AliAODParticleBaseCut
145  {
146   public: 
147     AliAODPseudoRapidityCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODPseudoRapidity){}
148     virtual ~AliAODPseudoRapidityCut(){}
149   protected:
150     Double_t  GetValue(AliVAODParticle * p)const{return p->Eta();}
151     ClassDef(AliAODPseudoRapidityCut,1)
152  };
153
154 class AliAODPxCut: public AliAODParticleBaseCut
155  {
156   public: 
157     AliAODPxCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODPx){}
158     virtual ~AliAODPxCut(){}
159   protected:
160     Double_t  GetValue(AliVAODParticle * p)const{return p->Px();}
161     ClassDef(AliAODPxCut,1)
162  };
163
164 class AliAODPyCut: public AliAODParticleBaseCut
165  {
166   public: 
167     AliAODPyCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODPy){}
168     virtual ~AliAODPyCut(){}
169   protected:
170     Double_t  GetValue(AliVAODParticle * p)const{return p->Py();}
171     ClassDef(AliAODPyCut,1)
172  };
173
174
175 class AliAODPzCut: public AliAODParticleBaseCut
176  {
177   public: 
178     AliAODPzCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODPz){}
179     virtual ~AliAODPzCut(){}
180   protected:
181     Double_t  GetValue(AliVAODParticle * p)const{return p->Pz();}
182     ClassDef(AliAODPzCut,1)
183  };
184
185 class AliAODPhiCut: public AliAODParticleBaseCut
186  {
187   public: 
188     AliAODPhiCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODPhi){}
189     virtual ~AliAODPhiCut(){}
190   protected:
191     Double_t  GetValue(AliVAODParticle * p)const{return p->Phi();}
192     ClassDef(AliAODPhiCut,1)
193   
194  };
195
196 class AliAODThetaCut: public AliAODParticleBaseCut
197  {
198   public: 
199     AliAODThetaCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODTheta){}
200     virtual ~AliAODThetaCut(){}
201   protected:
202     Double_t  GetValue(AliVAODParticle * p)const{return p->Theta();}
203     ClassDef(AliAODThetaCut,1)
204   
205  };
206
207 class AliAODVxCut: public AliAODParticleBaseCut
208  {
209  //Cut of the X coAnddinate of the vertex position
210   public: 
211     AliAODVxCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODVx){}
212     virtual ~AliAODVxCut(){}
213   protected:
214     Double_t  GetValue(AliVAODParticle * p)const{return p->Vx();} //retruns value of the vertex
215     ClassDef(AliAODVxCut,1)
216   
217  };
218
219
220 class AliAODVyCut: public AliAODParticleBaseCut
221  {
222  //Cut of the X coAnddinate of the vertex position
223   public: 
224     AliAODVyCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODVy){}
225     virtual ~AliAODVyCut(){}
226   protected:
227     Double_t  GetValue(AliVAODParticle * p)const{return p->Vy();} //retruns value of the vertex
228     ClassDef(AliAODVyCut,1)
229   
230  };
231
232 class AliAODVzCut: public AliAODParticleBaseCut
233  {
234  //Cut of the X coAnddinate of the vertex position
235   public: 
236     AliAODVzCut(Double_t min = 0.0, Double_t max = 0.0):AliAODParticleBaseCut(min,max,kAODVz){}
237     virtual ~AliAODVzCut(){}
238   protected:
239     Double_t  GetValue(AliVAODParticle * p)const{return p->Vz();} //retruns value of the vertex
240     
241     ClassDef(AliAODVzCut,1)
242   
243  };
244
245 class AliAODPIDCut:  public AliAODParticleBaseCut
246  {
247    public:
248      AliAODPIDCut():AliAODParticleBaseCut(0.0,0.0,kAODPid),fPID(0){}
249      AliAODPIDCut(Int_t pid, Double_t min = 0.0, Double_t max = 1.0):AliAODParticleBaseCut(min,max,kAODPid),fPID(pid){}
250      virtual ~AliAODPIDCut(){}
251      
252      void SetPID(Int_t pid){fPID = pid;}
253      void Print(const Option_t * opt = "") const;
254    protected:
255      Double_t  GetValue(AliVAODParticle * p)const{return p->GetProbability(fPID);}
256      Int_t     fPID; //pid of particle that the pid is set 
257      ClassDef(AliAODPIDCut,1)
258  };
259 //___________________________________________________
260 /////////////////////////////////////////////////////
261 //                                                 //
262 // class AliAODLogicalOperCut                      //
263 //                                                 //
264 // This cut is base class fAnd class that perfAndms  //
265 // logical operations on cuts                      //
266 //                                                 //
267 /////////////////////////////////////////////////////
268 class AliAODLogicalOperCut:  public AliAODParticleBaseCut
269  {
270    public:
271      AliAODLogicalOperCut();
272      AliAODLogicalOperCut(AliAODParticleBaseCut* first, AliAODParticleBaseCut* second);
273      virtual   ~AliAODLogicalOperCut();
274    protected:
275      Double_t  GetValue(AliVAODParticle * /*part*/) const {MayNotUse("GetValue");return 0.0;}
276      
277      AliAODParticleBaseCut* fFirst;   //second cut
278      AliAODParticleBaseCut* fSecond;  //first cut
279    private:  
280     class  AliAODDummyBaseCut: public AliAODParticleBaseCut 
281      {
282        Double_t  GetValue(AliVAODParticle * /*part*/) const {return 0.0;}
283        Bool_t    Rejected(AliVAODParticle* /*part*/) const;
284      };
285      
286     ClassDef(AliAODLogicalOperCut,1)
287  };
288
289 class AliAODOrCut: public AliAODLogicalOperCut
290 {
291    public:
292      AliAODOrCut(){}
293      AliAODOrCut(AliAODParticleBaseCut* first, AliAODParticleBaseCut* second):AliAODLogicalOperCut(first,second){}
294      virtual   ~AliAODOrCut(){}
295      Bool_t    Rejected(AliVAODParticle *p) const;
296      ClassDef(AliAODOrCut,1)
297 };
298
299 class AliAODAndCut: public AliAODLogicalOperCut
300 {
301    public:
302      AliAODAndCut(){}
303      AliAODAndCut(AliAODParticleBaseCut* first, AliAODParticleBaseCut* second):AliAODLogicalOperCut(first,second){}
304      virtual   ~AliAODAndCut(){}
305      Bool_t    Rejected(AliVAODParticle *p) const;
306      ClassDef(AliAODAndCut,1)
307 };
308
309 #endif