]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCut.cxx
fixed warnings
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCut.cxx
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     [--> MatchesValue()]
7 //
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
14 //
15 // authors: Martin Vala (martin.vala@cern.ch)
16 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17 //
18 #include "AliLog.h"
19
20 #include "AliRsnCut.h"
21
22 ClassImp(AliRsnCut)
23
24 //_________________________________________________________________________________________________
25 AliRsnCut::AliRsnCut() :
26     TNamed(),
27     fVarType(kInt),
28     fMinI(0),
29     fMaxI(0),
30     fMinU(0),
31     fMaxU(0),
32     fMinD(0.0),
33     fMaxD(0.0),
34     fCutValueI(0),
35     fCutValueU(0),
36     fCutValueD(0.0),
37     fCutResult(kTRUE),
38     fEvent(0x0)
39 {
40 //
41 // Default constructor.
42 //
43 }
44
45 //_________________________________________________________________________________________________
46 AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
47     TNamed(copy),
48     fVarType(copy.fVarType),
49     fMinI(copy.fMinI),
50     fMaxI(copy.fMaxI),
51     fMinU(copy.fMinU),
52     fMaxU(copy.fMaxU),
53     fMinD(copy.fMinD),
54     fMaxD(copy.fMaxD),
55     fCutValueI(copy.fCutValueI),
56     fCutValueU(copy.fCutValueU),
57     fCutValueD(copy.fCutValueD),
58     fCutResult(copy.fCutResult),
59     fEvent(copy.fEvent)
60 {
61 //
62 // Copy constructor.
63 //
64 }
65
66 //_________________________________________________________________________________________________
67 AliRsnCut::AliRsnCut
68 (const char *name, Int_t min, Int_t max) :
69     TNamed(name, ""),
70     fVarType(kInt),
71     fMinI(min),
72     fMaxI(max),
73     fMinU(0),
74     fMaxU(0),
75     fMinD(0.0),
76     fMaxD(0.0),
77     fCutValueI(0),
78     fCutValueU(0),
79     fCutValueD(0.0),
80     fCutResult(kTRUE),
81     fEvent(0x0)
82 {
83 //
84 // Constructor.
85 // If the cut must check values inside a range,
86 // both 'value' arguments must be used, and they are, in the order,
87 // the minimum and maximum of the allowed range.
88 // If the cut must check a value, the second 'value' argument will never be used.
89 //
90 }
91
92 //_________________________________________________________________________________________________
93 AliRsnCut::AliRsnCut
94 (const char *name, ULong_t min, ULong_t max) :
95     TNamed(name, ""),
96     fVarType(kULong),
97     fMinI(0),
98     fMaxI(0),
99     fMinU(min),
100     fMaxU(max),
101     fMinD(0.0),
102     fMaxD(0.0),
103     fCutValueI(0),
104     fCutValueU(0),
105     fCutValueD(0.0),
106     fCutResult(kTRUE),
107     fEvent(0x0)
108 {
109 //
110 // Constructor.
111 // If the cut must check values inside a range,
112 // both 'value' arguments must be used, and they are, in the order,
113 // the minimum and maximum of the allowed range.
114 // If the cut must check a value, the second 'value' argument will never be used.
115 //
116 }
117
118 //_________________________________________________________________________________________________
119 AliRsnCut::AliRsnCut
120 (const char *name, Double_t min, Double_t max) :
121     TNamed(name, ""),
122     fVarType(kDouble),
123     fMinI(0),
124     fMaxI(0),
125     fMinU(0),
126     fMaxU(0),
127     fMinD(min),
128     fMaxD(max),
129     fCutValueI(0),
130     fCutValueU(0),
131     fCutValueD(0.0),
132     fCutResult(kTRUE),
133     fEvent(0x0)
134 {
135 //
136 // Constructor.
137 // If the cut must check values inside a range,
138 // both 'value' arguments must be used, and they are, in the order,
139 // the minimum and maximum of the allowed range.
140 // If the cut must check a value, the second 'value' argument will never be used.
141 //
142 }
143
144 //_________________________________________________________________________________________________
145 AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
146 {
147 //
148 // Assignment operator
149 // don't duplicate memory occupancy for pointer
150 //
151
152   fVarType   = copy.fVarType;
153   fMinI      = copy.fMinI;
154   fMaxI      = copy.fMaxI;
155   fMinD      = copy.fMinD;
156   fMaxD      = copy.fMaxD;
157   fMinU      = copy.fMinU;
158   fMaxU      = copy.fMaxU;
159   fCutValueI = copy.fCutValueI;
160   fCutValueD = copy.fCutValueD;
161   fCutValueU = copy.fCutValueU;
162   fCutResult = copy.fCutResult;
163   fEvent     = copy.fEvent;
164
165   return (*this);
166 }
167
168 //_________________________________________________________________________________________________
169 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnDaughter* /*track*/)
170 {
171 //
172 // Virtual cut-checking method.
173 // In base class, these methods compare the argument type
174 // with the defined target, in order to detect a mismatch
175 //
176
177   AliWarning("This cut does not provide checks on AliRsnDaughter. This function will return kTRUE");
178   return kTRUE;
179 }
180
181 //_________________________________________________________________________________________________
182 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnPairParticle* /*pair*/)
183 {
184 //
185 // Virtual cut-checking method.
186 // In base class, these methods compare the argument type
187 // with the defined target, in order to detect a mismatch
188 //
189
190   AliWarning("This cut does not provide checks on AliRsnPairParticle. This function will return kTRUE");
191   return kTRUE;
192 }
193
194 //_________________________________________________________________________________________________
195 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*event*/)
196 {
197 //
198 // Virtual cut-checking method.
199 // In base class, these methods compare the argument type
200 // with the defined target, in order to detect a mismatch
201 //
202
203   AliWarning("This cut does not provide checks on AliRsnEvent. This function will return kTRUE");
204   return kTRUE;
205 }
206
207 //_________________________________________________________________________________________________
208 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*ev1*/, AliRsnEvent* /*ev2*/)
209 {
210 //
211 // Virtual cut-checking method.
212 // In base class, these methods compare the argument type
213 // with the defined target, in order to detect a mismatch
214 //
215
216   AliWarning("This cut does not provide checks on two AliRsnEvent's. This function will return kTRUE");
217   return kTRUE;
218 }
219
220 //_________________________________________________________________________________________________
221 Bool_t AliRsnCut::OkValue()
222 {
223 //
224 // This method is used when the cut consists in comparing the cut value
225 // with a reference value to which it must be equal (in case of doubles, 'almost' equal).
226 // Then, the cut result is kTRUE if the cut value is equal to this reference value.
227 //
228
229   switch (fVarType) {
230   case kInt:
231     // eval result
232     fCutResult = (fCutValueI == fMinI);
233     // print debug message
234     AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
235     AliDebug(AliLog::kDebug + 3, Form("Cut name     : %s", GetName()));
236     AliDebug(AliLog::kDebug + 3, Form("Checked value: %d", fCutValueI));
237     AliDebug(AliLog::kDebug + 3, Form("Cut value    : %d", fMinI));
238     AliDebug(AliLog::kDebug + 3, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
239     AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
240     break;
241   case kULong:
242     // eval result
243     fCutResult = (fCutValueU == fMinU);
244     // print debug message
245     AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
246     AliDebug(AliLog::kDebug + 3, Form("Cut name     : %s" , GetName()));
247     AliDebug(AliLog::kDebug + 3, Form("Checked value: %lu", fCutValueU));
248     AliDebug(AliLog::kDebug + 3, Form("Cut value    : %lu", fMinU));
249     AliDebug(AliLog::kDebug + 3, Form("Cut result   : %s" , (fCutResult ? "PASSED" : "NOT PASSED")));
250     AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
251     break;
252   case kDouble:
253     // eval result
254     fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
255     // print debug message
256     AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
257     AliDebug(AliLog::kDebug + 3, Form("Cut name     : %s", GetName()));
258     AliDebug(AliLog::kDebug + 3, Form("Checked value: %f", fCutValueD));
259     AliDebug(AliLog::kDebug + 3, Form("Cut value    : %f", fMinD));
260     AliDebug(AliLog::kDebug + 3, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
261     AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
262     break;
263   default:
264     AliError(Form("fVarType = %d --> not allowed", fVarType));
265     return kFALSE;
266   }
267
268   return fCutResult;
269 }
270
271 //_________________________________________________________________________________________________
272 Bool_t AliRsnCut::OkRange()
273 {
274 //
275 // This method is used when the cut consists in an allowed range
276 // where the cut value must be included to pass the cut.
277 // Then, the cut result is kTRUE if the cut value is inside this range.
278 //
279
280   switch (fVarType) {
281   case kInt:
282     // eval result
283     fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
284     // print debug message
285     AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
286     AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
287     AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
288     AliDebug(AliLog::kDebug + 2, Form("Cut range    : %d , %d", fMinI, fMaxI));
289     AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
290     AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
291     break;
292   case kULong:
293     // eval result
294     fCutResult = ((fCutValueU >= fMinU) && (fCutValueU <= fMaxU));
295     // print debug message
296     AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
297     AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s"       , GetName()));
298     AliDebug(AliLog::kDebug + 2, Form("Checked value: %lu"      , fCutValueU));
299     AliDebug(AliLog::kDebug + 2, Form("Cut range    : %lu , %lu", fMinU, fMaxU));
300     AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s"       , (fCutResult ? "PASSED" : "NOT PASSED")));
301     AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
302     break;
303   case kDouble:
304     // eval result
305     fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
306     // print debug message
307     AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ====================================");
308     AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
309     AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
310     AliDebug(AliLog::kDebug + 2, Form("Cut range    : %f , %f", fMinD, fMaxD));
311     AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
312     AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================");
313     break;
314   default:
315     AliError(Form("fVarType = %d --> not allowed", fVarType));
316     return kFALSE;
317   }
318
319   return fCutResult;
320 }
321