//
-// Class AliRsnDaughter
+// This class works as generic interface to each candidate resonance daughter.
+// Its main purpose is to provide a unique reference which includes all the
+// facilities available in the AliVParticle generic base class, plus all info
+// which could be needed during analysis, which are not in AliVParticle but
+// need to be accessed from ESD or AOD objects, usually in different ways.
+// When MC is available, AliRsnDaughter matches each reconstructed object with
+// its corresponding MC particle.
+//
+// Currently, this interface can point to all kinds of single-particle object
+// which one can have in the reconstructed event: charged tracks, V0s and
+// cascades. It is care of the user to treat each of them in the correct way,
+// regarding cuts, functions to be computed, etc.
//
-// Interface to candidate daughters of a resonance (tracks).
-// Points to the source of information, which is generally an AliVParticle-derived object
-// and contains few internal data-members to store "on fly" some important information
-// for the computations required during resonance analysis.
-// It contains a useful TLorentzVector data-member which, provided that a meaningful mass was assigned,
-// eases a lot the computation of invariant masses from summing up several of these objects.
-//
-// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
-// M. Vala (martin.vala@cern.ch)
+// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
+// M. Vala (martin.vala@cern.ch)
//
#include <TParticle.h>
-
-#include "AliStack.h"
-#include "AliMCEvent.h"
-#include "AliESDEvent.h"
-#include "AliAODEvent.h"
-#include "AliESDtrack.h"
-#include "AliAODEvent.h"
-#include "AliAODVertex.h"
-#include "AliAODTrack.h"
+#include <TDatabasePDG.h>
#include "AliRsnDaughter.h"
ClassImp(AliRsnDaughter)
-//_____________________________________________________________________________
-AliRsnDaughter::AliRsnDaughter() :
- fOK(kFALSE),
- fLabel(-1),
- fMotherPDG(0),
- fP(0.0, 0.0, 0.0, 0.0),
- fPMC(0.0, 0.0, 0.0, 0.0),
- fRef(0x0),
- fRefMC(0x0)
-{
-//
-// Default constructor.
-//
-}
-
//_____________________________________________________________________________
AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter ©) :
- TObject(copy),
- fOK(copy.fOK),
- fLabel(copy.fLabel),
- fMotherPDG(copy.fMotherPDG),
- fP(copy.fP),
- fPMC(copy.fPMC),
- fRef(copy.fRef),
- fRefMC(copy.fRefMC)
+ TObject(copy),
+ fOK(copy.fOK),
+ fLabel(copy.fLabel),
+ fMotherPDG(copy.fMotherPDG),
+ fRsnID(copy.fRsnID),
+ fPrec(copy.fPrec),
+ fPsim(copy.fPsim),
+ fRef(copy.fRef),
+ fRefMC(copy.fRefMC),
+ fOwnerEvent(copy.fOwnerEvent)
{
//
// Copy constructor.
// statement, but from just referencing something in the data source.
//
- fOK = copy.fOK;
- fLabel = copy.fLabel;
- fMotherPDG = copy.fMotherPDG;
- fP = copy.fP;
- fPMC = copy.fPMC;
- fRef = copy.fRef;
- fRefMC = copy.fRefMC;
-
- return (*this);
-}
+ fOK = copy.fOK;
+ fLabel = copy.fLabel;
+ fMotherPDG = copy.fMotherPDG;
+ fRsnID = copy.fRsnID;
+ fPsim = copy.fPsim;
+ fPrec = copy.fPrec;
+ fRef = copy.fRef;
+ fRefMC = copy.fRefMC;
+ fOwnerEvent = copy.fOwnerEvent;
-//_____________________________________________________________________________
-AliRsnDaughter::~AliRsnDaughter()
-{
-//
-// Destructor.
-// Since pointers do not allocate new objects, no 'delete' is done.
-//
+ return (*this);
}
//_____________________________________________________________________________
// for analysis unless initialized properly.
//
- fOK = kFALSE;
- fLabel = -1;
- fMotherPDG = 0;
- fRef = 0x0;
- fRefMC = 0x0;
-
- fP .SetXYZM(0.0, 0.0, 0.0, 0.0);
- fPMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
+ fOK = kFALSE;
+ fLabel = -1;
+ fMotherPDG = 0;
+ fRsnID = -1;
+
+ fPsim.SetXYZT(0.0, 0.0, 0.0, 0.0);
+ fPrec.SetXYZT(0.0, 0.0, 0.0, 0.0);
+
+ fRef = fRefMC = 0x0;
+ fOwnerEvent = 0x0;
}
//_____________________________________________________________________________
-void AliRsnDaughter::Print(Option_t * const /*option*/) const
+Int_t AliRsnDaughter::GetPDG()
{
//
-// Prints the values of data members, using the options:
-// - P --> momentum
-// - V --> DCA vertex
-// - C --> electric charge
-// - F --> flags
-// - I --> identification (PID, probability and mass)
-// - W --> PID weights
-// - M --> Montecarlo
-// - L --> index & label
-// - A --> angles
-// - ALL --> All oprions switched on
-//
-// Index and label are printed by default.
-//
-
- Char_t type[50], source[50];
- if (IsTrack()) sprintf(type, "track");
- else if (IsV0()) sprintf(type, "V0");
- else sprintf(type, "none");
-
- if (IsESD()) sprintf(source, "ESD");
- else if (IsAOD()) sprintf(source, "AOD");
- else if (fRefMC != 0x0) sprintf(source, "MC only");
- else sprintf(source, "none");
-
- AliInfo("===== ALIRSNDAUGHTER INFORMATION ==============================================");
- AliInfo(Form(".......Index : %d", GetID()));
- AliInfo(Form(".......Label : %d", GetLabel()));
- AliInfo(Form(".......Type, source : %s %s", type, source));
- AliInfo(Form(".......Charge : %c", ChargeChar()));
-
- if (fRef)
- {
- AliInfo(Form(".......Px, Py, Pz, Pt (ref) : %d %d %d %d", fP.X(), fP.Y(), fP.Z(), fP.Perp()));
- } else AliInfo("....... absent REF");
-
- if (fRefMC)
- {
- AliInfo(Form(".......Px, Py, Pz, Pt (ref MC): %d %d %d %d", fP.X(), fP.Y(), fP.Z(), fP.Perp()));
- AliInfo(Form(".......PDG code : %d", fRefMC->Particle()->GetPdgCode()));
- AliInfo(Form(".......Mother (label) : %d", fRefMC->Particle()->GetFirstMother()));
- AliInfo(Form(".......Mother (PDG code) : %d", fMotherPDG));
- } else AliInfo("....... absent REF MC");
-
- AliInfo("===== END ALIRSNDAUGHTER INFORMATION ==========================================");
+// Return the PDG code of the particle from MC ref (if any).
+// If argument is kTRUE, returns its absolute value.
+//
+
+ if (Match(fRefMC, AliMCParticle::Class()))
+ return ((AliMCParticle*)fRefMC)->Particle()->GetPdgCode();
+ else if (Match(fRefMC, AliAODMCParticle::Class()))
+ return ((AliAODMCParticle*)fRefMC)->GetPdgCode();
+ else {
+ AliWarning("Cannot retrieve PDG");
+ return 0;
+ }
}
//_____________________________________________________________________________
-Int_t AliRsnDaughter::GetID() const
+Int_t AliRsnDaughter::GetID()
{
//
// Return reference index, using the "GetID" method
// of the possible source object.
-// In case of V0s, since this method is unsuccessful, return the label.
+// When this method is unsuccessful (e.g.: V0s), return the label.
//
- const AliESDtrack *esd = GetRefESDtrack();
- if (esd) return esd->GetID();
+ // ESD tracks
+ AliESDtrack *esd = Ref2ESDtrack();
+ if (esd) return esd->GetID();
- const AliAODTrack *aod = GetRefAODtrack();
- if (aod) return aod->GetID();
+ // AOD tracks
+ AliAODTrack *aod = Ref2AODtrack();
+ if (aod) return aod->GetID();
- return GetLabel();
+ // whatever else
+ return GetLabel();
}
//_____________________________________________________________________________
-Bool_t AliRsnDaughter::HasFlag(ULong_t flag) const
+Int_t AliRsnDaughter::GetMother()
{
//
-// Checks that the 'status' flag of the source object has one or
-// a combination of status flags combined with the bitwise OR.
-// Works only with track-like objects.
+// Return index of the first mother of the MC reference, if any.
+// Otherwise, returns -1 (the same as for primary tracks)
//
- if (IsTrack())
- {
- AliVTrack *track = dynamic_cast<AliVTrack*>(fRef);
- ULong_t status = (ULong_t)track->GetStatus();
- return ((status & flag) != 0);
- }
-
- return kTRUE;
+ if (!fRefMC) return -1;
+
+ if (fRefMC->InheritsFrom(AliMCParticle::Class())) {
+ AliMCParticle *mc = (AliMCParticle*)fRefMC;
+ return mc->Particle()->GetFirstMother();
+ } else if (fRefMC->InheritsFrom(AliAODMCParticle::Class())) {
+ AliAODMCParticle *mc = (AliAODMCParticle*)fRefMC;
+ return mc->GetMother();
+ }
+ else
+ return -1;
}
+
+
-//_____________________________________________________________________________
-Bool_t AliRsnDaughter::SetMass(Double_t mass)
+//______________________________________________________________________________
+void AliRsnDaughter::Print(Option_t *) const
{
//
-// The argument defines a mass to be assigned to the 4-momentum.
-// This value is not stored as a data-member, but serves just to modify
-// the energy of the 4-momentum both in the MC and non-MC objects,
-// while the vector momentum is taken from the respective references.
-// The method returns a BOOL outcome which is kFALSE in the case that
-// mass is meaningless or when both references are NULL or the goodness
-// flag is not positive.
-//
-
- if (!fOK) return kFALSE;
- if (mass < 0.) return kFALSE;
- if (!fRef && !fRefMC) return kFALSE;
-
- if (fRef) fP .SetXYZM(fRef ->Px(), fRef ->Py(), fRef ->Pz(), mass);
- if (fRefMC) fPMC.SetXYZM(fRefMC->Px(), fRefMC->Py(), fRefMC->Pz(), mass);
-
- return kTRUE;
+// Override of TObject::Print()
+//
+
+ AliInfo("=== DAUGHTER INFO ======================================================================");
+ AliInfo(Form(" (sim) px,py,pz = %6.2f %6.2f %6.2f", fPsim.X(), fPsim.Y(), fPsim.Z()));
+ AliInfo(Form(" (rec) px,py,pz = %6.2f %6.2f %6.2f", fPrec.X(), fPrec.Y(), fPrec.Z()));
+ AliInfo(Form(" OK, RsnID, Label, MotherPDG = %s, %5d, %5d, %4d", (fOK ? "true " : "false"), fRsnID, fLabel, fMotherPDG));
+ AliInfo("========================================================================================");
+}
+
+//______________________________________________________________________________
+const char* AliRsnDaughter::SpeciesName(ESpecies species)
+{
+//
+// Return a string with the short name of the particle
+//
+
+ switch (species) {
+ case kElectron: return "E";
+ case kMuon: return "Mu";
+ case kPion: return "Pi";
+ case kKaon: return "K";
+ case kProton: return "P";
+ case kKaon0: return "K0s";
+ case kLambda: return "Lambda";
+ case kXi: return "Xi";
+ case kOmega: return "Omega";
+ default: return "Undef";
+ }
+}
+
+//______________________________________________________________________________
+Int_t AliRsnDaughter::SpeciesPDG(ESpecies species)
+{
+//
+// Return the PDG code of a particle species (abs value)
+//
+
+ switch (species) {
+ case kElectron: return 11;
+ case kMuon: return 13;
+ case kPion: return 211;
+ case kKaon: return 321;
+ case kProton: return 2212;
+ case kKaon0: return 310;
+ case kLambda: return 3122;
+ case kXi: return 3312;
+ case kOmega: return 3334;
+ default: return 0;
+ }
+}
+
+//______________________________________________________________________________
+Double_t AliRsnDaughter::SpeciesMass(ESpecies species)
+{
+//
+// Return the mass of a particle species
+//
+
+ TDatabasePDG *db = TDatabasePDG::Instance();
+ TParticlePDG *part = 0x0;
+
+ Int_t pdg = SpeciesPDG(species);
+ if (pdg) {
+ part = db->GetParticle(pdg);
+ return part->Mass();
+ }
+ else
+ return 0.0;
+}
+
+//______________________________________________________________________________
+EPARTYPE AliRsnDaughter::ToAliPID(ESpecies species)
+{
+//
+// Convert an enum element from this object
+// into the enumeration of AliPID.
+// If no match are cound 'kUnknown' is returned.
+//
+
+ switch (species) {
+ case kElectron: return AliPID::kElectron;
+ case kMuon: return AliPID::kMuon;
+ case kPion: return AliPID::kPion;
+ case kKaon: return AliPID::kKaon;
+ case kProton: return AliPID::kProton;
+ case kKaon0: return AliPID::kKaon0;
+ default: return AliPID::kUnknown;
+ }
+}
+
+//______________________________________________________________________________
+AliRsnDaughter::ESpecies AliRsnDaughter::FromAliPID(EPARTYPE pid)
+{
+//
+// Convert an enum element from AliPID
+// into the enumeration of this object.
+// If no match are cound 'kUnknown' is returned.
+//
+
+ switch (pid) {
+ case AliPID::kElectron: return kElectron;
+ case AliPID::kMuon: return kMuon;
+ case AliPID::kPion: return kPion;
+ case AliPID::kKaon: return kKaon;
+ case AliPID::kProton: return kProton;
+ case AliPID::kKaon0: return kKaon0;
+ default: return kUnknown;
+ }
}