]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCut.h
Added a new cut, an example macro for efficiency computation and a structure for...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCut.h
1 //
2 // Class AliRsnCut
3 //
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval  [--> IsBetween()]
6 // - a value equal to a given reference     [--> IsEqual()  ]
7 // In all cases, the reference value(s) is (are) given as data members
8 // and each kind of cut requires a given value type (Int, UInt, Double),
9 // but the cut check procedure is then automatized and chosen thanks to
10 // an enumeration of the implemented cut types.
11 // At the end, the user (or any other point which uses this object) has
12 // to use the method IsSelected() to check if this cut has been passed.
13 //
14 // authors: Martin Vala (martin.vala@cern.ch)
15 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
16 //
17
18 #ifndef ALIRSNCUT_H
19 #define ALIRSNCUT_H
20
21 #include "TNamed.h"
22
23 class AliRsnEvent;
24
25 class AliRsnCut : public TNamed
26 {
27   public:
28
29     // possible targets for a cut
30     enum ETarget 
31     {
32       kDaughter = 0,
33       kMother,
34       kEvent,
35       kMixEvent,
36       kLastCutTarget
37     };
38
39     // data type for check
40     enum EVarType 
41     {
42       kNoVar = 0,
43       kInt,
44       kDouble
45     };
46
47     AliRsnCut(ETarget target = kLastCutTarget);
48     AliRsnCut(const AliRsnCut& copy);
49     AliRsnCut& operator=(const AliRsnCut& copy);
50     AliRsnCut(const char *name, ETarget target, Int_t    min, Int_t    max = 0 );
51     AliRsnCut(const char *name, ETarget target, Double_t min, Double_t max = 0.);
52     virtual ~AliRsnCut() { /*nothing*/ };
53     
54     EVarType         GetVarTypeEnum() {return fVarType;}
55     Char_t           GetVarTypeChar() {if (fVarType == kInt) return 'I'; else if (fVarType == kDouble) return 'D'; else return 'X';}
56     ETarget          GetTargetEnum()  {return fTarget;}
57     Char_t           GetTargetChar()  {if (fTarget == kDaughter) return 'D'; else if (fTarget == kMother) return 'M'; else if (fTarget == kEvent) return 'E'; else return 'X';}
58     Bool_t           IsTarget(ETarget target) {return (fTarget == target);}
59     Bool_t           TargetOK(TObject *obj1, TObject *obj2 = 0x0);
60     Int_t            GetMinI()        {return fMinI;}
61     Int_t            GetMaxI()        {return fMaxI;}
62     Double_t         GetMinD()        {return fMinD;}
63     Double_t         GetMaxD()        {return fMaxD;}
64     Int_t            GetCutValueI()   {return fCutValueI;}
65     Double_t         GetCutValueD()   {return fCutValueD;}
66     Bool_t           GetCutResult()   {return fCutResult;}
67     
68     void             SetRange(Int_t    min, Int_t    max) {fMinI = min; fMaxI = max; fVarType = kInt;}
69     void             SetRange(Double_t min, Double_t max) {fMinD = min; fMaxD = max; fVarType = kDouble;}
70
71     void             SetValue(Int_t value)    {fMinI = value; fVarType = kInt;}
72     void             SetValue(Double_t value) {fMinD = value; fVarType = kDouble;}
73     
74     Bool_t           OkValue();
75     Bool_t           OkRange();
76     Bool_t           OkValueI();
77     Bool_t           OkRangeI();
78     Bool_t           OkValueD();
79     Bool_t           OkRangeD();
80
81     virtual void     SetEvent(AliRsnEvent *event);
82     AliRsnEvent*     GetEvent() {return fEvent;}
83     
84     virtual Bool_t   IsSelected(TObject *obj1, TObject *obj2 = 0x0);
85     virtual void     Print(Option_t *opt = "") const;
86
87   protected:
88
89     EVarType     fVarType;    // type of checked variable
90     ETarget      fTarget;     // type of object on which the cut is checked
91
92     Int_t        fMinI;       // lower edge of INT range or ref. value    for INT CUT
93     Int_t        fMaxI;       // upper edge of INT range (not used    for value cuts)
94     Double_t     fMinD;       // lower edge of DOUBLE range or ref. value    for INT CUT
95     Double_t     fMaxD;       // upper edge of DOUBLE range (not used    for value cuts)
96
97     Int_t        fCutValueI;  // cut value INT
98     Double_t     fCutValueD;  // cut value DOUBLE
99     
100     Bool_t       fCutResult;  // tells if the cut is passed or not
101
102     AliRsnEvent *fEvent;      //! pointer to current event (can be needed sometimes, but never streamed)
103
104     ClassDef(AliRsnCut, 1)
105 };
106
107 #endif