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()]
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.
15 // authors: Martin Vala (martin.vala@cern.ch)
16 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
20 #include "AliRsnCut.h"
24 //_________________________________________________________________________________________________
25 AliRsnCut::AliRsnCut() :
41 // Default constructor.
45 //_________________________________________________________________________________________________
46 AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
48 fVarType(copy.fVarType),
55 fCutValueI(copy.fCutValueI),
56 fCutValueU(copy.fCutValueU),
57 fCutValueD(copy.fCutValueD),
58 fCutResult(copy.fCutResult),
66 //_________________________________________________________________________________________________
68 (const char *name, Int_t min, Int_t max) :
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.
92 //_________________________________________________________________________________________________
94 (const char *name, ULong_t min, ULong_t max) :
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.
118 //_________________________________________________________________________________________________
120 (const char *name, Double_t min, Double_t max) :
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.
144 //_________________________________________________________________________________________________
145 AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
148 // Assignment operator
149 // don't duplicate memory occupancy for pointer
152 fVarType = copy.fVarType;
159 fCutValueI = copy.fCutValueI;
160 fCutValueD = copy.fCutValueD;
161 fCutValueU = copy.fCutValueU;
162 fCutResult = copy.fCutResult;
163 fEvent = copy.fEvent;
168 //_________________________________________________________________________________________________
169 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnDaughter* /*track*/)
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
177 AliWarning("This cut does not provide checks on AliRsnDaughter. This function will return kTRUE");
181 //_________________________________________________________________________________________________
182 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnPairParticle* /*pair*/)
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
190 AliWarning("This cut does not provide checks on AliRsnPairParticle. This function will return kTRUE");
194 //_________________________________________________________________________________________________
195 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*event*/)
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
203 AliWarning("This cut does not provide checks on AliRsnEvent. This function will return kTRUE");
207 //_________________________________________________________________________________________________
208 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*ev1*/, AliRsnEvent* /*ev2*/)
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
216 AliWarning("This cut does not provide checks on two AliRsnEvent's. This function will return kTRUE");
220 //_________________________________________________________________________________________________
221 Bool_t AliRsnCut::OkValue()
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.
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 ================================");
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 ================================");
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 ================================");
264 AliError(Form("fVarType = %d --> not allowed", fVarType));
271 //_________________________________________________________________________________________________
272 Bool_t AliRsnCut::OkRange()
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.
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 ================================");
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 ================================");
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 ================================");
315 AliError(Form("fVarType = %d --> not allowed", fVarType));