From: pulvir Date: Mon, 21 Feb 2011 08:17:42 +0000 (+0000) Subject: AliRsnCut: X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;ds=sidebyside;h=eaa44581ec40789e1a8254aed9d736b63907cbb9;p=u%2Fmrichter%2FAliRoot.git AliRsnCut: - some restyling of the class AliRsnValue: - added the possibility to retrieve an AliESDpid object from an AliESDInputHandler, in order to compute as values also the detector responses AliRsnTarget: - added an utility static function to retrieve the target type for a given object AliRsnEvent: - removed most of the dynamic_cast calls, replaced with ROOT RTTI using TClass --- diff --git a/PWG2/RESONANCES/AliRsnCut.cxx b/PWG2/RESONANCES/AliRsnCut.cxx index 17a67f29cdd..ecab5947a1e 100644 --- a/PWG2/RESONANCES/AliRsnCut.cxx +++ b/PWG2/RESONANCES/AliRsnCut.cxx @@ -13,10 +13,6 @@ // Martin Vala (martin.vala@cern.ch) // -#include "AliRsnDaughter.h" -#include "AliRsnMother.h" -#include "AliRsnEvent.h" - #include "AliRsnCut.h" ClassImp(AliRsnCut) @@ -106,6 +102,7 @@ AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy) fMaxD = copy.fMaxD; fCutValueI = copy.fCutValueI; fCutValueD = copy.fCutValueD; + fCutResult = copy.fCutResult; return (*this); } @@ -128,20 +125,20 @@ Bool_t AliRsnCut::IsSelected(TObject* /*object*/) Bool_t AliRsnCut::OkValueI() { // -// This method is used when the cut consists in comparing the cut value -// with a reference integer value to which it must be equal. +// This method is used to compare a value with a reference. +// In the case of integers, the equality must be exact. // // eval result fCutResult = (fCutValueI == fMinI); // print debug message - AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ===================================="); + 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 ================================"); + AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================="); return fCutResult; } @@ -150,20 +147,20 @@ Bool_t AliRsnCut::OkValueI() Bool_t AliRsnCut::OkValueD() { // -// 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). +// This method is used to compare a value with a reference. +// In the case of doubles, the equality consists in being very close. // // eval result - fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6); + fCutResult = (TMath::Abs(fCutValueD - fMinD) < fgkVerySmall); // print debug message - AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ===================================="); + 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 ================================"); + AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ==================================================="); return fCutResult; } @@ -172,21 +169,19 @@ Bool_t AliRsnCut::OkValueD() Bool_t AliRsnCut::OkRangeI() { // -// 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. +// This method is used to compare a value with an integer range. // // eval result fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI)); // print debug message - AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ===================================="); + 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 ================================"); + AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================="); return fCutResult; } @@ -195,21 +190,19 @@ Bool_t AliRsnCut::OkRangeI() Bool_t AliRsnCut::OkRangeD() { // -// 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. +// This method is used to compare a value with a double-float range. // // eval result fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD)); // print debug message - AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ===================================="); + 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 ================================"); + AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================="); return fCutResult; } diff --git a/PWG2/RESONANCES/AliRsnCut.h b/PWG2/RESONANCES/AliRsnCut.h index a8f60a933e9..e4800911930 100644 --- a/PWG2/RESONANCES/AliRsnCut.h +++ b/PWG2/RESONANCES/AliRsnCut.h @@ -6,8 +6,10 @@ // must be overloaded by any specific cut implementation. // // This class provides some default instruments to check values -// agains a reference or an allowed range, in order to permit +// against a reference or an allowed range, in order to permit // a unique way to execute such kind of checks. +// Moreover, if one checks values and ranges using default methods +// a debug message can be printed on request. // // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) // Martin Vala (martin.vala@cern.ch) @@ -18,8 +20,6 @@ #include "AliRsnTarget.h" -class AliRsnEvent; - class AliRsnCut : public AliRsnTarget { public: @@ -30,13 +30,13 @@ public: AliRsnCut& operator=(const AliRsnCut& copy); virtual ~AliRsnCut() { }; - Int_t GetMinI() {return fMinI;} - Int_t GetMaxI() {return fMaxI;} - Double_t GetMinD() {return fMinD;} - Double_t GetMaxD() {return fMaxD;} - Int_t GetCutValueI() {return fCutValueI;} - Double_t GetCutValueD() {return fCutValueD;} - Bool_t GetCutResult() {return fCutResult;} + Int_t GetMinI() {return fMinI;} + Int_t GetMaxI() {return fMaxI;} + Double_t GetMinD() {return fMinD;} + Double_t GetMaxD() {return fMaxD;} + Int_t GetCutValueI() {return fCutValueI;} + Double_t GetCutValueD() {return fCutValueD;} + Bool_t GetCutResult() {return fCutResult;} void SetRangeI(Int_t min, Int_t max) {fMinI = min; fMaxI = max;} void SetRangeD(Double_t min, Double_t max) {fMinD = min; fMaxD = max;} diff --git a/PWG2/RESONANCES/AliRsnEvent.cxx b/PWG2/RESONANCES/AliRsnEvent.cxx index bbcf407f63a..fd012458858 100644 --- a/PWG2/RESONANCES/AliRsnEvent.cxx +++ b/PWG2/RESONANCES/AliRsnEvent.cxx @@ -95,10 +95,10 @@ Bool_t AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t i, AliRsnDaughter::ER // Returns kFALSE whenever the operation fails (out of range, NULL references). // - if (IsESD() && type == AliRsnDaughter::kTrack) return SetDaughterESDtrack(out, i); - if (IsAOD() && type == AliRsnDaughter::kTrack) return SetDaughterAODtrack(out, i); - if (IsESD() && type == AliRsnDaughter::kV0) return SetDaughterESDv0(out, i); - if (IsAOD() && type == AliRsnDaughter::kV0) return SetDaughterAODv0(out, i); + if (IsESD() && type == AliRsnDaughter::kTrack) return SetDaughterESDtrack (out, i); + if (IsAOD() && type == AliRsnDaughter::kTrack) return SetDaughterAODtrack (out, i); + if (IsESD() && type == AliRsnDaughter::kV0) return SetDaughterESDv0 (out, i); + if (IsAOD() && type == AliRsnDaughter::kV0) return SetDaughterAODv0 (out, i); if (IsESD() && type == AliRsnDaughter::kCascade) return SetDaughterESDcascade(out, i); if (IsAOD() && type == AliRsnDaughter::kCascade) return SetDaughterAODcascade(out, i); diff --git a/PWG2/RESONANCES/AliRsnEvent.h b/PWG2/RESONANCES/AliRsnEvent.h index 3861777681e..bdd1fd12f71 100644 --- a/PWG2/RESONANCES/AliRsnEvent.h +++ b/PWG2/RESONANCES/AliRsnEvent.h @@ -43,10 +43,10 @@ public: Int_t GetLocalID() const {return fLocalID;} // getters which convert into allowed input types - AliESDEvent* GetRefESD() {return dynamic_cast(fRef);} - AliAODEvent* GetRefAOD() {return dynamic_cast(fRef);} - AliMCEvent* GetRefMCESD() {return dynamic_cast(fRefMC);} - AliAODEvent* GetRefMCAOD() {return dynamic_cast(fRefMC);} + AliESDEvent* GetRefESD() {if (fRef ->IsA() == AliESDEvent::Class()) return static_cast(fRef) ; else return 0x0;} + AliAODEvent* GetRefAOD() {if (fRef ->IsA() == AliAODEvent::Class()) return static_cast(fRef) ; else return 0x0;} + AliMCEvent* GetRefMCESD() {if (fRefMC->IsA() == AliMCEvent ::Class()) return static_cast (fRefMC); else return 0x0;} + AliAODEvent* GetRefMCAOD() {if (fRefMC->IsA() == AliAODEvent::Class()) return static_cast(fRefMC); else return 0x0;} Bool_t IsESD() {return (GetRefESD() != 0x0);} Bool_t IsAOD() {return (GetRefAOD() != 0x0);} @@ -69,14 +69,14 @@ public: Bool_t GetAngleDistr(Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter reference); // statig getters - static AliRsnEvent *GetCurrentEvent1() {return fgRsnEvent1;} - static AliRsnEvent *GetCurrentEvent2() {return fgRsnEvent2;} - static void SetCurrentEvent1(AliRsnEvent *event, Int_t id = 0) {fgRsnEvent1 = event; fgRsnEvent1->SetLocalID(id);} - static void SetCurrentEvent2(AliRsnEvent *event, Int_t id = 0) {fgRsnEvent2 = event; fgRsnEvent2->SetLocalID(id);} - static Bool_t IsCurrentEvent1() {if (fgRsnEvent1 != 0x0) return kTRUE; return kFALSE;} - static Bool_t IsCurrentEvent2() {if (fgRsnEvent2 != 0x0) return kTRUE; return kFALSE;} - static Bool_t SameEvent() {if (fgRsnEvent1 == fgRsnEvent2) return kTRUE; return kFALSE;} - + static AliRsnEvent *GetCurrentEvent1() {return fgRsnEvent1;} + static AliRsnEvent *GetCurrentEvent2() {return fgRsnEvent2;} + static void SetCurrentEvent1(AliRsnEvent *event, Int_t id = 0) {fgRsnEvent1 = event; fgRsnEvent1->SetLocalID(id);} + static void SetCurrentEvent2(AliRsnEvent *event, Int_t id = 0) {fgRsnEvent2 = event; fgRsnEvent2->SetLocalID(id);} + static Bool_t IsCurrentEvent1() {if (fgRsnEvent1 != 0x0) return kTRUE; return kFALSE;} + static Bool_t IsCurrentEvent2() {if (fgRsnEvent2 != 0x0) return kTRUE; return kFALSE;} + static Bool_t SameEvent() {if (fgRsnEvent1 == fgRsnEvent2) return kTRUE; return kFALSE;} + private: Bool_t SetDaughterESDtrack(AliRsnDaughter &target, Int_t index); @@ -88,13 +88,13 @@ private: Bool_t SetMCInfoESD(AliRsnDaughter &target); Bool_t SetMCInfoAOD(AliRsnDaughter &target); - AliVEvent *fRef; // pointer to input event - AliVEvent *fRefMC; // pointer to reference MC event (if any) - Int_t fLeading; // index of leading track - Int_t fLocalID; // identification number used locally + AliVEvent *fRef; // pointer to input event + AliVEvent *fRefMC; // pointer to reference MC event (if any) + Int_t fLeading; // index of leading track + Int_t fLocalID; // identification number used locally - static AliRsnEvent *fgRsnEvent1; //! pointer to current event #1 (default current event) - static AliRsnEvent *fgRsnEvent2; //! pointer to current event #2 (different from the other when doing mixing) + static AliRsnEvent *fgRsnEvent1; //! pointer to current event #1 (default current event) + static AliRsnEvent *fgRsnEvent2; //! pointer to current event #2 (different from the other when doing mixing) ClassDef(AliRsnEvent, 4); }; diff --git a/PWG2/RESONANCES/AliRsnPairDef.h b/PWG2/RESONANCES/AliRsnPairDef.h index d6a83a6368b..178000417ff 100644 --- a/PWG2/RESONANCES/AliRsnPairDef.h +++ b/PWG2/RESONANCES/AliRsnPairDef.h @@ -23,7 +23,6 @@ public: AliRsnPairDef(); AliRsnPairDef(EPARTYPE type1, Char_t sign1, EPARTYPE type2, Char_t sign2, Int_t motherPDG = 0, Double_t motherMass = 0.0); - AliRsnPairDef(AliRsnDaughterDef def1, AliRsnDaughterDef def2); AliRsnPairDef(const AliRsnPairDef ©); const AliRsnPairDef& operator= (const AliRsnPairDef ©); virtual ~AliRsnPairDef() { } diff --git a/PWG2/RESONANCES/AliRsnTarget.cxx b/PWG2/RESONANCES/AliRsnTarget.cxx index ed6709db0a7..929424b6874 100644 --- a/PWG2/RESONANCES/AliRsnTarget.cxx +++ b/PWG2/RESONANCES/AliRsnTarget.cxx @@ -8,6 +8,9 @@ // operate on any of such objects, then this class helps in making sure // that the object being processed corresponds to what is expected. // +// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// Martin Vala (martin.vala@cern.ch) +// #include "AliLog.h" @@ -18,20 +21,18 @@ ClassImp(AliRsnTarget) -AliRsnEvent* AliRsnTarget::fgCurrentEvent = 0x0; - -const Double_t AliRsnTarget::fgkVeryBig = 1E+10; -const Double_t AliRsnTarget::fgkVerySmall = 1E-10; +AliRsnEvent* AliRsnTarget::fgCurrentEvent = 0x0; +const Double_t AliRsnTarget::fgkVeryBig = 1E+10; +const Double_t AliRsnTarget::fgkVerySmall = 1E-10; //_____________________________________________________________________________ Bool_t AliRsnTarget::TargetOK(TObject *object) { // -// This method compares the target type stored as data member -// with the type of the object passed as argument, and returns -// kTRUE or kFALSE depending if they match or not. -// This check is done by comparing the object class type with -// one of the allowed types +// This method doew two things: +// 1) check if the object class matches the required target type +// 2) if (1) is successful, set the built-in pointer data member +// in order to point to it, after being casted accordingly // // fails by default if a NULL pointer is passed diff --git a/PWG2/RESONANCES/AliRsnTarget.h b/PWG2/RESONANCES/AliRsnTarget.h index f3702db784a..2302f086476 100644 --- a/PWG2/RESONANCES/AliRsnTarget.h +++ b/PWG2/RESONANCES/AliRsnTarget.h @@ -8,6 +8,9 @@ // operate on any of such objects, then this class helps in making sure // that the object being processed corresponds to what is expected. // +// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// Martin Vala (martin.vala@cern.ch) +// #ifndef ALIRSNTARGET_H #define ALIRSNTARGET_H @@ -32,7 +35,7 @@ public: AliRsnTarget() : fTargetType(kTargetTypes), fDaughter(0x0), fMother(0x0), fEvent(0x0) { /*nothing*/ } AliRsnTarget(const char *name, ETargetType type) : TNamed(name, ""), fTargetType(type), fDaughter(0x0), fMother(0x0), fEvent(0x0) { /*nothing*/ } AliRsnTarget(const AliRsnTarget& copy) : TNamed(copy), fTargetType(copy.fTargetType), fDaughter(0x0), fMother(0x0), fEvent(0x0) { /*nothing*/ } - AliRsnTarget& operator=(const AliRsnTarget& copy) { TNamed::operator=(copy); fTargetType = copy.fTargetType; fDaughter = 0x0; fMother = 0x0; fEvent = 0x0; return (*this); } + AliRsnTarget& operator=(const AliRsnTarget& copy) { TNamed::operator=(copy); fTargetType = copy.fTargetType; return (*this); } virtual ~AliRsnTarget() { /*nothing*/ } Bool_t IsAllNull() {return (!fDaughter && !fMother && !fEvent);} @@ -40,11 +43,11 @@ public: ETargetType GetTargetType() const {return fTargetType;} Char_t GetTargetTypeChar() const; const char* GetTargetTypeName() const; - void SetTargetType(ETargetType type) {fTargetType = type;} - Bool_t TargetOK(TObject *object); AliRsnDaughter* GetTargetDaughter() {return fDaughter;} AliRsnMother* GetTargetMother() {return fMother;} AliRsnEvent* GetTargetEvent() {return fEvent;} + void SetTargetType(ETargetType type) {fTargetType = type;} + Bool_t TargetOK(TObject *object); static AliRsnEvent* GetCurrentEvent() {return fgCurrentEvent;} static void SetCurrentEvent(AliRsnEvent *event) {fgCurrentEvent = event;} @@ -53,15 +56,14 @@ public: protected: - ETargetType fTargetType; // target type selected for this object - static AliRsnEvent *fgCurrentEvent; //! pointer to current event (useful in many cases) - - AliRsnDaughter *fDaughter; // utility pointer to target object (daughter) - AliRsnMother *fMother; // utility pointer to target object (mother) - AliRsnEvent *fEvent; // utility pointer to target object (event) + ETargetType fTargetType; // target type selected for this object + AliRsnDaughter *fDaughter; //! internal pointer to which any checked object is cast if it matches expected type + AliRsnMother *fMother; //! internal pointer to which any checked object is cast if it matches expected type + AliRsnEvent *fEvent; //! internal pointer to which any checked object is cast if it matches expected type - static const Double_t fgkVeryBig; // utility value for very large value - static const Double_t fgkVerySmall; // utility value for very small value + static AliRsnEvent *fgCurrentEvent; //! pointer to current event (useful in many cases) + static const Double_t fgkVeryBig; // utility value for very large value + static const Double_t fgkVerySmall; // utility value for very small value // ROOT dictionary ClassDef(AliRsnTarget, 1) diff --git a/PWG2/RESONANCES/AliRsnValue.cxx b/PWG2/RESONANCES/AliRsnValue.cxx index 0238cfe5f9e..774c7256a4f 100644 --- a/PWG2/RESONANCES/AliRsnValue.cxx +++ b/PWG2/RESONANCES/AliRsnValue.cxx @@ -9,9 +9,15 @@ #include +#include "AliPID.h" #include "AliESDtrackCuts.h" #include "AliESDpid.h" #include "AliAODPid.h" +#include "AliVEventHandler.h" +#include "AliInputEventHandler.h" +#include "AliMultiInputEventHandler.h" +#include "AliESDInputHandler.h" +#include "AliAnalysisManager.h" #include "AliRsnEvent.h" #include "AliRsnDaughter.h" @@ -37,14 +43,12 @@ AliRsnValue::AliRsnValue() : // This method is provided for ROOT streaming, // but should never be used directly by a user. // - - AssignTarget(); } //_____________________________________________________________________________ AliRsnValue::AliRsnValue (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) : - AliRsnTarget(name, AliRsnTarget::kTargetTypes), + AliRsnTarget(name, TargetType(type)), fComputedValue(0.0), fValueType(type), fBinArray(0), @@ -62,14 +66,13 @@ AliRsnValue::AliRsnValue // binning array, in order not to allocate memory when this is useless. // - AssignTarget(); SetBins(nbins, min, max); } //_____________________________________________________________________________ AliRsnValue::AliRsnValue (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) : - AliRsnTarget(name, AliRsnTarget::kTargetTypes), + AliRsnTarget(name, TargetType(type)), fComputedValue(0.0), fValueType(type), fBinArray(0), @@ -82,14 +85,13 @@ AliRsnValue::AliRsnValue // the required interval. // - AssignTarget(); SetBins(min, max, step); } //_____________________________________________________________________________ AliRsnValue::AliRsnValue (const char *name, EValueType type, Int_t nbins, Double_t *array) : - AliRsnTarget(name, AliRsnTarget::kTargetTypes), + AliRsnTarget(name, TargetType(type)), fComputedValue(0.0), fValueType(type), fBinArray(0), @@ -101,7 +103,6 @@ AliRsnValue::AliRsnValue // and creates a set of variable bins delimited by the passed array. // - AssignTarget(); SetBins(nbins, array); } @@ -119,8 +120,6 @@ AliRsnValue::AliRsnValue(const AliRsnValue& copy) : // Calls also the function that assigns properly the // expected target, depending on the computation type. // - - AssignTarget(); } //_____________________________________________________________________________ @@ -136,8 +135,7 @@ AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy) fComputedValue = copy.fComputedValue; fBinArray = copy.fBinArray; fSupportObject = copy.fSupportObject; - - AssignTarget(); + fValueType = copy.fValueType; return (*this); } @@ -206,59 +204,43 @@ const char* AliRsnValue::GetValueTypeName() const // switch (fValueType) { - case kTrackP: return "SingleTrackPtot"; - case kTrackPt: return "SingleTrackPt"; - case kTrackEta: return "SingleTrackEta"; - case kTrackY: return "SingleTrackRapidity"; - case kTrackITSsignal: return "SingleTrackITSsignal"; - case kTrackTPCsignal: return "SingleTrackTPCsignal"; - case kTrackTOFsignal: return "SingleTrackTOFsignal"; - case kTrackLength: return "SingleTrackLength"; - case kPairP1: return "PairPtotDaughter1"; - case kPairP2: return "PairPtotDaughter2"; - case kPairP1t: return "PairPtDaughter1"; - case kPairP2t: return "PairPtDaughter2"; - case kPairP1z: return "PairPzDaughter1"; - case kPairP2z: return "PairPzDaughter2"; - case kPairInvMass: return "PairInvMass"; - case kPairInvMassMC: return "PairInvMassMC"; - case kPairInvMassRes: return "PairInvMassResolution"; - case kPairPt: return "PairPt"; - case kPairPz: return "PairPz"; - case kPairEta: return "PairEta"; - case kPairMt: return "PairMt"; - case kPairY: return "PairY"; - case kPairPhi: return "PairPhi"; - case kPairPhiMC: return "PairPhiMC"; - case kPairPtRatio: return "PairPtRatio"; - case kPairDipAngle: return "PairDipAngle"; - case kPairCosThetaStar: return "PairCosThetaStar"; - case kPairQInv: return "PairQInv"; - case kPairAngleToLeading: return "PairAngleToLeading"; - case kEventLeadingPt: return "EventLeadingPt"; - case kEventMult: return "EventMult"; - case kEventMultESDCuts: return "EventMultESDCuts"; - case kEventVz: return "EventVz"; - default: return "Undefined"; + case kTrackP: return "SingleTrackPtot"; + case kTrackPt: return "SingleTrackPt"; + case kTrackEta: return "SingleTrackEta"; + case kTrackY: return "SingleTrackRapidity"; + case kTrackITSsignal: return "SingleTrackITSsignal"; + case kTrackTPCsignal: return "SingleTrackTPCsignal"; + case kTrackTOFsignal: return "SingleTrackTOFsignal"; + case kTrackLength: return "SingleTrackLength"; + case kPairP1: return "PairPtotDaughter1"; + case kPairP2: return "PairPtotDaughter2"; + case kPairP1t: return "PairPtDaughter1"; + case kPairP2t: return "PairPtDaughter2"; + case kPairP1z: return "PairPzDaughter1"; + case kPairP2z: return "PairPzDaughter2"; + case kPairInvMass: return "PairInvMass"; + case kPairInvMassMC: return "PairInvMassMC"; + case kPairInvMassRes: return "PairInvMassResolution"; + case kPairPt: return "PairPt"; + case kPairPz: return "PairPz"; + case kPairEta: return "PairEta"; + case kPairMt: return "PairMt"; + case kPairY: return "PairY"; + case kPairPhi: return "PairPhi"; + case kPairPhiMC: return "PairPhiMC"; + case kPairPtRatio: return "PairPtRatio"; + case kPairDipAngle: return "PairDipAngle"; + case kPairCosThetaStar: return "PairCosThetaStar"; + case kPairQInv: return "PairQInv"; + case kPairAngleToLeading: return "PairAngleToLeading"; + case kEventLeadingPt: return "EventLeadingPt"; + case kEventMult: return "EventMult"; + case kEventMultESDCuts: return "EventMultESDCuts"; + case kEventVz: return "EventVz"; + default: return "Undefined"; } } -//_____________________________________________________________________________ -void AliRsnValue::AssignTarget() -{ -// -// This method assigns the target to be expected by this object -// in the computation, depending on its type chosen in the enum. -// - - if (fValueType < kTrackValues) - SetTargetType(AliRsnTarget::kDaughter); - else if (fValueType < kPairValues) - SetTargetType(AliRsnTarget::kMother); - else - SetTargetType(AliRsnTarget::kEvent); // end of event-related values -} - //_____________________________________________________________________________ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) { @@ -281,6 +263,7 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) // cast the input to the allowed types AliRsnDaughter *daughter = fDaughter; AliRsnMother *mother = fMother; + AliRsnEvent *event = fgCurrentEvent; AliESDtrack *esdt = 0x0; AliAODTrack *aodt = 0x0; @@ -313,7 +296,7 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) pSim1 = mother->GetDaughter(1)->Psim(); break; case AliRsnTarget::kEvent: - if (!AliRsnTarget::GetCurrentEvent()) { + if (!event) { AliError(Form("[%s] current event not initialized", GetName())); return kFALSE; } @@ -331,8 +314,28 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) if (fSupportObject->InheritsFrom(AliESDtrackCuts ::Class())) esdCuts = static_cast(fSupportObject); if (fSupportObject->InheritsFrom(AliRsnPairDef ::Class())) pairDef = static_cast(fSupportObject); if (fSupportObject->InheritsFrom(AliRsnDaughterDef::Class())) daughterDef = static_cast(fSupportObject); - if (fSupportObject->InheritsFrom(AliESDpid ::Class())) esdPID = dynamic_cast(fSupportObject); - + + // for retrieving the ESD pid it needs some more tricky operations + // which consist in understanding if the default input event handler + // is that which manages ESDs; if this is true take its ESDpid object + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliVEventHandler *evh = mgr->GetInputEventHandler(); + AliESDInputHandler *esdin = 0x0; + if (evh->IsA() == AliMultiInputEventHandler::Class()) { + AliMultiInputEventHandler *multh = static_cast(evh); + AliInputEventHandler *input = multh->GetFirstInputEventHandler(); + if (input->IsA() == AliESDInputHandler::Class()) { + esdin = static_cast(input); + } + } + else if (evh->IsA() == AliESDInputHandler::Class()) { + esdin = static_cast(evh); + } + // if it is initialized, get ESD pid + if (esdin) { + esdPID = esdin->GetESDpid(); + } + // compute value depending on type switch (fValueType) { case kTrackP: @@ -345,11 +348,10 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); break; case kTrackY: - // for this computation, replace the computed mass with the default mass - // for doing this, an initialized daughterDef is required to get the mass + // for this computation, an initialized daughterDef is required to get the mass hypothesis if (!daughterDef) { - AliError(Form("[%s] Required a correctly initialized DaughterDef to compute this value", GetName())); - fComputedValue = 1E+10; + AliError(Form("[%s] Required a correctly initialized AliRsnDaughterDef support object to compute this value", GetName())); + fComputedValue = fgkVeryBig; return kFALSE; } else { pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), daughterDef->GetMass()); @@ -366,12 +368,12 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) if (pidObj) fComputedValue = pidObj->GetITSsignal(); else { - fComputedValue = 1E+10; + fComputedValue = fgkVeryBig; return kFALSE; } } else { - fComputedValue = 1E+10; + fComputedValue = fgkVeryBig; return kFALSE; } break; @@ -384,20 +386,20 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) if (pidObj) fComputedValue = pidObj->GetTPCsignal(); else { - fComputedValue = 1E+10; + fComputedValue = fgkVeryBig; return kFALSE; } } else { - fComputedValue = 1E+10; + fComputedValue = fgkVeryBig; return kFALSE; } break; case kTrackTOFsignal: if (esdt) { if (!esdPID) { - AliError(Form("[%s] Required a correctly initialized ESDpid to compute this value with ESDs", GetName())); - fComputedValue = 1E+10; + AliError(Form("[%s] Required a correctly initialized AliESDpid support object to compute this value with ESDs", GetName())); + fComputedValue = fgkVeryBig; return kFALSE; } else @@ -408,12 +410,12 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) if (pidObj) fComputedValue = pidObj->GetTOFsignal(); else { - fComputedValue = 1E+10; + fComputedValue = fgkVeryBig; return kFALSE; } } else { - fComputedValue = 1E+10; + fComputedValue = fgkVeryBig; return kFALSE; } break; @@ -423,7 +425,7 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) } else { AliError(Form("[%s] Length information not available in AODs", GetName())); - fComputedValue = 1E+10; + fComputedValue = fgkVeryBig; return kFALSE; } break; @@ -458,11 +460,10 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); break; case kPairMt: - // for this computation, replace the computed mass with the default mass - // for doing this, an initialized pairDef is required to get the mass + // for this computation, an initialized pairDef is required to get the mass if (!pairDef) { - AliError(Form("[%s] Required a correctly initialized PairDef to compute this value", GetName())); - fComputedValue = 1E+10; + AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName())); + fComputedValue = fgkVeryBig; return kFALSE; } else { pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); @@ -471,11 +472,10 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) } break; case kPairY: - // for this computation, replace the computed mass with the default mass - // for doing this, an initialized pairDef is required to get the mass + // for this computation, an initialized pairDef is required to get the mass if (!pairDef) { - AliError(Form("[%s] Required a correctly initialized PairDef to compute this value", GetName())); - fComputedValue = 1E+10; + AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName())); + fComputedValue = fgkVeryBig; return kFALSE; } else { pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); @@ -496,8 +496,14 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) } break; case kPairDipAngle: - fComputedValue = useMC ? pSim0.Angle(pSim1.Vect()) : pRec0.Angle(pRec1.Vect()); - fComputedValue = TMath::Abs(TMath::Cos(fComputedValue)); + if (useMC) { + fComputedValue = pSim0.Perp() * pSim1.Perp() + pSim0.Z() * pSim1.Z(); + fComputedValue /= pSim0.Mag() * pSim1.Mag(); + } else { + fComputedValue = pRec0.Perp() * pRec1.Perp() + pRec0.Z() * pRec1.Z(); + fComputedValue /= pRec0.Mag() * pRec1.Mag(); + } + fComputedValue = TMath::Abs(TMath::ACos(fComputedValue)); break; case kPairCosThetaStar: fComputedValue = mother->CosThetaStar(useMC); @@ -507,48 +513,48 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) pRec0 -= pRec1; fComputedValue = useMC ? pSim0.M() : pRec0.M(); break; - case kPairAngleToLeading: { - AliRsnEvent *event = AliRsnTarget::GetCurrentEvent(); - int ID1 = (mother->GetDaughter(0))->GetID(); - int ID2 = (mother->GetDaughter(1))->GetID(); - //int leadingID = event->SelectLeadingParticle(0); - Int_t leadingID = event->GetLeadingParticleID(); - if (leadingID == ID1 || leadingID == ID2) { - fComputedValue = -99.; - return kFALSE; + case kPairAngleToLeading: + { + int ID1 = (mother->GetDaughter(0))->GetID(); + int ID2 = (mother->GetDaughter(1))->GetID(); + //int leadingID = event->SelectLeadingParticle(0); + Int_t leadingID = event->GetLeadingParticleID(); + if (leadingID == ID1 || leadingID == ID2) { + fComputedValue = -99.; + return kFALSE; + } + AliRsnDaughter leadingPart = event->GetDaughter(leadingID); + AliVParticle *ref = leadingPart.GetRef(); + fComputedValue = ref->Phi() - mother->Sum().Phi(); + //return angle w.r.t. leading particle in the range -pi/2, 3/2pi + while (fComputedValue >= 1.5 * TMath::Pi()) fComputedValue -= 2 * TMath::Pi(); + while (fComputedValue < -0.5 * TMath::Pi()) fComputedValue += 2 * TMath::Pi(); } - AliRsnDaughter leadingPart = event->GetDaughter(leadingID); - AliVParticle *ref = leadingPart.GetRef(); - fComputedValue = ref->Phi() - mother->Sum().Phi(); - //return angle w.r.t. leading particle in the range -pi/2, 3/2pi - while (fComputedValue >= 1.5 * TMath::Pi()) fComputedValue -= 2 * TMath::Pi(); - while (fComputedValue < -0.5 * TMath::Pi()) fComputedValue += 2 * TMath::Pi(); - //Printf("%g", fComputedValue); - } - break; + break; case kEventMult: - fComputedValue = (Double_t)AliRsnTarget::GetCurrentEvent()->GetMultiplicity(0x0); + fComputedValue = (Double_t)event->GetMultiplicity(0x0); break; case kEventMultESDCuts: // this value requires an initialized ESDtrackCuts if (!esdCuts) { - AliError(Form("[%s] Required a correctly initialized ESDtrackCuts to compute this value", GetName())); - fComputedValue = 1E+10; + AliError(Form("[%s] Required a correctly initialized AliESDtrackCuts support object to compute this value", GetName())); + fComputedValue = fgkVeryBig; return kFALSE; } - fComputedValue = (Double_t)AliRsnTarget::GetCurrentEvent()->GetMultiplicity(esdCuts); - break; - case kEventLeadingPt: { - int leadingID = AliRsnTarget::GetCurrentEvent()->GetLeadingParticleID(); //fEvent->SelectLeadingParticle(0); - if (leadingID >= 0) { - AliRsnDaughter leadingPart = AliRsnTarget::GetCurrentEvent()->GetDaughter(leadingID); - AliVParticle *ref = leadingPart.GetRef(); - fComputedValue = ref->Pt(); - } else fComputedValue = 0; - } - break; + fComputedValue = (Double_t)event->GetMultiplicity(esdCuts); + break; + case kEventLeadingPt: + { + int leadingID = event->GetLeadingParticleID(); //fEvent->SelectLeadingParticle(0); + if (leadingID >= 0) { + AliRsnDaughter leadingPart = event->GetDaughter(leadingID); + AliVParticle *ref = leadingPart.GetRef(); + fComputedValue = ref->Pt(); + } else fComputedValue = 0; + } + break; case kEventVz: - fComputedValue = AliRsnTarget::GetCurrentEvent()->GetRef()->GetPrimaryVertex()->GetZ(); + fComputedValue = event->GetRef()->GetPrimaryVertex()->GetZ(); break; default: AliError(Form("[%s] Invalid value type for this computation", GetName())); @@ -576,3 +582,19 @@ void AliRsnValue::Print(Option_t * /*option */) const AliInfo(Form(" Support object : %s", (fSupportObject ? fSupportObject->ClassName() : " NO SUPPORT"))); AliInfo("=== END VALUE INFO ============================================="); } + +//_____________________________________________________________________________ +RSNTARGET AliRsnValue::TargetType(EValueType type) +{ +// +// This method assigns the target to be expected by this object +// in the computation, depending on its type chosen in the enum. +// + + if (type < kTrackValues) + return AliRsnTarget::kDaughter; + else if (type < kPairValues) + return AliRsnTarget::kMother; + else + return AliRsnTarget::kEvent; +} diff --git a/PWG2/RESONANCES/AliRsnValue.h b/PWG2/RESONANCES/AliRsnValue.h index 67670a2973a..535733e651e 100644 --- a/PWG2/RESONANCES/AliRsnValue.h +++ b/PWG2/RESONANCES/AliRsnValue.h @@ -24,44 +24,44 @@ public: // this enumeration lists all available computations // any user feedback proposing new ones is welcome enum EValueType { - kTrackP, // single track total momentum - kTrackPt, // single track transverse momentum - kTrackEta, // single track pseudo-rapidity - kTrackY, // single track rapidity - kTrackITSsignal, // single track ITS signal - kTrackTPCsignal, // single track TPC signal - kTrackTOFsignal, // single track TOF signal - kTrackLength, // single track integrated length - kTrackValues, // --- limitator for track values --------------------------------------- - - kPairP1, // total momentum of 1st daughter of a pair - kPairP2, // total momentum of 2nd daughter of a pair - kPairP1t, // total momentum of 1st daughter of a pair - kPairP2t, // total momentum of 2nd daughter of a pair - kPairP1z, // total momentum of 1st daughter of a pair - kPairP2z, // total momentum of 2nd daughter of a pair - kPairInvMass, // pair invariant mass (with reconstructed momenta) - kPairInvMassMC, // pair invariant mass (with MC momenta) - kPairInvMassRes, // pair invariant mass resolution - kPairPt, // pair transverse momentum - kPairPz, // pair longitudinal momentum - kPairEta, // pair pseudo-rapidity - kPairMt, // pair transverse mass (need a reference mass) - kPairY, // pair rapidity (need a reference mass) - kPairPhi, // pair azimuthal angle (with reconstructed momenta) - kPairPhiMC, // pair azimuthal angle (with MC momenta) - kPairPtRatio, // ratio |pt1 - pt2|/(pt1 + pt2) of daughter transverse momenta - kPairDipAngle, // inverse cosine of the angle between daughter vector momenta - kPairCosThetaStar, // polarization angle - kPairQInv, // invariant relative momentum of the two daughters - kPairAngleToLeading, // angle between the pair momentum and that of the event leading particle - kPairValues, // --- limitator for pair values ---------------------------------------- - - kEventLeadingPt, // transverse momentum of the event leading particle - kEventMult, // multiplicity computed as the number of tracks - kEventMultESDCuts, // multiplicity computed as the number of track passing an ESD quality cut (need this cut defined) - kEventVz, // Z position of event primary vertex - kValueTypes // --- last value (used to have a meaningless enum value) --------------- + kTrackP, // single track total momentum + kTrackPt, // single track transverse momentum + kTrackEta, // single track pseudo-rapidity + kTrackY, // single track rapidity + kTrackITSsignal, // single track ITS signal + kTrackTPCsignal, // single track TPC signal + kTrackTOFsignal, // single track TOF signal + kTrackLength, // single track integrated length + kTrackValues, // --- limitator for track values --------------------------------------- + + kPairP1, // total momentum of 1st daughter of a pair + kPairP2, // total momentum of 2nd daughter of a pair + kPairP1t, // total momentum of 1st daughter of a pair + kPairP2t, // total momentum of 2nd daughter of a pair + kPairP1z, // total momentum of 1st daughter of a pair + kPairP2z, // total momentum of 2nd daughter of a pair + kPairInvMass, // pair invariant mass (with reconstructed momenta) + kPairInvMassMC, // pair invariant mass (with MC momenta) + kPairInvMassRes, // pair invariant mass resolution + kPairPt, // pair transverse momentum + kPairPz, // pair longitudinal momentum + kPairEta, // pair pseudo-rapidity + kPairMt, // pair transverse mass (need a reference mass) + kPairY, // pair rapidity (need a reference mass) + kPairPhi, // pair azimuthal angle (with reconstructed momenta) + kPairPhiMC, // pair azimuthal angle (with MC momenta) + kPairPtRatio, // ratio |pt1 - pt2|/(pt1 + pt2) of daughter transverse momenta + kPairDipAngle, // inverse cosine of the angle between daughter vector momenta + kPairCosThetaStar, // polarization angle + kPairQInv, // invariant relative momentum of the two daughters + kPairAngleToLeading, // angle between the pair momentum and that of the event leading particle + kPairValues, // --- limitator for pair values ---------------------------------------- + + kEventLeadingPt, // transverse momentum of the event leading particle + kEventMult, // multiplicity computed as the number of tracks + kEventMultESDCuts, // multiplicity computed as the number of track passing an ESD quality cut (need this cut defined) + kEventVz, // Z position of event primary vertex + kValueTypes // --- last value (used to have a meaningless enum value) --------------- }; AliRsnValue(); @@ -89,8 +89,9 @@ public: void Set(EValueType type, Int_t n, Double_t *array) {fValueType = type; AssignTarget(); SetBins(n, array);} void Set(EValueType type, Double_t min, Double_t max, Double_t step) {fValueType = type; AssignTarget(); SetBins(min, max, step);} - virtual Bool_t Eval(TObject *object, Bool_t useMC = kFALSE); - virtual void Print(Option_t *option = "") const; + virtual Bool_t Eval(TObject *object, Bool_t useMC = kFALSE); + virtual void Print(Option_t *option = "") const; + static RSNTARGET TargetType(EValueType type); protected: