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 "AliRsnDaughter.h"
21 #include "AliRsnMother.h"
22 #include "AliRsnEvent.h"
24 #include "AliRsnCut.h"
28 //_________________________________________________________________________________________________
29 AliRsnCut::AliRsnCut(ETarget target) :
43 // Default constructor.
47 //_________________________________________________________________________________________________
48 AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
50 fVarType(copy.fVarType),
51 fTarget(copy.fTarget),
56 fCutValueI(copy.fCutValueI),
57 fCutValueD(copy.fCutValueD),
58 fCutResult(copy.fCutResult),
66 //_________________________________________________________________________________________________
68 (const char *name, ETarget target, Int_t min, Int_t max) :
82 // Constructor with integer values.
83 // If the cut must check values inside a range,
84 // both 'value' arguments must be used, and they are, in the order,
85 // the minimum and maximum of the allowed range.
86 // If the cut must check a value, the second 'value' argument will never be used.
90 //_________________________________________________________________________________________________
92 (const char *name, ETarget target, Double_t min, Double_t max) :
106 // Constructor with double values.
107 // If the cut must check values inside a range,
108 // both 'value' arguments must be used, and they are, in the order,
109 // the minimum and maximum of the allowed range.
110 // If the cut must check a value, the second 'value' argument will never be used.
114 //_________________________________________________________________________________________________
115 AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
118 // Assignment operator
119 // don't duplicate memory occupancy for pointer
122 fVarType = copy.fVarType;
123 fTarget = copy.fTarget;
128 fCutValueI = copy.fCutValueI;
129 fCutValueD = copy.fCutValueD;
130 fCutResult = copy.fCutResult;
131 fEvent = copy.fEvent;
136 //_________________________________________________________________________________________________
137 Bool_t AliRsnCut::TargetOK(TObject *obj1, TObject *obj2)
140 // This method checks if the expected target and the passed object match.
145 AliError("Cannot cut on a NULL object!");
152 if (dynamic_cast<AliRsnDaughter*>(obj1) == 0x0)
154 AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnDaughter', passed '%s'", GetName(), obj1->ClassName()));
160 if (dynamic_cast<AliRsnMother*>(obj1) == 0x0)
162 AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnMother', passed '%s'", GetName(), obj1->ClassName()));
168 if (dynamic_cast<AliRsnEvent*>(obj1) == 0x0)
170 AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnEvent', passed '%s'", GetName(), obj1->ClassName()));
176 if (dynamic_cast<AliRsnEvent*>(obj1) == 0x0)
178 AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnEvent', passed '%s' an", GetName(), obj1->ClassName()));
184 if (dynamic_cast<AliRsnEvent*>(obj2) == 0x0)
186 AliError(Form("[%s] Target mismatch (obj #2): expected 'AliRsnEvent', passed '%s' an", GetName(), obj2->ClassName()));
193 AliError("Mix-event cuts require 2 not NULL objects");
205 //_________________________________________________________________________________________________
206 Bool_t AliRsnCut::IsSelected(TObject* /*obj1*/, TObject* /*obj2*/)
209 // Virtual cut-checking method for event mixing.
210 // This method checks only that the target is the oner for mixing.
213 AliWarning("Single-object cuts are not implemented here.");
217 //_________________________________________________________________________________________________
218 Bool_t AliRsnCut::OkValue()
221 // This method is used when the cut consists in comparing the cut value
222 // with a reference value to which it must be equal (in case of doubles, 'almost' equal).
223 // Then, the cut result is kTRUE if the cut value is equal to this reference value.
233 AliError(Form("fVarType = %d --> not allowed", fVarType));
238 //_________________________________________________________________________________________________
239 Bool_t AliRsnCut::OkRange()
242 // This method is used when the cut consists in an allowed range
243 // where the cut value must be included to pass the cut.
244 // Then, the cut result is kTRUE if the cut value is inside this range.
254 AliError(Form("fVarType = %d --> not allowed", fVarType));
259 //_________________________________________________________________________________________________
260 Bool_t AliRsnCut::OkValueI()
263 // This method is used when the cut consists in comparing the cut value
264 // with a reference integer value to which it must be equal.
268 fCutResult = (fCutValueI == fMinI);
270 // print debug message
271 AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
272 AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
273 AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
274 AliDebug(AliLog::kDebug + 2, Form("Cut value : %d", fMinI));
275 AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
276 AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
281 //_________________________________________________________________________________________________
282 Bool_t AliRsnCut::OkValueD()
285 // This method is used when the cut consists in comparing the cut value
286 // with a reference double value to which it must be equal (or at least, almost).
290 fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
292 // print debug message
293 AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
294 AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
295 AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
296 AliDebug(AliLog::kDebug + 2, Form("Cut value : %f", fMinD));
297 AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
298 AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
303 //_________________________________________________________________________________________________
304 Bool_t AliRsnCut::OkRangeI()
307 // This method is used when the cut consists in an allowed range
308 // where the cut value must be included to pass the cut.
309 // Then, the cut result is kTRUE if the cut value is inside this range.
313 fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
315 // print debug message
316 AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
317 AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
318 AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
319 AliDebug(AliLog::kDebug + 2, Form("Cut range : %d , %d", fMinI, fMaxI));
320 AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
321 AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
326 //_________________________________________________________________________________________________
327 Bool_t AliRsnCut::OkRangeD()
330 // This method is used when the cut consists in an allowed range
331 // where the cut value must be included to pass the cut.
332 // Then, the cut result is kTRUE if the cut value is inside this range.
336 fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
338 // print debug message
339 AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
340 AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
341 AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
342 AliDebug(AliLog::kDebug + 2, Form("Cut range : %f , %f", fMinD, fMaxD));
343 AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
344 AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
349 //_________________________________________________________________________________________________
350 void AliRsnCut::Print(Option_t*) const
353 // Override TObject::Print() method
359 case kDaughter: sprintf(target, "DAUGHTER"); break;
360 case kMother : sprintf(target, "MOTHER"); break;
361 case kEvent : sprintf(target, "EVENT"); break;
362 case kMixEvent: sprintf(target, "MIX EVENT"); break;
363 default : sprintf(target, "UNDEFINED"); break;
366 AliInfo("=== CUT DETAILS ====================================");
367 AliInfo(Form("Cut name : [%s]", GetName()));
368 AliInfo(Form("Cut target : [%s]", target));
369 AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD));
370 AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI));
371 AliInfo("====================================================");
374 //_________________________________________________________________________________________________
375 void AliRsnCut::SetEvent(AliRsnEvent *event)
378 // Sets the reference event