//
-// Class AliRsnCut
+// *** Class AliRsnCut ***
//
-// General implementation of a single cut strategy, which can be:
-// - a value contained in a given interval [--> IsBetween() ]
-// - a value equal to a given reference [--> MatchesValue()]
+// Cut base class: all other cuts inherit from it.
+// The 'core' of the class is the method "IsSelected()" which
+// must be overloaded by any specific cut implementation.
//
-// In all cases, the reference value(s) is (are) given as data members
-// and each kind of cut requires a given value type (Int, UInt, Double),
-// but the cut check procedure is then automatized and chosen thanks to
-// an enumeration of the implemented cut types.
-// At the end, the user (or any other point which uses this object) has
-// to use the method IsSelected() to check if this cut has been passed.
+// This class provides some default instruments to check values
+// agains a reference or an allowed range, in order to permit
+// a unique way to execute such kind of checks.
//
-// authors: Martin Vala (martin.vala@cern.ch)
-// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+// Martin Vala (martin.vala@cern.ch)
//
-#include "AliLog.h"
-
-#include "AliRsnDaughter.h"
-#include "AliRsnMCInfo.h"
-#include "AliRsnPairParticle.h"
-#include "AliRsnPairDef.h"
-#include "AliRsnEvent.h"
#include "AliRsnCut.h"
-const Double_t AliRsnCut::fgkDSmallNumber = 1e-100;
-const Double_t AliRsnCut::fgkDBigNumber = 1e10;
-const Int_t AliRsnCut::fgkIBigNumber = 32767;
-
ClassImp(AliRsnCut)
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut() :
- TNamed(),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin(0),
- fULMax(2 * (ULong_t) fgkIBigNumber),
- fType(kLastCutType),
- fVarType(kDouble_t)
+//______________________________________________________________________________
+AliRsnCut::AliRsnCut(const char *name, RSNTARGET target) :
+ AliRsnTarget(name, target),
+ fMinI(0),
+ fMaxI(0),
+ fMinD(0.),
+ fMaxD(0.),
+ fCutValueI(0),
+ fCutValueD(0.0),
+ fCutResult(kTRUE)
{
//
-// Constructor
+// Default constructor.
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char *name, const char *title, EType type) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin(0),
- fULMax(2 * (ULong_t) fgkIBigNumber),
- fType(type),
- fVarType(kDouble_t)
+//______________________________________________________________________________
+AliRsnCut::AliRsnCut
+(const char *name, RSNTARGET target, Int_t imin, Int_t imax, Double_t dmin, Double_t dmax) :
+ AliRsnTarget(name, target),
+ fMinI(imin),
+ fMaxI(imax),
+ fMinD(dmin),
+ fMaxD(dmax),
+ fCutValueI(0),
+ fCutValueD(0.0),
+ fCutResult(kTRUE)
{
//
-// Constructor with arguments but not limits
+// Constructor with arguments.
+// This is provided to allow a quick setting of all data members.
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char *name, const char *title, EType type, Double_t min, Double_t max) :
- TNamed(name,title),
- fDMin(min),
- fDMax(max),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin(min),
- fULMax(max),
- fType(type),
- fVarType(kDouble_t)
+//______________________________________________________________________________
+AliRsnCut::AliRsnCut
+(const char *name, RSNTARGET target, Double_t dmin, Double_t dmax, Int_t imin, Int_t imax) :
+ AliRsnTarget(name, target),
+ fMinI(imin),
+ fMaxI(imax),
+ fMinD(dmin),
+ fMaxD(dmax),
+ fCutValueI(0),
+ fCutValueD(0.0),
+ fCutResult(kTRUE)
{
//
-// Constructor with arguments and limits
+// Constructor with arguments.
+// This is provided to allow a quick setting of all data members.
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, Int_t min, Int_t max) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(min),
- fIMax(max),
- fUIMin(0),
- fUIMax(2 * (UInt_t) fgkIBigNumber),
- fULMin(min),
- fULMax(max),
- fType(type),
- fVarType(kInt_t)
+//______________________________________________________________________________
+AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
+ AliRsnTarget(copy),
+ fMinI(copy.fMinI),
+ fMaxI(copy.fMaxI),
+ fMinD(copy.fMinD),
+ fMaxD(copy.fMaxD),
+ fCutValueI(copy.fCutValueI),
+ fCutValueD(copy.fCutValueD),
+ fCutResult(copy.fCutResult)
{
//
-// Constructor with arguments and limits
+// Copy constructor.
+// Don't duplicate memory occupancy for pointer
//
}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, UInt_t min, UInt_t max) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(min),
- fUIMax(max),
- fULMin(min),
- fULMax(max),
- fType(type),
- fVarType(kUInt_t)
+//______________________________________________________________________________
+AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
{
//
-// Constructor with arguments and limits
+// Assignment operator.
+// Don't duplicate memory occupancy for pointer
//
-}
-//________________________________________________________________________________________________________________
-AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, ULong_t min, ULong_t max) :
- TNamed(name,title),
- fDMin(-fgkDBigNumber),
- fDMax(fgkDBigNumber),
- fIMin(-fgkIBigNumber),
- fIMax(fgkIBigNumber),
- fUIMin(min),
- fUIMax(max),
- fULMin(min),
- fULMax(max),
- fType(type),
- fVarType(kUInt_t)
-{
-//
-// Constructor with arguments and limits
-//
-}
+ AliRsnTarget::operator=(copy);
-//________________________________________________________________________________________________________________
-AliRsnCut::~AliRsnCut()
-{
-//
-// Destructor.
-// Does absolutely nothing.
-//
-}
+ fMinI = copy.fMinI;
+ fMaxI = copy.fMaxI;
+ fMinD = copy.fMinD;
+ fMaxD = copy.fMaxD;
+ fCutValueI = copy.fCutValueI;
+ fCutValueD = copy.fCutValueD;
+ fCutResult = copy.fCutResult;
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsBetween(const Double_t &theValue)
-{
-//
-// Interval check.
-// Question: "Is the argument included between fDMin and fDMax?"
-// (not implemented for integer values because usually it is not used with them)
-//
- return ((theValue >= fDMin) && (theValue <= fDMax));
+ return (*this);
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsBetween(const Int_t &theValue)
+//______________________________________________________________________________
+Bool_t AliRsnCut::IsSelected(TObject* /*object*/)
{
//
-// Interval check.
-// Question: "Is the argument included between fDMin and fDMax?"
-// (not implemented for integer values because usually it is not used with them)
+// Virtual cut-checking method.
+// In this implementation, it does nothing, and all classes
+// inheriting from this, should provide a proper implementation
+// which must return kTRUE if the cut is passed, and kFALSE otherwise.
//
- return ((theValue >= fIMin) && (theValue <= fIMax));
-}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const Int_t &theValue)
-{
-//
-// Reference check.
-// Question: "Is the argument equal to fIMin?" (fIMax is assumed never used)
-//
- return (theValue == fIMin);
+ AliWarning("This virtual function must be implemented properly");
+ return kTRUE;
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const UInt_t &theValue)
+//______________________________________________________________________________
+Bool_t AliRsnCut::OkValueI()
{
//
-// Reference check.
-// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
+// This method is used to compare a value with a reference.
+// In the case of integers, the equality must be exact.
//
- return (theValue == fUIMin);
-}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const ULong_t &theValue)
-{
- //
-// Reference check.
-// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
- //
- return (theValue == fULMin);
-}
+ // eval result
+ fCutResult = (fCutValueI == fMinI);
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::MatchesValue(const Double_t &theValue)
-{
-//
-// Reference check.
-// Question: "Is the argument reasonably close to fDMin?" (fDMax is assumed never used)
-// Here, "reasonably close" means that the difference is smaller than the
-// 'fgkSmallNumber' global static data member of this class
-//
- return (TMath::Abs(theValue - fDMin) < fgkDSmallNumber);
-}
+ // print debug message
+ AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================");
+ AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
+ AliDebug(AliLog::kDebug + 2, Form("Cut value : %d", fMinI));
+ AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ====================================================");
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const Double_t &theValue, const Double_t &theValue2)
-{
-//
-// (Re)assignment of cut values
-//
- fType = type;
- fDMin = theValue;
- fDMax = theValue2;
+ return fCutResult;
}
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const Int_t &theValue, const Int_t &theValue2)
+//______________________________________________________________________________
+Bool_t AliRsnCut::OkValueD()
{
//
-// (Re)assignment of cut values
+// This method is used to compare a value with a reference.
+// In the case of doubles, the equality consists in being very close.
//
- fType = type;
- fIMin = theValue;
- fIMax = theValue2;
-}
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const UInt_t &theValue, const UInt_t &theValue2)
-{
-//
-// (Re)assignment of cut values
-//
- fType = type;
- fUIMin = theValue;
- fUIMax = theValue2;
-}
+ // eval result
+ fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
-//________________________________________________________________________________________________________________
-void AliRsnCut::SetCutValues(EType type, const ULong_t &theValue, const ULong_t &theValue2)
-{
- //
-// (Re)assignment of cut values
- //
- fType = type;
- fULMin = theValue;
- fULMax = theValue2;
+ // print debug message
+ AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG =======================================================");
+ AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
+ AliDebug(AliLog::kDebug + 2, Form("Cut value : %f", fMinD));
+ AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================");
+
+ return fCutResult;
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnDaughter *daughter)
+//______________________________________________________________________________
+Bool_t AliRsnCut::OkRangeI()
{
//
-// Core of the whole class.
-// According to the kind of cut selected in the enumeration,
-// checks the cut taking the right values from the argument.
-// Depending on the second argument type, only some cuts are checked
-// (the ones for that type of object), otherwise kTRUE is returned in order
-// not to act as a cleaning factor for an AND with other cuts.
+// This method is used to compare a value with an integer range.
//
- AliDebug(AliLog::kDebug, "<-");
- AliRsnMCInfo *mcinfo = daughter->GetMCInfo();
-
- // check type
- if (type != kParticle)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnDaughter)", type, kParticle, daughter->ClassName()));
- return kTRUE;
- }
- // utility variables
- AliRsnPID::EType pidType;
- Double_t prob;
+ // eval result
+ fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
- switch (fType)
- {
- case kMomentum:
- return IsBetween(daughter->P());
- case kTransMomentum:
- return IsBetween(daughter->Pt());
- case kEta:
- return IsBetween(daughter->Eta());
- case kRadialImpactParam:
- return IsBetween(daughter->Dr());
- case kMomentumMC:
- if (mcinfo) return IsBetween(mcinfo->P());
- else return kTRUE;
- case kTransMomentumMC:
- if (mcinfo) return IsBetween(mcinfo->P());
- else return kTRUE;
- case kStatus:
- return daughter->CheckFlag(fUIMin);
- case kChargePos:
- return (daughter->Charge() > 0);
- case kChargeNeg:
- return (daughter->Charge() < 0);
- case kPIDType:
- case kPIDProb:
- pidType = daughter->PIDType(prob);
- if (fType == kPIDType) return MatchesValue((Int_t) pidType);
- if (fType == kPIDProb) return IsBetween(prob);
- case kEtaMC:
- if (mcinfo) return IsBetween(mcinfo->Eta());
- else return kTRUE;
- case kIsPrimary:
- if (mcinfo) return (mcinfo->Mother() < 0);
- else return kTRUE;
- case kNSigma:
- return IsBetween(daughter->NSigmaToVertex());
- /*
- case kEsdNSigmaCalculate:
- return IsBetween (daughter->GetESDInfo()->GetNSigmaCalculate());
- */
- default:
- AliWarning("Requested a cut which cannot be applied to a single track");
- return kTRUE;
- }
+ // print debug message
+ AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================");
+ AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
+ AliDebug(AliLog::kDebug + 2, Form("Cut range : %d , %d", fMinI, fMaxI));
+ AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ====================================================");
- return kTRUE;
+ return fCutResult;
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnPairParticle * pair)
+//______________________________________________________________________________
+Bool_t AliRsnCut::OkRangeD()
{
- AliDebug(AliLog::kDebug, "<-");
-
- // check type
- if (type != kPair)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnPairParticle)", type, kPair, pair->ClassName()));
- return kTRUE;
- }
-
- switch (fType)
- {
- case kMomentum:
- return IsBetween(pair->GetP());
- case kTransMomentum:
- return IsBetween(pair->GetPt());
- /*
- case kEta:
- return IsBetween (daughter->Eta());
- */
- case kMomentumMC:
- return IsBetween(pair->GetPMC());
- case kTransMomentumMC:
- return IsBetween(pair->GetPtMC());
- case kIsLabelEqual:
- return pair->IsLabelEqual();
- case kIsTruePair:
- return pair->IsTruePair(fIMin);
- default:
- AliWarning("Requested a cut which cannot be applied to a pair");
- return kTRUE;
- }
-
- return kTRUE;
-}
-
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * event)
-{
- AliDebug(AliLog::kDebug, "<-");
+//
+// This method is used to compare a value with a double-float range.
+//
- // check type
- if (type != kEvent)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnEvent)", type, kEvent, event->ClassName()));
- return kTRUE;
- }
+ // eval result
+ fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
- switch (fType)
- {
- case kMultiplicity:
- return IsBetween((Int_t) event->GetMultiplicity());
- default:
- AliWarning("Requested a cut which cannot be applied to an event");
- return kTRUE;
- }
+ // print debug message
+ AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================");
+ AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName()));
+ AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
+ AliDebug(AliLog::kDebug + 2, Form("Cut range : %f , %f", fMinD, fMaxD));
+ AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
+ AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ====================================================");
- return kTRUE;
+ return fCutResult;
}
-//________________________________________________________________________________________________________________
-Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * ev1, AliRsnEvent * ev2)
+//______________________________________________________________________________
+void AliRsnCut::Print(Option_t*) const
{
- AliDebug(AliLog::kDebug, "<-");
-
- // check type
- if (type != kMixEvent)
- {
- AliWarning(Form("Mismatch: type = %d (expected %d)", type, kMixEvent));
- return kTRUE;
- }
-
- Double_t valueD, mult1, mult2;
- Int_t valueI;
-
- switch (fType)
- {
- case kMultiplicityDifference:
- valueI = TMath::Abs(ev1->GetMultiplicity() - ev2->GetMultiplicity());
- return IsBetween((Int_t)valueI);
- case kMultiplicityRatio:
- mult1 = (Double_t)ev1->GetMultiplicity();
- mult2 = (Double_t)ev2->GetMultiplicity();
- if (mult1 == 0.0 && mult2 == 0.0) return kTRUE;
- valueD = 100.0 * TMath::Abs(mult1 - mult2) / TMath::Max(mult1, mult2); // in %
- return IsBetween((Double_t)valueD);
- case kVzDifference:
- valueD = TMath::Abs(ev1->GetVz() - ev2->GetVz());
- return IsBetween((Double_t)valueD);
- case kPhiMeanDifference:
- valueD = TMath::Abs(ev1->GetPhiMean() - ev2->GetPhiMean());
- if (valueD > 180.0) valueD = 360.0 - valueD;
- return IsBetween((Double_t)valueD);
- default:
- AliWarning("Requested a cut which cannot be applied to an event");
- return kTRUE;
- }
-
- return kTRUE;
-}
+//
+// Override TObject::Print() method,
+// and print some useful info about the cut general parameters.
+//
-//________________________________________________________________________________________________________________
-void AliRsnCut::PrintAllValues()
-{
- AliInfo(Form("fType=%d fVarType=%d",fType,fVarType));
- AliInfo(Form("fDMin=%.2e fDMax=%.2e",fDMin,fDMax));
- AliInfo(Form("fIMin=%d fIMax=%d",fIMin,fIMax));
- AliInfo(Form("fUIMin=%d fUIMax=%d",fUIMin,fUIMax));
- AliInfo(Form("fULMin=%d fULMax=%d",fULMin,fULMax));
+ AliInfo("=== CUT DETAILS ====================================");
+ AliInfo(Form("Cut name : [%s]", GetName()));
+ AliInfo(Form("Cut target : [%s]", GetTargetTypeName()));
+ AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD));
+ AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI));
+ AliInfo("====================================================");
}