X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PWG2%2FRESONANCES%2FAliRsnCut.cxx;h=4d618dca1ce25d727947a462ba8e08b3ba3cca21;hb=2a573e237b68fb426e8e2155683a67404329e3d7;hp=732f37f467ff74b6eaeb8545b3e2800ae7a822ba;hpb=06351446b84a6b389b9dcdddbde5338c95562348;p=u%2Fmrichter%2FAliRoot.git diff --git a/PWG2/RESONANCES/AliRsnCut.cxx b/PWG2/RESONANCES/AliRsnCut.cxx index 732f37f467f..4d618dca1ce 100644 --- a/PWG2/RESONANCES/AliRsnCut.cxx +++ b/PWG2/RESONANCES/AliRsnCut.cxx @@ -1,24 +1,10 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -//========================================================================= +// // 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 [--> IsEqual() ] +// - a value contained in a given interval [--> IsBetween() ] +// - a value equal to a given reference [--> MatchesValue()] +// // 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 @@ -28,322 +14,369 @@ // // 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 "AliRsnCut.h" +#include "AliRsnMother.h" +#include "AliRsnEvent.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) +ClassImp(AliRsnCut) -//________________________________________________________________________________________________________________ -AliRsnCut::AliRsnCut() : +//_________________________________________________________________________________________________ +AliRsnCut::AliRsnCut(ETarget target) : TNamed(), - fDMin(-fgkDBigNumber), - fDMax( fgkDBigNumber), - fIMin(-fgkIBigNumber), - fIMax( fgkIBigNumber), - fUIMin(0), - fUIMax(2 * (UInt_t)fgkIBigNumber), - fRsnCutType (kLastCutType), - fRsnCutVarType (kDouble_t) + 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, ERsnCutType type) : - TNamed (name,title), - fDMin(-fgkDBigNumber), - fDMax( fgkDBigNumber), - fIMin(-fgkIBigNumber), - fIMax( fgkIBigNumber), - fUIMin(0), - fUIMax(2 * (UInt_t)fgkIBigNumber), - fRsnCutType (type), - fRsnCutVarType (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, ERsnCutType 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), - fRsnCutType (type), - fRsnCutVarType (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, ERsnCutType 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), - fRsnCutType (type), - fRsnCutVarType (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, ERsnCutType type, UInt_t min, UInt_t max) : - TNamed (name,title), - fDMin(-fgkDBigNumber), - fDMax( fgkDBigNumber), - fIMin(-fgkIBigNumber), - fIMax( fgkIBigNumber), - fUIMin(min), - fUIMax(max), - fRsnCutType (type), - fRsnCutVarType (kUInt_t) +//_________________________________________________________________________________________________ +AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy) { // -// Constructor with arguments and limits +// Assignment operator +// don't duplicate memory occupancy for pointer // + + 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; + + return (*this); } -//________________________________________________________________________________________________________________ -AliRsnCut::~ AliRsnCut() +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::TargetOK(TObject *obj1, TObject *obj2) { // -// Destructor. -// Does absolutely nothing. -// +// This method checks if the expected target and the passed object match. +// + + if (!obj1) + { + AliError("Cannot cut on a NULL object!"); + return kFALSE; + } + + 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::IsBetween (const Double_t & theValue) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::IsSelected(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) +// Virtual cut-checking method for event mixing. +// This method checks only that the target is the oner for mixing. // - return ((theValue >= fDMin) && (theValue <= fDMax)); + + AliWarning("Single-object cuts are not implemented here."); + return kTRUE; } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsEqual (const Int_t &theValue) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkValue() { // -// Reference check. -// Question: "Is the argument equal to fIMin?" (fIMax is assumed never used) -// - return (theValue == fIMin); +// 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. +// + + switch (fVarType) + { + case kInt: + return OkValueI(); + case kDouble: + return OkValueD(); + default: + AliError(Form("fVarType = %d --> not allowed", fVarType)); + return kFALSE; + } } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsEqual (const UInt_t &theValue) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkRange() { // -// Reference check. -// Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used) -// - return (theValue == fUIMin); +// 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. +// + + switch (fVarType) + { + case kInt: + return OkRangeI(); + case kDouble: + return OkRangeD(); + default: + AliError(Form("fVarType = %d --> not allowed", fVarType)); + return kFALSE; + } } -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsEqual (const Double_t &theValue) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkValueI() { // -// 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); +// This method is used when the cut consists in comparing the cut value +// with a reference integer value to which it must be equal. +// + + // 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 (ERsnCutType type, const Double_t & theValue, const Double_t & theValue2) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkValueD() { // -// (Re)assignment of cut values -// - fRsnCutType = type; - fDMin = theValue; - fDMax = theValue2; +// 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). +// + + // 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; } -//________________________________________________________________________________________________________________ -void AliRsnCut::SetCutValues (ERsnCutType type, const Int_t& theValue, const Int_t& theValue2) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkRangeI() { // -// (Re)assignment of cut values -// - fRsnCutType = type; - fIMin = theValue; - fIMax = theValue2; +// 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. +// + + // 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; } -//________________________________________________________________________________________________________________ -void AliRsnCut::SetCutValues (ERsnCutType type, const UInt_t& theValue, const UInt_t& theValue2) +//_________________________________________________________________________________________________ +Bool_t AliRsnCut::OkRangeD() { // -// (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. // - fRsnCutType = type; - fUIMin = theValue; - fUIMax = theValue2; -} -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnDaughter *daughter) -{ -// -// 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. -// - 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; - } - - switch (fRsnCutType) { - case kMomentum: - return IsBetween (daughter->P()); - case kTransMomentum: - return IsBetween (daughter->Pt()); - case kEta: - return IsBetween (daughter->Eta()); - case kRadialImpactParam: - return IsBetween (daughter->Vt()); - 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: - return IsEqual((Int_t)daughter->PIDType()); - /* - case kEtaMC: - if (mcinfo) return IsBetween (mcinfo->Eta()); - else return kTRUE; - case kMcVt: - if (mcinfo) return IsBetween (mcinfo->Vt()); - else return kTRUE; - case kEsdNSigma: - return IsBetween (daughter->GetNSigma()); - case kEsdNSigmaCalculate: - return IsBetween (daughter->GetESDInfo()->GetNSigmaCalculate()); - */ - } - - 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 ================================"); -//________________________________________________________________________________________________________________ -Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnPairParticle * pair) -{ - 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 (fRsnCutType) { - 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 kRestMomentum: - return CheckRestMomentum(pair); - case kIsPdgEqual: - return pair->IsPDGEqual(); - case kIsLabelEqual: - return pair->IsLabelEqual(); - case kIsTruePair: - return pair->IsTruePair(fIMin); - } - - return kTRUE; + return fCutResult; } -//________________________________________________________________________________________________________________ -void AliRsnCut::PrintAllValues() +//_________________________________________________________________________________________________ +void AliRsnCut::Print(Option_t*) const { - AliInfo (Form ("fRsnCutType=%d fRsnCutVarType=%d",fRsnCutType,fRsnCutVarType)); - AliInfo (Form ("fDMin=%.2e fDMax=%.2e",fDMin,fDMax)); - AliInfo (Form ("fIMin=%d fIMax=%d",fIMin,fIMax)); - AliInfo (Form ("fUIMin=%d fUIMax=%d",fUIMin,fUIMax)); +// +// Override TObject::Print() method +// + + Char_t target[100]; + switch (fTarget) + { + 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; + } + + 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::CheckRestMomentum(AliRsnPairParticle *pair) +//_________________________________________________________________________________________________ +void AliRsnCut::SetEvent(AliRsnEvent *event) { // -// Check the cut on daughter momenta in rest reference frame of mother +// Sets the reference event // - Double_t beta = pair->GetP() / pair->GetMass(); - Double_t gamma = 1. / TMath::Sqrt(1. - beta*beta); - - Double_t p1labP = 0.0, p1labT, p1restP, p1restTot; - p1labP += pair->GetDaughter(0)->Px() * pair->GetP(0); - p1labP += pair->GetDaughter(0)->Py() * pair->GetP(1); - p1labP += pair->GetDaughter(0)->Pz() * pair->GetP(2); - p1labP /= pair->GetP(); - - p1labT = TMath::Sqrt(pair->GetDaughter(0)->P2() - p1labP*p1labP); - - p1restP = gamma*p1labP - beta*gamma*pair->GetDaughter(0)->E(); - - p1restTot = TMath::Sqrt(p1restP*p1restP + p1labT*p1labT); - - return IsBetween(p1restTot); + fEvent = event; } - - -