X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PWG2%2FRESONANCES%2FAliRsnCut.cxx;h=4d618dca1ce25d727947a462ba8e08b3ba3cca21;hb=9a838fb778f46ceb900c62c1c1c9480dcdfcae5a;hp=91f6d94f13019988002924e2bd8ad1d02cfe483e;hpb=78b94cbd2efd11d75a7ab734ccfbe9a5c06cfc9d;p=u%2Fmrichter%2FAliRoot.git diff --git a/PWG2/RESONANCES/AliRsnCut.cxx b/PWG2/RESONANCES/AliRsnCut.cxx index 91f6d94f130..4d618dca1ce 100644 --- a/PWG2/RESONANCES/AliRsnCut.cxx +++ b/PWG2/RESONANCES/AliRsnCut.cxx @@ -15,431 +15,368 @@ // authors: Martin Vala (martin.vala@cern.ch) // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) // - #include "AliLog.h" #include "AliRsnDaughter.h" -#include "AliRsnMCInfo.h" -#include "AliRsnPairParticle.h" -#include "AliRsnPairDef.h" +#include "AliRsnMother.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; +#include "AliRsnCut.h" 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(ETarget target) : + TNamed(), + fVarType(kInt), + fTarget(target), + fMinI(0), + fMaxI(0), + fMinD(0.0), + fMaxD(0.0), + fCutValueI(0), + fCutValueD(0.0), + fCutResult(kTRUE), + fEvent(0x0) { // -// 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 AliRsnCut& copy) : + TNamed(copy), + fVarType(copy.fVarType), + fTarget(copy.fTarget), + fMinI(copy.fMinI), + fMaxI(copy.fMaxI), + fMinD(copy.fMinD), + fMaxD(copy.fMaxD), + fCutValueI(copy.fCutValueI), + fCutValueD(copy.fCutValueD), + fCutResult(copy.fCutResult), + fEvent(copy.fEvent) { // -// Constructor with arguments but not limits +// Copy constructor. // } -//________________________________________________________________________________________________________________ -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, ETarget target, Int_t min, Int_t max) : + TNamed(name, ""), + fVarType(kInt), + fTarget(target), + fMinI(min), + fMaxI(max), + fMinD(0.0), + fMaxD(0.0), + fCutValueI(0), + fCutValueD(0.0), + fCutResult(kTRUE), + fEvent(0x0) { // -// Constructor with arguments and limits +// Constructor with integer values. +// If the cut must check values inside a range, +// both 'value' arguments must be used, and they are, in the order, +// the minimum and maximum of the allowed range. +// If the cut must check a value, the second 'value' argument will never be used. // } -//________________________________________________________________________________________________________________ -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 char *name, ETarget target, Double_t min, Double_t max) : + TNamed(name, ""), + fVarType(kDouble), + fTarget(target), + fMinI(0), + fMaxI(0), + fMinD(min), + fMaxD(max), + fCutValueI(0), + fCutValueD(0.0), + fCutResult(kTRUE), + fEvent(0x0) { // -// Constructor with arguments and limits +// Constructor with double values. +// If the cut must check values inside a range, +// both 'value' arguments must be used, and they are, in the order, +// the minimum and maximum of the allowed range. +// If the cut must check a value, the second 'value' argument will never be used. // } -//________________________________________________________________________________________________________________ -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 -// -} + fVarType = copy.fVarType; + fTarget = copy.fTarget; + fMinI = copy.fMinI; + fMaxI = copy.fMaxI; + fMinD = copy.fMinD; + fMaxD = copy.fMaxD; + fCutValueI = copy.fCutValueI; + fCutValueD = copy.fCutValueD; + fCutResult = copy.fCutResult; + fEvent = copy.fEvent; -//________________________________________________________________________________________________________________ -AliRsnCut::~AliRsnCut() -{ -// -// Destructor. -// Does absolutely nothing. -// + return (*this); } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsBetween(const Double_t &theValue) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::TargetOK(TObject *obj1, TObject *obj2) { // -// Interval check. -// Question: "Is the argument included between fDMin and fDMax?" -// (not implemented for integer values because usually it is not used with them) +// This method checks if the expected target and the passed object match. // - return ((theValue >= fDMin) && (theValue <= fDMax)); -} -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsBetween(const Int_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 >= fIMin) && (theValue <= fIMax)); -} + if (!obj1) + { + AliError("Cannot cut on a NULL object!"); + return kFALSE; + } -//________________________________________________________________________________________________________________ -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); + switch (fTarget) + { + case kDaughter: + if (dynamic_cast(obj1) == 0x0) + { + AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnDaughter', passed '%s'", GetName(), obj1->ClassName())); + Print(); + return kFALSE; + } + break; + case kMother: + if (dynamic_cast(obj1) == 0x0) + { + AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnMother', passed '%s'", GetName(), obj1->ClassName())); + Print(); + return kFALSE; + } + break; + case kEvent: + if (dynamic_cast(obj1) == 0x0) + { + AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnEvent', passed '%s'", GetName(), obj1->ClassName())); + Print(); + return kFALSE; + } + break; + case kMixEvent: + if (dynamic_cast(obj1) == 0x0) + { + AliError(Form("[%s] Target mismatch (obj #1): expected 'AliRsnEvent', passed '%s' an", GetName(), obj1->ClassName())); + Print(); + return kFALSE; + } + if (obj2) + { + if (dynamic_cast(obj2) == 0x0) + { + AliError(Form("[%s] Target mismatch (obj #2): expected 'AliRsnEvent', passed '%s' an", GetName(), obj2->ClassName())); + Print(); + return kFALSE; + } + } + else + { + AliError("Mix-event cuts require 2 not NULL objects"); + Print(); + return kFALSE; + } + break; + default: + return kTRUE; + } + + return kTRUE; } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::MatchesValue(const UInt_t &theValue) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::IsSelected(TObject* /*obj1*/, TObject* /*obj2*/) { // -// Reference check. -// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used) +// Virtual cut-checking method for event mixing. +// This method checks only that the target is the oner for mixing. // - 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); + AliWarning("Single-object cuts are not implemented here."); + return kTRUE; } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::MatchesValue(const Double_t &theValue) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkValue() { // -// 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 +// This method is used when the cut consists in comparing the cut value +// with a reference value to which it must be equal (in case of doubles, 'almost' equal). +// Then, the cut result is kTRUE if the cut value is equal to this reference value. // - return (TMath::Abs(theValue - fDMin) < fgkDSmallNumber); + + switch (fVarType) + { + case kInt: + return OkValueI(); + case kDouble: + return OkValueD(); + default: + AliError(Form("fVarType = %d --> not allowed", fVarType)); + return kFALSE; + } } -//________________________________________________________________________________________________________________ -void AliRsnCut::SetCutValues(EType type, const Double_t &theValue, const Double_t &theValue2) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkRange() { // -// (Re)assignment of cut values +// This method is used when the cut consists in an allowed range +// where the cut value must be included to pass the cut. +// Then, the cut result is kTRUE if the cut value is inside this range. // - fType = type; - fDMin = theValue; - fDMax = theValue2; + + switch (fVarType) + { + case kInt: + return OkRangeI(); + case kDouble: + return OkRangeD(); + default: + AliError(Form("fVarType = %d --> not allowed", fVarType)); + return kFALSE; + } } -//________________________________________________________________________________________________________________ -void AliRsnCut::SetCutValues(EType type, const Int_t &theValue, const Int_t &theValue2) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkValueI() { // -// (Re)assignment of cut values +// This method is used when the cut consists in comparing the cut value +// with a reference integer value to which it must be equal. // - fType = type; - fIMin = theValue; - fIMax = theValue2; + + // eval result + fCutResult = (fCutValueI == fMinI); + + // 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 ================================"); + + return fCutResult; } -//________________________________________________________________________________________________________________ -void AliRsnCut::SetCutValues(EType type, const UInt_t &theValue, const UInt_t &theValue2) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkValueD() { // -// (Re)assignment of cut values +// This method is used when the cut consists in comparing the cut value +// with a reference double value to which it must be equal (or at least, almost). // - fType = type; - fUIMin = theValue; - fUIMax = theValue2; -} -//________________________________________________________________________________________________________________ -void AliRsnCut::SetCutValues(EType type, const ULong_t &theValue, const ULong_t &theValue2) -{ - // -// (Re)assignment of cut values - // - fType = type; - fULMin = theValue; - fULMax = theValue2; + // eval result + fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6); + + // 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 when the cut consists in an allowed range +// where the cut value must be included to pass the cut. +// Then, the cut result is kTRUE if the cut value is inside this 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; - - 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 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; - } - - return kTRUE; + // eval result + fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI)); + + // 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 fCutResult; } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnPairParticle * pair) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkRangeD() { - AliDebug(AliLog::kDebug, "<-"); +// +// This method is used when the cut consists in an allowed range +// where the cut value must be included to pass the cut. +// Then, the cut result is kTRUE if the cut value is inside this range. +// - // check type - if (type != kPair) - { - AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnPairParticle)", type, kPair, pair->ClassName())); - return kTRUE; - } + // eval result + fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD)); + + // 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 ================================"); - 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; + return fCutResult; } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * event) +//_________________________________________________________________________________________________ +void AliRsnCut::Print(Option_t*) const { - AliDebug(AliLog::kDebug, "<-"); - - // check type - if (type != kEvent) - { - AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnEvent)", type, kEvent, event->ClassName())); - return kTRUE; - } +// +// Override TObject::Print() method +// - switch (fType) + Char_t target[100]; + switch (fTarget) { - case kMultiplicity: - return IsBetween((Int_t) event->GetMultiplicity()); - default: - AliWarning("Requested a cut which cannot be applied to an event"); - return kTRUE; + case kDaughter: snprintf(target, strlen("DAUGHTER") , "DAUGHTER") ; break; + case kMother : snprintf(target, strlen("MOTHER") , "MOTHER") ; break; + case kEvent : snprintf(target, strlen("EVENT") , "EVENT") ; break; + case kMixEvent: snprintf(target, strlen("MIX EVENT"), "MIX EVENT"); break; + default : snprintf(target, strlen("UNDEFINED"), "UNDEFINED"); break; } - return kTRUE; + AliInfo("=== CUT DETAILS ===================================="); + AliInfo(Form("Cut name : [%s]", GetName())); + AliInfo(Form("Cut target : [%s]", target)); + AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD)); + AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI)); + AliInfo("===================================================="); } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * ev1, AliRsnEvent * ev2) +//_________________________________________________________________________________________________ +void AliRsnCut::SetEvent(AliRsnEvent *event) { - 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; -} +// +// Sets the reference event +// -//________________________________________________________________________________________________________________ -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)); + fEvent = event; }