]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAODParticleCut.h
AliAODParticle -> AliVAODParticle; AliAODStdParticle -> AliAODParticle
[u/mrichter/AliRoot.git] / ANALYSIS / AliAODParticleCut.h
1 #ifndef ALIAODPARTICLECUT_H
2 #define ALIAODPARTICLECUT_H
3 //__________________________________________________________________________
4 ////////////////////////////////////////////////////////////////////////////
5 //                                                                        //
6 // class AliAODParticleCut                                                //
7 //                                                                        //
8 // Classes for single particle cuts                                       //
9 // User should use only AliAODParticleCut, eventually                     //
10 // EmptyCut which passes all particles                                    //
11 // There is all interface for setting cuts on all particle properties     //
12 // The main method is Pass - which returns                                //
13 //         True to reject particle                                        //
14 //         False in case it meets all the criteria of the given cut       //
15 //                                                                        //
16 // User should create (and also destroy) cuts himself                     // 
17 // and then pass them to the Analysis And Function by a proper method     //
18 //                                                                        //
19 //                                                                        //
20 // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html   //
21 // resonsible: Piotr Skowronski@cern.ch                                   //
22 //                                                                        //
23 ////////////////////////////////////////////////////////////////////////////
24
25
26 #include <TObject.h>
27 #include "AliVAODParticle.h"
28
29
30 class AliAODEmptyParticleCut;
31 class AliAODParticleCut;
32 class AliAODBaseCut;
33
34
35 /******************************************************************/
36 /******************************************************************/
37 /******************************************************************/
38
39 enum AliAODCutProperty
40  {
41 //codes particle property
42   kAODP,  //Momentum
43   kAODPt, //Transverse momentum
44   kAODE,  //Energy
45   kAODRapidity, //
46   kAODPseudoRapidity,
47   kAODPx, //X coAnddinate of the momentum
48   kAODPy, //Y coAnddinate of the momentum
49   kAODPz, //Z coAnddinate of the momentum
50   kAODPhi,//angle
51   kAODTheta,//angle
52   kAODVx,  // vertex X coAnddinate
53   kAODVy,  // vertex Y coAnddinate
54   kAODVz,  // vertex Z coAnddinate
55   kAODPid, // vertex Z coAnddinate
56 //_____________________________
57   kAODNone
58  };
59
60 /******************************************************************/
61 /******************************************************************/
62 /******************************************************************/
63
64 class AliAODParticleCut: public TObject
65 {
66 //Class describing cut on particle
67   public:
68     AliAODParticleCut();
69     AliAODParticleCut(const AliAODParticleCut& in);
70     virtual ~AliAODParticleCut();
71     AliAODParticleCut& operator = (const AliAODParticleCut& in);
72     
73     virtual Bool_t Pass(AliVAODParticle* p) const;
74     Bool_t IsEmpty() const {return kFALSE;}
75     
76     void AddBasePartCut(AliAODBaseCut* basecut);
77     
78     Int_t GetPID() const { return fPID;}
79     void SetPID(Int_t pid){fPID=pid;}
80     void SetMomentumRange(Double_t min, Double_t max);
81     void SetPRange(Double_t min, Double_t max){SetMomentumRange(min,max);}
82     void SetPtRange(Double_t min, Double_t max);
83     void SetEnergyRange(Double_t min, Double_t max);
84     void SetRapidityRange(Double_t min, Double_t max);
85     void SetYRange(Double_t min, Double_t max){SetRapidityRange(min,max);}
86     void SetPseudoRapidityRange(Double_t min, Double_t max);
87     void SetPxRange(Double_t min, Double_t max);
88     void SetPyRange(Double_t min, Double_t max);
89     void SetPzRange(Double_t min, Double_t max);
90     void SetPhiRange(Double_t min, Double_t max);
91     void SetThetaRange(Double_t min, Double_t max);
92     void SetVxRange(Double_t min, Double_t max);
93     void SetVyRange(Double_t min, Double_t max);
94     void SetVzRange(Double_t min, Double_t max);
95     
96     void Print(void) const;
97   protected:
98      
99     AliAODBaseCut* FindCut(AliAODCutProperty property);
100
101     AliAODBaseCut ** fCuts;//! Array with cuts
102     Int_t fNCuts; //number of base cuts stored in fCuts
103
104     Int_t fPID; //particle PID  - if=0 (rootino) all pids are accepted
105           
106   private:
107     static const Int_t fgkMaxCuts; //Size of the fCuts array
108
109     ClassDef(AliAODParticleCut,1)
110 };
111 /******************************************************************/
112 /******************************************************************/
113 /******************************************************************/
114
115 class AliAODEmptyParticleCut:  public AliAODParticleCut
116 {
117 //Empty - it passes possitively all particles - it means returns always False
118 //Class describing cut on particles
119   public:
120     AliAODEmptyParticleCut(){};
121     virtual ~AliAODEmptyParticleCut(){};
122     
123     Bool_t Pass(AliVAODParticle*) const {return kFALSE;} //accept everything
124     Bool_t IsEmpty() const {return kTRUE;}
125
126     ClassDef(AliAODEmptyParticleCut,1)
127  
128 };
129
130 /******************************************************************/
131 /******************************************************************/
132 /******************************************************************/
133
134 class AliAODBaseCut: public TObject
135  {
136    //This class defines the range of some property - pure virtual
137    //Property is coded by AliAODCutTypes type
138    
139    public:
140      
141      AliAODBaseCut(Double_t min = 0.0, Double_t max = 0.0,AliAODCutProperty prop = kAODNone):
142                    fProperty(prop),fMin(min),fMax(max){}
143
144      virtual           ~AliAODBaseCut(){}
145      
146      virtual Bool_t    Pass(AliVAODParticle *p) const;
147      
148      void              SetRange(Double_t min, Double_t max){fMin = min; fMax = max;}
149
150      void              SetMinimum(Double_t min){fMin = min;}
151      void              SetMaximum(Double_t max){fMax = max;}
152      
153      Double_t          GetMinimum() const {return fMin;}
154      Double_t          GetMaximum() const {return fMax;}
155      
156      AliAODCutProperty GetProperty() const {return fProperty;}
157      virtual void Print(void) const;
158      
159    protected:
160      virtual Double_t  GetValue(AliVAODParticle *) const = 0;
161
162      AliAODCutProperty fProperty; //property that this cut describes
163      Double_t fMin;//minimum value
164      Double_t fMax;//maximum value
165      
166    private:
167      void PrintProperty(void) const;
168      ClassDef(AliAODBaseCut,1)
169    
170  };
171
172 inline Bool_t
173 AliAODBaseCut::Pass(AliVAODParticle *p) const
174 {
175   //cjecks if particle property fits in range
176   if ( (GetValue(p) < fMin) || (GetValue(p) > fMax ) ) return kTRUE; //rejected
177   else return kFALSE; //accepted
178 }
179 /******************************************************************/
180 /******************************************************************/
181 /******************************************************************/
182
183  
184 class AliAODMomentumCut: public AliAODBaseCut
185  {
186   public: 
187     AliAODMomentumCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODP){}
188     virtual ~AliAODMomentumCut(){}
189   protected:
190     Double_t  GetValue(AliVAODParticle * p)const{return p->P();}
191     ClassDef(AliAODMomentumCut,1)
192  };
193
194 class AliAODPtCut: public AliAODBaseCut
195  {
196   public: 
197     AliAODPtCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODPt){}
198     virtual ~AliAODPtCut(){}
199   protected:
200     Double_t  GetValue(AliVAODParticle * p)const{return p->Pt();}
201     ClassDef(AliAODPtCut,1)
202  };
203
204
205 class AliAODEnergyCut: public AliAODBaseCut
206  {
207   public: 
208     AliAODEnergyCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODE){}
209     virtual ~AliAODEnergyCut(){}
210   protected:
211     Double_t  GetValue(AliVAODParticle * p)const {return p->E();}
212     ClassDef(AliAODEnergyCut,1)
213  };
214
215 class AliAODRapidityCut: public AliAODBaseCut
216  {
217   public: 
218     AliAODRapidityCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODRapidity){}
219     virtual ~AliAODRapidityCut(){}
220   protected:
221     Double_t  GetValue(AliVAODParticle * p)const{return p->Y();}
222     ClassDef(AliAODRapidityCut,1)
223  };
224
225 class AliAODPseudoRapidityCut: public AliAODBaseCut
226  {
227   public: 
228     AliAODPseudoRapidityCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODPseudoRapidity){}
229     virtual ~AliAODPseudoRapidityCut(){}
230   protected:
231     Double_t  GetValue(AliVAODParticle * p)const{return p->Eta();}
232     ClassDef(AliAODPseudoRapidityCut,1)
233  };
234
235 class AliAODPxCut: public AliAODBaseCut
236  {
237   public: 
238     AliAODPxCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODPx){}
239     virtual ~AliAODPxCut(){}
240   protected:
241     Double_t  GetValue(AliVAODParticle * p)const{return p->Px();}
242     ClassDef(AliAODPxCut,1)
243  };
244
245 class AliAODPyCut: public AliAODBaseCut
246  {
247   public: 
248     AliAODPyCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODPy){}
249     virtual ~AliAODPyCut(){}
250   protected:
251     Double_t  GetValue(AliVAODParticle * p)const{return p->Py();}
252     ClassDef(AliAODPyCut,1)
253  };
254
255
256 class AliAODPzCut: public AliAODBaseCut
257  {
258   public: 
259     AliAODPzCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODPz){}
260     virtual ~AliAODPzCut(){}
261   protected:
262     Double_t  GetValue(AliVAODParticle * p)const{return p->Pz();}
263     ClassDef(AliAODPzCut,1)
264  };
265
266 class AliAODPhiCut: public AliAODBaseCut
267  {
268   public: 
269     AliAODPhiCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODPhi){}
270     virtual ~AliAODPhiCut(){}
271   protected:
272     Double_t  GetValue(AliVAODParticle * p)const{return p->Phi();}
273     ClassDef(AliAODPhiCut,1)
274   
275  };
276
277 class AliAODThetaCut: public AliAODBaseCut
278  {
279   public: 
280     AliAODThetaCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODTheta){}
281     virtual ~AliAODThetaCut(){}
282   protected:
283     Double_t  GetValue(AliVAODParticle * p)const{return p->Theta();}
284     ClassDef(AliAODThetaCut,1)
285   
286  };
287
288 class AliAODVxCut: public AliAODBaseCut
289  {
290  //Cut of the X coAnddinate of the vertex position
291   public: 
292     AliAODVxCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODVx){}
293     virtual ~AliAODVxCut(){}
294   protected:
295     Double_t  GetValue(AliVAODParticle * p)const{return p->Vx();} //retruns value of the vertex
296     ClassDef(AliAODVxCut,1)
297   
298  };
299
300
301 class AliAODVyCut: public AliAODBaseCut
302  {
303  //Cut of the X coAnddinate of the vertex position
304   public: 
305     AliAODVyCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODVy){}
306     virtual ~AliAODVyCut(){}
307   protected:
308     Double_t  GetValue(AliVAODParticle * p)const{return p->Vy();} //retruns value of the vertex
309     ClassDef(AliAODVyCut,1)
310   
311  };
312
313 class AliAODVzCut: public AliAODBaseCut
314  {
315  //Cut of the X coAnddinate of the vertex position
316   public: 
317     AliAODVzCut(Double_t min = 0.0, Double_t max = 0.0):AliAODBaseCut(min,max,kAODVz){}
318     virtual ~AliAODVzCut(){}
319   protected:
320     Double_t  GetValue(AliVAODParticle * p)const{return p->Vz();} //retruns value of the vertex
321     
322     ClassDef(AliAODVzCut,1)
323   
324  };
325
326 class AliAODPIDCut:  public AliAODBaseCut
327  {
328    public:
329      AliAODPIDCut():AliAODBaseCut(0.0,0.0,kAODPid),fPID(0){}
330      AliAODPIDCut(Int_t pid, Double_t min = 0.0, Double_t max = 1.0):AliAODBaseCut(min,max,kAODPid),fPID(pid){}
331      virtual ~AliAODPIDCut(){}
332      
333      void SetPID(Int_t pid){fPID = pid;}
334      void Print(void) const;
335    protected:
336      Double_t  GetValue(AliVAODParticle * p)const{return p->GetProbability(fPID);}
337      Int_t     fPID; //pid of particle that the pid is set 
338      ClassDef(AliAODPIDCut,1)
339  };
340 //___________________________________________________
341 /////////////////////////////////////////////////////
342 //                                                 //
343 // class AliAODLogicalOperCut                      //
344 //                                                 //
345 // This cut is base class fAnd class that perfAndms  //
346 // logical operations on cuts                      //
347 //                                                 //
348 /////////////////////////////////////////////////////
349 class AliAODLogicalOperCut:  public AliAODBaseCut
350  {
351    public:
352      AliAODLogicalOperCut();
353      AliAODLogicalOperCut(AliAODBaseCut* first, AliAODBaseCut* second);
354      virtual   ~AliAODLogicalOperCut();
355    protected:
356      Double_t  GetValue(AliVAODParticle * /*part*/) const {MayNotUse("GetValue");return 0.0;}
357      
358      AliAODBaseCut* fFirst;   //second cut
359      AliAODBaseCut* fSecond;  //first cut
360    private:  
361     class  AliAODDummyBaseCut: public AliAODBaseCut 
362      {
363        Double_t  GetValue(AliVAODParticle * /*part*/) const {return 0.0;}
364        Bool_t    Pass(AliVAODParticle* /*part*/) const;
365      };
366      
367     ClassDef(AliAODLogicalOperCut,1)
368  };
369
370 class AliAODOrCut: public AliAODLogicalOperCut
371 {
372    public:
373      AliAODOrCut(){}
374      AliAODOrCut(AliAODBaseCut* first, AliAODBaseCut* second):AliAODLogicalOperCut(first,second){}
375      virtual   ~AliAODOrCut(){}
376      Bool_t    Pass(AliVAODParticle *p) const;
377      ClassDef(AliAODOrCut,1)
378 };
379
380 class AliAODAndCut: public AliAODLogicalOperCut
381 {
382    public:
383      AliAODAndCut(){}
384      AliAODAndCut(AliAODBaseCut* first, AliAODBaseCut* second):AliAODLogicalOperCut(first,second){}
385      virtual   ~AliAODAndCut(){}
386      Bool_t    Pass(AliVAODParticle *p) const;
387      ClassDef(AliAODAndCut,1)
388 };
389
390 #endif