]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCut.cxx
AliRsnCutManager:
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCut.cxx
1 //
2 // *** Class AliRsnCut ***
3 //
4 // Cut base class: all other cuts inherit from it.
5 // The 'core' of the class is the method "IsSelected()" which
6 // must be overloaded by any specific cut implementation.
7 //
8 // This class provides some default instruments to check values
9 // agains a reference or an allowed range, in order to permit
10 // a unique way to execute such kind of checks.
11 //
12 // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
13 //          Martin Vala (martin.vala@cern.ch)
14 //
15
16 #include "AliRsnDaughter.h"
17 #include "AliRsnMother.h"
18 #include "AliRsnEvent.h"
19
20 #include "AliRsnCut.h"
21
22 ClassImp(AliRsnCut)
23
24 //______________________________________________________________________________
25 AliRsnCut::AliRsnCut(const char *name, RSNTARGET target) :
26   AliRsnTarget(name, target),
27   fMinI(0),
28   fMaxI(0),
29   fMinD(0.),
30   fMaxD(0.),
31   fCutValueI(0),
32   fCutValueD(0.0),
33   fCutResult(kTRUE)
34 {
35 //
36 // Default constructor.
37 //
38 }
39
40 //______________________________________________________________________________
41 AliRsnCut::AliRsnCut
42 (const char *name, RSNTARGET target, Int_t imin, Int_t imax, Double_t dmin, Double_t dmax) :
43   AliRsnTarget(name, target),
44   fMinI(imin),
45   fMaxI(imax),
46   fMinD(dmin),
47   fMaxD(dmax),
48   fCutValueI(0),
49   fCutValueD(0.0),
50   fCutResult(kTRUE)
51 {
52 //
53 // Constructor with arguments.
54 // This is provided to allow a quick setting of all data members.
55 //
56 }
57
58 //______________________________________________________________________________
59 AliRsnCut::AliRsnCut
60 (const char *name, RSNTARGET target, Double_t dmin, Double_t dmax, Int_t imin, Int_t imax) :
61   AliRsnTarget(name, target),
62   fMinI(imin),
63   fMaxI(imax),
64   fMinD(dmin),
65   fMaxD(dmax),
66   fCutValueI(0),
67   fCutValueD(0.0),
68   fCutResult(kTRUE)
69 {
70 //
71 // Constructor with arguments.
72 // This is provided to allow a quick setting of all data members.
73 //
74 }
75
76 //______________________________________________________________________________
77 AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
78   AliRsnTarget(copy),
79   fMinI(copy.fMinI),
80   fMaxI(copy.fMaxI),
81   fMinD(copy.fMinD),
82   fMaxD(copy.fMaxD),
83   fCutValueI(copy.fCutValueI),
84   fCutValueD(copy.fCutValueD),
85   fCutResult(copy.fCutResult)
86 {
87 //
88 // Copy constructor.
89 // Don't duplicate memory occupancy for pointer
90 //
91 }
92
93 //______________________________________________________________________________
94 AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
95 {
96 //
97 // Assignment operator.
98 // Don't duplicate memory occupancy for pointer
99 //
100
101   AliRsnTarget::operator=(copy);
102   
103   fMinI      = copy.fMinI;
104   fMaxI      = copy.fMaxI;
105   fMinD      = copy.fMinD;
106   fMaxD      = copy.fMaxD;
107   fCutValueI = copy.fCutValueI;
108   fCutValueD = copy.fCutValueD;
109
110   return (*this);
111 }
112
113 //______________________________________________________________________________
114 Bool_t AliRsnCut::IsSelected(TObject* /*object*/)
115 {
116 //
117 // Virtual cut-checking method.
118 // In this implementation, it does nothing, and all classes
119 // inheriting from this, should provide a proper implementation
120 // which must return kTRUE if the cut is passed, and kFALSE otherwise.
121 //
122
123   AliWarning("This virtual function must be implemented properly");
124   return kTRUE;
125 }
126
127 //______________________________________________________________________________
128 Bool_t AliRsnCut::OkValueI()
129 {
130 //
131 // This method is used when the cut consists in comparing the cut value
132 // with a reference integer value to which it must be equal.
133 //
134
135   // eval result
136   fCutResult = (fCutValueI == fMinI);
137   
138   // print debug message
139   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
140   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
141   AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
142   AliDebug(AliLog::kDebug + 2, Form("Cut value    : %d", fMinI));
143   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
144   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
145   
146   return fCutResult;
147 }
148
149 //______________________________________________________________________________
150 Bool_t AliRsnCut::OkValueD()
151 {
152 //
153 // This method is used when the cut consists in comparing the cut value
154 // with a reference double value to which it must be equal (or at least, almost).
155 //
156
157   // eval result
158   fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
159   
160   // print debug message
161   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
162   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
163   AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
164   AliDebug(AliLog::kDebug + 2, Form("Cut value    : %f", fMinD));
165   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
166   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
167   
168   return fCutResult;
169 }
170
171 //______________________________________________________________________________
172 Bool_t AliRsnCut::OkRangeI()
173 {
174 //
175 // This method is used when the cut consists in an allowed range
176 // where the cut value must be included to pass the cut.
177 // Then, the cut result is kTRUE if the cut value is inside this range.
178 //
179
180   // eval result
181   fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
182   
183   // print debug message
184   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
185   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
186   AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
187   AliDebug(AliLog::kDebug + 2, Form("Cut range    : %d , %d", fMinI, fMaxI));
188   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
189   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
190   
191   return fCutResult;
192 }
193
194 //______________________________________________________________________________
195 Bool_t AliRsnCut::OkRangeD()
196 {
197 //
198 // This method is used when the cut consists in an allowed range
199 // where the cut value must be included to pass the cut.
200 // Then, the cut result is kTRUE if the cut value is inside this range.
201 //
202
203   // eval result
204   fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
205    
206   // print debug message
207   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
208   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
209   AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
210   AliDebug(AliLog::kDebug + 2, Form("Cut range    : %f , %f", fMinD, fMaxD));
211   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
212   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
213
214   return fCutResult;
215 }
216
217 //______________________________________________________________________________
218 void AliRsnCut::Print(Option_t*) const
219 {
220 //
221 // Override TObject::Print() method,
222 // and print some useful info about the cut general parameters.
223 //
224
225   AliInfo("=== CUT DETAILS ====================================");
226   AliInfo(Form("Cut name     : [%s]", GetName()));
227   AliInfo(Form("Cut target   : [%s]", GetTargetTypeName()));
228   AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD));
229   AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI));
230   AliInfo("====================================================");
231 }