From 32992791e67f65021ebf6708a987bc83ea0558a6 Mon Sep 17 00:00:00 2001 From: pulvir Date: Fri, 19 Nov 2010 10:06:29 +0000 Subject: [PATCH] Update of package classes. Introduced a common base class for cuts and values, which allows to generalize the evaluation methods, and select the target "a posteriori". Generalized the AliRsnValue computation with the addition of a generic cut support object which can be any TObject (this copes with the need to have an AliRsnPair in some cuts related to the mother, and AliESDtrackCuts for multiplicity computation. In processInfo adjusted some indentation and adapted also to PROOF. Adapted some header comments and removed some useless methods. --- PWG2/PWG2resonancesLinkDef.h | 19 +- PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx | 20 +- PWG2/RESONANCES/AliRsnAnalysisManager.cxx | 43 +- PWG2/RESONANCES/AliRsnAnalysisManager.h | 10 +- PWG2/RESONANCES/AliRsnAnalysisSE.cxx | 31 +- PWG2/RESONANCES/AliRsnAnalysisSE.h | 34 +- PWG2/RESONANCES/AliRsnCut.cxx | 286 +++------- PWG2/RESONANCES/AliRsnCut.h | 103 ++-- PWG2/RESONANCES/AliRsnCutAOD2010.cxx | 4 +- PWG2/RESONANCES/AliRsnCutAOD2010.h | 2 +- PWG2/RESONANCES/AliRsnCutBetheBloch.cxx | 16 +- PWG2/RESONANCES/AliRsnCutBetheBloch.h | 2 +- PWG2/RESONANCES/AliRsnCutDaughterType.cxx | 10 +- PWG2/RESONANCES/AliRsnCutDaughterType.h | 2 +- PWG2/RESONANCES/AliRsnCutESD2010.cxx | 387 +++++++------ PWG2/RESONANCES/AliRsnCutESD2010.h | 109 +++- PWG2/RESONANCES/AliRsnCutESDCutMultiplicity.h | 2 +- PWG2/RESONANCES/AliRsnCutESDPrimary.cxx | 10 +- PWG2/RESONANCES/AliRsnCutESDPrimary.h | 2 +- PWG2/RESONANCES/AliRsnCutManager.cxx | 63 ++- PWG2/RESONANCES/AliRsnCutManager.h | 57 +- PWG2/RESONANCES/AliRsnCutPID.cxx | 15 +- PWG2/RESONANCES/AliRsnCutPID.h | 2 +- PWG2/RESONANCES/AliRsnCutPrimaryVertex.cxx | 19 +- PWG2/RESONANCES/AliRsnCutPrimaryVertex.h | 5 +- PWG2/RESONANCES/AliRsnCutSet.cxx | 65 ++- PWG2/RESONANCES/AliRsnCutSet.h | 12 +- PWG2/RESONANCES/AliRsnCutValue.cxx | 89 +-- PWG2/RESONANCES/AliRsnCutValue.h | 33 +- PWG2/RESONANCES/AliRsnDaughter.cxx | 26 + PWG2/RESONANCES/AliRsnDaughter.h | 75 +-- PWG2/RESONANCES/AliRsnEvent.cxx | 286 +++++++--- PWG2/RESONANCES/AliRsnEvent.h | 36 +- PWG2/RESONANCES/AliRsnFunction.cxx | 107 ++-- PWG2/RESONANCES/AliRsnFunction.h | 2 +- PWG2/RESONANCES/AliRsnMother.cxx | 39 +- PWG2/RESONANCES/AliRsnMother.h | 7 - PWG2/RESONANCES/AliRsnPair.cxx | 48 +- PWG2/RESONANCES/AliRsnPair.h | 1 + PWG2/RESONANCES/AliRsnPairFunctions.cxx | 1 - PWG2/RESONANCES/AliRsnPairNtuple.cxx | 34 +- PWG2/RESONANCES/AliRsnPairNtuple.h | 2 +- PWG2/RESONANCES/AliRsnVATProcessInfo.cxx | 119 ++-- PWG2/RESONANCES/AliRsnVATProcessInfo.h | 26 +- PWG2/RESONANCES/AliRsnValue.cxx | 523 +++++++++++------- PWG2/RESONANCES/AliRsnValue.h | 125 +++-- .../train/LHC2010-7TeV-phi/AddRsnAnalysis.C | 25 +- .../LHC2010-7TeV-phi/AddRsnAnalysisMult.C | 2 +- .../train/LHC2010-7TeV-phi/AddRsnEfficiency.C | 56 +- .../train/LHC2010-7TeV-phi/ConfigESDCutsITS.C | 4 +- .../train/LHC2010-7TeV-phi/ConfigESDCutsTPC.C | 7 +- .../macros/train/LHC2010-7TeV-phi/RsnConfig.C | 89 +-- PWG2/libPWG2resonances.pkg | 15 +- 53 files changed, 1755 insertions(+), 1352 deletions(-) diff --git a/PWG2/PWG2resonancesLinkDef.h b/PWG2/PWG2resonancesLinkDef.h index 83b6cb62123..eca71b320c2 100644 --- a/PWG2/PWG2resonancesLinkDef.h +++ b/PWG2/PWG2resonancesLinkDef.h @@ -2,29 +2,28 @@ #pragma link C++ class AliRsnDaughter+; #pragma link C++ class AliRsnMother+; +#pragma link C++ class AliRsnPairDef+; #pragma link C++ class AliRsnEvent+; +#pragma link C++ class AliRsnTarget+; #pragma link C++ class AliRsnValue+; -#pragma link C++ class AliRsnFunction+; - -#pragma link C++ class AliRsnExpression+; -#pragma link C++ class AliRsnVariableExpression+; #pragma link C++ class AliRsnCut+; -#pragma link C++ class AliRsnCutStd+; + +#pragma link C++ class AliRsnCutValue+; #pragma link C++ class AliRsnCutPID+; #pragma link C++ class AliRsnCutBetheBloch+; -#pragma link C++ class AliRsnCutESDPrimary+; -#pragma link C++ class AliRsnCutESDCutMultiplicity+; #pragma link C++ class AliRsnCutPrimaryVertex+; +#pragma link C++ class AliRsnCutESDPrimary+; #pragma link C++ class AliRsnCutDaughterType+; #pragma link C++ class AliRsnCutESD2010+; #pragma link C++ class AliRsnCutAOD2010+; -#pragma link C++ class AliRsnCutValue+; #pragma link C++ class AliRsnCutSet+; +#pragma link C++ class AliRsnExpression+; +#pragma link C++ class AliRsnVariableExpression+; #pragma link C++ class AliRsnCutManager+; -#pragma link C++ class AliRsnPairDef+; +#pragma link C++ class AliRsnFunction+; #pragma link C++ class AliRsnPair+; #pragma link C++ class AliRsnPairFunctions+; #pragma link C++ class AliRsnPairNtuple+; @@ -46,7 +45,5 @@ #pragma link C++ class AliRsnMonitorTrack+; #pragma link C++ class AliRsnAnalysisMonitorTask+; -#pragma link C++ class AliRsnAnalysisMonitorPairTask+; -//#pragma link C++ class AliRsnFitResult+; #endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx b/PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx index 11232ea9f9f..817cee3b34b 100644 --- a/PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx +++ b/PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx @@ -555,8 +555,9 @@ void AliRsnAnalysisEffSE::FillContainer(AliCFContainer *cont, const TObjArray *s // Fill the containers // - Int_t iaxis, nAxes = fAxisList.GetEntries(); - Int_t istep, nSteps = stepList->GetEntries(); + Int_t iaxis, nAxes = fAxisList.GetEntries(); + Int_t istep, nSteps = stepList->GetEntries(); + Bool_t computeOK; // set daughters to pair fPair.SetDaughters(&fDaughter[0], pd->GetMass(0), &fDaughter[1], pd->GetMass(1)); @@ -566,7 +567,20 @@ void AliRsnAnalysisEffSE::FillContainer(AliCFContainer *cont, const TObjArray *s { AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis); fVar[iaxis] = -1E10; - if (fcnAxis->Eval(&fPair, pd, &fRsnEvent)) fVar[iaxis] = (Float_t)fcnAxis->GetValue(); + switch (fcnAxis->GetTargetType()) + { + case AliRsnTarget::kMother: + fcnAxis->SetSupportObject(pd); + computeOK = fcnAxis->Eval(&fPair); + break; + case AliRsnTarget::kEvent: + computeOK = fcnAxis->Eval(&fRsnEvent); + break; + default: + AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", fcnAxis->GetName(), fcnAxis->GetTargetTypeName())); + computeOK = kFALSE; + } + if (computeOK) fVar[iaxis] = ((Float_t)fcnAxis->GetComputedValue()); } // fill all steps diff --git a/PWG2/RESONANCES/AliRsnAnalysisManager.cxx b/PWG2/RESONANCES/AliRsnAnalysisManager.cxx index b71f62bdce1..df8149219e8 100644 --- a/PWG2/RESONANCES/AliRsnAnalysisManager.cxx +++ b/PWG2/RESONANCES/AliRsnAnalysisManager.cxx @@ -16,7 +16,6 @@ // revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it] // -#include #include #include "AliLog.h" @@ -24,7 +23,8 @@ #include "AliVEvent.h" #include "AliMCEvent.h" #include "AliRsnEvent.h" -#include "AliRsnPair.h" +#include "AliRsnPairFunctions.h" +#include "AliRsnPairNtuple.h" #include "AliRsnAnalysisManager.h" @@ -33,14 +33,12 @@ ClassImp(AliRsnAnalysisManager) //_____________________________________________________________________________ AliRsnAnalysisManager::AliRsnAnalysisManager(const char*name) : TNamed(name, ""), - fPairs(0) + fPairs(0), + fGlobalTrackCuts() { // // Default constructor // - - AliDebug(AliLog::kDebug+2, "<-"); - AliDebug(AliLog::kDebug+2, "->"); } //_____________________________________________________________________________ @@ -52,13 +50,14 @@ void AliRsnAnalysisManager::Add(AliRsnPair *pair) AliDebug(AliLog::kDebug+2,"<-"); - if (!pair) { + if (!pair) + { AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair)); return; } AliDebug(AliLog::kDebug+1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries())); - fPairs.Add((AliRsnPair*)pair); + fPairs.Add(pair); AliDebug(AliLog::kDebug+2,"->"); } @@ -128,27 +127,28 @@ void AliRsnAnalysisManager::ProcessAllPairs(AliRsnEvent *ev0, AliRsnEvent *ev1) if (!ev1) ev1 = ev0; - Int_t nTracks[2], nV0[2], nTot[2]; - nTracks[0] = ev0->GetRef()->GetNumberOfTracks(); - nV0[0] = ev0->GetRef()->GetNumberOfV0s(); - nTracks[1] = ev1->GetRef()->GetNumberOfTracks(); - nV0[1] = ev1->GetRef()->GetNumberOfV0s(); - nTot[0] = nTracks[0] + nV0[0]; - nTot[1] = nTracks[1] + nV0[1]; + Int_t nTot[2]; + nTot[0] = ev0->GetAbsoluteSum(); + nTot[1] = ev1->GetAbsoluteSum();; // external loop // joins the loop on tracks and v0s, by looping the indexes from 0 // to the sum of them, and checking what to take depending of its value - Int_t i0, i1, i; + // in this step, the global cuts are checked + Int_t i0, i1, i, realIndex; AliRsnDaughter daughter0, daughter1; AliRsnPair *pair = 0x0; TObjArrayIter next(&fPairs); + AliRsnDaughter::ERefType type; for (i0 = 0; i0 < nTot[0]; i0++) { // assign first track - if (i0 < nTracks[0]) ev0->SetDaughter(daughter0, i0, AliRsnDaughter::kTrack); - else ev0->SetDaughter(daughter0, i0 - nTracks[0], AliRsnDaughter::kV0); + if (!ev0->ConvertAbsoluteIndex(i0, realIndex, type)) continue; + ev0->SetDaughter(daughter0, realIndex, type); + + // check global cuts + if (!fGlobalTrackCuts.IsSelected(&daughter0)) continue; // internal loop (same criterion) for (i1 = 0; i1 < nTot[1]; i1++) @@ -157,8 +157,11 @@ void AliRsnAnalysisManager::ProcessAllPairs(AliRsnEvent *ev0, AliRsnEvent *ev1) if (ev0 == ev1 && i0 == i1) continue; // assign second track - if (i1 < nTracks[1]) ev1->SetDaughter(daughter1, i1, AliRsnDaughter::kTrack); - else ev1->SetDaughter(daughter1, i1 - nTracks[1], AliRsnDaughter::kV0); + if (!ev1->ConvertAbsoluteIndex(i1, realIndex, type)) continue; + ev1->SetDaughter(daughter1, realIndex, type); + + // check global cuts + if (!fGlobalTrackCuts.IsSelected(&daughter1)) continue; // loop over all pairs and make computations next.Reset(); diff --git a/PWG2/RESONANCES/AliRsnAnalysisManager.h b/PWG2/RESONANCES/AliRsnAnalysisManager.h index 1612717cc05..130b9272ca6 100644 --- a/PWG2/RESONANCES/AliRsnAnalysisManager.h +++ b/PWG2/RESONANCES/AliRsnAnalysisManager.h @@ -19,7 +19,9 @@ #ifndef ALIRSNANALYSISMANAGER_H #define ALIRSNANALYSISMANAGER_H -class TROOT; +#include + +#include "AliRsnCutSet.h" class AliRsnEvent; class AliRsnPair; @@ -29,7 +31,7 @@ class AliRsnAnalysisManager : public TNamed public: AliRsnAnalysisManager(const char*name = "defaultAnalysisMgr"); - virtual ~AliRsnAnalysisManager() {;}; + virtual ~AliRsnAnalysisManager() { } virtual void Add(AliRsnPair *pair); virtual void PrintArray() const; @@ -38,10 +40,12 @@ class AliRsnAnalysisManager : public TNamed void InitAllPairs(TList*list); void ProcessAllPairs(AliRsnEvent *ev0, AliRsnEvent *ev1); void ProcessAllPairsMC(AliRsnEvent *ev0, AliRsnEvent *ev1); + AliRsnCutSet* GetGlobalTrackCuts() {return &fGlobalTrackCuts;} private: - TObjArray fPairs; + TObjArray fPairs; // collection of pair objects for the different outputs + AliRsnCutSet fGlobalTrackCuts; // a set of cuts which are applied to all tracks for all analysis, in order to put only once ClassDef(AliRsnAnalysisManager, 1) }; diff --git a/PWG2/RESONANCES/AliRsnAnalysisSE.cxx b/PWG2/RESONANCES/AliRsnAnalysisSE.cxx index 8d7da929f9d..6912e88b73a 100644 --- a/PWG2/RESONANCES/AliRsnAnalysisSE.cxx +++ b/PWG2/RESONANCES/AliRsnAnalysisSE.cxx @@ -49,21 +49,25 @@ AliRsnAnalysisSE::AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) : // // Copy constructor. // - - AliDebug(AliLog::kDebug+2,"<-"); - AliDebug(AliLog::kDebug+2,"->"); } -// //_____________________________________________________________________________ -// AliRsnAnalysisSE::~AliRsnAnalysisSE() -// { -// // -// // Destructor -// // -// -// fOutList->Clear(); -// -// } +//_____________________________________________________________________________ +AliRsnAnalysisSE& AliRsnAnalysisSE::operator=(const AliRsnAnalysisSE& copy) +{ +// +// Copy constructor. +// + + AliRsnVAnalysisTaskSE::operator=(copy); + + fRsnAnalysisManager = copy.fRsnAnalysisManager; + fEventCuts = copy.fEventCuts; + if (fOutList) fOutList->Clear(); + fZeroEventPercentWarning = copy.fZeroEventPercentWarning; + fUseZeroEventWarning = copy.fUseZeroEventWarning; + + return (*this); +} //_____________________________________________________________________________ void AliRsnAnalysisSE::RsnUserCreateOutputObjects() @@ -77,6 +81,7 @@ void AliRsnAnalysisSE::RsnUserCreateOutputObjects() AliDebug(AliLog::kDebug+2,"<-"); + if (fOutList) fOutList->Clear(); fOutList = new TList; fRsnAnalysisManager.InitAllPairs(fOutList); diff --git a/PWG2/RESONANCES/AliRsnAnalysisSE.h b/PWG2/RESONANCES/AliRsnAnalysisSE.h index 0a34a87066b..a551389903e 100644 --- a/PWG2/RESONANCES/AliRsnAnalysisSE.h +++ b/PWG2/RESONANCES/AliRsnAnalysisSE.h @@ -20,34 +20,30 @@ class AliRsnPIDDefESD; class AliRsnAnalysisSE : public AliRsnVAnalysisTaskSE { - public: + AliRsnAnalysisSE(const char *name = "AliRsnAnalysisSE", Bool_t useKine = kFALSE); AliRsnAnalysisSE(const AliRsnAnalysisSE& copy); -// virtual ~AliRsnAnalysisSE(); - - // Implement this - virtual void RsnUserCreateOutputObjects(); - virtual void RsnUserExec(Option_t*); - virtual void RsnTerminate(Option_t*); + AliRsnAnalysisSE& operator=(const AliRsnAnalysisSE& copy); + virtual ~AliRsnAnalysisSE() {} - AliRsnAnalysisManager *GetAnalysisManager() {return &fRsnAnalysisManager;} - void SetAnalysisManagerName(const char *name) {fRsnAnalysisManager.SetName(name);} + virtual void RsnUserCreateOutputObjects(); + virtual void RsnUserExec(Option_t*); + virtual void RsnTerminate(Option_t*); - AliRsnCutSet* GetEventCuts() {return &fEventCuts;} -// void SetEventCuts(AliRsnCutSet *const cuts) {fEventCuts = cuts;} + AliRsnCutSet* GetEventCuts() {return &fEventCuts;} + AliRsnAnalysisManager* GetAnalysisManager() {return &fRsnAnalysisManager;} + void SetAnalysisManagerName(const char *name) {fRsnAnalysisManager.SetName(name);} - Double_t GetZeroEventPercentWarning() const {return fZeroEventPercentWarning;} - void SetZeroEventPercentWarning(Double_t val = 50) {fZeroEventPercentWarning = val;} - void UseZeroEventWarning(Bool_t b = true) {fUseZeroEventWarning = b;} + Double_t GetZeroEventPercentWarning() const {return fZeroEventPercentWarning;} + void SetZeroEventPercentWarning(Double_t val = 50) {fZeroEventPercentWarning = val;} + void UseZeroEventWarning(Bool_t b = true) {fUseZeroEventWarning = b;} private: - AliRsnAnalysisSE& operator=(const AliRsnAnalysisSE& /*copy*/) {return *this;} - - AliRsnAnalysisManager fRsnAnalysisManager; // analysis main engine - AliRsnCutSet fEventCuts; // event cuts - TList *fOutList; // list of output events + AliRsnAnalysisManager fRsnAnalysisManager; // analysis main engine + AliRsnCutSet fEventCuts; // event cuts + TList *fOutList; // list of output events Double_t fZeroEventPercentWarning; // Percent Number for Zero Event Warning Bool_t fUseZeroEventWarning; // flag if Zero Event Warning is used (default is true) diff --git a/PWG2/RESONANCES/AliRsnCut.cxx b/PWG2/RESONANCES/AliRsnCut.cxx index 4d618dca1ce..6a1f75dafdc 100644 --- a/PWG2/RESONANCES/AliRsnCut.cxx +++ b/PWG2/RESONANCES/AliRsnCut.cxx @@ -1,21 +1,17 @@ // -// 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 "AliRsnMother.h" @@ -25,15 +21,13 @@ ClassImp(AliRsnCut) -//_________________________________________________________________________________________________ -AliRsnCut::AliRsnCut(ETarget target) : - TNamed(), - fVarType(kInt), - fTarget(target), +//______________________________________________________________________________ +AliRsnCut::AliRsnCut(const char *name, RSNTARGET target) : + AliRsnTarget(name, target), fMinI(0), fMaxI(0), - fMinD(0.0), - fMaxD(0.0), + fMinD(0.), + fMaxD(0.), fCutValueI(0), fCutValueD(0.0), fCutResult(kTRUE), @@ -44,83 +38,72 @@ AliRsnCut::AliRsnCut(ETarget target) : // } -//_________________________________________________________________________________________________ -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) -{ -// -// Copy constructor. -// -} - -//_________________________________________________________________________________________________ +//______________________________________________________________________________ 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), +(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), fEvent(0x0) { // -// 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. +// Constructor with arguments. +// This is provided to allow a quick setting of all data members. // } -//_________________________________________________________________________________________________ +//______________________________________________________________________________ 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), +(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), fEvent(0x0) { // -// 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. +// Constructor with arguments. +// This is provided to allow a quick setting of all data members. // } -//_________________________________________________________________________________________________ +//______________________________________________________________________________ +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), + fEvent(copy.fEvent) +{ +// +// Copy constructor. +// Don't duplicate memory occupancy for pointer +// +} + +//______________________________________________________________________________ AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy) { // -// Assignment operator -// don't duplicate memory occupancy for pointer +// Assignment operator. +// Don't duplicate memory occupancy for pointer // - fVarType = copy.fVarType; - fTarget = copy.fTarget; + AliRsnTarget::operator=(copy); + fMinI = copy.fMinI; fMaxI = copy.fMaxI; fMinD = copy.fMinD; @@ -133,130 +116,21 @@ AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy) return (*this); } -//_________________________________________________________________________________________________ -Bool_t AliRsnCut::TargetOK(TObject *obj1, TObject *obj2) +//______________________________________________________________________________ +Bool_t AliRsnCut::IsSelected(TObject* /*object*/) { // -// This method checks if the expected target and the passed object match. +// 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. // - 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; - } - + AliWarning("This virtual function must be implemented properly"); return kTRUE; } -//_________________________________________________________________________________________________ -Bool_t AliRsnCut::IsSelected(TObject* /*obj1*/, TObject* /*obj2*/) -{ -// -// Virtual cut-checking method for event mixing. -// This method checks only that the target is the oner for mixing. -// - - AliWarning("Single-object cuts are not implemented here."); - return kTRUE; -} - -//_________________________________________________________________________________________________ -Bool_t AliRsnCut::OkValue() -{ -// -// 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::OkRange() -{ -// -// 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::OkValueI() { // @@ -278,7 +152,7 @@ Bool_t AliRsnCut::OkValueI() return fCutResult; } -//_________________________________________________________________________________________________ +//______________________________________________________________________________ Bool_t AliRsnCut::OkValueD() { // @@ -300,7 +174,7 @@ Bool_t AliRsnCut::OkValueD() return fCutResult; } -//_________________________________________________________________________________________________ +//______________________________________________________________________________ Bool_t AliRsnCut::OkRangeI() { // @@ -310,7 +184,7 @@ Bool_t AliRsnCut::OkRangeI() // // eval result - fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI)); + fCutResult = ((fCutValueI >= fMinI) && (fCutValueI < fMaxI)); // print debug message AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ===================================="); @@ -323,7 +197,7 @@ Bool_t AliRsnCut::OkRangeI() return fCutResult; } -//_________________________________________________________________________________________________ +//______________________________________________________________________________ Bool_t AliRsnCut::OkRangeD() { // @@ -333,7 +207,7 @@ Bool_t AliRsnCut::OkRangeD() // // eval result - fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD)); + fCutResult = ((fCutValueD >= fMinD) && (fCutValueD < fMaxD)); // print debug message AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ===================================="); @@ -346,36 +220,30 @@ Bool_t AliRsnCut::OkRangeD() return fCutResult; } -//_________________________________________________________________________________________________ +//______________________________________________________________________________ void AliRsnCut::Print(Option_t*) const { // -// Override TObject::Print() method +// Override TObject::Print() method, +// and print some useful info about the cut general parameters. // - 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 target : [%s]", GetTargetTypeName())); AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD)); AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI)); AliInfo("===================================================="); } -//_________________________________________________________________________________________________ +//______________________________________________________________________________ void AliRsnCut::SetEvent(AliRsnEvent *event) { // -// Sets the reference event +// Sets the reference event. +// When this requires some additional operation, this function +// should be overloaded by the specific cut implementation. +// For an example, see AliRsnCutESD2010 class. // fEvent = event; diff --git a/PWG2/RESONANCES/AliRsnCut.h b/PWG2/RESONANCES/AliRsnCut.h index 6438a55df85..2a9bcda2044 100644 --- a/PWG2/RESONANCES/AliRsnCut.h +++ b/PWG2/RESONANCES/AliRsnCut.h @@ -1,78 +1,50 @@ // -// 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 [--> IsEqual() ] -// 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. +// 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. // -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// 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: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// Martin Vala (martin.vala@cern.ch) // #ifndef ALIRSNCUT_H #define ALIRSNCUT_H -#include "TNamed.h" +#include "AliRsnTarget.h" class AliRsnEvent; -class AliRsnCut : public TNamed +class AliRsnCut : public AliRsnTarget { public: - // possible targets for a cut - enum ETarget - { - kDaughter = 0, - kMother, - kEvent, - kMixEvent, - kLastCutTarget - }; - - // data type for check - enum EVarType - { - kNoVar = 0, - kInt, - kDouble - }; - - AliRsnCut(ETarget target = kLastCutTarget); + AliRsnCut(const char *name = "dummy", RSNTARGET target = AliRsnTarget::kTargetTypes); + AliRsnCut(const char *name, RSNTARGET target, Int_t imin, Int_t imax=0 , Double_t dmin=0., Double_t dmax=0.); + AliRsnCut(const char *name, RSNTARGET target, Double_t dmin, Double_t dmax=0., Int_t imin=0 , Int_t imax=0 ); AliRsnCut(const AliRsnCut& copy); AliRsnCut& operator=(const AliRsnCut& copy); - AliRsnCut(const char *name, ETarget target, Int_t min, Int_t max = 0 ); - AliRsnCut(const char *name, ETarget target, Double_t min, Double_t max = 0.); - virtual ~AliRsnCut() { /*nothing*/ }; + virtual ~AliRsnCut() { fEvent = 0x0; }; - EVarType GetVarTypeEnum() {return fVarType;} - Char_t GetVarTypeChar() {if (fVarType == kInt) return 'I'; else if (fVarType == kDouble) return 'D'; else return 'X';} - ETarget GetTargetEnum() {return fTarget;} - Char_t GetTargetChar() {if (fTarget == kDaughter) return 'D'; else if (fTarget == kMother) return 'M'; else if (fTarget == kEvent) return 'E'; else return 'X';} - Bool_t IsTarget(ETarget target) {return (fTarget == target);} - Bool_t TargetOK(TObject *obj1, TObject *obj2 = 0x0); - 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 SetRange(Int_t min, Int_t max) {fMinI = min; fMaxI = max; fVarType = kInt;} - void SetRange(Double_t min, Double_t max) {fMinD = min; fMaxD = max; fVarType = kDouble;} + void SetRangeI(Int_t min, Int_t max) {fMinI = min; fMaxI = max;} + void SetRangeD(Double_t min, Double_t max) {fMinD = min; fMaxD = max;} + + void SetValueI(Int_t value) {fMinI = value;} + void SetValueD(Double_t value) {fMinD = value;} - void SetValue(Int_t value) {fMinI = value; fVarType = kInt;} - void SetValue(Double_t value) {fMinD = value; fVarType = kDouble;} - - Bool_t OkValue(); - Bool_t OkRange(); Bool_t OkValueI(); Bool_t OkRangeI(); Bool_t OkValueD(); @@ -81,23 +53,20 @@ class AliRsnCut : public TNamed virtual void SetEvent(AliRsnEvent *event); AliRsnEvent* GetEvent() {return fEvent;} - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); virtual void Print(Option_t *opt = "") const; protected: - EVarType fVarType; // type of checked variable - ETarget fTarget; // type of object on which the cut is checked - - Int_t fMinI; // lower edge of INT range or ref. value for INT CUT - Int_t fMaxI; // upper edge of INT range (not used for value cuts) - Double_t fMinD; // lower edge of DOUBLE range or ref. value for INT CUT - Double_t fMaxD; // upper edge of DOUBLE range (not used for value cuts) + Int_t fMinI; // lower edge of INT range or ref. value for INT CUT + Int_t fMaxI; // upper edge of INT range (not used for value cuts) + Double_t fMinD; // lower edge of DOUBLE range or ref. value for DOUBLE CUT + Double_t fMaxD; // upper edge of DOUBLE range (not used for value cuts) - Int_t fCutValueI; // cut value INT - Double_t fCutValueD; // cut value DOUBLE + Int_t fCutValueI; // cut value INT + Double_t fCutValueD; // cut value DOUBLE - Bool_t fCutResult; // tells if the cut is passed or not + Bool_t fCutResult; // tells if the cut is passed or not AliRsnEvent *fEvent; //! pointer to current event (can be needed sometimes, but never streamed) diff --git a/PWG2/RESONANCES/AliRsnCutAOD2010.cxx b/PWG2/RESONANCES/AliRsnCutAOD2010.cxx index 238035895c8..e234c78c581 100644 --- a/PWG2/RESONANCES/AliRsnCutAOD2010.cxx +++ b/PWG2/RESONANCES/AliRsnCutAOD2010.cxx @@ -149,14 +149,14 @@ void AliRsnCutAOD2010::SetMC(Bool_t yn) } //_________________________________________________________________________________________________ -Bool_t AliRsnCutAOD2010::IsSelected(TObject *obj1, TObject* /*obj2*/) +Bool_t AliRsnCutAOD2010::IsSelected(TObject *object) { // // Cut checker. // // coherence check: require an AOD track - AliRsnDaughter *daughter = dynamic_cast(obj1); + AliRsnDaughter *daughter = dynamic_cast(object); if (!daughter) return kFALSE; AliAODTrack *track = daughter->GetRefAODtrack(); if (!track) return kFALSE; diff --git a/PWG2/RESONANCES/AliRsnCutAOD2010.h b/PWG2/RESONANCES/AliRsnCutAOD2010.h index 9e93800eb0e..869efb6f1bd 100644 --- a/PWG2/RESONANCES/AliRsnCutAOD2010.h +++ b/PWG2/RESONANCES/AliRsnCutAOD2010.h @@ -26,7 +26,7 @@ class AliRsnCutAOD2010 : public AliRsnCut AliRsnCutAOD2010(const AliRsnCutAOD2010& copy); virtual ~AliRsnCutAOD2010() {;}; - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); void SetMC (Bool_t yn = kTRUE); void SetCheckITS (Bool_t yn = kTRUE) {fCheckITS = yn;} diff --git a/PWG2/RESONANCES/AliRsnCutBetheBloch.cxx b/PWG2/RESONANCES/AliRsnCutBetheBloch.cxx index 619042c7284..8ee144d6aae 100644 --- a/PWG2/RESONANCES/AliRsnCutBetheBloch.cxx +++ b/PWG2/RESONANCES/AliRsnCutBetheBloch.cxx @@ -26,7 +26,7 @@ ClassImp(AliRsnCutBetheBloch) //_________________________________________________________________________________________________ AliRsnCutBetheBloch::AliRsnCutBetheBloch() : - AliRsnCut(AliRsnCut::kDaughter), + AliRsnCut("dummyBBCut", AliRsnTarget::kDaughter), fCorrect(kTRUE), fMIP(50.0), fType(AliPID::kUnknown) @@ -110,22 +110,18 @@ Double_t AliRsnCutBetheBloch::RelDiff(AliRsnDaughter *track) } //_________________________________________________________________________________________________ -Bool_t AliRsnCutBetheBloch::IsSelected(TObject *obj1, TObject* /*obj2*/) +Bool_t AliRsnCutBetheBloch::IsSelected(TObject *object) { // // Cut checker. // // dynamic cast the object into AliRsnDaughter - AliRsnDaughter *track = dynamic_cast(obj1); - if (!track) - { - AliError(Form("[%s]: this cut works only with AliRsnDaughter objects", GetName())); - return kTRUE; - } + if (!TargetOK(object)) return kFALSE; // retrieve the TPC signal - AliESDtrack *esd = track->GetRefESDtrack(); + AliRsnDaughter *track = dynamic_cast(object); + AliESDtrack *esd = track->GetRefESDtrack(); if (!esd) { AliError("ESD information unavailable"); return kTRUE; @@ -143,5 +139,5 @@ Bool_t AliRsnCutBetheBloch::IsSelected(TObject *obj1, TObject* /*obj2*/) fCutValueD = RelDiff(track); // then, this cut is checked inside the range - return OkRange(); + return OkRangeD(); } diff --git a/PWG2/RESONANCES/AliRsnCutBetheBloch.h b/PWG2/RESONANCES/AliRsnCutBetheBloch.h index 4bcbaabdc1d..1421d6da07e 100644 --- a/PWG2/RESONANCES/AliRsnCutBetheBloch.h +++ b/PWG2/RESONANCES/AliRsnCutBetheBloch.h @@ -29,7 +29,7 @@ class AliRsnCutBetheBloch : public AliRsnCut Double_t BetheBloch(AliRsnDaughter*const track); Double_t RelDiff(AliRsnDaughter *track); - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); protected: diff --git a/PWG2/RESONANCES/AliRsnCutDaughterType.cxx b/PWG2/RESONANCES/AliRsnCutDaughterType.cxx index aa834d3d827..0ff9abd526d 100644 --- a/PWG2/RESONANCES/AliRsnCutDaughterType.cxx +++ b/PWG2/RESONANCES/AliRsnCutDaughterType.cxx @@ -23,12 +23,14 @@ ClassImp(AliRsnCutDaughterType) //_________________________________________________________________________________________________ AliRsnCutDaughterType::AliRsnCutDaughterType() : - AliRsnCut(AliRsnCut::kDaughter), + AliRsnCut(), fRefType(kTypes) { // // Default constructor. // + + SetTargetType(AliRsnTarget::kDaughter); } //_________________________________________________________________________________________________ @@ -43,18 +45,18 @@ AliRsnCutDaughterType::AliRsnCutDaughterType } //_________________________________________________________________________________________________ -Bool_t AliRsnCutDaughterType::IsSelected(TObject *obj1, TObject* /*obj2*/) +Bool_t AliRsnCutDaughterType::IsSelected(TObject *object) { // // Cut checker. // // coherence check - AliRsnDaughter *daughter = dynamic_cast(obj1); - if (!daughter) return kFALSE; + if (!TargetOK(object)) return kFALSE; // check the daughter according to the selected type // in some cases this means to retrieve the track status + AliRsnDaughter *daughter = dynamic_cast(object); AliVTrack *track = dynamic_cast(daughter->GetRef()); AliESDtrack *esdT = dynamic_cast(daughter->GetRef()); ULong_t status = 0x0; diff --git a/PWG2/RESONANCES/AliRsnCutDaughterType.h b/PWG2/RESONANCES/AliRsnCutDaughterType.h index 0e40b2df697..69ece70ff9b 100644 --- a/PWG2/RESONANCES/AliRsnCutDaughterType.h +++ b/PWG2/RESONANCES/AliRsnCutDaughterType.h @@ -30,7 +30,7 @@ class AliRsnCutDaughterType : public AliRsnCut AliRsnCutDaughterType(const char *name, EType type); virtual ~AliRsnCutDaughterType() {;}; - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); protected: diff --git a/PWG2/RESONANCES/AliRsnCutESD2010.cxx b/PWG2/RESONANCES/AliRsnCutESD2010.cxx index 9f3a9b7f918..11ecb4b58c6 100644 --- a/PWG2/RESONANCES/AliRsnCutESD2010.cxx +++ b/PWG2/RESONANCES/AliRsnCutESD2010.cxx @@ -30,6 +30,8 @@ ClassImp(AliRsnCutESD2010) +Int_t AliRsnCutESD2010::fgLastRun = -1; + //_________________________________________________________________________________________________ AliRsnCutESD2010::AliRsnCutESD2010 (const char *name, Bool_t isMC) : @@ -38,17 +40,17 @@ AliRsnCutESD2010::AliRsnCutESD2010 fCheckITS(kTRUE), fCheckTPC(kTRUE), fCheckTOF(kTRUE), - fUseGlobal(kTRUE), + fUseITSTPC(kTRUE), fUseITSSA(kTRUE), fPID(AliPID::kKaon), - fMaxEta(1E6), + fMaxITSPIDmom(0.0), fMaxITSband(3.0), fTPCpLimit(0.35), fMinTPCband(3.0), fMaxTPCband(5.0), + fESDpid(0x0), fESDtrackCutsTPC(), fESDtrackCutsITS(), - fESDpid(0x0), fTOFmaker(0x0), fTOFcalib(0x0), fTOFcalibrateESD(!isMC), @@ -57,40 +59,13 @@ AliRsnCutESD2010::AliRsnCutESD2010 fTOFtuneMC(isMC), fTOFresolution(100.0), fMinTOF(-2.5), - fMaxTOF( 3.5), - fLastRun(-1) + fMaxTOF( 3.5) { // // Main constructor. // SetMC(isMC); - - // set default quality cuts for TPC+ITS tracks - // TPC - fESDtrackCutsTPC.SetRequireTPCStandAlone(kTRUE); // to get chi2 and ncls of kTPCin - fESDtrackCutsTPC.SetMinNClustersTPC(70); - fESDtrackCutsTPC.SetMaxChi2PerClusterTPC(4); - fESDtrackCutsTPC.SetAcceptKinkDaughters(kFALSE); - fESDtrackCutsTPC.SetRequireTPCRefit(kTRUE); - // ITS - fESDtrackCutsTPC.SetRequireITSRefit(kTRUE); - fESDtrackCutsTPC.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - fESDtrackCutsTPC.SetMaxDCAToVertexXYPtDep("0.0350+0.0490/pt^1.0"); - fESDtrackCutsTPC.SetMaxDCAToVertexZ(1.e6); - fESDtrackCutsTPC.SetDCAToVertex2D(kFALSE); - fESDtrackCutsTPC.SetRequireSigmaToVertex(kFALSE); - fESDtrackCutsTPC.SetEtaRange(-fMaxEta, fMaxEta); - - // set default quality cuts for ITS standalone tracks - fESDtrackCutsITS.SetRequireITSStandAlone(kTRUE); - fESDtrackCutsITS.SetRequireITSPureStandAlone(kFALSE); - fESDtrackCutsITS.SetRequireITSRefit(kTRUE); - fESDtrackCutsITS.SetMinNClustersITS(4); - fESDtrackCutsITS.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); - fESDtrackCutsITS.SetMaxChi2PerClusterITS(2.5); - fESDtrackCutsITS.SetMaxDCAToVertexXYPtDep("0.0595+0.0182/pt^1.55"); - fESDtrackCutsITS.SetEtaRange(-fMaxEta, fMaxEta); } //_________________________________________________________________________________________________ @@ -101,17 +76,17 @@ AliRsnCutESD2010::AliRsnCutESD2010 fCheckITS(copy.fCheckITS), fCheckTPC(copy.fCheckTPC), fCheckTOF(copy.fCheckTOF), - fUseGlobal(copy.fUseGlobal), + fUseITSTPC(copy.fUseITSTPC), fUseITSSA(copy.fUseITSSA), fPID(copy.fPID), - fMaxEta(copy.fMaxEta), + fMaxITSPIDmom(copy.fMaxITSPIDmom), fMaxITSband(copy.fMaxITSband), fTPCpLimit(copy.fTPCpLimit), fMinTPCband(copy.fMinTPCband), fMaxTPCband(copy.fMaxTPCband), + fESDpid(0x0), fESDtrackCutsTPC(copy.fESDtrackCutsTPC), fESDtrackCutsITS(copy.fESDtrackCutsITS), - fESDpid(0x0), fTOFmaker(0x0), fTOFcalib(0x0), fTOFcalibrateESD(copy.fTOFcalibrateESD), @@ -120,8 +95,7 @@ AliRsnCutESD2010::AliRsnCutESD2010 fTOFtuneMC(copy.fTOFtuneMC), fTOFresolution(copy.fTOFresolution), fMinTOF(copy.fMinTOF), - fMaxTOF(copy.fMaxTOF), - fLastRun(-1) + fMaxTOF(copy.fMaxTOF) { // // Copy constructor. @@ -129,9 +103,6 @@ AliRsnCutESD2010::AliRsnCutESD2010 Int_t i = 0; for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i]; - - copy.GetCutsTPC()->Copy(fESDtrackCutsTPC); - copy.GetCutsITS()->Copy(fESDtrackCutsITS); } //_________________________________________________________________________________________________ @@ -147,10 +118,10 @@ AliRsnCutESD2010& AliRsnCutESD2010::operator=(const AliRsnCutESD2010& copy) fCheckITS = copy.fCheckITS; fCheckTPC = copy.fCheckTPC; fCheckTOF = copy.fCheckTOF; - fUseGlobal = copy.fUseGlobal; + fUseITSTPC = copy.fUseITSTPC; fUseITSSA = copy.fUseITSSA; fPID = copy.fPID; - fMaxEta = copy.fMaxEta; + fMaxITSPIDmom = copy.fMaxITSPIDmom; fMaxITSband = copy.fMaxITSband; fTPCpLimit = copy.fTPCpLimit; fMinTPCband = copy.fMinTPCband; @@ -162,11 +133,13 @@ AliRsnCutESD2010& AliRsnCutESD2010::operator=(const AliRsnCutESD2010& copy) fTOFresolution = copy.fTOFresolution; fMinTOF = copy.fMinTOF; fMaxTOF = copy.fMaxTOF; - fLastRun = copy.fLastRun; Int_t i = 0; for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i]; + delete fESDpid; + fESDpid = 0x0; + copy.GetCutsTPC()->Copy(fESDtrackCutsTPC); copy.GetCutsITS()->Copy(fESDtrackCutsITS); @@ -213,36 +186,40 @@ void AliRsnCutESD2010::SetEvent(AliRsnEvent *event) { fEvent = event; } - - // if absent, initialize ESD pid responst - if (!fESDpid) - { - fESDpid = new AliESDpid; - fESDpid->GetTPCResponse().SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]); - } - - // initialize DB to current run + + // if the run number has changed, + // reset the CDB in order to point to the correct one Int_t run = esd->GetRunNumber(); - if (run != fLastRun) + if (run != fgLastRun) { - cout << "Run = " << run << " -- LAST = " << fLastRun << endl; - fLastRun = run; - - // setup TOF maker & calibration - if (!fTOFcalib) fTOFcalib = new AliTOFcalib; - fTOFcalib->SetCorrectTExp(fTOFcorrectTExp); - if (!fTOFmaker) fTOFmaker = new AliTOFT0maker(fESDpid, fTOFcalib); - fTOFmaker->SetTimeResolution(fTOFresolution); + AliInfo("============================================================================================"); + AliInfo(Form("*** CHANGING RUN NUMBER: PREVIOUS = %d --> CURRENT = %d ***", fgLastRun, run)); + AliInfo("============================================================================================"); + fgLastRun = run; AliCDBManager *cdb = AliCDBManager::Instance(); cdb->ClearCache(); // suggestion by Annalisa cdb->Clear(); // suggestion by Annalisa cdb->SetDefaultStorage("raw://"); cdb->SetRun(run); - - fTOFcalib->SetCorrectTExp(fTOFcorrectTExp); - fTOFcalib->Init(); } + + // if absent, initialize ESD pid response + if (!fESDpid) + { + AliITSPIDResponse itsresponse(fIsMC); + + fESDpid = new AliESDpid; + fESDpid->GetTPCResponse().SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]); + fESDpid->GetITSResponse() = itsresponse; + } + + // if absent, initialize TOF objects for calibration + if (!fTOFcalib) fTOFcalib = new AliTOFcalib; + fTOFcalib->SetCorrectTExp(fTOFcorrectTExp); + fTOFcalib->Init(); + if (!fTOFmaker) fTOFmaker = new AliTOFT0maker(fESDpid, fTOFcalib); + fTOFmaker->SetTimeResolution(fTOFresolution); // if required, calibrate the TOF t0 maker with current event if (fTOFcalibrateESD) fTOFcalib->CalibrateESD(esd); @@ -256,14 +233,14 @@ void AliRsnCutESD2010::SetEvent(AliRsnEvent *event) } //_________________________________________________________________________________________________ -Bool_t AliRsnCutESD2010::IsSelected(TObject *obj1, TObject* /*obj2*/) +Bool_t AliRsnCutESD2010::IsSelected(TObject *object) { // // Cut checker. // // coherence check: require an ESD track - AliRsnDaughter *daughter = dynamic_cast(obj1); + AliRsnDaughter *daughter = dynamic_cast(object); if (!daughter) return kFALSE; AliESDtrack *track = daughter->GetRefESDtrack(); if (!track) return kFALSE; @@ -271,144 +248,188 @@ Bool_t AliRsnCutESD2010::IsSelected(TObject *obj1, TObject* /*obj2*/) // if no reference event, skip if (!fEvent) return kFALSE; - // ITS: create the response function - AliITSPIDResponse itsrsp(fIsMC); - - // TOF: define fixed function for compatibility range - //Double_t a1 = 0.01, a2 = -0.03; - //Double_t b1 = 0.25, b2 = 0.25; - //Double_t c1 = 0.05, c2 = -0.03; - //Double_t ymax, ymin; - - ULong_t status; - Int_t k, nITS; - Double_t times[10], tpcNSigma, tpcMaxNSigma, itsSignal, itsNSigma, mom, tofTime, tofSigma, tofRef, tofRel; - Bool_t okQuality, okTOF, okTPC, okITS, isTPC, isITSSA, isTOF; - UChar_t itsCluMap; - - // get commonly used variables - status = (ULong_t)track->GetStatus(); - mom = track->P(); - isTPC = ((status & AliESDtrack::kTPCin) != 0); - isITSSA = (((status & AliESDtrack::kTPCin) == 0) && ((status & AliESDtrack::kITSrefit) != 0) && ((status & AliESDtrack::kITSpureSA) == 0) && ((status & AliESDtrack::kITSpid) != 0)); - isTOF = (((status & AliESDtrack::kTOFout) != 0) && ((status & AliESDtrack::kTIME) != 0) /* && mom > TMath::Max(b1, b2)*/); - - // check if the track type matches what is required - if (!isTPC && !isITSSA) - { - AliDebug(AliLog::kDebug + 2, "Track is not either a TPC track or a ITS standalone. Rejected"); - return kFALSE; - } - else if (isTPC && !fUseGlobal) - { - AliDebug(AliLog::kDebug + 2, "Global tracks not used. Rejected"); - return kFALSE; - } - else if (isITSSA && !fUseITSSA) + // check quality and track type and reject tracks not passing this step + if (!OkQuality(track)) { - AliDebug(AliLog::kDebug + 2, "ITS standalone not used. Rejected"); + AliDebug(AliLog::kDebug+2, "Failed quality cut"); return kFALSE; } - // does a preliminary check on TOF values, if necessary - // then, if the reference time or TOF signal are meaningless - // even if the 'isTOF' flag is true, switch it to false - if (isTOF) - { - track->GetIntegratedTimes(times); - tofTime = (Double_t)track->GetTOFsignal(); - tofSigma = fTOFmaker->GetExpectedSigma(mom, times[(Int_t)fPID], AliPID::ParticleMass((Int_t)fPID)); - tofRef = times[(Int_t)fPID]; - if (tofRef <= 0.0 && tofSigma <= 0.0) isTOF = kFALSE; - } + // ITS PID can be checked always + // if PID is not required, the flag is sed as + // if the cut was alsways passed + Bool_t okITSpid = OkITSPID(track); + if (!fCheckITS) okITSpid = kTRUE; + + // TPC PID can be checked only for TPC+ITS tracks + // if PID is not required, the flag is sed as + // if the cut was alsways passed + Bool_t okTPCpid = kFALSE; + if (IsITSTPC(track)) okTPCpid = OkTPCPID(track); + if (!fCheckTPC) okTPCpid = kTRUE; - // check quality (eta range must be adapted) - AliESDtrackCuts *cuts = 0x0; - if (isTPC) cuts = &fESDtrackCutsTPC; - if (isITSSA) cuts = &fESDtrackCutsITS; - if (!cuts) return kFALSE; - cuts->SetEtaRange(-fMaxEta, fMaxEta); - okQuality = cuts->IsSelected(track); - AliDebug(AliLog::kDebug + 2, Form("Global quality cut = %s", (okQuality ? "GOOD" : "BAD"))); - if (!okQuality) return kFALSE; + // TOF PID can be checked only if TOF is matched + // if PID is not required, the flag is sed as + // if the cut was alsways passed + Bool_t okTOFpid = kFALSE; + if (IsITSTPC(track) && MatchTOF(track)) okTOFpid = OkTOFPID(track); + if (!fCheckTOF) okTOFpid = kTRUE; - if (isTPC) // this branch is entered by all global tracks + // now combine all outcomes according to the different possibilities: + // -- ITS standalone: + // --> only ITS PID, always + // -- ITS + TPC: + // --> ITS PID, only for momenta lower than 'fMaxITSPIDmom' and when the ITSpid flag is active + // --> TPC PID, always --> MASTER (first to be checked, if fails, track is rejected) + // --> TOF PID, only if matched + if (IsITSSA(track)) { - // check TPC dE/dx: - if (fCheckTPC) + if (!okITSpid) { - tpcNSigma = TMath::Abs(fESDpid->NumberOfSigmasTPC(track, fPID)); - if (track->GetInnerParam()->P() > fTPCpLimit) tpcMaxNSigma = fMinTPCband; else tpcMaxNSigma = fMaxTPCband; - okTPC = (tpcNSigma <= tpcMaxNSigma); - AliDebug(AliLog::kDebug + 2, Form("TPC nsigma = %f -- max = %f -- cut %s", tpcNSigma, tpcMaxNSigma, (okTPC ? "passed" : "failed"))); + AliDebug(AliLog::kDebug+2, "ITS standalone track --> ITS PID failed"); + return kFALSE; } - else + } + else // checking IsITSTPC() is redundant due to OkQuality() cut check + { + if (!okTPCpid) { - // if TPC is not checked, it is as if all tracks do pass the cut - okTPC = kTRUE; - AliDebug(AliLog::kDebug + 2, "TPC not checked, track accepted"); + AliDebug(AliLog::kDebug+2, "ITS+TPC track --> TPC PID failed"); + return kFALSE; } - - // check TOF (only if flags are OK) - if (fCheckTOF) + else if (MatchTOF(track) && !okTOFpid) { - if (isTOF) - { - // TOF can be checked only when track is matched there - track->GetIntegratedTimes(times); - tofTime = (Double_t)track->GetTOFsignal(); - tofSigma = fTOFmaker->GetExpectedSigma(mom, times[(Int_t)fPID], AliPID::ParticleMass((Int_t)fPID)); - tofRef = times[(Int_t)fPID]; - /* - tofRel = (tofTime - tofRef) / tofRef; - ymax = a1 / (mom - b1) + c1; - ymin = a2 / (mom - b2) + c2; - okTOF = (tofRel >= ymin && tofRel <= ymax); - */ - tofRel = (tofTime - tofRef) / tofSigma; - okTOF = (tofRel >= fMinTOF && tofRel <= fMaxTOF); - AliDebug(AliLog::kDebug + 2, Form("TOF nsigma = %f -- range = %f %f -- cut %s", tofRel, fMinTOF, fMaxTOF, (okTOF ? "passed" : "failed"))); - } - else - { - // if TOF is not matched, the answer depends on TPC: - // - if TPC is required, track is checked only there and TOF simply ignored - // - if TPC is not required, track is rejected when TOF does not match it, if TOF check is required - if (fCheckTPC) okTOF = kTRUE; else okTOF = kFALSE; - } + AliDebug(AliLog::kDebug+2, "ITS+TPC track --> TOF matched but TOF PID failed"); + return kFALSE; } - else + else if (track->IsOn(AliESDtrack::kITSpid) && track->P() <= fMaxITSPIDmom && !okITSpid) { - okTOF = kTRUE; + AliDebug(AliLog::kDebug+2, Form("ITS+TPC track --> Momentum lower than limit (%.2f) and ITS PID failed", fMaxITSPIDmom)); + return kFALSE; } - - // properly combine the outcome of TPC and TOF cuts - return okTPC && okTOF; } - else if (isITSSA) // this branch is entered by all ITS standalone tracks - { - // check dE/dx only if this is required, otherwise ITS standalone are just added but not checked for PID - if (fCheckITS) - { - itsSignal = track->GetITSsignal(); - itsCluMap = track->GetITSClusterMap(); - nITS = 0; - for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITS; - if (nITS < 3) return kFALSE; - itsNSigma = itsrsp.GetNumberOfSigmas(mom, itsSignal, fPID, nITS, kTRUE); - okITS = (TMath::Abs(itsNSigma) <= fMaxITSband); - AliDebug(AliLog::kDebug + 2, Form("ITS nsigma = %f -- max = %f -- cut %s", itsNSigma, fMaxITSband, (okITS ? "passed" : "failed"))); - } - else - { - okITS = kTRUE; - } + + // arriving here, the track has survived all checks + return kTRUE; +} + +//______________________________________________________________________________ +Bool_t AliRsnCutESD2010::OkQuality(AliESDtrack *track) +{ +// +// Check track quality parameters. +// Rejects all tracks which are not either TPC+ITS nor ITS standalone. +// If tracks of any type are not flagged to be used, they are rejected anyway. +// + + if (IsITSTPC(track)) return (fUseITSTPC && fESDtrackCutsTPC.IsSelected(track)); + if (IsITSSA (track)) return (fUseITSSA && fESDtrackCutsITS.IsSelected(track)); + + return kFALSE; +} - return okITS; +//______________________________________________________________________________ +Bool_t AliRsnCutESD2010::OkITSPID (AliESDtrack *track) +{ +// +// Check ITS particle identification with 3sigma cut +// + + // count PID layers and reject if they are too few + Int_t k, nITSpidLayers = 0; + UChar_t itsCluMap = track->GetITSClusterMap(); + for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITSpidLayers; + if (nITSpidLayers < 3) + { + AliDebug(AliLog::kDebug+2, "Rejecting track with too few ITS pid layers"); + return kFALSE; } + + // check the track type (ITS+TPC or ITS standalone) + // and reject it if it is of none of the allowed types + Bool_t isSA = kFALSE; + if (IsITSTPC(track)) isSA = kFALSE; + else if (IsITSSA(track)) isSA = kTRUE; else { - // if we are here, the track is surely bad + AliWarning("Track is neither ITS+TPC nor ITS standalone"); return kFALSE; } + + // create the PID response object and compute nsigma + AliITSPIDResponse &itsrsp = fESDpid->GetITSResponse(); + Double_t mom = track->P(); + Double_t nSigma = itsrsp.GetNumberOfSigmas(mom, track->GetITSsignal(), fPID, nITSpidLayers, isSA); + + // evaluate the cut + Bool_t ok = (TMath::Abs(nSigma) <= fMaxITSband); + + // debug message + AliDebug(AliLog::kDebug + 2, Form("ITS nsigma = %f -- max = %f -- cut %s", nSigma, fMaxITSband, (ok ? "passed" : "failed"))); + + // outcome + return ok; +} + +//______________________________________________________________________________ +Bool_t AliRsnCutESD2010::OkTPCPID (AliESDtrack *track) +{ +// +// Check TPC particle identification with {3|5}sigmacut, +// depending on the track total momentum. +// + + // setup TPC PID response + AliTPCPIDResponse &tpcrsp = fESDpid->GetTPCResponse(); + tpcrsp.SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]); + + // get momentum and number of sigmas and choose the reference band + Double_t mom = track->GetInnerParam()->P(); + Double_t nSigma = tpcrsp.GetNumberOfSigmas(mom, track->GetTPCsignal(), track->GetTPCsignalN(), fPID); + Double_t maxNSigma = fMaxTPCband; + if (mom < fTPCpLimit) maxNSigma = fMinTPCband; + + // evaluate the cut + Bool_t ok = (TMath::Abs(nSigma) <= maxNSigma); + + // debug message + AliDebug(AliLog::kDebug + 2, Form("TPC nsigma = %f -- max = %f -- cut %s", nSigma, maxNSigma, (ok ? "passed" : "failed"))); + + // outcome + return ok; +} + +//______________________________________________________________________________ +Bool_t AliRsnCutESD2010::OkTOFPID (AliESDtrack *track) +{ +// +// Check TOF particle identification if matched there. +// + + // check integrated length + if (track->GetIntegratedLength() < 350.) return kFALSE; + + // setup TOF PID response + AliTOFPIDResponse &tofrsp = fESDpid->GetTOFResponse(); + + // get info for computation + Double_t momentum = track->P(); + Double_t time = track->GetTOFsignal(); + Double_t timeint[AliPID::kSPECIES]; + tofrsp.GetStartTime(momentum); + track->GetIntegratedTimes(timeint); + + // check the cut + Double_t timeDiff = time - timeint[(Int_t)fPID]; + Double_t sigmaRef = tofrsp.GetExpectedSigma(momentum, timeint[(Int_t)fPID], AliPID::ParticleMass(fPID)); + Double_t nSigma = timeDiff / sigmaRef; + + // evaluate the cut + Bool_t ok = (nSigma >= fMinTOF && nSigma <= fMaxTOF); + + // debug message + AliDebug(AliLog::kDebug + 2, Form("TOF nsigma = %f -- range = %f - %f -- cut %s", nSigma, fMinTOF, fMaxTOF, (ok ? "passed" : "failed"))); + + // outcome + return ok; } diff --git a/PWG2/RESONANCES/AliRsnCutESD2010.h b/PWG2/RESONANCES/AliRsnCutESD2010.h index 9c985a27f43..6024d40e971 100644 --- a/PWG2/RESONANCES/AliRsnCutESD2010.h +++ b/PWG2/RESONANCES/AliRsnCutESD2010.h @@ -1,9 +1,10 @@ // -// Class AliRsnCutRange +// *** Class AliRsnCutESD2010 *** // -// General implementation of cuts which check a value inside a range. -// This range can be defined by two integers or two doubles. -// A user-friendly enumeration allows to define what is checked. +// This class implements all cuts which have to be used for the 2010 runs +// for phi and generic resonance analysis. +// It contains an AliESDtrackCuts object for track quality selection +// and some criteria for particle identification with ITS, TPC and TOF. // // authors: Martin Vala (martin.vala@cern.ch) // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) @@ -13,6 +14,7 @@ #define ALIRSNCUTESD2010_H #include "AliPID.h" +#include "AliESDtrack.h" #include "AliESDtrackCuts.h" #include "AliRsnCut.h" @@ -31,18 +33,18 @@ class AliRsnCutESD2010 : public AliRsnCut const AliESDtrackCuts* GetCutsTPC() const {return &fESDtrackCutsTPC;} const AliESDtrackCuts* GetCutsITS() const {return &fESDtrackCutsITS;} - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); void SetMC (Bool_t yn = kTRUE); void SetCheckITS (Bool_t yn = kTRUE) {fCheckITS = yn;} void SetCheckTPC (Bool_t yn = kTRUE) {fCheckTPC = yn;} void SetCheckTOF (Bool_t yn = kTRUE) {fCheckTOF = yn;} - void SetUseGlobal(Bool_t yn = kTRUE) {fUseGlobal = yn;} + void SetUseITSTPC(Bool_t yn = kTRUE) {fUseITSTPC = yn;} void SetUseITSSA (Bool_t yn = kTRUE) {fUseITSSA = yn;} - void SetMaxEta (Double_t v) {fMaxEta = v;} void SetPID (AliPID::EParticleType t) {fPID = t;} - void SetITSband(Double_t v) {fMaxITSband = v;} + void SetMaxITSPIDmom(Double_t v) {fMaxITSPIDmom = v;} + void SetITSband(Double_t v) {fMaxITSband = v;} void SetTPCpLimit(Double_t v) {fTPCpLimit = v;} void SetTPCrange(Double_t min, Double_t max) {fMinTPCband = min; fMaxTPCband = max;} @@ -60,16 +62,23 @@ class AliRsnCutESD2010 : public AliRsnCut protected: + Bool_t OkQuality(AliESDtrack *d); // check track quality parameters and DCA + Bool_t OkITSPID (AliESDtrack *d); // check ITS PID + Bool_t OkTPCPID (AliESDtrack *d); // check TPC PID + Bool_t OkTOFPID (AliESDtrack *d); // check TOF PID + Bool_t IsITSTPC (AliESDtrack *d); // check that the track is TPC+ITS + Bool_t IsITSSA (AliESDtrack *d); // check that the track is ITS standalone + Bool_t MatchTOF (AliESDtrack *d); // check that the track matches the TOF + Bool_t fIsMC; // switch for MC analysis Bool_t fCheckITS; // switch for ITS dE/dx check Bool_t fCheckTPC; // switch for TPC dE/dx check Bool_t fCheckTOF; // switch for TOF time check - Bool_t fUseGlobal; // switch to use TPC global tracks + Bool_t fUseITSTPC; // switch to use TPC global tracks Bool_t fUseITSSA; // switch to use ITS standalone tracks AliPID::EParticleType fPID; // PID reference type used for checks - Double_t fMaxEta; // cut in eta - + Double_t fMaxITSPIDmom; // maximum momentum where ITS PID is used for TPC+ITS tracks Double_t fMaxITSband; // range for ITS de/dx band Double_t fTPCpLimit; // limit to choose what band to apply @@ -77,11 +86,11 @@ class AliRsnCutESD2010 : public AliRsnCut Double_t fMinTPCband; // range for TPC de/dx band - min Double_t fMaxTPCband; // range for TPC de/dx band - max + AliESDpid *fESDpid; // ESD PID object AliESDtrackCuts fESDtrackCutsTPC; // ESD standard defined track cuts for TPC tracks AliESDtrackCuts fESDtrackCutsITS; // ESD standard defined track cuts for ITS-SA tracks - AliESDpid *fESDpid; //! PID manager - AliTOFT0maker *fTOFmaker; //! TOF time0 computator - AliTOFcalib *fTOFcalib; //! TOF calibration + AliTOFT0maker *fTOFmaker; //! TOF time0 computator + AliTOFcalib *fTOFcalib; //! TOF calibration Bool_t fTOFcalibrateESD; // TOF settings Bool_t fTOFcorrectTExp; // TOF settings Bool_t fTOFuseT0; // TOF settings @@ -89,9 +98,79 @@ class AliRsnCutESD2010 : public AliRsnCut Double_t fTOFresolution; // TOF settings Double_t fMinTOF; // range for TOF PID (min) Double_t fMaxTOF; // range for TOF PID (max) - Int_t fLastRun; // last run number + + static Int_t fgLastRun; //! last run number ClassDef(AliRsnCutESD2010, 1) }; +inline Bool_t AliRsnCutESD2010::IsITSTPC(AliESDtrack *vtrack) +{ +// +// Checks if the track has the status flags required for a global track +// + + if (!vtrack) + { + AliWarning("NULL argument: impossible to check status"); + return kFALSE; + } + + ULong_t status = (ULong_t)vtrack->GetStatus(); + ULong_t sTPCin = status & AliESDtrack::kTPCin; + + if (sTPCin == 0) return kFALSE; + + return kTRUE; +} + +inline Bool_t AliRsnCutESD2010::IsITSSA(AliESDtrack *vtrack) +{ +// +// Checks if the track has the status flags required for an ITS standalone track +// + + if (!vtrack) + { + AliWarning("NULL argument: impossible to check status"); + return kFALSE; + } + + ULong_t status = (ULong_t)vtrack->GetStatus(); + ULong_t sTPCin = status & AliESDtrack::kTPCin; + ULong_t sITSrefit = status & AliESDtrack::kITSrefit; + ULong_t sITSpureSA = status & AliESDtrack::kITSpureSA; + ULong_t sITSpid = status & AliESDtrack::kITSpid; + + if (sTPCin != 0) return kFALSE; + if (sITSrefit == 0) return kFALSE; + if (sITSpureSA != 0) return kFALSE; + if (sITSpid == 0) return kFALSE; + + return kTRUE; +} + + +inline Bool_t AliRsnCutESD2010::MatchTOF(AliESDtrack *vtrack) +{ +// +// Checks if the track has matched the TOF detector +// + + if (!vtrack) + { + AliWarning("NULL argument: impossible to check status"); + return kFALSE; + } + + ULong_t status = (ULong_t)vtrack->GetStatus(); + ULong_t sTOFout = status & AliESDtrack::kTOFout; + ULong_t sTIME = status & AliESDtrack::kTIME; + + if (sTOFout == 0) return kFALSE; + if (sTIME == 0) return kFALSE; + + return kTRUE; +} + #endif diff --git a/PWG2/RESONANCES/AliRsnCutESDCutMultiplicity.h b/PWG2/RESONANCES/AliRsnCutESDCutMultiplicity.h index d08db1e884a..f18b89da94a 100644 --- a/PWG2/RESONANCES/AliRsnCutESDCutMultiplicity.h +++ b/PWG2/RESONANCES/AliRsnCutESDCutMultiplicity.h @@ -24,7 +24,7 @@ class AliRsnCutESDCutMultiplicity : public AliRsnCut virtual ~AliRsnCutESDCutMultiplicity() {;}; const AliESDtrackCuts* GetCuts() const {return &fCuts;} - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); protected: diff --git a/PWG2/RESONANCES/AliRsnCutESDPrimary.cxx b/PWG2/RESONANCES/AliRsnCutESDPrimary.cxx index 9599ceb0baf..ec6cf6a0038 100644 --- a/PWG2/RESONANCES/AliRsnCutESDPrimary.cxx +++ b/PWG2/RESONANCES/AliRsnCutESDPrimary.cxx @@ -23,12 +23,14 @@ ClassImp(AliRsnCutESDPrimary) //_________________________________________________________________________________________________ AliRsnCutESDPrimary::AliRsnCutESDPrimary() : - AliRsnCut(AliRsnCut::kDaughter), + AliRsnCut(), fCuts() { // // Default constructor. // + + SetTargetType(AliRsnTarget::kDaughter); } //_________________________________________________________________________________________________ @@ -43,17 +45,17 @@ AliRsnCutESDPrimary::AliRsnCutESDPrimary } //_________________________________________________________________________________________________ -Bool_t AliRsnCutESDPrimary::IsSelected(TObject *obj1, TObject* /*obj2*/) +Bool_t AliRsnCutESDPrimary::IsSelected(TObject *object) { // // Cut checker. // // coherence check - AliRsnDaughter *daughter = dynamic_cast(obj1); - if (!daughter) return kFALSE; + if (!TargetOK(object)) return kFALSE; // retrieve the TPC signal + AliRsnDaughter *daughter = dynamic_cast(object); AliESDtrack *esdTrack = daughter->GetRefESDtrack(); if (!esdTrack) { diff --git a/PWG2/RESONANCES/AliRsnCutESDPrimary.h b/PWG2/RESONANCES/AliRsnCutESDPrimary.h index f9dc1dafc09..0e8cfc994f5 100644 --- a/PWG2/RESONANCES/AliRsnCutESDPrimary.h +++ b/PWG2/RESONANCES/AliRsnCutESDPrimary.h @@ -24,7 +24,7 @@ class AliRsnCutESDPrimary : public AliRsnCut virtual ~AliRsnCutESDPrimary() {;}; AliESDtrackCuts* GetCuts() {return &fCuts;} - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); protected: diff --git a/PWG2/RESONANCES/AliRsnCutManager.cxx b/PWG2/RESONANCES/AliRsnCutManager.cxx index b950120390a..2b07d88b5dc 100644 --- a/PWG2/RESONANCES/AliRsnCutManager.cxx +++ b/PWG2/RESONANCES/AliRsnCutManager.cxx @@ -1,16 +1,25 @@ // -// Class AliRsnCutManager -// -// The cut manager: contains a complete set of cut definitions -// to be applied to all possible targets (one for each target), -// in order to ease the set-up procedure of cuts and allow to -// pass them at once to each object which must use them -// -// author: Martin Vala (martin.vala@cern.ch) +// *** Class AliRsnCutManager *** +// +// This class is used both in normal analysis and efficiency computation +// as a collection of all cuts which could be needed in a single job. +// It allocates an AliRsnCutSet for each possible target: +// - one with all cuts common to all tracks +// - one with all cuts for first candidate daughter (definition #1 in pairDef) +// - one with all cuts for second candidate daughter (definition #2 in pairDef) +// - one with all cuts on the pair +// ----- +// This object is used to define a step in efficiency CORRFW container +// and also is contained in all AliRsnPair objects to decide if two candidates +// can be accepted or not. +// +// authors: Martin Vala (martin.vala@cern.ch) +// Alberto Pulvirenti (alberto.pulvirenti@cern.ch) // #include "AliLog.h" +#include "AliRsnCut.h" #include "AliRsnCutManager.h" ClassImp(AliRsnCutManager) @@ -18,10 +27,10 @@ ClassImp(AliRsnCutManager) //_____________________________________________________________________________ AliRsnCutManager::AliRsnCutManager() : TNamed("defaultName", "defaultTitle"), - fDaughterCutsCommon(0x0), - fDaughterCuts1(0x0), - fDaughterCuts2(0x0), - fMotherCuts(0x0) + fDaughterCutsCommon("defaultCommon", AliRsnTarget::kDaughter), + fDaughterCuts1("defaultD1", AliRsnTarget::kDaughter), + fDaughterCuts2("defaultD2", AliRsnTarget::kDaughter), + fMotherCuts("defaultPair", AliRsnTarget::kMother) { // // Constructor without arguments. @@ -31,10 +40,10 @@ AliRsnCutManager::AliRsnCutManager() : //_____________________________________________________________________________ AliRsnCutManager::AliRsnCutManager(const char *name, const char *title) : TNamed(name, title), - fDaughterCutsCommon(0x0), - fDaughterCuts1(0x0), - fDaughterCuts2(0x0), - fMotherCuts(0x0) + fDaughterCutsCommon(Form("common_%s", name), AliRsnTarget::kDaughter), + fDaughterCuts1(Form("d1_%s", name), AliRsnTarget::kDaughter), + fDaughterCuts2(Form("d2_%s", name), AliRsnTarget::kDaughter), + fMotherCuts(Form("pair_%s", name), AliRsnTarget::kMother) { // // Constructor with name and title. @@ -54,6 +63,7 @@ AliRsnCutManager::AliRsnCutManager(const AliRsnCutManager &cut) : // } +//_____________________________________________________________________________ AliRsnCutManager& AliRsnCutManager::operator=(const AliRsnCutManager &cut) { // @@ -63,10 +73,10 @@ AliRsnCutManager& AliRsnCutManager::operator=(const AliRsnCutManager &cut) SetName(cut.GetName()); SetTitle(cut.GetTitle()); - fDaughterCuts2 = cut.fDaughterCuts2; - fDaughterCuts1 = cut.fDaughterCuts1; + fDaughterCuts2 = cut.fDaughterCuts2; + fDaughterCuts1 = cut.fDaughterCuts1; fDaughterCutsCommon = cut.fDaughterCutsCommon; - fMotherCuts = cut.fMotherCuts; + fMotherCuts = cut.fMotherCuts; return (*this); } @@ -76,13 +86,8 @@ AliRsnCutManager::~AliRsnCutManager() { // // Destructor. -// Deletes all cut definitions. +// Does nothing. // - - delete fDaughterCuts2; - delete fDaughterCuts1; - delete fDaughterCutsCommon; - delete fMotherCuts; } //_____________________________________________________________________________ @@ -92,8 +97,8 @@ void AliRsnCutManager::SetEvent(AliRsnEvent *event) // Sets reference event in all cut sets // - if (fDaughterCuts2 ) fDaughterCuts2 ->SetEvent(event); - if (fDaughterCuts1 ) fDaughterCuts1 ->SetEvent(event); - if (fDaughterCutsCommon) fDaughterCutsCommon ->SetEvent(event); - if (fMotherCuts ) fMotherCuts ->SetEvent(event); + fDaughterCuts2.SetEvent(event); + fDaughterCuts1.SetEvent(event); + fDaughterCutsCommon.SetEvent(event); + fMotherCuts.SetEvent(event); } diff --git a/PWG2/RESONANCES/AliRsnCutManager.h b/PWG2/RESONANCES/AliRsnCutManager.h index 41fa4f0bead..64558228146 100644 --- a/PWG2/RESONANCES/AliRsnCutManager.h +++ b/PWG2/RESONANCES/AliRsnCutManager.h @@ -1,12 +1,20 @@ // -// Class AliRsnCutManager +// *** Class AliRsnCutManager *** // -// The cut manager: contains a complete set of cut definitions -// to be applied to all possible targets (one for each target), -// in order to ease the set-up procedure of cuts and allow to -// pass them at once to each object which must use them +// This class is used both in normal analysis and efficiency computation +// as a collection of all cuts which could be needed in a single job. +// It allocates an AliRsnCutSet for each possible target: +// - one with all cuts common to all tracks +// - one with all cuts for first candidate daughter (definition #1 in pairDef) +// - one with all cuts for second candidate daughter (definition #2 in pairDef) +// - one with all cuts on the pair +// ----- +// This object is used to define a step in efficiency CORRFW container +// and also is contained in all AliRsnPair objects to decide if two candidates +// can be accepted or not. // -// author: Martin Vala (martin.vala@cern.ch) +// authors: Martin Vala (martin.vala@cern.ch) +// Alberto Pulvirenti (alberto.pulvirenti@cern.ch) // #ifndef ALIRSNCUTMANAGER_H @@ -14,11 +22,12 @@ #include -#include "AliRsnCut.h" #include "AliRsnDaughter.h" #include "AliRsnMother.h" #include "AliRsnCutSet.h" +class AliRsnCut; + class AliRsnCutManager : public TNamed { public: @@ -29,30 +38,26 @@ class AliRsnCutManager : public TNamed AliRsnCutManager& operator=(const AliRsnCutManager& cut); ~AliRsnCutManager(); - AliRsnCutSet* GetCommonDaughterCuts() {return fDaughterCutsCommon;} - AliRsnCutSet* GetDaughter1Cuts() {return fDaughterCuts1;} - AliRsnCutSet* GetDaughter2Cuts() {return fDaughterCuts2;} - AliRsnCutSet* GetMotherCuts() {return fMotherCuts;} - - void SetCommonDaughterCuts(AliRsnCutSet *cuts) {fDaughterCutsCommon = cuts;} - void SetDaughter1Cuts(AliRsnCutSet *cuts) {fDaughterCuts1 = cuts;} - void SetDaughter2Cuts(AliRsnCutSet *cuts) {fDaughterCuts2 = cuts;} - void SetMotherCuts(AliRsnCutSet *cuts) {fMotherCuts = cuts;} - void SetEvent(AliRsnEvent *event); + void SetEvent(AliRsnEvent *event); + + AliRsnCutSet* GetCommonDaughterCuts() {return &fDaughterCutsCommon;} + AliRsnCutSet* GetDaughter1Cuts() {return &fDaughterCuts1;} + AliRsnCutSet* GetDaughter2Cuts() {return &fDaughterCuts2;} + AliRsnCutSet* GetMotherCuts() {return &fMotherCuts;} - Bool_t PassCommonDaughterCuts(AliRsnDaughter *daughter) const {if (fDaughterCutsCommon) return fDaughterCutsCommon->IsSelected(daughter); return kTRUE;} - Bool_t PassDaughter1Cuts(AliRsnDaughter *daughter) const {if (fDaughterCuts1) return fDaughterCuts2->IsSelected(daughter); return kTRUE;} - Bool_t PassDaughter2Cuts(AliRsnDaughter *daughter) const {if (fDaughterCuts2) return fDaughterCuts2->IsSelected(daughter); return kTRUE;} - Bool_t PassMotherCuts(AliRsnMother *mother) {if (fMotherCuts) return fMotherCuts->IsSelected(mother); return kTRUE;} + Bool_t PassCommonDaughterCuts(AliRsnDaughter *daughter) {return fDaughterCutsCommon.IsSelected(daughter);} + Bool_t PassDaughter1Cuts(AliRsnDaughter *daughter) {return fDaughterCuts2.IsSelected(daughter);} + Bool_t PassDaughter2Cuts(AliRsnDaughter *daughter) {return fDaughterCuts2.IsSelected(daughter);} + Bool_t PassMotherCuts(AliRsnMother *mother) {return fMotherCuts.IsSelected(mother);} private: - AliRsnCutSet *fDaughterCutsCommon; // single-track cuts common to both daughters - AliRsnCutSet *fDaughterCuts1; // single-track cuts for only first daughter - AliRsnCutSet *fDaughterCuts2; // single-track cuts for only second daughter - AliRsnCutSet *fMotherCuts; // mother cuts (on relations between daughters) + AliRsnCutSet fDaughterCutsCommon; // single-track cuts common to both daughters + AliRsnCutSet fDaughterCuts1; // single-track cuts for only first daughter + AliRsnCutSet fDaughterCuts2; // single-track cuts for only second daughter + AliRsnCutSet fMotherCuts; // mother cuts (on relations between daughters) - ClassDef(AliRsnCutManager, 1) // dictionary + ClassDef(AliRsnCutManager, 2) // dictionary }; #endif diff --git a/PWG2/RESONANCES/AliRsnCutPID.cxx b/PWG2/RESONANCES/AliRsnCutPID.cxx index 08b8f7daad9..ca6863af6c9 100644 --- a/PWG2/RESONANCES/AliRsnCutPID.cxx +++ b/PWG2/RESONANCES/AliRsnCutPID.cxx @@ -26,7 +26,7 @@ ClassImp(AliRsnCutPID) //_________________________________________________________________________________________________ AliRsnCutPID::AliRsnCutPID() : - AliRsnCut(AliRsnCut::kDaughter), + AliRsnCut(), fPerfect(kFALSE), fUseDefault(kTRUE) { @@ -51,6 +51,8 @@ AliRsnCutPID::AliRsnCutPID() : fWeight[i] = 0.0; fPrior[i] = 1.0; } + + SetTargetType(AliRsnTarget::kDaughter); } //_________________________________________________________________________________________________ @@ -83,6 +85,8 @@ AliRsnCutPID::AliRsnCutPID(const char *name, AliPID::EParticleType pid, Double_t fMinD = probMin; fMaxD = 1.000001; + + SetTargetType(AliRsnTarget::kDaughter); } //_____________________________________________________________________________ @@ -251,20 +255,23 @@ Int_t AliRsnCutPID::PerfectPID(AliRsnDaughter * const daughter) } //_________________________________________________________________________________________________ -Bool_t AliRsnCutPID::IsSelected(TObject *obj1, TObject* /*obj2*/) +Bool_t AliRsnCutPID::IsSelected(TObject *object) { // // Cut checker. // // convert the object into the unique correct type - AliRsnDaughter *daughter = dynamic_cast(obj1); - if (!daughter) + + if (!TargetOK(object)) { AliError(Form("[%s]: this cut works only with AliRsnDaughter objects", GetName())); return kTRUE; } + // if target is OK, do a dynamic cast + AliRsnDaughter *daughter = dynamic_cast(object); + // depending on the PID type, recalls the appropriate method: // in case of perfect PID, checks only if the PID type is // corresponding to the request in the cut (fMinI) diff --git a/PWG2/RESONANCES/AliRsnCutPID.h b/PWG2/RESONANCES/AliRsnCutPID.h index 39f883970d0..baf07489e53 100644 --- a/PWG2/RESONANCES/AliRsnCutPID.h +++ b/PWG2/RESONANCES/AliRsnCutPID.h @@ -47,7 +47,7 @@ class AliRsnCutPID : public AliRsnCut Int_t PerfectPID(AliRsnDaughter * const daughter); Double_t GetWeight(Int_t i) {if (i>=0&&i(obj1); + AliRsnEvent *rsn = dynamic_cast(object); if (!rsn) return kFALSE; AliESDEvent *esd = rsn->GetRefESD(); AliAODEvent *aod = rsn->GetRefAOD(); @@ -115,7 +105,7 @@ Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *obj1, TObject* /*obj2*/) AliAODVertex *prim = (AliAODVertex*)aod->GetPrimaryVertex(); if (!prim) return kFALSE; - //fCutValueI = prim->GetNContributors(); + fCutValueI = prim->GetNContributors(); fCutValueD = prim->GetZ(); } else @@ -125,4 +115,3 @@ Bool_t AliRsnCutPrimaryVertex::IsSelected(TObject *obj1, TObject* /*obj2*/) Bool_t result = ((!OkRangeI()) && OkRangeD()); return result; } - diff --git a/PWG2/RESONANCES/AliRsnCutPrimaryVertex.h b/PWG2/RESONANCES/AliRsnCutPrimaryVertex.h index 14599be8813..9e28b6b136c 100644 --- a/PWG2/RESONANCES/AliRsnCutPrimaryVertex.h +++ b/PWG2/RESONANCES/AliRsnCutPrimaryVertex.h @@ -30,11 +30,10 @@ class AliRsnCutPrimaryVertex : public AliRsnCut { public: - AliRsnCutPrimaryVertex(); - AliRsnCutPrimaryVertex(const char *name, Double_t maxVz, Int_t minContributors = 1, Bool_t acceptTPC = kFALSE); + AliRsnCutPrimaryVertex(const char *name = "cutPrimVert", Double_t maxVz = 10.0, Int_t minContributors = 1, Bool_t acceptTPC = kFALSE); virtual ~AliRsnCutPrimaryVertex() {;}; - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + virtual Bool_t IsSelected(TObject *object); protected: diff --git a/PWG2/RESONANCES/AliRsnCutSet.cxx b/PWG2/RESONANCES/AliRsnCutSet.cxx index 7dc1910d663..fd465767445 100644 --- a/PWG2/RESONANCES/AliRsnCutSet.cxx +++ b/PWG2/RESONANCES/AliRsnCutSet.cxx @@ -16,9 +16,8 @@ ClassImp(AliRsnCutSet) //_____________________________________________________________________________ -AliRsnCutSet::AliRsnCutSet(AliRsnCut::ETarget target) : - TNamed(), - fTarget(target), +AliRsnCutSet::AliRsnCutSet() : + AliRsnTarget(), fCuts(0), fNumOfCuts(0), fCutScheme(""), @@ -36,9 +35,8 @@ AliRsnCutSet::AliRsnCutSet(AliRsnCut::ETarget target) : } //_____________________________________________________________________________ -AliRsnCutSet::AliRsnCutSet(TString name, AliRsnCut::ETarget target) : - TNamed(name, name), - fTarget(target), +AliRsnCutSet::AliRsnCutSet(const char *name, RSNTARGET target) : + AliRsnTarget(name, target), fCuts(0), fNumOfCuts(0), fCutScheme(""), @@ -58,8 +56,7 @@ AliRsnCutSet::AliRsnCutSet(TString name, AliRsnCut::ETarget target) : //_____________________________________________________________________________ AliRsnCutSet::AliRsnCutSet(const AliRsnCutSet & copy) : - TNamed((TNamed) copy), - fTarget(copy.fTarget), + AliRsnTarget(copy), fCuts(copy.fCuts), fNumOfCuts(copy.fNumOfCuts), fCutScheme(copy.fCutScheme), @@ -72,7 +69,44 @@ AliRsnCutSet::AliRsnCutSet(const AliRsnCutSet & copy) : // Copy constructor // + Int_t i; + fBoolValues = new Bool_t[fNumOfCuts]; + for (i = 0; i < fNumOfCuts; ++i) + { + fBoolValues[i] = copy.fBoolValues[i]; + } + + AliRsnExpression::fgCutSet = this; +} + +//_____________________________________________________________________________ +AliRsnCutSet& AliRsnCutSet::operator=(const AliRsnCutSet & copy) +{ +// +// Assignment operator. +// + + AliRsnTarget::operator=(copy); + + fCuts = copy.fCuts; + fNumOfCuts = copy.fNumOfCuts; + fCutScheme = copy.fCutScheme; + fCutSchemeIndexed = copy.fCutSchemeIndexed; + fIsScheme = copy.fIsScheme; + fExpression = copy.fExpression; + + if (fBoolValues) delete [] fBoolValues; + + Int_t i; + fBoolValues = new Bool_t[fNumOfCuts]; + for (i = 0; i < fNumOfCuts; ++i) + { + fBoolValues[i] = copy.fBoolValues[i]; + } + AliRsnExpression::fgCutSet = this; + + return (*this); } //_____________________________________________________________________________ @@ -96,9 +130,9 @@ void AliRsnCutSet::AddCut(AliRsnCut *cut) // the cut is not added. // - if (!cut->IsTarget(fTarget)) + if (!cut->IsTarget(GetTargetType())) { - AliError("Cut target does not match the cut-set target. Not added."); + AliError(Form("Cannot add this cut (cut set name,target = [%s],[%s] --- cut name,target = [%s],[%s]", GetName(), GetTargetTypeName(), cut->GetName(), cut->GetTargetTypeName())); return; } @@ -136,7 +170,7 @@ void AliRsnCutSet::ShowCuts() const } //_____________________________________________________________________________ -Bool_t AliRsnCutSet::IsSelected(TObject *obj1, TObject *obj2) +Bool_t AliRsnCutSet::IsSelected(TObject *object) { // // Checks an object according to the cut expression defined here. @@ -150,7 +184,7 @@ Bool_t AliRsnCutSet::IsSelected(TObject *obj1, TObject *obj2) AliRsnCut *cut; for (i = 0; i < fNumOfCuts; i++) { cut = (AliRsnCut*)fCuts.At(i); - fBoolValues[i] = cut->IsSelected(obj1, obj2); + fBoolValues[i] = cut->IsSelected(object); } if (fIsScheme) boolReturn = Passed(); @@ -213,12 +247,17 @@ Bool_t AliRsnCutSet::Passed() // and gives a global response to the cut check // + AliInfo(Form("Name: %s", GetName())); + AliRsnExpression::fgCutSet = this; - if (!fExpression) { + if (!fExpression) + { fExpression = new AliRsnExpression(fCutSchemeIndexed); AliDebug(AliLog::kDebug,"fExpression was created."); } + if (fCuts.IsEmpty()) return kTRUE; + return fExpression->Value(*GetCuts()); } diff --git a/PWG2/RESONANCES/AliRsnCutSet.h b/PWG2/RESONANCES/AliRsnCutSet.h index f49a9af5845..04c1bfc486d 100644 --- a/PWG2/RESONANCES/AliRsnCutSet.h +++ b/PWG2/RESONANCES/AliRsnCutSet.h @@ -15,6 +15,7 @@ #include #include +#include "AliRsnTarget.h" #include "AliRsnCut.h" class AliRsnDaughter; @@ -22,14 +23,14 @@ class AliRsnExpression; class AliRsnPairParticle; class AliRsnEvent; -class AliRsnCutSet : public TNamed +class AliRsnCutSet : public AliRsnTarget { public: - AliRsnCutSet(AliRsnCut::ETarget target = AliRsnCut::kLastCutTarget); - AliRsnCutSet(TString name, AliRsnCut::ETarget target); + AliRsnCutSet(); + AliRsnCutSet(const char *name, RSNTARGET target); AliRsnCutSet(const AliRsnCutSet ©); - AliRsnCutSet& operator=(const AliRsnCutSet& /*copy*/) {return (*this);} + AliRsnCutSet& operator=(const AliRsnCutSet& copy); ~AliRsnCutSet(); void AddCut(AliRsnCut* cut); @@ -42,7 +43,7 @@ class AliRsnCutSet : public TNamed Int_t TestExpression(TString opt="short"); void PrintSetInfo(); - Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + Bool_t IsSelected(TObject *object); void SetBoolValue(Bool_t theValue,Int_t index) { fBoolValues[index] = theValue; } Bool_t GetBoolValue(Int_t index) const { return fBoolValues[index]; } @@ -59,7 +60,6 @@ class AliRsnCutSet : public TNamed private: - AliRsnCut::ETarget fTarget; // cut target TObjArray fCuts; // array of cuts Int_t fNumOfCuts; // number of cuts TString fCutScheme; // cut scheme diff --git a/PWG2/RESONANCES/AliRsnCutValue.cxx b/PWG2/RESONANCES/AliRsnCutValue.cxx index 9e795594712..1f406f41975 100644 --- a/PWG2/RESONANCES/AliRsnCutValue.cxx +++ b/PWG2/RESONANCES/AliRsnCutValue.cxx @@ -1,30 +1,24 @@ // -// Class AliRsnCutValue +// *** Class AliRsnCutValue *** // -// 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()] +// This cut implementation can be used to cut generically on +// any value which can be computed from AliRsnValue class. +// Since that value is implemented always as a Double_t one, +// then this cut operates only with the Double_t data members +// of the AliRsnCut base class. +// It allows to cusomize the reference AliRsnValue object by +// means of a getter that returns a pointer to it. +// This cut can apply to any kind of object, but the type of +// target must be one of those for which the chosen value type +// makes sense to be computed // -// 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. +// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) // -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include -#include -#include "AliStack.h" -#include "AliMCEvent.h" #include "AliRsnDaughter.h" #include "AliRsnMother.h" #include "AliRsnEvent.h" -#include "AliRsnValue.h" +#include "AliRsnPairDef.h" #include "AliRsnCutValue.h" @@ -39,18 +33,24 @@ AliRsnCutValue::AliRsnCutValue() : // // Default constructor. // + + SetTargetType(fValue.GetTargetType()); } //_________________________________________________________________________________________________ AliRsnCutValue::AliRsnCutValue -(const char *name, ETarget target, Double_t min, Double_t max, AliRsnPairDef *pd) : - AliRsnCut(name, target, min, max), - fValue(Form("val_%s", name), AliRsnValue::kValueTypes), +(const char *name, AliRsnValue::EValueType type, Double_t min, Double_t max, AliRsnPairDef *pd) : + AliRsnCut(name, AliRsnTarget::kTargetTypes, min, max), + fValue(Form("val_%s", name), type), fPairDef(pd) { // // Main constructor. +// Recalls the setter for the value type of the AliRsnValue data member, +// which determines also the type of target to be expected // + + SetTargetType(fValue.GetTargetType()); } //_________________________________________________________________________________________________ @@ -60,47 +60,60 @@ AliRsnCutValue::AliRsnCutValue(const AliRsnCutValue& copy) : fPairDef(copy.fPairDef) { // -// Copy constructor +// Copy constructor. +// Does not duplicate memory allocation. // + + SetTargetType(fValue.GetTargetType()); } //_________________________________________________________________________________________________ AliRsnCutValue& AliRsnCutValue::operator=(const AliRsnCutValue& copy) { // -// Assignment operator +// Assignment operator. +// Does not duplicate memory allocation. // - (*this) = copy; + AliRsnCut::operator=(copy); + fValue = copy.fValue; fPairDef = copy.fPairDef; + SetTargetType(fValue.GetTargetType()); return (*this); } //_________________________________________________________________________________________________ -Bool_t AliRsnCutValue::IsSelected(TObject *obj1, TObject * /*obj2*/) +Bool_t AliRsnCutValue::IsSelected(TObject *object) { // // Checks the cut. -// Calls the appropriate AliRsnValue::Eval() method -// depending on the type of passed object. -// It is up to the user to be sure that the association is meaningful +// Calls the AliRsnValue::Eval() method and then checks its output. // - AliRsnDaughter *daughter = dynamic_cast(obj1); - AliRsnMother *mother = dynamic_cast(obj1); - - if (daughter) + // make sure that target of this object matches that + // of the inserted value object + SetTargetType(fValue.GetTargetType()); + + // check target coherence + if (!TargetOK(object)) { - if (!fValue.Eval(daughter, fEvent)) return kFALSE; - fCutValueD = fValue.GetValue(); + AliWarning("Returning kFALSE"); + return kFALSE; } - else if (mother) + + // try to compute values + Bool_t success = fValue.Eval(object); + + // check success + if (!success) { - if (!fValue.Eval(mother, fPairDef, fEvent)) return kFALSE; - fCutValueD = fValue.GetValue(); + AliWarning(Form("[%s] Failed to compute value", GetName())); + return kFALSE; } + // check in range + fCutValueD = fValue.GetComputedValue(); return OkRangeD(); } diff --git a/PWG2/RESONANCES/AliRsnCutValue.h b/PWG2/RESONANCES/AliRsnCutValue.h index 53520eb5663..8d7f627b202 100644 --- a/PWG2/RESONANCES/AliRsnCutValue.h +++ b/PWG2/RESONANCES/AliRsnCutValue.h @@ -1,37 +1,44 @@ // -// Class AliRsnCutRange +// *** Class AliRsnCutValue *** // -// General implementation of cuts which check a value inside a range. -// This range can be defined by two integers or two doubles. -// A user-friendly enumeration allows to define what is checked. +// This cut implementation can be used to cut generically on +// any value which can be computed from AliRsnValue class. +// Since that value is implemented always as a Double_t one, +// then this cut operates only with the Double_t data members +// of the AliRsnCut base class. +// It allows to cusomize the reference AliRsnValue object by +// means of a getter that returns a pointer to it. +// This cut can apply to any kind of object, but the type of +// target must be one of those for which the chosen value type +// makes sense to be computed // -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) // #ifndef ALIRSNCUTVALUE_H #define ALIRSNCUTVALUE_H #include "AliRsnCut.h" +#include "AliRsnValue.h" -class AliRsnDaughter; -class AliRsnMother; -class AliRsnEvent; +class AliRsnPairDef; class AliRsnCutValue : public AliRsnCut { public: AliRsnCutValue(); - AliRsnCutValue(const char *name, ETarget target, Double_t min, Double_t max, AliRsnPairDef *pd = 0x0); + AliRsnCutValue(const char *name, AliRsnValue::EValueType type, Double_t min, Double_t max, AliRsnPairDef *pd = 0x0); AliRsnCutValue(const AliRsnCutValue& copy); AliRsnCutValue& operator=(const AliRsnCutValue& copy); virtual ~AliRsnCutValue() { } void SetPairDef(AliRsnPairDef *pd) {fPairDef = pd;} - AliRsnValue* GetRsnValue() {return &fValue;} - Double_t GetCutValue() {return fValue.GetValue();} - virtual Bool_t IsSelected(TObject *obj1, TObject *obj2 = 0x0); + AliRsnPairDef* GetPairDef() {return fPairDef;} + Double_t GetValue() {return fValue.GetComputedValue();} + AliRsnValue* GetValueObj() {return &fValue;} + + virtual Bool_t IsSelected(TObject *object); protected: diff --git a/PWG2/RESONANCES/AliRsnDaughter.cxx b/PWG2/RESONANCES/AliRsnDaughter.cxx index ae9b3494fc1..2a7ab26d845 100644 --- a/PWG2/RESONANCES/AliRsnDaughter.cxx +++ b/PWG2/RESONANCES/AliRsnDaughter.cxx @@ -171,3 +171,29 @@ Bool_t AliRsnDaughter::SetMass(Double_t mass) return kTRUE; } + +//_____________________________________________________________________________ +Bool_t AliRsnDaughter::IsKinkDaughter() +{ +// +// Checks if this track is a kink daughter. +// this information is important for some cuts, in some cases +// and it is retrieved differently from ESDs and AODs, so +// this is done here in order to have a unique outcome. +// + + AliESDtrack *etrack = GetRefESDtrack(); + AliAODTrack *atrack = GetRefAODtrack(); + + if (etrack) + { + return (etrack->GetKinkIndex(0) > 0); + } + else if (atrack) + { + AliAODVertex *vertex = atrack->GetProdVertex(); + if (vertex) if (vertex->GetType() == AliAODVertex::kKink) return kTRUE; + } + + return kFALSE; +} diff --git a/PWG2/RESONANCES/AliRsnDaughter.h b/PWG2/RESONANCES/AliRsnDaughter.h index 73138fb3f24..9ea337a5dcb 100644 --- a/PWG2/RESONANCES/AliRsnDaughter.h +++ b/PWG2/RESONANCES/AliRsnDaughter.h @@ -19,10 +19,12 @@ #include "AliESDtrack.h" #include "AliESDv0.h" +#include "AliESDcascade.h" #include "AliMCParticle.h" #include "AliAODTrack.h" #include "AliAODv0.h" +#include "AliAODcascade.h" #include "AliAODMCParticle.h" typedef AliPID::EParticleType EPARTYPE; @@ -35,6 +37,7 @@ class AliRsnDaughter : public TObject { kTrack = 0, kV0, + kCascade, kNoType }; @@ -44,22 +47,22 @@ class AliRsnDaughter : public TObject virtual ~AliRsnDaughter() { /*nothing*/ } // basic getters (for data members) - Bool_t IsOK() const {return fOK;} - Int_t GetLabel() const {return fLabel;} - Int_t GetMotherPDG() const {return fMotherPDG;} - TLorentzVector& Prec() {return fPrec;} - TLorentzVector& Psim() {return fPsim;} - TLorentzVector& P(Bool_t mc = kFALSE) {return (mc ? fPsim : fPrec);} - AliVParticle* GetRef() {return fRef;} - AliVParticle* GetRefMC() {return fRefMC;} + Bool_t IsOK() const {return fOK;} + Int_t GetLabel() const {return fLabel;} + Int_t GetMotherPDG() const {return fMotherPDG;} + TLorentzVector& Prec() {return fPrec;} + TLorentzVector& Psim() {return fPsim;} + TLorentzVector& P(Bool_t mc = kFALSE) {return (mc ? fPsim : fPrec);} + AliVParticle* GetRef() {return fRef;} + AliVParticle* GetRefMC() {return fRefMC;} // basic setters (for data members) - void SetBad() {fOK = kFALSE;} - void SetGood() {fOK = kTRUE;} - void SetLabel(Int_t label) {fLabel = label;} - void SetMotherPDG(Int_t value) {fMotherPDG = value;} - void SetRef(AliVParticle *p) {fRef = p;} - void SetRefMC(AliVParticle *p = 0x0) {fRefMC = p;} + void SetBad() {fOK = kFALSE;} + void SetGood() {fOK = kTRUE;} + void SetLabel(Int_t label) {fLabel = label;} + void SetMotherPDG(Int_t value) {fMotherPDG = value;} + void SetRef(AliVParticle *p) {fRef = p;} + void SetRefMC(AliVParticle *p = 0x0) {fRefMC = p;} // charge checkers Bool_t IsPos() const {return (fRef->Charge() > 0);} @@ -70,31 +73,37 @@ class AliRsnDaughter : public TObject Char_t ChargeChar() const {if (IsPos()) return '+'; else if (IsNeg()) return '-'; else return '0';} // utilities - void Reset(); - Int_t GetPDG(Bool_t abs = kTRUE); - Int_t GetID(); - Bool_t HasFlag(ULong_t flag); - Bool_t SetMass(Double_t mass); + void Reset(); + Int_t GetPDG(Bool_t abs = kTRUE); + Int_t GetID(); + Bool_t HasFlag(ULong_t flag); + Bool_t SetMass(Double_t mass); + Bool_t IsKinkDaughter(); // getters which automatically convert refs into allowed types - AliMCParticle* GetRefMCtrack() {return dynamic_cast(fRef);} - AliESDtrack* GetRefESDtrack() {return dynamic_cast(fRef);} - AliAODTrack* GetRefAODtrack() {return dynamic_cast(fRef);} - AliESDv0* GetRefESDv0() {return dynamic_cast(fRef);} - AliAODv0* GetRefAODv0() {return dynamic_cast(fRef);} - AliMCParticle* GetRefMCESD() {return dynamic_cast(fRefMC);} - AliAODMCParticle* GetRefMCAOD() {return dynamic_cast(fRefMC);} - Bool_t IsMC() {if (GetRefMCtrack()) return kTRUE; return kFALSE;} - Bool_t IsAOD() {if (GetRefAODtrack() || GetRefAODv0()) return kTRUE; return kFALSE;} - Bool_t IsESD() {if (GetRefESDtrack() || GetRefESDv0()) return kTRUE; return kFALSE;} - Bool_t IsTrack() {if (GetRefESDtrack() || GetRefAODtrack() || GetRefMCtrack()) return kTRUE; return kFALSE;} - Bool_t IsV0() {if (GetRefESDv0() || GetRefAODv0()) return kTRUE; return kFALSE;} - ERefType RefType() {if (IsTrack()) return kTrack; if (IsV0()) return kV0; return kNoType;} + AliESDtrack* GetRefESDtrack() {return dynamic_cast(fRef);} + AliESDv0* GetRefESDv0() {return dynamic_cast(fRef);} + AliESDcascade* GetRefESDcascade() {return dynamic_cast(fRef);} + AliAODTrack* GetRefAODtrack() {return dynamic_cast(fRef);} + AliAODv0* GetRefAODv0() {return dynamic_cast(fRef);} + AliAODcascade* GetRefAODcascade() {return dynamic_cast(fRef);} + AliMCParticle* GetRefMCtrack() {return dynamic_cast(fRef);} + AliMCParticle* GetRefMCESD() {return dynamic_cast(fRefMC);} + AliAODMCParticle* GetRefMCAOD() {return dynamic_cast(fRefMC);} + + // check the input type + Bool_t IsMC() {if (GetRefMCtrack()) return kTRUE; return kFALSE;} + Bool_t IsAOD() {if (GetRefAODtrack() || GetRefAODv0()) return kTRUE; return kFALSE;} + Bool_t IsESD() {if (GetRefESDtrack() || GetRefESDv0()) return kTRUE; return kFALSE;} + Bool_t IsTrack() {if (GetRefESDtrack() || GetRefAODtrack() || GetRefMCtrack()) return kTRUE; return kFALSE;} + Bool_t IsV0() {if (GetRefESDv0() || GetRefAODv0()) return kTRUE; return kFALSE;} + Bool_t IsCascade() {if (GetRefESDcascade() || GetRefAODcascade()) return kTRUE; return kFALSE;} + ERefType RefType() {if (IsTrack()) return kTrack; if (IsV0()) return kV0; if (IsCascade()) return kCascade; return kNoType;} private: Bool_t fOK; // internal utility flag which is kFALSE when this object should not be used - Int_t fLabel; // GEANT label of corresponding MC (not trivial for V0s) + Int_t fLabel; // GEANT label of corresponding MC Int_t fMotherPDG; // PDG code of mother (makes sense only if fRefMC is defined) TLorentzVector fPrec; // 4-vector filled with track info from default ref (if present) diff --git a/PWG2/RESONANCES/AliRsnEvent.cxx b/PWG2/RESONANCES/AliRsnEvent.cxx index 8387092b8e7..99e19c5054e 100644 --- a/PWG2/RESONANCES/AliRsnEvent.cxx +++ b/PWG2/RESONANCES/AliRsnEvent.cxx @@ -76,15 +76,15 @@ Bool_t AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t i, AliRsnDaughter::ER // of the V0 point to the same mother. // Returns kFALSE whenever the operation fails (out of range, NULL references). // - - Int_t result = 0; - if (IsESD() && type == AliRsnDaughter::kTrack) result = SetDaughterESDtrack(out, i); - if (IsAOD() && type == AliRsnDaughter::kTrack) result = SetDaughterAODtrack(out, i); - if (IsESD() && type == AliRsnDaughter::kV0 ) result = SetDaughterESDv0 (out, i); - if (IsAOD() && type == AliRsnDaughter::kV0 ) result = 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); - return (result == 0); + return kFALSE; } //_____________________________________________________________________________ @@ -196,6 +196,71 @@ AliRsnDaughter AliRsnEvent::GetDaughterMC(Int_t i) return d; } +//_____________________________________________________________________________ +Int_t AliRsnEvent::GetAbsoluteSum() +{ +// +// Utility method that returns the sum of all daughter-like objects: +// tracks, V0s and cascades +// + + Int_t total = 0; + + total += fRef->GetNumberOfTracks(); + total += fRef->GetNumberOfV0s(); + total += fRef->GetNumberOfCascades(); + + return total; +} + +//_____________________________________________________________________________ +Bool_t AliRsnEvent::ConvertAbsoluteIndex(Int_t index, Int_t &realIndex, AliRsnDaughter::ERefType &type) +{ +// +// Using the phylosophy of the absolute index, which loops over +// all tracks, V0s and cascades, returns the result of a check +// on it (first argument) based on this criterion: +// 1) if the absolute ID is smaller than number of tracks, +// return itself and the type 'track' +// 2) if the absolute ID is larger than number of tracks, subtract it +// and if the result is smaller than number of V0s, +// return the corresponding V0 index and type +// 3) if the absolute ID is larger than number of tracks + V0s, subtract them +// and if the result is smaller than number of cascades, +// return the corresponding cascade index and type +// The results of this check are stored in the reference arguments, while the outcome of +// the function is kTRUE if one of these checks was successful, otherwise it is kFALSE, +// meaning that the absolute index reached the end. +// + + Int_t nTracks = fRef->GetNumberOfTracks(); + Int_t nV0s = fRef->GetNumberOfV0s(); + Int_t nCascades = fRef->GetNumberOfCascades(); + + if (index < nTracks) + { + realIndex = index; + type = AliRsnDaughter::kTrack; + return kTRUE; + } + else if (index >= nTracks && index < nTracks + nV0s) + { + realIndex = index - nTracks; + type = AliRsnDaughter::kV0; + return kTRUE; + } + else if (index >= nTracks + nV0s && index < nTracks + nV0s + nCascades) + { + realIndex = index - nTracks - nV0s; + type = AliRsnDaughter::kCascade; + return kTRUE; + } + + realIndex = -1; + type = AliRsnDaughter::kNoType; + return kFALSE; +} + //_____________________________________________________________________________ Int_t AliRsnEvent::GetMultiplicity(AliESDtrackCuts *cuts) { @@ -319,7 +384,7 @@ Bool_t AliRsnEvent::GetAngleDistr } //_____________________________________________________________________________ -Int_t AliRsnEvent::SetDaughterESDtrack(AliRsnDaughter &out, Int_t i) +Bool_t AliRsnEvent::SetDaughterESDtrack(AliRsnDaughter &out, Int_t i) { // // Setup the first argument to the track identified by the index. @@ -332,7 +397,7 @@ Int_t AliRsnEvent::SetDaughterESDtrack(AliRsnDaughter &out, Int_t i) if (i < 0 || i >= fRef->GetNumberOfTracks()) { out.SetBad(); - return 1; + return kFALSE; } // check 2: not NULL object @@ -340,7 +405,7 @@ Int_t AliRsnEvent::SetDaughterESDtrack(AliRsnDaughter &out, Int_t i) if (!track) { out.SetBad(); - return 2; + return kFALSE; } // assign references of reconstructed track @@ -349,36 +414,12 @@ Int_t AliRsnEvent::SetDaughterESDtrack(AliRsnDaughter &out, Int_t i) out.SetLabel(label); out.SetGood(); - // search for MC track, if available - AliMCEvent *mc = GetRefMCESD(); - if (!mc) return 0; - - // loop on particles using the track label as reference - // and then assign also the mother type, if found - AliStack *stack = mc->Stack(); - if (label >= 0 && label < stack->GetNtrack()) - { - TParticle *part = stack->Particle(label); - if (part) - { - Int_t imum = part->GetFirstMother(); - if (imum >= 0 && imum <= stack->GetNtrack()) - { - TParticle *mum = stack->Particle(imum); - if (mum) out.SetMotherPDG(TMath::Abs(mum->GetPdgCode())); - } - } - else - { - return 3; - } - } - - return 0; + // assign MC info, if available + return SetMCInfoESD(out); } //_____________________________________________________________________________ -Int_t AliRsnEvent::SetDaughterAODtrack(AliRsnDaughter &out, Int_t i) +Bool_t AliRsnEvent::SetDaughterAODtrack(AliRsnDaughter &out, Int_t i) { // // Setup the first argument to the track identified by the index. @@ -391,7 +432,7 @@ Int_t AliRsnEvent::SetDaughterAODtrack(AliRsnDaughter &out, Int_t i) if (i < 0 || i >= fRef->GetNumberOfTracks()) { out.SetBad(); - return 1; + return kFALSE; } // check 2: not NULL object @@ -399,7 +440,7 @@ Int_t AliRsnEvent::SetDaughterAODtrack(AliRsnDaughter &out, Int_t i) if (!track) { out.SetBad(); - return 2; + return kFALSE; } // assign references of reconstructed track @@ -408,36 +449,12 @@ Int_t AliRsnEvent::SetDaughterAODtrack(AliRsnDaughter &out, Int_t i) out.SetLabel(label); out.SetGood(); - // search for MC track, if available - AliAODEvent *mc = GetRefMCAOD(); - if (!mc) return 0; - - // loop on particles using the track label as reference - // and then assign also the mother type, if found - TClonesArray *mcArray = (TClonesArray*)mc->GetList()->FindObject(AliAODMCParticle::StdBranchName()); - if(!mcArray) return 0; - TObjArrayIter next(mcArray); - AliAODMCParticle *part = 0x0; - while ( (part = (AliAODMCParticle*)next()) ) - { - if (TMath::Abs(part->GetLabel()) == label) - { - out.SetRefMC(part); - Int_t imum = part->GetMother(); - if (imum >= 0 && imum <= mcArray->GetEntriesFast()) - { - AliAODMCParticle *mum = (AliAODMCParticle*)mcArray->At(imum); - if (mum) out.SetMotherPDG(TMath::Abs(mum->GetPdgCode())); - } - break; - } - } - - return 0; + // assign MC info, if available + return SetMCInfoAOD(out); } //_____________________________________________________________________________ -Int_t AliRsnEvent::SetDaughterESDv0(AliRsnDaughter &out, Int_t i) +Bool_t AliRsnEvent::SetDaughterESDv0(AliRsnDaughter &out, Int_t i) { // // Setup the first argument to the track identified by the index. @@ -483,11 +500,12 @@ Int_t AliRsnEvent::SetDaughterESDv0(AliRsnDaughter &out, Int_t i) if (pp->GetFirstMother() == pn->GetFirstMother()) out.SetLabel(pp->GetFirstMother()); } - return 0; + // assign MC info, if available + return SetMCInfoESD(out); } //_____________________________________________________________________________ -Int_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) +Bool_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) { // // Setup the first argument to the track identified by the index. @@ -500,7 +518,7 @@ Int_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) if (i > fRef->GetNumberOfV0s()) { out.SetBad(); - return 1; + return kFALSE; } // check 2: not NULL object @@ -509,7 +527,7 @@ Int_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) if (!v0) { out.SetBad(); - return 2; + return kFALSE; } // assign references of reconstructed track @@ -537,19 +555,135 @@ Int_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) if (TMath::Abs(part->GetLabel()) == ln) pn = (AliAODMCParticle*)mcArray->IndexOf(part); } // assign a MC reference and a label only to true V0s - if (pp->GetMother() == pn->GetMother()) + if (pp->GetMother() == pn->GetMother()) out.SetLabel(pp->GetMother()); + } + + // assign MC info, if available + return SetMCInfoAOD(out); +} + +//_____________________________________________________________________________ +Bool_t AliRsnEvent::SetDaughterESDcascade(AliRsnDaughter &out, Int_t i) +{ +// +// Setup the first argument to the track identified by the index. +// When available, adds the MC information and references. +// --- +// Version #3: ESD cascade +// + + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliRsnEvent::SetDaughterAODcascade(AliRsnDaughter &out, Int_t i) +{ +// +// Setup the first argument to the track identified by the index. +// When available, adds the MC information and references. +// --- +// Version #4: AOD cascade +// + + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliRsnEvent::SetMCInfoESD(AliRsnDaughter &out) +{ +// +// Using the label assigned to the daughter, searches for the MC informations: +// -- MC reference +// -- mother +// + + Int_t label = out.GetLabel(); + if (label < 0) return kFALSE; + + // if no MC reference is available, exit here (successfully) + AliMCEvent *mc = GetRefMCESD(); + if (!mc) return kTRUE; + Int_t nMC = mc->GetNumberOfTracks(); + + // assign MC reference, being aware of eventual + // overflows in the array (sometimes happened) + if (label < 0 || label >= nMC) + { + AliWarning(Form("Stack overflow: track label = %d -- stack maximum = %d", label, nMC)); + return kFALSE; + } + AliMCParticle *mcPart = (AliMCParticle*)mc->GetTrack(label); + if (!mcPart) + { + AliWarning(Form("Stack discontinuity: label %d refers to a NULL object", label)); + return kFALSE; + } + out.SetRefMC(mcPart); + + // if this is a primary track, exit here (successfully) + Int_t imum = mcPart->Particle()->GetFirstMother(); + if (imum < 0) return kTRUE; + + // if didn't stop there, search for the mother + if (imum >= nMC) + { + AliWarning(Form("Stack overflow: track mother label = %d -- stack maximum = %d", label, nMC)); + return kFALSE; + } + AliMCParticle *mcMother = (AliMCParticle*)mc->GetTrack(imum); + if (!mcMother) + { + AliWarning(Form("Stack discontinuity: label %d refers to a NULL object", imum)); + return kFALSE; + } + out.SetMotherPDG(TMath::Abs(mcMother->Particle()->GetPdgCode())); + + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliRsnEvent::SetMCInfoAOD(AliRsnDaughter &out) +{ +// +// Using the label assigned to the daughter, searches for the MC informations: +// -- MC reference +// -- mother +// + + Int_t label = out.GetLabel(); + if (label < 0) return kFALSE; + + // if no MC reference is available, exit here (successfully) + AliAODEvent *mc = GetRefMCAOD(); + if (!mc) return kTRUE; + + // loop on particles using the track label as reference + // and then assign also the mother type, if found + TClonesArray *mcArray = (TClonesArray*)mc->GetList()->FindObject(AliAODMCParticle::StdBranchName()); + if(!mcArray) return kFALSE; + TObjArrayIter next(mcArray); + AliAODMCParticle *part = 0x0; + while ( (part = (AliAODMCParticle*)next()) ) + { + if (TMath::Abs(part->GetLabel()) == label) { - AliAODMCParticle *mcv0 = (AliAODMCParticle*)mcArray->At(pp->GetMother()); - out.SetRefMC(mcv0); - out.SetLabel(pp->GetMother()); - Int_t imum = mcv0->GetMother(); + out.SetRefMC(part); + Int_t imum = part->GetMother(); if (imum >= 0 && imum <= mcArray->GetEntriesFast()) { AliAODMCParticle *mum = (AliAODMCParticle*)mcArray->At(imum); if (mum) out.SetMotherPDG(TMath::Abs(mum->GetPdgCode())); } + else + { + AliWarning(Form("Array overflow: track mother label = %d -- stack maximum = %d", imum, mcArray->GetEntriesFast())); + return kFALSE; + } + + // if a MC reference is found, there is no need to go on with the loop + break; } } - return 0; + return kTRUE; } diff --git a/PWG2/RESONANCES/AliRsnEvent.h b/PWG2/RESONANCES/AliRsnEvent.h index 331ffa160c7..260095907c0 100644 --- a/PWG2/RESONANCES/AliRsnEvent.h +++ b/PWG2/RESONANCES/AliRsnEvent.h @@ -33,17 +33,18 @@ class AliRsnEvent : public TObject virtual ~AliRsnEvent() { /*nothing*/ } // basic setters/getters - void SetRef(AliVEvent *ref) {fRef = ref;} - void SetRefMC(AliVEvent *refmc) {fRefMC = refmc;} - void SetLeadingIndex(Int_t i) {fLeading = i;} - AliVEvent* GetRef() {return fRef;} - AliVEvent* GetRefMC() {return fRefMC;} - Int_t GetLeadingIndex() const {return fLeading;} + void SetRef (AliVEvent *ref) {fRef = ref;} + void SetRefMC(AliVEvent *refmc) {fRefMC = refmc;} + void SetLeadingIndex(Int_t i) {fLeading = i;} + AliVEvent* GetRef() {return fRef;} + AliVEvent* GetRefMC() {return fRefMC;} + Int_t GetLeadingIndex() const {return fLeading;} + Int_t GetLeadingParticleID() const {return fLeading;} // 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);} + AliMCEvent* GetRefMCESD() {return dynamic_cast (fRefMC);} AliAODEvent* GetRefMCAOD() {return dynamic_cast(fRefMC);} Bool_t IsESD() {return (GetRefESD() != 0x0);} Bool_t IsAOD() {return (GetRefAOD() != 0x0);} @@ -53,24 +54,29 @@ class AliRsnEvent : public TObject Int_t GetMultiplicity(AliESDtrackCuts *cuts = 0x0); // setters for a daughter - Bool_t SetDaughter(AliRsnDaughter &daughter, Int_t index, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack); + Bool_t SetDaughter (AliRsnDaughter &daughter, Int_t index, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack); Bool_t SetDaughterMC(AliRsnDaughter &daughter, Int_t index); - AliRsnDaughter GetDaughter(Int_t i, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack); + AliRsnDaughter GetDaughter (Int_t i, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack); AliRsnDaughter GetDaughterMC(Int_t i); + Int_t GetAbsoluteSum(); + Bool_t ConvertAbsoluteIndex(Int_t index, Int_t &realIndex, AliRsnDaughter::ERefType &type); // leading particle stuff - Int_t SelectLeadingParticle(Double_t ptMin = 0.0, AliRsnCutPID *cutPID = 0x0); - Int_t GetLeadingParticleID() {return fLeading;} void SetLeadingParticle(AliRsnDaughter &leading) {if (fLeading >= 0) SetDaughter(leading, fLeading);} + Int_t SelectLeadingParticle(Double_t ptMin = 0.0, AliRsnCutPID *cutPID = 0x0); Double_t GetAverageMomentum(Int_t &count, AliRsnCutPID *cutPID = 0x0); Bool_t GetAngleDistr(Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter reference); private: - Int_t SetDaughterESDtrack(AliRsnDaughter &target, Int_t index); - Int_t SetDaughterAODtrack(AliRsnDaughter &target, Int_t index); - Int_t SetDaughterESDv0 (AliRsnDaughter &target, Int_t index); - Int_t SetDaughterAODv0 (AliRsnDaughter &target, Int_t index); + Bool_t SetDaughterESDtrack (AliRsnDaughter &target, Int_t index); + Bool_t SetDaughterAODtrack (AliRsnDaughter &target, Int_t index); + Bool_t SetDaughterESDv0 (AliRsnDaughter &target, Int_t index); + Bool_t SetDaughterAODv0 (AliRsnDaughter &target, Int_t index); + Bool_t SetDaughterESDcascade(AliRsnDaughter &target, Int_t index); + Bool_t SetDaughterAODcascade(AliRsnDaughter &target, Int_t index); + 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) diff --git a/PWG2/RESONANCES/AliRsnFunction.cxx b/PWG2/RESONANCES/AliRsnFunction.cxx index bcbe014c660..c4edb0f2b94 100644 --- a/PWG2/RESONANCES/AliRsnFunction.cxx +++ b/PWG2/RESONANCES/AliRsnFunction.cxx @@ -36,15 +36,15 @@ ClassImp(AliRsnFunction) //________________________________________________________________________________________ AliRsnFunction::AliRsnFunction(Bool_t useTH1) : - TObject(), - fPairDef(0x0), - fAxisList("AliRsnValue", 0), - fPair(0x0), - fEvent(0x0), - fUseTH1(useTH1), - fSize(0), - fH1(0x0), - fHSparse(0x0) + TObject(), + fPairDef(0x0), + fAxisList("AliRsnValue", 0), + fPair(0x0), + fEvent(0x0), + fUseTH1(useTH1), + fSize(0), + fH1(0x0), + fHSparse(0x0) { // // Constructor. @@ -53,15 +53,15 @@ AliRsnFunction::AliRsnFunction(Bool_t useTH1) : //________________________________________________________________________________________ AliRsnFunction::AliRsnFunction(const AliRsnFunction ©) : - TObject(copy), - fPairDef(copy.fPairDef), - fAxisList(copy.fAxisList), - fPair(copy.fPair), - fEvent(copy.fEvent), - fUseTH1(copy.fUseTH1), - fSize(copy.fSize), - fH1(0x0), - fHSparse(0x0) + TObject(copy), + fPairDef(copy.fPairDef), + fAxisList(copy.fAxisList), + fPair(copy.fPair), + fEvent(copy.fEvent), + fUseTH1(copy.fUseTH1), + fSize(copy.fSize), + fH1(0x0), + fHSparse(0x0) { // // Copy constructor. @@ -75,9 +75,6 @@ const AliRsnFunction& AliRsnFunction::operator=(const AliRsnFunction& copy) // Assignment operator. // - //SetName(copy.GetName()); - //SetTitle(copy.GetTitle()); - fPairDef = copy.fPairDef; fPair = copy.fPair; fEvent = copy.fEvent; @@ -106,7 +103,8 @@ const char* AliRsnFunction::GetName() const TObjArrayIter next(&fAxisList); AliRsnValue *axis = 0; - while ((axis = (AliRsnValue*)next())) { + while ((axis = (AliRsnValue*)next())) + { if (name.Length() > 1) name += '_'; name += axis->GetName(); } @@ -115,18 +113,35 @@ const char* AliRsnFunction::GetName() const } //________________________________________________________________________________________ -void AliRsnFunction::AddAxis(AliRsnValue *const axis) +Bool_t AliRsnFunction::AddAxis(AliRsnValue *const axis) { - AliDebug(AliLog::kDebug+2,"<-"); +// +// Try to add a new axis to this function. +// The operation succeeds only if the related value object +// has a target amon those allowed here (AliRsnMother, AliRsnEvent), +// otherwise the axis is not added. +// +// If more than 3 axes are added, switch to THnSparseF output. +// NOTE: this can cause large files and high memory occupancy. +// + + RSNTARGET target = axis->GetTargetType(); + if (target != AliRsnTarget::kMother && target != AliRsnTarget::kEvent) + { + AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", axis->GetName(), axis->GetTargetTypeName())); + return kFALSE; + } + Int_t size = fAxisList.GetEntries(); - new(fAxisList[size]) AliRsnValue(*axis); - AliDebug(AliLog::kDebug+2,"->"); + new (fAxisList[size]) AliRsnValue(*axis); if (fAxisList.GetEntries() > 3) { - AliWarning("A TH1-type output cannot add more than 3 axes: switching to THnSparse -- THIS COULD CAUSE VERY LARGE FILES!!!"); + AliWarning("Adding more than 3 axes will produce a THnSparseD output."); fUseTH1 = kFALSE; } + + return kTRUE; } //________________________________________________________________________________________ @@ -143,13 +158,14 @@ TH1* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTit // fSize = fAxisList.GetEntries(); - if (!fSize) { + if (!fSize) + { AliError("No axes defined"); return 0x0; } - else if (fSize < 1 || fSize > 3) + else if (fSize > 3) { - AliError("Too few or too many axes defined"); + AliError("Too many axes defined for a TH1 object"); return 0x0; } @@ -205,7 +221,8 @@ THnSparseF* AliRsnFunction::CreateHistogramSparse(const char *histoName, const c // fSize = fAxisList.GetEntries(); - if (!fSize) { + if (!fSize) + { AliError("No axes defined"); return 0x0; } @@ -260,23 +277,36 @@ Bool_t AliRsnFunction::Fill() Int_t i; Double_t *values = new Double_t[fSize]; + Bool_t computeOK = kFALSE; AliRsnValue *fcnAxis = 0; - for (i = 0; i < fSize; i++) { + for (i = 0; i < fSize; i++) + { + values[i] = 0.0; fcnAxis = (AliRsnValue*)fAxisList.At(i); - if (!fcnAxis) + if (!fcnAxis) continue; + switch (fcnAxis->GetTargetType()) { - values[i] = 0.0; - continue; + case AliRsnTarget::kMother: + fcnAxis->SetSupportObject(fPairDef); + computeOK = fcnAxis->Eval(fPair); + break; + case AliRsnTarget::kEvent: + computeOK = fcnAxis->Eval(fEvent); + break; + default: + AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", fcnAxis->GetName(), fcnAxis->GetTargetTypeName())); + computeOK = kFALSE; } - if (fcnAxis->Eval(fPair, fPairDef, fEvent)) values[i] = (Double_t)((Float_t)fcnAxis->GetValue()); + if (computeOK) values[i] = ((Float_t)fcnAxis->GetComputedValue()); } // fill histogram if (fUseTH1) { // check presence of output histogram - if (!fH1) { + if (!fH1) + { AliError("Required a TH1 which is not initialized"); delete [] values; return kFALSE; @@ -312,7 +342,8 @@ Bool_t AliRsnFunction::Fill() else { // check presence of output histogram - if (!fHSparse) { + if (!fHSparse) + { AliError("Required a THnSparseF which is not initialized"); delete [] values; return kFALSE; diff --git a/PWG2/RESONANCES/AliRsnFunction.h b/PWG2/RESONANCES/AliRsnFunction.h index 93f27983ad3..d0e8791afb1 100644 --- a/PWG2/RESONANCES/AliRsnFunction.h +++ b/PWG2/RESONANCES/AliRsnFunction.h @@ -57,7 +57,7 @@ class AliRsnFunction : public TObject Bool_t IsUsingTH1() {return fUseTH1;} void UseTH1() {fUseTH1 = kTRUE;} void UseSparse() {fUseTH1 = kFALSE;} - void AddAxis(AliRsnValue* const axis); + Bool_t AddAxis(AliRsnValue* const axis); Int_t GetNumberOfAxes() {return fAxisList.GetEntries();} TH1* CreateHistogram(const char *histoName, const char *histoTitle); THnSparseF* CreateHistogramSparse(const char *histoName, const char *histoTitle); diff --git a/PWG2/RESONANCES/AliRsnMother.cxx b/PWG2/RESONANCES/AliRsnMother.cxx index b4079e049de..be1fc657ee2 100644 --- a/PWG2/RESONANCES/AliRsnMother.cxx +++ b/PWG2/RESONANCES/AliRsnMother.cxx @@ -22,11 +22,8 @@ ClassImp(AliRsnMother) //_____________________________________________________________________________ AliRsnMother::AliRsnMother() : fUseMC(kFALSE), - fDefaultMass(0.0), fSum(), - fSumMC(), - fRef(), - fRefMC() + fSumMC() { // // Constructor. @@ -41,11 +38,8 @@ AliRsnMother::AliRsnMother() : AliRsnMother::AliRsnMother(const AliRsnMother &obj) : TObject(obj), fUseMC(obj.fUseMC), - fDefaultMass(obj.fDefaultMass), fSum(obj.fSum), - fSumMC(obj.fSumMC), - fRef(obj.fRef), - fRefMC(obj.fRefMC) + fSumMC(obj.fSumMC) { // // Copy constructor. @@ -68,11 +62,8 @@ AliRsnMother& AliRsnMother::operator=(const AliRsnMother &obj) Int_t i; - fDefaultMass = obj.fDefaultMass; fSum = obj.fSum; - fRef = obj.fRef; fSumMC = obj.fSumMC; - fRefMC = obj.fRefMC; for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i]; @@ -152,9 +143,6 @@ void AliRsnMother::SetDaughters fSum = fDaughter[0]->P(kFALSE) + fDaughter[1]->P(kFALSE); fSumMC = fDaughter[0]->P(kTRUE) + fDaughter[1]->P(kTRUE); - - fRef .SetXYZM(fSum .X(), fSum .Y(), fSum .Z(), fDefaultMass); - fRefMC.SetXYZM(fSumMC.X(), fSumMC.Y(), fSumMC.Z(), fDefaultMass); } //_____________________________________________________________________________ @@ -168,9 +156,7 @@ void AliRsnMother::ResetPair() for (i = 0; i < 2; i++) fDaughter[i] = 0x0; fSum .SetXYZM(0.0, 0.0, 0.0, 0.0); - fRef .SetXYZM(0.0, 0.0, 0.0, 0.0); fSumMC.SetXYZM(0.0, 0.0, 0.0, 0.0); - fRefMC.SetXYZM(0.0, 0.0, 0.0, 0.0); } //_____________________________________________________________________________ @@ -180,12 +166,9 @@ Double_t AliRsnMother::CosThetaStar(Bool_t first, Bool_t useMC) TLorentzVector daughter0 = (first ? fDaughter[0]->P() : fDaughter[1]->P()); TLorentzVector daughter1 = (first ? fDaughter[1]->P() : fDaughter[0]->P()); TVector3 momentumM (mother.Vect()); - //cout << mother.Vect().X() << ' ' << mother.Vect().Y() << ' ' << mother.Vect().Z() << endl; TVector3 normal (mother.Y()/momentumM.Mag(), -mother.X()/momentumM.Mag(), 0.0); - //cout << momentumM.Mag() << ' ' << normal.X() << ' ' << normal.Y() << ' ' << normal.Z() << endl; - -// Computes first the invariant mass of the mother + // Computes first the invariant mass of the mother Double_t mass0 = fDaughter[0]->P().M(); Double_t mass1 = fDaughter[1]->P().M(); Double_t p0 = daughter0.Vect().Mag(); @@ -195,23 +178,19 @@ Double_t AliRsnMother::CosThetaStar(Bool_t first, Bool_t useMC) Double_t MotherMass = TMath::Sqrt((E0+E1)*(E0+E1)-(p0*p0+2.0*daughter0.Vect().Dot(daughter1.Vect())+p1*p1)); MotherMass = fSum.M(); -// Computes components of beta - - Double_t betaX = -mother.X()/mother.E(); //TMath::Sqrt(momentumM.Mag()*momentumM.Mag()+MotherMass*MotherMass); - Double_t betaY = -mother.Y()/mother.E(); //TMath::Sqrt(momentumM.Mag()*momentumM.Mag()+MotherMass*MotherMass); - Double_t betaZ = -mother.Z()/mother.E(); //TMath::Sqrt(momentumM.Mag()*momentumM.Mag()+MotherMass*MotherMass); - -// Computes Lorentz transformation of the momentum of the first daughter -// into the rest frame of the mother and theta* - //cout << "Beta = " << betaX << ' ' << betaY << ' ' << betaZ << endl; + // Computes components of beta + Double_t betaX = -mother.X()/mother.E(); + Double_t betaY = -mother.Y()/mother.E(); + Double_t betaZ = -mother.Z()/mother.E(); + // Computes Lorentz transformation of the momentum of the first daughter + // into the rest frame of the mother and theta* daughter0.Boost(betaX,betaY,betaZ); TVector3 momentumD = daughter0.Vect(); Double_t cosThetaStar = normal.Dot(momentumD)/momentumD.Mag(); return cosThetaStar; - } //_____________________________________________________________________________ diff --git a/PWG2/RESONANCES/AliRsnMother.h b/PWG2/RESONANCES/AliRsnMother.h index 6f29d9a9b75..cdfe3a46a9a 100644 --- a/PWG2/RESONANCES/AliRsnMother.h +++ b/PWG2/RESONANCES/AliRsnMother.h @@ -29,12 +29,8 @@ class AliRsnMother : public TObject AliRsnMother& operator=(const AliRsnMother &obj); virtual ~AliRsnMother(); - void SetDefaultMass(Double_t mass) {fDefaultMass = mass; fRef.SetXYZM(fSum.X(),fSum.Y(),fSum.Z(),mass); fRefMC.SetXYZM(fSumMC.X(),fSumMC.Y(),fSumMC.Z(),mass);} TLorentzVector& Sum() {return fSum;} - TLorentzVector& Ref() {return fRef;} TLorentzVector& SumMC() {return fSumMC;} - TLorentzVector& RefMC() {return fRefMC;} - Double_t OpeningAngle(Bool_t mc = kFALSE) const {if (fDaughter[0] && fDaughter[1]) return fDaughter[0]->P(mc).Angle(fDaughter[1]->P(mc).Vect()); return 1E6;} Double_t AngleTo(AliRsnDaughter track, Bool_t mc = kFALSE) const {return fSum.Angle(track.P(mc).Vect());} Double_t CosThetaStar(Bool_t first = kTRUE, Bool_t useMC = kFALSE); @@ -55,12 +51,9 @@ class AliRsnMother : public TObject private: Bool_t fUseMC; // choose if momenta are taken from ESD/AOD or MC - Double_t fDefaultMass; // nominal resonance mass AliRsnDaughter *fDaughter[2]; // elements of the pair TLorentzVector fSum; // sum computed from the two daughters TLorentzVector fSumMC; // sum computed from the two daughters - TLorentzVector fRef; // a 4-vector with same momentum as the sum but the nominal mass of mother - TLorentzVector fRefMC; // a 4-vector with same momentum as the sum but the nominal mass of mother ClassDef(AliRsnMother,1) }; diff --git a/PWG2/RESONANCES/AliRsnPair.cxx b/PWG2/RESONANCES/AliRsnPair.cxx index 2eae80b515d..2666cb2464d 100644 --- a/PWG2/RESONANCES/AliRsnPair.cxx +++ b/PWG2/RESONANCES/AliRsnPair.cxx @@ -12,7 +12,6 @@ // M. Vala (email: martin.vala@cern.ch) // -#include #include #include "AliLog.h" @@ -21,7 +20,6 @@ #include "AliRsnEvent.h" #include "AliRsnFunction.h" #include "AliRsnCutSet.h" -#include "AliRsnCutStd.h" #include "AliRsnValue.h" #include "AliRsnCutManager.h" @@ -43,9 +41,6 @@ AliRsnPair::AliRsnPair(const char *name, AliRsnPairDef *def) : // // Default constructor // - - AliDebug(AliLog::kDebug+2,"<-"); - AliDebug(AliLog::kDebug+2,"->"); } //_____________________________________________________________________________ @@ -62,9 +57,6 @@ AliRsnPair::AliRsnPair(const AliRsnPair& copy) : // // Default constructor // - - AliDebug(AliLog::kDebug+2,"<-"); - AliDebug(AliLog::kDebug+2,"->"); } //_____________________________________________________________________________ @@ -87,9 +79,6 @@ AliRsnPair::~AliRsnPair() // // Destructor // - - AliDebug(AliLog::kDebug+2,"<-"); - AliDebug(AliLog::kDebug+2,"->"); } //_____________________________________________________________________________ @@ -99,11 +88,8 @@ void AliRsnPair::Print(Option_t* /*option*/) const // Prints info about pair // - AliDebug(AliLog::kDebug+2,"<-"); - AliInfo(Form("PDG %d %d", AliPID::ParticleCode(fPairDef->GetPID(0)), AliPID::ParticleCode(fPairDef->GetPID(1)))); + AliInfo(Form("PDG %d %d", AliPID::ParticleCode(fPairDef->GetPID(0)), AliPID::ParticleCode(fPairDef->GetPID(1)))); AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1))); - - AliDebug(AliLog::kDebug+2,"->"); } //_____________________________________________________________________________ @@ -176,28 +162,44 @@ Bool_t AliRsnPair::Fill if (!fMother.CommonMother(m0, m1)) return kFALSE; if (m0 < 0 || m1 < 0) return kFALSE; - //cout << "Checking a true pair..." << endl; + AliDebug(AliLog::kDebug+2, "Checking a true pair..."); // if they do, is this mother the correct type? Int_t mpdg0 = TMath::Abs(daughter0->GetMotherPDG()); Int_t mpdg1 = TMath::Abs(daughter1->GetMotherPDG()); Int_t mpdg = TMath::Abs(fPairDef->GetMotherPDG()); - if (mpdg0 != mpdg) return kFALSE; //{cout << "Mother of d0 is " << mpdg0 << " instead of " << mpdg << endl; return kFALSE;} - if (mpdg1 != mpdg) return kFALSE; //{cout << "Mother of d1 is " << mpdg1 << " instead of " << mpdg << endl; return kFALSE;} + if (mpdg0 != mpdg) + { + AliDebug(AliLog::kDebug+2, Form("Mother of d0 is %d instead of %d", mpdg0, mpdg)); + return kFALSE; + } + if (mpdg1 != mpdg) + { + AliDebug(AliLog::kDebug+2, Form("Mother of d1 is %d instead of %d", mpdg1, mpdg)); + return kFALSE; + } // do they match the expected decay channel (that is, are they the expected types)? if (fCheckDecay) { - //cout << "Checking decay tree..." << endl; + AliDebug(AliLog::kDebug, "Checking decay tree..."); Int_t pdg0 = TMath::Abs(daughter0->GetPDG()); Int_t pdg1 = TMath::Abs(daughter1->GetPDG()); - if (AliPID::ParticleCode(fPairDef->GetPID(0)) != pdg0) return kFALSE; // {cout << "PDG0 is " << pdg0 << " instead of " << fPairDef->GetPID(0) << endl; return kFALSE;}; - if (AliPID::ParticleCode(fPairDef->GetPID(1)) != pdg1) return kFALSE; // {cout << "PDG1 is " << pdg1 << " instead of " << fPairDef->GetPID(1) << endl; return kFALSE;}; - //cout << "Decay tree accepted!" << endl; + if (AliPID::ParticleCode(fPairDef->GetPID(0)) != pdg0) + { + AliDebug(AliLog::kDebug+2, Form("PDG0 is %d instead of %d", pdg0, fPairDef->GetPID(0))); + return kFALSE; + } + if (AliPID::ParticleCode(fPairDef->GetPID(1)) != pdg1) + { + AliDebug(AliLog::kDebug+2, Form("PDG1 is %d instead of %d", pdg1, fPairDef->GetPID(1))); + return kFALSE; + } + AliDebug(AliLog::kDebug, "Decay tree accepted"); } // ok... if we arrive here that must really be a true pair! :-) - //cout << "Pair accepted!" << endl; + AliDebug(AliLog::kDebug+2, "Pair accepted"); } AliDebug(AliLog::kDebug+2,"->"); diff --git a/PWG2/RESONANCES/AliRsnPair.h b/PWG2/RESONANCES/AliRsnPair.h index c6689e709fe..6b6057e2513 100644 --- a/PWG2/RESONANCES/AliRsnPair.h +++ b/PWG2/RESONANCES/AliRsnPair.h @@ -48,6 +48,7 @@ class AliRsnPair : public TNamed AliRsnMother* GetMother() {return &fMother;} AliRsnPairDef* GetPairDef() {return fPairDef;} Bool_t Fill(AliRsnDaughter *d0, AliRsnDaughter *d1, AliRsnEvent *ev1, AliRsnEvent *ev2); + virtual void Compute(); virtual void Init(const char *prefix, TList *list); diff --git a/PWG2/RESONANCES/AliRsnPairFunctions.cxx b/PWG2/RESONANCES/AliRsnPairFunctions.cxx index 9b2944f45ed..7d7a798d260 100644 --- a/PWG2/RESONANCES/AliRsnPairFunctions.cxx +++ b/PWG2/RESONANCES/AliRsnPairFunctions.cxx @@ -20,7 +20,6 @@ #include "AliRsnEvent.h" #include "AliRsnFunction.h" #include "AliRsnCutSet.h" -#include "AliRsnCutStd.h" #include "AliRsnValue.h" #include "AliRsnPairFunctions.h" diff --git a/PWG2/RESONANCES/AliRsnPairNtuple.cxx b/PWG2/RESONANCES/AliRsnPairNtuple.cxx index 035a3c0bb59..55855eb48e9 100644 --- a/PWG2/RESONANCES/AliRsnPairNtuple.cxx +++ b/PWG2/RESONANCES/AliRsnPairNtuple.cxx @@ -21,7 +21,6 @@ #include "AliRsnEvent.h" #include "AliRsnFunction.h" #include "AliRsnCutSet.h" -#include "AliRsnCutStd.h" #include "AliRsnValue.h" #include "AliRsnPairNtuple.h" @@ -99,11 +98,25 @@ void AliRsnPairNtuple::Compute() Int_t i, n = fValues.GetEntries(); TArrayF values(n); AliRsnValue *value = 0x0; + Bool_t computeOK = kFALSE; for (i = 0; i < n; i++) { values[i] = -1E10; value = (AliRsnValue*)fValues[i]; - if (value->Eval(&fMother, fPairDef, fEvent)) values[i] = (Float_t)value->GetValue(); + switch (value->GetTargetType()) + { + case AliRsnTarget::kMother: + value->SetSupportObject(fPairDef); + computeOK = value->Eval(&fMother); + break; + case AliRsnTarget::kEvent: + computeOK = value->Eval(fEvent); + break; + default: + AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", value->GetName(), value->GetTargetTypeName())); + computeOK = kFALSE; + } + if (computeOK) values[i] = ((Float_t)value->GetComputedValue()); } fNtuple->Fill(values.GetArray()); @@ -143,14 +156,21 @@ void AliRsnPairNtuple::Init(const char *prefix, TList *list) } //_____________________________________________________________________________ -void AliRsnPairNtuple::AddValue(AliRsnValue *const val) +Bool_t AliRsnPairNtuple::AddValue(AliRsnValue *const val) { // -// Adds a new computing function +// Adds a new computing function. // - AliDebug(AliLog::kDebug+2,"<-"); + RSNTARGET target = val->GetTargetType(); + if (target != AliRsnTarget::kMother && target != AliRsnTarget::kEvent) + { + AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", val->GetName(), val->GetTargetTypeName())); + return kFALSE; + } + Int_t size = fValues.GetEntries(); - new(fValues[size]) AliRsnValue(*val); - AliDebug(AliLog::kDebug+2,"->"); + new (fValues[size]) AliRsnValue(*val); + + return kTRUE; } diff --git a/PWG2/RESONANCES/AliRsnPairNtuple.h b/PWG2/RESONANCES/AliRsnPairNtuple.h index 9f1827891f2..2d3132f16a0 100644 --- a/PWG2/RESONANCES/AliRsnPairNtuple.h +++ b/PWG2/RESONANCES/AliRsnPairNtuple.h @@ -24,7 +24,7 @@ class AliRsnPairNtuple : public AliRsnPair AliRsnPairNtuple& operator=(const AliRsnPairNtuple&); ~AliRsnPairNtuple(); - void AddValue(AliRsnValue*const val); + Bool_t AddValue(AliRsnValue*const val); void GenerateNtuple(const char *prefix = "", TList *list = 0); virtual void Compute(); virtual void Init(const char *prefix, TList *list); diff --git a/PWG2/RESONANCES/AliRsnVATProcessInfo.cxx b/PWG2/RESONANCES/AliRsnVATProcessInfo.cxx index d0160296ed8..78396f2513d 100644 --- a/PWG2/RESONANCES/AliRsnVATProcessInfo.cxx +++ b/PWG2/RESONANCES/AliRsnVATProcessInfo.cxx @@ -1,8 +1,10 @@ // // *** Class AliRsnVATProcessInfo *** // -// TODO -// TODO +// Virtual class which makes computations at the event level, +// in order to return a list of histograms useful to have a look +// of the characteristics of used events. +// If can be inherited and customized for the needs of the analysis. // // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) // M. Vala (email: martin.vala@cern.ch) @@ -17,83 +19,113 @@ ClassImp(AliRsnVATProcessInfo) -//_____________________________________________________________________________ +//______________________________________________________________________________ AliRsnVATProcessInfo::AliRsnVATProcessInfo(const char *name) : - TNamed(name,name), - fHistUsedEvents(0x0), - fEventUsed(kFALSE), - fPrintInfoNumber(1000) + TNamed(name,name), + fHistUsedEvents(0x0), + fEventUsed(kFALSE), + fPrintInfoNumber(1000) { // // Constructor. +// Does nothing more than initialization of data members. // - AliDebug(AliLog::kDebug+2,"<-"); - AliDebug(AliLog::kDebug+2,"->"); + AliDebug(AliLog::kDebug+2, "Entering"); + AliDebug(AliLog::kDebug+2, "Exiting"); } -//_____________________________________________________________________________ +//______________________________________________________________________________ AliRsnVATProcessInfo::AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy) : - TNamed(copy), - fHistUsedEvents(copy.fHistUsedEvents), - fEventUsed(copy.fEventUsed), - fPrintInfoNumber(copy.fPrintInfoNumber) + TNamed(copy), + fHistUsedEvents(0x0), + fEventUsed(copy.fEventUsed), + fPrintInfoNumber(copy.fPrintInfoNumber) { // // Copy constructor. +// Clones the histogram and copies the values of other data members // - AliDebug(AliLog::kDebug+2,"<-"); - AliDebug(AliLog::kDebug+2,"->"); + AliDebug(AliLog::kDebug+2, "Entering"); + + fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone(); + + AliDebug(AliLog::kDebug+2, "Exiting"); } -//_____________________________________________________________________________ -AliRsnVATProcessInfo::~AliRsnVATProcessInfo() +//______________________________________________________________________________ +AliRsnVATProcessInfo& AliRsnVATProcessInfo::operator= +(const AliRsnVATProcessInfo& copy) { // -// Destructor. +// Assignment operator. +// Clones the histogram and copies the values of other data members. // - AliDebug(AliLog::kDebug+2,"<-"); - AliDebug(AliLog::kDebug+2,"->"); + AliDebug(AliLog::kDebug+2, "Entering"); + + fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone(); + fEventUsed = copy.fEventUsed; + fPrintInfoNumber = copy.fPrintInfoNumber; + + AliDebug(AliLog::kDebug+2, "Exiting"); + + return (*this); } -//_____________________________________________________________________________ +//______________________________________________________________________________ +AliRsnVATProcessInfo::~AliRsnVATProcessInfo() +{ +// +// Destructor. +// Does nothing, since the histogram it creates is usually owned +// by another object (TList output of AnalysisTask's), but sets +// the data member pointers to NULL. +// + + AliDebug(AliLog::kDebug+2, "Entering"); + + fHistUsedEvents = 0x0; + fEventUsed = 0; + fPrintInfoNumber = 0; + + AliDebug(AliLog::kDebug+2, "Exiting"); +} + +//______________________________________________________________________________ void AliRsnVATProcessInfo::GenerateInfoList(TList *list) { // -// Creates a TList containing all objects created in this class. -// This list will be passe to the AnalysisTask object and will generate -// a separate directory in the output file, with these informations. -// This TList will have the same name of this object and will own its content. +// Allocate in memory the histograms created in this class and store them +// inside the TList object passed as argument, which usually belongs to +// an AnalysisTask object, and represents one of its outputs. +// If the histogram was already initialized, it is deleted and recreated. // - AliDebug(AliLog::kDebug+2,"<-"); - - // create list - AliDebug(AliLog::kWarning,"Doing new TList(), so make sure you delete this list ... "); -// TList* list = new TList(); -// list->SetName(GetName()); -// list->SetOwner(); + AliDebug(AliLog::kDebug+2, "Entering"); - // initialize contained objects + // delete existing allocation of stored objects + if (fHistUsedEvents) delete fHistUsedEvents; + + // create stored objects fHistUsedEvents = new TH1I(GetEventHistogramName(), "Skipped/used events", 2, 0, 2); // ad objects to list list->Add(fHistUsedEvents); - AliDebug(AliLog::kDebug+2,"->"); + AliDebug(AliLog::kDebug+2, "Exiting"); } -//_____________________________________________________________________________ +//______________________________________________________________________________ void AliRsnVATProcessInfo::FillInfo() { // // This method defines how the information histograms must be filled. -// The structure of this class is auto-consistend, but in case of inheritance +// The structure of this class is auto-consistent, but in case of inheritance // this method must be modified accordingly. // Current implementation uses the 'fEventUsed' flag to choose if the event -// has been used or not, and increments the corrisponding bin in the related +// has been used or not, and increments the corresponding bin in the related // histogram (bin '0' = skipped, bin '1' = used). // @@ -103,7 +135,7 @@ void AliRsnVATProcessInfo::FillInfo() fHistUsedEvents->Fill(0); } -//_____________________________________________________________________________ +//______________________________________________________________________________ void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num) { // @@ -111,17 +143,16 @@ void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num) // to inform about number of events processed // - if ((num+1) % fPrintInfoNumber == 0) AliInfo(Form("Events processed %lld",num+1)); + if ((num+1) % fPrintInfoNumber == 0) AliInfo(Form("Events processed %lld", num+1)); } - +//______________________________________________________________________________ Long64_t AliRsnVATProcessInfo::GetNumerOfEventsProcessed() { // // returns number of events from histogram // - if (fHistUsedEvents) - return fHistUsedEvents->Integral(); + + if (fHistUsedEvents) return fHistUsedEvents->Integral(); return 0; } - diff --git a/PWG2/RESONANCES/AliRsnVATProcessInfo.h b/PWG2/RESONANCES/AliRsnVATProcessInfo.h index 5bd10af97da..affea6d1c80 100644 --- a/PWG2/RESONANCES/AliRsnVATProcessInfo.h +++ b/PWG2/RESONANCES/AliRsnVATProcessInfo.h @@ -1,7 +1,10 @@ // // *** Class AliRsnVATProcessInfo *** // -// TODO +// Virtual class which makes computations at the event level, +// in order to return a list of histograms useful to have a look +// of the characteristics of used events. +// If can be inherited and customized for the needs of the analysis. // // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) // M. Vala (email: martin.vala@cern.ch) @@ -11,26 +14,27 @@ #define ALIRSNVATPROCESSINFO_H #include + class TH1I; class AliRsnVATProcessInfo : public TNamed { public: - AliRsnVATProcessInfo(const char*name = "AT_RSNInfo"); + AliRsnVATProcessInfo(const char *name = "RSNInfo"); AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy); - AliRsnVATProcessInfo& operator= (const AliRsnVATProcessInfo& /*copy*/) {return *this;} + AliRsnVATProcessInfo& operator= (const AliRsnVATProcessInfo& copy); ~AliRsnVATProcessInfo(); - void GenerateInfoList(TList* list); - virtual void FillInfo(); - virtual void PrintInfo(const Long64_t &num); + void GenerateInfoList(TList* list); + virtual void FillInfo(); + virtual void PrintInfo(const Long64_t &num); - const char* GetEventHistogramName() { return Form("hEventsUsed_%s",GetName()); }; - Long64_t GetNumerOfEventsProcessed(); - void SetEventUsed(Bool_t isUsed = kTRUE) { fEventUsed = isUsed; } - Bool_t IsEventUsed() const { return fEventUsed; }; + const char* GetEventHistogramName() { return Form("hEventsUsed_%s",GetName()); }; + Long64_t GetNumerOfEventsProcessed(); + void SetEventUsed(Bool_t isUsed = kTRUE) { fEventUsed = isUsed; } + Bool_t IsEventUsed() const { return fEventUsed; }; - void SetPrintInfoNumber(const Long64_t &num=1) { fPrintInfoNumber = num; } + void SetPrintInfoNumber(const Long64_t &num=1) { fPrintInfoNumber = num; } private: diff --git a/PWG2/RESONANCES/AliRsnValue.cxx b/PWG2/RESONANCES/AliRsnValue.cxx index fa393e73475..922cb1f441d 100644 --- a/PWG2/RESONANCES/AliRsnValue.cxx +++ b/PWG2/RESONANCES/AliRsnValue.cxx @@ -8,6 +8,7 @@ // #include +#include "AliESDtrackCuts.h" #include "AliRsnEvent.h" #include "AliRsnDaughter.h" #include "AliRsnMother.h" @@ -19,93 +20,119 @@ ClassImp(AliRsnValue) //_____________________________________________________________________________ AliRsnValue::AliRsnValue() : - TNamed(), - fValue(0.0), - fType(kValueTypes), - fArray(0), - fESDCuts() + AliRsnTarget(), + fComputedValue(0), + fValueType(kValueTypes), + fBinArray(0), + fSupportObject(0x0) { // -// Main constructor (version 1) -// This can also be created without any argument. +// Default constructor without arguments. +// Initialize data members to meaningless values. +// 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) : - TNamed(name, ""), - fValue(0.0), - fType(type), - fArray(0), - fESDCuts() + AliRsnTarget(name, AliRsnTarget::kTargetTypes), + fComputedValue(0.0), + fValueType(type), + fBinArray(0), + fSupportObject(0x0) { // -// Main constructor (version 1) -// This can also be created without any argument. +// Main constructor (version 1). +// This constructor defines in meaningful way all data members, +// and defined a fixed binnings, subdividing the specified interval +// into that many bins as specified in the integer argument. +// --- +// This method is also the entry point for all instances +// of this class which don't need to do binning (e.g.: TNtuple inputs), +// since arguments 3 to 5 have default values which don't create any +// 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) : - TNamed(name, ""), - fValue(0.0), - fType(type), - fArray(0), - fESDCuts() + AliRsnTarget(name, AliRsnTarget::kTargetTypes), + fComputedValue(0.0), + fValueType(type), + fBinArray(0), + fSupportObject(0x0) { // -// Main constructor (version 2) +// Main constructor (version 2). +// This constructor defines in meaningful way all data members +// and creates enough equal bins of the specified size to cover +// the required interval. // + AssignTarget(); SetBins(min, max, step); } //_____________________________________________________________________________ AliRsnValue::AliRsnValue (const char *name, EValueType type, Int_t nbins, Double_t *array) : - TNamed(name, ""), - fValue(0.0), - fType(type), - fArray(0), - fESDCuts() + AliRsnTarget(name, AliRsnTarget::kTargetTypes), + fComputedValue(0.0), + fValueType(type), + fBinArray(0), + fSupportObject(0x0) { // -// Main constructor (version 2) +// Main constructor (version 3). +// This constructor defines in meaningful way all data members +// and creates a set of variable bins delimited by the passed array. // + AssignTarget(); SetBins(nbins, array); } //_____________________________________________________________________________ AliRsnValue::AliRsnValue(const AliRsnValue& copy) : - TNamed(copy), - fValue(copy.fValue), - fType(copy.fType), - fArray(copy.fArray), - fESDCuts(copy.fESDCuts) + AliRsnTarget(copy), + fComputedValue(copy.fComputedValue), + fValueType(copy.fValueType), + fBinArray(copy.fBinArray), + fSupportObject(copy.fSupportObject) { // -// Copy constructor +// Copy constructor. +// Duplicates the binning array and copies all settings. +// Calls also the function that assigns properly the +// expected target, depending on the computation type. // + + AssignTarget(); } //_____________________________________________________________________________ AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy) { // -// Assignment operator +// Assignment operator. +// Works like copy constructor. // - SetName(copy.GetName()); + AliRsnTarget::operator=(copy); + + fComputedValue = copy.fComputedValue; + fBinArray = copy.fBinArray; + fSupportObject = copy.fSupportObject; - fType = copy.fType; - fValue = copy.fValue; - fArray = copy.fArray; - fESDCuts = copy.fESDCuts; + AssignTarget(); return (*this); } @@ -118,7 +145,13 @@ void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max) // where the number of bins, minimum and maximum are given. // - fArray.Set(nbins + 1); + if (!nbins) + { + fBinArray.Set(0); + return; + } + + fBinArray.Set(nbins + 1); Double_t mymax = TMath::Max(min, max); Double_t mymin = TMath::Min(min, max); @@ -126,9 +159,8 @@ void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max) Int_t k = 0; Double_t binSize = (mymax - mymin) / ((Double_t)nbins); - fArray[0] = mymin; - for (k = 1; k <= nbins; k++) fArray[k] = fArray[k-1] + binSize; - for (k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1])); + fBinArray[0] = mymin; + for (k = 1; k <= nbins; k++) fBinArray[k] = fBinArray[k-1] + binSize; } //_____________________________________________________________________________ @@ -153,157 +185,321 @@ void AliRsnValue::SetBins(Int_t nbins, Double_t *array) // using the same way it is done in TAxis // - fArray.Adopt(nbins, array); - for (Int_t k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1])); + if (!nbins) + { + fBinArray.Set(0); + return; + } + + fBinArray.Adopt(nbins, array); +} + +//_____________________________________________________________________________ +const char* AliRsnValue::GetValueTypeName() const +{ +// +// This method returns a string to give a name to each possible +// computation value. +// + + switch (fValueType) + { + case kTrackP: return "SingleTrackPtot"; + case kTrackPt: return "SingleTrackPt"; + case kTrackEta: return "SingleTrackEta"; + 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"; + 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. +// + + switch (fValueType) + { + // track related values + case kTrackP: + case kTrackPt: + case kTrackEta: + SetTargetType(AliRsnTarget::kDaughter); // end of track-related values + break; + // pair related values + case kPairP1: + case kPairP2: + case kPairP1t: + case kPairP2t: + case kPairP1z: + case kPairP2z: + case kPairInvMass: + case kPairInvMassMC: + case kPairInvMassRes: + case kPairPt: + case kPairPz: + case kPairEta: + case kPairMt: + case kPairY: + case kPairPhi: + case kPairPhiMC: + case kPairPtRatio: + case kPairDipAngle: + case kPairCosThetaStar: + case kPairQInv: + case kPairAngleToLeading: + SetTargetType(AliRsnTarget::kMother); // end of pair-related values + break; + // event related values + case kEventLeadingPt: + case kEventMult: + case kEventMultESDCuts: + SetTargetType(AliRsnTarget::kEvent); // end of event-related values + break; + // undefined value + default: + SetTargetType(AliRsnTarget::kTargetTypes); // undefined targets + } } //_____________________________________________________________________________ -Bool_t AliRsnValue::Eval(AliRsnMother *mother, AliRsnPairDef *pairDef, AliRsnEvent *event) +Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) { // // Evaluation of the required value. // Checks that the passed object is of the right type -// and if this check is successful, returns the required value. -// The output of the function tells if it was successful, +// and if this check is successful, computes the required value. +// The output of the function tells if computing was successful, // and the values must be taken with GetValue(). // - // avoid segfaults - if (!mother) return kFALSE; - if (!pairDef) return kFALSE; + // cast the input to the allowed types + AliRsnDaughter *daughter = dynamic_cast(object); + AliRsnMother *mother = dynamic_cast(object); + AliRsnEvent *event = dynamic_cast(object); + + // check that the input object is the correct class type + switch (fTargetType) + { + case AliRsnTarget::kDaughter: + if (!daughter) + { + AliError(Form("[%s] expected: AliRsnDaughter, passed: [%s]", GetName(), object->ClassName())); + return kFALSE; + } + break; + case AliRsnTarget::kMother: + if (!mother) + { + AliError(Form("[%s] expected: AliRsnMother, passed: [%s]", GetName(), object->ClassName())); + return kFALSE; + } + break; + case AliRsnTarget::kEvent: + if (!event) + { + AliError(Form("[%s] expected: AliRsnEvent, passed: [%s]", GetName(), object->ClassName())); + return kFALSE; + } + break; + default: + AliError(Form("[%s] Wrong type", GetName())); + return kFALSE; + } - Double_t mass = pairDef->GetMotherMass(); + // cast the support object to the types which could be needed + AliESDtrackCuts *esdCuts = dynamic_cast(fSupportObject); + AliRsnPairDef *pairDef = dynamic_cast(fSupportObject); - switch (fType) + // common variables + TLorentzVector pRec; // 4-momentum for single track or pair sum (reco) + TLorentzVector pSim; // 4-momentum for single track or pair sum (MC) + TLorentzVector pRec0; // 4-momentum of first daughter (reco) + TLorentzVector pSim0; // 4-momentum of first daughter (MC) + TLorentzVector pRec1; // 4-momentum of second daughter (reco) + TLorentzVector pSim1; // 4-momentum of second daughter (MC) + if (daughter) { - case kTrack1P: - fValue = mother->GetDaughter(0)->P().Mag(); - break; - case kTrack2P: - fValue = mother->GetDaughter(1)->P().Mag(); + pRec = daughter->Psim(); + pSim = daughter->Prec(); + } + if (mother) + { + pRec = mother->Sum(); + pSim = mother->SumMC(); + pRec0 = mother->GetDaughter(0)->Prec(); + pRec1 = mother->GetDaughter(1)->Prec(); + pSim0 = mother->GetDaughter(0)->Psim(); + pSim1 = mother->GetDaughter(1)->Psim(); + } + + // compute value depending on type + switch (fValueType) + { + case kTrackP: + fComputedValue = useMC ? pSim.Mag() : pRec.Mag(); break; - case kTrack1Pt: - fValue = mother->GetDaughter(0)->P().Perp(); + case kTrackPt: + fComputedValue = useMC ? pSim.Perp() : pRec.Perp(); break; - case kTrack2Pt: - fValue = mother->GetDaughter(1)->P().Perp(); + case kTrackEta: + fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); break; - case kTrack1Px: - fValue = mother->GetDaughter(0)->P().X(); + case kPairP1: + fComputedValue = useMC ? pSim0.Mag() : pRec0.Mag(); break; - case kTrack1Py: - fValue = mother->GetDaughter(0)->P().Y(); + case kPairP2: + fComputedValue = useMC ? pSim1.Mag() : pRec1.Mag(); break; - case kTrack1Pz: - fValue = mother->GetDaughter(0)->P().Z(); + case kPairP1t: + fComputedValue = useMC ? pSim0.Perp() : pRec0.Perp(); break; - case kTrack2Px: - fValue = mother->GetDaughter(1)->P().X(); + case kPairP2t: + fComputedValue = useMC ? pSim1.Perp() : pRec1.Perp(); break; - case kTrack2Py: - fValue = mother->GetDaughter(1)->P().Y(); + case kPairP1z: + fComputedValue = useMC ? pSim0.Z() : pRec0.Z(); break; - case kTrack2Pz: - fValue = mother->GetDaughter(1)->P().Z(); + case kPairP2z: + fComputedValue = useMC ? pSim1.Z() : pRec1.Z(); break; case kPairInvMass: - fValue = mother->Sum().M(); - break; - case kPairInvMassMC: - fValue = mother->SumMC().M(); + fComputedValue = useMC ? pSim.M() : pRec.M(); break; case kPairInvMassRes: - fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M(); + fComputedValue = (pSim.M() - pRec.M()) / pSim.M(); break; case kPairPt: - fValue = mother->Sum().Perp(); + fComputedValue = useMC ? pSim.Perp() : pRec.Perp(); break; case kPairEta: - fValue = mother->Sum().Eta(); + fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); break; case kPairMt: - if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); - fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass); + // for this computation, replace the computed mass with the default mass + // for doing this, 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; + return kFALSE; + } + else + { + pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); + pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass()); + fComputedValue = useMC ? pSim.Mt() : pRec.Mt(); + } break; case kPairY: - if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); - mother->SetDefaultMass(mass); - fValue = mother->Ref().Rapidity(); + // for this computation, replace the computed mass with the default mass + // for doing this, 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; + return kFALSE; + } + else + { + pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); + pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass()); + fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity(); + } break; case kPairPhi: - fValue = mother->Sum().Phi(); - break; - case kPairPhiMC: - fValue = mother->SumMC().Phi(); + fComputedValue = useMC ? pSim.Phi() : pRec.Phi(); break; case kPairPtRatio: - fValue = TMath::Abs(mother->GetDaughter(0)->P().Perp() - mother->GetDaughter(1)->P().Perp()); - fValue /= TMath::Abs(mother->GetDaughter(0)->P().Perp() + mother->GetDaughter(1)->P().Perp()); + if (useMC) + { + fComputedValue = TMath::Abs(pSim0.Perp() - pSim1.Perp()); + fComputedValue /= TMath::Abs(pSim0.Perp() + pSim1.Perp()); + } + else + { + fComputedValue = TMath::Abs(pRec0.Perp() - pRec1.Perp()); + fComputedValue /= TMath::Abs(pRec0.Perp() + pRec1.Perp()); + } break; case kPairDipAngle: - fValue = mother->GetDaughter(0)->P().Angle(mother->GetDaughter(1)->P().Vect()); - fValue = TMath::Abs(TMath::ACos(fValue)); + fComputedValue = useMC ? pSim0.Angle(pSim1.Vect()) : pRec0.Angle(pRec1.Vect()); + fComputedValue = TMath::Abs(TMath::ACos(fComputedValue)); break; case kPairCosThetaStar: - fValue = mother->CosThetaStar(); + fComputedValue = mother->CosThetaStar(useMC); break; - case kAngleToLeading: + case kPairQInv: + pSim0 -= pSim1; + pRec0 -= pRec1; + fComputedValue = useMC ? pSim0.M() : pRec0.M(); + break; + case kPairAngleToLeading: { int ID1 = (mother->GetDaughter(0))->GetID(); int ID2 = (mother->GetDaughter(1))->GetID(); int leadingID = event->SelectLeadingParticle(0); - if(leadingID == ID1 || leadingID == ID2) return kFALSE; + if (leadingID == ID1 || leadingID == ID2) return kFALSE; AliRsnDaughter leadingPart = event->GetDaughter(leadingID); AliVParticle *ref = leadingPart.GetRef(); - - fValue = ref->Phi() - mother->Sum().Phi(); + fComputedValue = ref->Phi() - mother->Sum().Phi(); //return angle w.r.t. leading particle in the range -pi/2, 3/2pi - while(fValue >= TMath::Pi()) fValue -= 2*TMath::Pi(); - while(fValue < -0.5*TMath::Pi()) fValue += 2*TMath::Pi(); - //Printf("%g", fValue); + while(fComputedValue >= TMath::Pi()) fComputedValue -= 2*TMath::Pi(); + while(fComputedValue < -0.5*TMath::Pi()) fComputedValue += 2*TMath::Pi(); + //Printf("%g", fComputedValue); } break; case kEventMult: - if (!event) - { - fValue = 0.0; - return kFALSE; - } - else fValue = (Double_t)event->GetMultiplicity(0x0); + fComputedValue = (Double_t)event->GetMultiplicity(0x0); break; case kEventMultESDCuts: - if (!event) + // this value requires an initialized ESDtrackCuts + if (!esdCuts) { - fValue = 0.0; + AliError(Form("[%s] Required a correctly initialized ESDtrackCuts to compute this value", GetName())); + fComputedValue = 1E+10; return kFALSE; } - else fValue = (Double_t)event->GetMultiplicity(&fESDCuts); + fComputedValue = (Double_t)event->GetMultiplicity(esdCuts); break; - case kLeadingPt: - if (!event) - { - fValue = 0.0; - return kFALSE; - } - else + case kEventLeadingPt: { int leadingID = event->SelectLeadingParticle(0); if(leadingID >= 0) { AliRsnDaughter leadingPart = event->GetDaughter(leadingID); AliVParticle *ref = leadingPart.GetRef(); - fValue = ref->Pt(); + fComputedValue = ref->Pt(); } - else fValue = 0; - } - break; - case kQInv: - { - TLorentzVector diff = mother->GetDaughter(0)->P() - mother->GetDaughter(1)->P(); - fValue = diff.M(); + else fComputedValue = 0; } break; default: - AliWarning("Invalid value type"); + AliError(Form("[%s] Invalid value type for this computation", GetName())); return kFALSE; } @@ -311,74 +507,21 @@ Bool_t AliRsnValue::Eval(AliRsnMother *mother, AliRsnPairDef *pairDef, AliRsnEve } //_____________________________________________________________________________ -Bool_t AliRsnValue::Eval(AliRsnDaughter * const daughter, AliRsnEvent * const event) +void AliRsnValue::Print(Option_t * /*option */) const { // -// Evaluation of the required value. -// Checks that the passed object is of the right type -// and if this check is successful, returns the required value. -// The output of the function tells if it was successful, -// and the values must be taken with GetValue(). +// Print informations about this object // - // avoid segfaults - if (!daughter) return kFALSE; - - switch (fType) + AliInfo("=== VALUE INFO ================================================="); + AliInfo(Form(" Name : %s", GetName())); + AliInfo(Form(" Type : %s", GetValueTypeName())); + AliInfo(Form(" Current computed value: %f", fComputedValue)); + Int_t i; + for (i = 0; i < fBinArray.GetSize(); i++) { - case kEventMult: - if (!event) - { - fValue = 0.0; - return kFALSE; - } - else fValue = (Double_t)event->GetMultiplicity(); - break; - case kEventMultESDCuts: - if (!event) - { - fValue = 0.0; - return kFALSE; - } - else fValue = (Double_t)event->GetMultiplicity(&fESDCuts); - break; - case kLeadingPt: - if (!event) - { - fValue = 0.0; - return kFALSE; - } - else - { - int leadingID = event->SelectLeadingParticle(0); - if(leadingID >= 0) { - AliRsnDaughter leadingPart = event->GetDaughter(leadingID); - AliVParticle *ref = leadingPart.GetRef(); - fValue = ref->Pt(); - } - else fValue = 0; - } - break; - default: - AliWarning("Invalid value type"); - return kFALSE; + AliInfo(Form(" Bin limit #%d = %f", i, fBinArray[i])); } - - return kTRUE; -} - -//_____________________________________________________________________________ -void AliRsnValue::Print(Option_t *) const -{ -// -// Print all bins -// - - Int_t i, n = fArray.GetSize(); - TString msg("Array values: "); - - for (i = 0; i < n; i++) msg += Form("%f, ", fArray[i]); - - AliInfo(Form("Axis name: %s", GetName())); - AliInfo(msg.Data()); + AliInfo(Form(" Support object : %s", (fSupportObject ? fSupportObject->ClassName() : " NO SUPPORT"))); + AliInfo("=== END VALUE INFO ============================================="); } diff --git a/PWG2/RESONANCES/AliRsnValue.h b/PWG2/RESONANCES/AliRsnValue.h index 0a1ef2270d6..49288db295f 100644 --- a/PWG2/RESONANCES/AliRsnValue.h +++ b/PWG2/RESONANCES/AliRsnValue.h @@ -1,91 +1,100 @@ // // Class AliRsnValue // -// Definition of a single value which can be computed -// from any of the defined input objects implemented -// in the resonance package. +// This class implements all the computations which could be useful +// during the analysis, both for cuts and for output histograms. +// +// It inherits from the AliRsnTarget base class since it can operate +// on tracks, pairs and events, and the kind of expected object to +// be processed depends on the kind of requested computation. +// +// Since this class is used to produce the outputs, it contains the +// facilities to define a binning in an output histogram. // #ifndef ALIRSNVALUE_H #define ALIRSNVALUE_H -#include "TNamed.h" #include "TArrayD.h" -#include "AliESDtrackCuts.h" - -class AliRsnPairDef; -class AliRsnMother; +#include "AliRsnTarget.h" -class AliRsnValue : public TNamed +class AliRsnValue : public AliRsnTarget { public: - + + // this enumeration lists all available computations + // any user feedback proposing new ones is welcome enum EValueType { - kTrack1P, - kTrack2P, - kTrack1Pt, - kTrack2Pt, - kTrack1Px, - kTrack1Py, - kTrack1Pz, - kTrack2Px, - kTrack2Py, - kTrack2Pz, - kPairInvMass, - kPairInvMassMC, - kPairInvMassRes, - kPairPt, - kPairEta, - kPairMt, - kPairY, - kPairPhi, - kPairPhiMC, - kPairPtRatio, - kPairDipAngle, - kPairCosThetaStar, - kAngleToLeading, - kLeadingPt, - kQInv, - kEventMult, - kEventMultESDCuts, - kValueTypes + kTrackP, // single track total momentum + kTrackPt, // single track transverse momentum + kTrackEta, // single track pseudo-rapidity + 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 + 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) + + kValueTypes // last value is used to have a meaningless enum value for initializations }; AliRsnValue(); - AliRsnValue(const char *name, EValueType type, Int_t n = 0, Double_t min = 0.0, Double_t max = 0.0); + AliRsnValue(const char *name, EValueType type, Int_t nbins = 0, Double_t min = 0.0, Double_t max = 0.0); AliRsnValue(const char *name, EValueType type, Double_t min, Double_t max, Double_t step); - AliRsnValue(const char *name, EValueType type, Int_t n, Double_t *array); + AliRsnValue(const char *name, EValueType type, Int_t nbins, Double_t *array); AliRsnValue(const AliRsnValue& copy); AliRsnValue& operator=(const AliRsnValue& copy); - virtual ~AliRsnValue() { } + virtual ~AliRsnValue() { /*does nothing, since pointers are not owned by this object*/ } + + TArrayD GetArray() const {return fBinArray;} + Double_t GetComputedValue() const {return fComputedValue;} + EValueType GetValueType() const {return fValueType;} + const char* GetValueTypeName() const; + TObject* GetSupportObject() {return fSupportObject;} + void SetSupportObject(TObject *obj) {fSupportObject = obj;} + void SetValueType(EValueType type) {fValueType = type;} + void AssignTarget(); - TArrayD GetArray() const {return fArray;} - Double_t GetValue() const {return fValue;} - EValueType GetValueType() const {return fType;} - const AliESDtrackCuts* GetCuts() const {return &fESDCuts;} - - void SetValueType(EValueType type) {fType = type;} void SetBins(Int_t n, Double_t min, Double_t max); - void SetBins(Double_t min, Double_t max, Double_t step); void SetBins(Int_t n, Double_t *array); - void Set(EValueType type, Int_t n = 0, Double_t min = 0.0, Double_t max = 0.0) {fType = type; SetBins(n, min, max);} - void Set(EValueType type, Double_t min, Double_t max, Double_t step) {fType = type; SetBins(min, max, step);} - void Set(EValueType type, Int_t n, Double_t *array) {fType = type; SetBins(n, array);} + void SetBins(Double_t min, Double_t max, Double_t step); + + void Set(EValueType type, Int_t n, Double_t min, Double_t max) {fValueType = type; AssignTarget(); SetBins(n, min, max);} + 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(AliRsnMother *mother, AliRsnPairDef *pairDef, AliRsnEvent *event); - virtual Bool_t Eval(AliRsnDaughter *daughter, AliRsnEvent *event); + virtual Bool_t Eval(TObject *object, Bool_t useMC = kFALSE); virtual void Print(Option_t *option = "") const; protected: - Double_t fValue; // computed value - EValueType fType; // value type - TArrayD fArray; // array of bins (when necessary) - AliESDtrackCuts fESDCuts; // ESD track cuts used for a way to compute multiplicity + Double_t fComputedValue; // computed value + EValueType fValueType; // value type + TArrayD fBinArray; // array of bins (when used for a histogram axis) + TObject *fSupportObject; // support object needed for computing some of the values // ROOT dictionary - ClassDef(AliRsnValue, 1) + ClassDef(AliRsnValue, 2) }; #endif diff --git a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysis.C b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysis.C index b0a8bbca8a0..e0cf52d43e7 100644 --- a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysis.C +++ b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysis.C @@ -20,31 +20,16 @@ Bool_t AddRsnAnalysis // retrieve analysis manager AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - // interpret config string - TString strDataLabel(options); - Bool_t isSim = strDataLabel.Contains("sim"); - Bool_t isMC = strDataLabel.Contains("MC"); - // initialize task with all available slots, even if not all of them will be used: AliRsnAnalysisSE *task = new AliRsnAnalysisSE("RsnAnalysis"); task->SetZeroEventPercentWarning(100.0); task->SelectCollisionCandidates(); - if (isMC) task->SetMCOnly(kTRUE); - // if not MC kinematics, set cuts for events : primary vertex range and type - if (!isMC) - { - gROOT->LoadMacro("$(ALICE_ROOT)/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsTPC.C"); - AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE); - AliRsnCutESDCutMultiplicity *cutMult = new AliRsnCutESDCutMultiplicity("cutMult", 0, 10); - - ConfigESDCutsTPC(cutMult->GetCuts()); - - task->GetEventCuts()->AddCut(cutVertex); - //task->GetEventCuts()->AddCut(cutMult); - //task->GetEventCuts()->SetCutScheme("cutVertex&cutMult"); - task->GetEventCuts()->SetCutScheme("cutVertex"); - } + // set cuts for events : primary vertex range and type + gROOT->LoadMacro("$(ALICE_ROOT)/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsTPC.C"); + AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE); + task->GetEventCuts()->AddCut(cutVertex); + task->GetEventCuts()->SetCutScheme(cutVertex->GetName()); // add the task to manager mgr->AddTask(task); diff --git a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysisMult.C b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysisMult.C index 5fcd41b0ebe..a739fcd0a78 100644 --- a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysisMult.C +++ b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnAnalysisMult.C @@ -13,7 +13,7 @@ Bool_t AddRsnAnalysisMult ( const char *options, - const char *configs = "RsnConfigNoSA.C RsnConfigSA.C", + const char *configs = "RsnConfigNoSA.C RsnConfigSA.C RsnConfigDipNoSA.C RsnConfigDipSA.C", const char *path = "$(ALICE_ROOT)/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi" ) { diff --git a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnEfficiency.C b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnEfficiency.C index aa8a7177594..25000221b1e 100644 --- a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnEfficiency.C +++ b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/AddRsnEfficiency.C @@ -31,24 +31,22 @@ Bool_t AddRsnEfficiency(const char *dataLabel) // 1) transverse momentum // 2) rapidity // 3) multiplicity - Double_t pt [] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0}; - Double_t y [] = {-1.0, -0.9, -0.8, -0.7, -0.6, -0.5, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}; - Double_t mult[] = {0.0, 5.0, 9.0, 14.0, 22.0, 100000.0}; - Int_t npt = sizeof(pt ) / sizeof(pt [0]); - Int_t ny = sizeof(y ) / sizeof(y [0]); + Double_t mult[] = {0., 6., 10., 15., 23., 1E6}; Int_t nmult = sizeof(mult) / sizeof(mult[0]); - AliRsnValue *axisIM = new AliRsnValue("IM" , AliRsnValue::kPairInvMass , 500 , 0.9, 1.4); - //AliRsnValue *axisPt = new AliRsnValue("PT" , AliRsnValue::kPairPt , npt , pt); - //AliRsnValue *axisY = new AliRsnValue("Y" , AliRsnValue::kPairY , ny , y); - //AliRsnValue *axisMult = new AliRsnValue("Mult", AliRsnValue::kEventMultESDcuts, nmult, mult); - AliRsnValue *axisPt = new AliRsnValue("PT" , AliRsnValue::kPairPt , 100, 0.0, 10.0); - AliRsnValue *axisY = new AliRsnValue("Y" , AliRsnValue::kPairY , 20, -1.0, 1.0); - ConfigESDCutsTPC(axisMult->GetCuts()); + AliRsnValue *axisIM = new AliRsnValue("IM" , AliRsnValue::kPairInvMass , 0.9, 1.4, 0.001); + AliRsnValue *axisPt = new AliRsnValue("PT" , AliRsnValue::kPairPt , 0.0, 10.0, 0.100); + AliRsnValue *axisY = new AliRsnValue("Y" , AliRsnValue::kPairY ,-1.2, 1.2, 0.100); + AliRsnValue *axisMult = new AliRsnValue("Mult", AliRsnValue::kEventMultESDCuts, nmult, mult); + + // add the support cut to the value which computes the multiplicity + AliESDtrackCuts *cuts = new AliESDtrackCuts; + ConfigESDCutsTPC(cuts); + axisMult->SetSupportObject(cuts); // define cuts for event selection: // this will determine the filling of bins in the "info" histograms // and should be computed as additional correction factor in efficiency - AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE); + AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 1, kFALSE); // define standard 2010 track quality/PID cuts: // - first index: [0] = no PID, [1] = PID @@ -68,7 +66,7 @@ Bool_t AddRsnEfficiency(const char *dataLabel) cuts2010[ipid][iits]->SetMC(kTRUE); // all use global tracks - cuts2010[ipid][iits]->SetUseGlobal(kTRUE); + cuts2010[ipid][iits]->SetUseITSTPC(kTRUE); // other flags, depend on indexes cuts2010[ipid][iits]->SetUseITSSA((Bool_t)iits); @@ -83,7 +81,7 @@ Bool_t AddRsnEfficiency(const char *dataLabel) } // define cut on dip angle: - AliRsnCutStd *cutDip = new AliRsnCutStd("cutDip", AliRsnCut::kMother, AliRsnCutStd::kDipAngle, 0.0, 0.04); + AliRsnCutValue *cutDip = new AliRsnCutValue("cutDip", AliRsnValue::kPairDipAngle, 0.02, 1.01); // define a common path for the output file Char_t commonPath[500]; @@ -104,7 +102,7 @@ Bool_t AddRsnEfficiency(const char *dataLabel) // add the cut only when working on ESD, not on MC only task[itask]->GetEventCuts()->AddCut(cutVertex); - task[itask]->GetEventCuts()->SetCutScheme("cutVertex"); + task[itask]->GetEventCuts()->SetCutScheme(cutVertex->GetName()); // // *** STEP 0 - All resonances which decay in the specified pair @@ -122,42 +120,44 @@ Bool_t AddRsnEfficiency(const char *dataLabel) // its requirement is automatically checked during execution, // but to avoid segfaults, it is better to initialize a cut manager. // - AliRsnCutManager *mgr_step1 = new AliRsnCutManager("reco_step0", ""); + AliRsnCutManager *mgr_step1 = new AliRsnCutManager("esd_step0", ""); // // *** STEP 2 - Reconstruction & track quality // - - AliRsnCutSet *set_step2 = new AliRsnCutSet("cuts_step2", AliRsnCut::kDaughter); + // Define a cut on track quality, disabling the PID cuts (first index = [0]) + // AliRsnCutManager *mgr_step2 = new AliRsnCutManager("esd_step2", ""); + AliRsnCutSet *set_step2 = mgr_step2->GetCommonDaughterCuts(); set_step2->AddCut(cuts2010[0][itask]); set_step2->SetCutScheme(cuts2010[0][itask]->GetName()); - mgr_step2->SetCommonDaughterCuts(set_step2); // // *** STEP 3 - PID // - - AliRsnCutSet *set_step3 = new AliRsnCutSet("cuts_step3", AliRsnCut::kDaughter); + // Define a cut on track quality, enabling the PID cuts (first index = [1]) + // AliRsnCutManager *mgr_step3 = new AliRsnCutManager("esd_step3", ""); + AliRsnCutSet *set_step3 = mgr_step3->GetCommonDaughterCuts(); set_step3->AddCut(cuts2010[1][itask]); set_step3->SetCutScheme(cuts2010[1][itask]->GetName()); - mgr_step3->SetCommonDaughterCuts(set_step3); // // *** STEP 4 - Dip angle // - - AliRsnCutSet *set_step4 = new AliRsnCutSet("cuts_step4", AliRsnCut::kMother); + // Add a cut on the pair dip angle + // AliRsnCutManager *mgr_step4 = new AliRsnCutManager("esd_step4", ""); + AliRsnCutSet *set_step4 = mgr_step4->GetMotherCuts(); set_step4->AddCut(cutDip); - set_step4->SetCutScheme(Form("!%s", cutDip->GetName())); - mgr_step4->SetMotherCuts(set_step4); + set_step4->SetCutScheme(Form("%s", cutDip->GetName())); - // add all steps to the task + // add all steps to the task: + // - first step computed on MC + // - all other steps computed on reconstruction task[itask]->AddStepMC (mgr_step0); task[itask]->AddStepESD(mgr_step1); task[itask]->AddStepESD(mgr_step2); diff --git a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsITS.C b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsITS.C index b5599d383bd..89d42af19cd 100644 --- a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsITS.C +++ b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsITS.C @@ -6,8 +6,8 @@ void ConfigESDCutsITS(AliESDtrackCuts * &cuts) { // general acceptance/pt cuts - cuts->SetPtRange(0.15, 10.0); - cuts->SetEtaRange(-0.8, 0.8); + cuts->SetPtRange ( 0.15, 10.00); + cuts->SetEtaRange(-0.80, 0.80); // DCA cuts cuts->SetMaxDCAToVertexXYPtDep("0.0595+0.0182/pt^1.55"); diff --git a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsTPC.C b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsTPC.C index f007d579ed0..f3ebefd3e3a 100644 --- a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsTPC.C +++ b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/ConfigESDCutsTPC.C @@ -6,11 +6,11 @@ void ConfigESDCutsTPC(AliESDtrackCuts * &cuts) { // general acceptance/pt cuts - cuts->SetPtRange(0.15, 10.0); - cuts->SetEtaRange(-0.8, 0.8); + cuts->SetPtRange ( 0.15, 1.0e+10); + cuts->SetEtaRange(-0.8 , 0.8); // DCA cuts - cuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0224/pt^1.78"); + cuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); cuts->SetMaxDCAToVertexZ(2.0); cuts->SetDCAToVertex2D(kFALSE); cuts->SetRequireSigmaToVertex(kFALSE); @@ -25,4 +25,3 @@ void ConfigESDCutsTPC(AliESDtrackCuts * &cuts) cuts->SetRequireITSRefit(kTRUE); cuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny); } - diff --git a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/RsnConfig.C b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/RsnConfig.C index 753f982801c..6a9fe749d6f 100644 --- a/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/RsnConfig.C +++ b/PWG2/RESONANCES/macros/train/LHC2010-7TeV-phi/RsnConfig.C @@ -94,10 +94,10 @@ Bool_t RsnConfig cuts2010_esd->SetMC(isSim); cuts2010_aod->SetMC(isSim); // ----> include or not the ITS standalone (TPC is always in) - cuts2010_esd->SetUseGlobal(kTRUE); + cuts2010_esd->SetUseITSTPC(kTRUE); cuts2010_esd->SetUseITSSA (addITSSA); - cuts2010_aod->SetUseGlobal(kTRUE); - cuts2010_aod->SetUseITSSA (addITSSA); + //cuts2010_aod->SetUseITSTPC(kTRUE); + //cuts2010_aod->SetUseITSSA (addITSSA); // ----> require to check PID or not, depending on the label if (realPID) { @@ -130,21 +130,28 @@ Bool_t RsnConfig // pair cut ---------------------- // --> dip angle between daughters - AliRsnCutStd *cutDip = new AliRsnCutStd("cutDip", AliRsnCut::kMother, AliRsnCutStd::kDipAngle, 0.02, 1.1); + AliRsnCutValue *cutDip = new AliRsnCutValue("cutDip", AliRsnValue::kPairDipAngle, 0.03, 1.01); // cut set for tracks------------------------ // --> only common cuts for tracks are needed // --> standard 2010 cuts are applied always - TString cutSchemeTrack; - AliRsnCutSet *cutSetDaughterCommon = new AliRsnCutSet("commonDaughterCuts", AliRsnCut::kDaughter); + TString cutSchemeTrack; if (isESD) { - cutSetDaughterCommon->AddCut(cuts2010_esd); + pairPM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_esd); + truePM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_esd); + pairPP->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_esd); + pairMM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_esd); + cutSchemeTrack += cuts2010_esd->GetName(); } else if (isAOD) { - cutSetDaughterCommon->AddCut(cuts2010_aod); + pairPM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_aod); + truePM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_aod); + pairPP->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_aod); + pairMM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cuts2010_aod); + cutSchemeTrack += cuts2010_aod->GetName(); } else @@ -154,30 +161,34 @@ Bool_t RsnConfig } if (perfPID) { - cutSetDaughterCommon->AddCut(cutPID); + pairPM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cutPID); + truePM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cutPID); + pairPP->GetCutManager()->GetCommonDaughterCuts()->AddCut(cutPID); + pairMM->GetCutManager()->GetCommonDaughterCuts()->AddCut(cutPID); + cutSchemeTrack += "&cutPID"; } - cutSetDaughterCommon->SetCutScheme(cutSchemeTrack.Data()); + pairPM->GetCutManager()->GetCommonDaughterCuts()->SetCutScheme(cutSchemeTrack.Data()); + truePM->GetCutManager()->GetCommonDaughterCuts()->SetCutScheme(cutSchemeTrack.Data()); + pairPP->GetCutManager()->GetCommonDaughterCuts()->SetCutScheme(cutSchemeTrack.Data()); + pairMM->GetCutManager()->GetCommonDaughterCuts()->SetCutScheme(cutSchemeTrack.Data()); // cut set for pairs--------------------------------------- // --> add dip angle cut (but then include only if required) AliRsnCutSet *cutSetPair = new AliRsnCutSet("cutsPair", AliRsnCut::kMother); cutSetPair->AddCut(cutDip); cutSetPair->SetCutScheme(cutDip->GetName()); - - // configure cut managers ------------------- - // --> track cuts are always defined, so add them by default - pairPM->GetCutManager()->SetCommonDaughterCuts(cutSetDaughterCommon); - truePM->GetCutManager()->SetCommonDaughterCuts(cutSetDaughterCommon); - pairPP->GetCutManager()->SetCommonDaughterCuts(cutSetDaughterCommon); - pairMM->GetCutManager()->SetCommonDaughterCuts(cutSetDaughterCommon); - // --> pair cut is added only when dip angle cut is required if (dipAngleCut) { - pairPM->GetCutManager()->SetMotherCuts(cutSetPair); - truePM->GetCutManager()->SetMotherCuts(cutSetPair); - pairPP->GetCutManager()->SetMotherCuts(cutSetPair); - pairMM->GetCutManager()->SetMotherCuts(cutSetPair); + pairPM->GetCutManager()->GetMotherCuts()->AddCut(cutDip); + truePM->GetCutManager()->GetMotherCuts()->AddCut(cutDip); + pairPP->GetCutManager()->GetMotherCuts()->AddCut(cutDip); + pairMM->GetCutManager()->GetMotherCuts()->AddCut(cutDip); + + pairPM->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName()); + truePM->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName()); + pairPP->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName()); + pairMM->GetCutManager()->GetMotherCuts()->SetCutScheme(cutDip->GetName()); } // set additional option for true pairs when needed @@ -188,25 +199,29 @@ Bool_t RsnConfig // -- Setup functions ----------------------------------------------------------------------------- // - // function axes - Double_t pt [] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0}; - Double_t y [] = {-0.8, -0.7, -0.6, 0.6, 0.7, 0.8}; - Double_t mult[] = {0.0, 5.0, 9.0, 14.0, 22.0, 1000.0}; - Int_t npt = sizeof(pt ) / sizeof(pt [0]); - Int_t ny = sizeof(y ) / sizeof(y [0]); + // axis definition + // 0) invariant mass + // 1) transverse momentum + // 2) rapidity + // 3) multiplicity + Double_t mult[] = {0., 6., 10., 15., 23., 1E6}; Int_t nmult = sizeof(mult) / sizeof(mult[0]); - AliRsnValue *axisIM = new AliRsnValue("IM" , AliRsnValue::kPairInvMass , 500 , 0.9, 1.4); - AliRsnValue *axisPt = new AliRsnValue("PT" , AliRsnValue::kPairPt , npt , pt); - AliRsnValue *axisY = new AliRsnValue("Y" , AliRsnValue::kPairY , ny , y); + AliRsnValue *axisIM = new AliRsnValue("IM" , AliRsnValue::kPairInvMass , 0.9, 1.4, 0.001); + AliRsnValue *axisPt = new AliRsnValue("PT" , AliRsnValue::kPairPt , 0.0, 10.0, 0.100); + AliRsnValue *axisY = new AliRsnValue("Y" , AliRsnValue::kPairY ,-1.2, 1.2, 0.100); AliRsnValue *axisMult = new AliRsnValue("Mult", AliRsnValue::kEventMultESDCuts, nmult, mult); - ConfigESDCutsTPC(axisMult->GetCuts()); + + // add the support cut to the value which computes the multiplicity + AliESDtrackCuts *cuts = new AliESDtrackCuts; + ConfigESDCutsTPC(cuts); + axisMult->SetSupportObject(cuts); // create function and add axes AliRsnFunction *fcnImPtY = new AliRsnFunction; - fcnImPtY->AddAxis(axisIM); - fcnImPtY->AddAxis(axisPt); - fcnImPtY->AddAxis(axisY); - fcnImPtY->AddAxis(axisMult); + if ( !fcnImPtY->AddAxis(axisIM ) ) return kFALSE; + if ( !fcnImPtY->AddAxis(axisPt ) ) return kFALSE; + if ( !fcnImPtY->AddAxis(axisY ) ) return kFALSE; + if ( !fcnImPtY->AddAxis(axisMult) ) return kFALSE; // add functions to pairs pairPM->AddFunction(fcnImPtY); @@ -222,7 +237,7 @@ Bool_t RsnConfig task->GetAnalysisManager()->Add(pairPM); task->GetAnalysisManager()->Add(pairPP); task->GetAnalysisManager()->Add(pairMM); - //if (isSim) task->GetAnalysisManager()->Add(truePM); + if (isSim) task->GetAnalysisManager()->Add(truePM); return kTRUE; } diff --git a/PWG2/libPWG2resonances.pkg b/PWG2/libPWG2resonances.pkg index 4ca746140f4..4d519e3d200 100644 --- a/PWG2/libPWG2resonances.pkg +++ b/PWG2/libPWG2resonances.pkg @@ -2,25 +2,24 @@ SRCS= RESONANCES/AliRsnDaughter.cxx \ RESONANCES/AliRsnMother.cxx \ + RESONANCES/AliRsnPairDef.cxx \ RESONANCES/AliRsnEvent.cxx \ + RESONANCES/AliRsnTarget.cxx \ RESONANCES/AliRsnValue.cxx \ - RESONANCES/AliRsnFunction.cxx \ - RESONANCES/AliRsnExpression.cxx \ - RESONANCES/AliRsnVariableExpression.cxx \ RESONANCES/AliRsnCut.cxx \ - RESONANCES/AliRsnCutStd.cxx \ + RESONANCES/AliRsnCutValue.cxx \ RESONANCES/AliRsnCutPID.cxx \ RESONANCES/AliRsnCutBetheBloch.cxx \ RESONANCES/AliRsnCutPrimaryVertex.cxx \ RESONANCES/AliRsnCutESDPrimary.cxx \ - RESONANCES/AliRsnCutESDCutMultiplicity.cxx \ RESONANCES/AliRsnCutDaughterType.cxx \ RESONANCES/AliRsnCutESD2010.cxx \ RESONANCES/AliRsnCutAOD2010.cxx \ RESONANCES/AliRsnCutSet.cxx \ - RESONANCES/AliRsnCutValue.cxx \ + RESONANCES/AliRsnExpression.cxx \ + RESONANCES/AliRsnVariableExpression.cxx \ RESONANCES/AliRsnCutManager.cxx \ - RESONANCES/AliRsnPairDef.cxx \ + RESONANCES/AliRsnFunction.cxx \ RESONANCES/AliRsnPair.cxx \ RESONANCES/AliRsnPairFunctions.cxx \ RESONANCES/AliRsnPairNtuple.cxx \ @@ -37,8 +36,6 @@ SRCS= RESONANCES/AliRsnDaughter.cxx \ RESONANCES/AliRsnAnalysisPhi7TeVNoPID.cxx \ RESONANCES/AliRsnMonitorTrack.cxx \ RESONANCES/AliRsnAnalysisMonitorTask.cxx \ - RESONANCES/AliRsnAnalysisMonitorPairTask.cxx \ -# RESONANCES/AliRsnFitResult.cxx \ HDRS= $(SRCS:.cxx=.h) -- 2.39.3