-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice *
- **************************************************************************/
-
-//-------------------------------------------------------------------------
-// Class AliRsnDaughter
-//
-// A simple object which describes a reconstructed track
-// with some references to its related generated particle
-// and some facilities which could help in composing its
-// 4-momentum, for resonance study.
-//
-// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
-//-------------------------------------------------------------------------
-
#ifndef ALIRSNDAUGHTER_H
#define ALIRSNDAUGHTER_H
-#include "AliPID.h"
-#include <TVector3.h>
-#include <TParticle.h>
+//
+// Interface to single daughter candidate.
+// Used for old-version analysis and for
+// selecting tracks in mini package
+//
+
+#include <TMath.h>
#include <TLorentzVector.h>
-class AliESDtrack;
+#include "AliPID.h"
+#include "AliVTrack.h"
+#include "AliESDtrack.h"
+#include "AliESDv0.h"
+#include "AliESDcascade.h"
+#include "AliMCParticle.h"
+#include "AliAODTrack.h"
+#include "AliAODv0.h"
+#include "AliAODcascade.h"
+#include "AliAODMCParticle.h"
+
+class AliRsnEvent;
-class AliRsnDaughter : public TObject
-{
+typedef AliPID::EParticleType EPARTYPE;
+
+class AliRsnDaughter : public TObject {
public:
- AliRsnDaughter();
- AliRsnDaughter(const AliRsnDaughter ©);
-
- virtual ~AliRsnDaughter() { }
-
- Bool_t Adopt(TParticle* particle);
- Bool_t Adopt(const AliESDtrack* track, Bool_t checkRefit = kTRUE);
- TVector3 Get3Momentum() const {TVector3 v(fP[0],fP[1],fP[2]); return v;}
- TLorentzVector Get4Momentum() const {TLorentzVector v(fP[0],fP[1],fP[2],GetEnergy()); return v;}
- Double_t GetEnergy() const {return TMath::Sqrt(fMass*fMass + GetP2());}
- UShort_t GetIndex() const {return fIndex;}
- Int_t GetLabel() const {return fLabel;}
- Double_t GetMass() const {return fMass;}
- Int_t GetMother() const {return fMother;}
- Short_t GetMotherPDG() const {return fMotherPDG;}
- UShort_t GetPDG() const {return fPDG;}
- Double_t GetPIDweight(Int_t i) const {return ( (i>=0&&i<AliPID::kSPECIES)?fPIDwgt[i]:-1.0 );}
- Char_t GetSign() const {return fSign;}
- Double_t GetP2() const {return fP[0]*fP[0] + fP[1]*fP[1] + fP[2]*fP[2];}
- Double_t GetP() const {return TMath::Sqrt(GetP2());}
- Double_t GetPx() const {return fP[0];}
- Double_t GetPy() const {return fP[1];}
- Double_t GetPz() const {return fP[2];}
- Double_t GetPt() const {return TMath::Sqrt(fP[0]*fP[0] + fP[1]*fP[1]);}
- Short_t GetTruePDG() const {return fTruePDG;}
- TVector3 GetVertex() const {TVector3 v(fV[0],fV[1],fV[2]); return v;}
- Double_t GetVx() const {return fV[0];}
- Double_t GetVy() const {return fV[1];}
- Double_t GetVz() const {return fV[2];}
- Double_t GetVt() const {return TMath::Sqrt(fV[0]*fV[0] + fV[1]*fV[1]);}
- void SetIndex(UShort_t value) {fIndex = value;}
- void SetIndex(Int_t value) {fIndex = (UShort_t)value;}
- void SetLabel(Int_t l) {fLabel = l;}
- void SetMass(Double_t m) {fMass = m;}
- void SetMother(Int_t l) {fMother = l;}
- void SetMotherPDG(Short_t pdg) {fMotherPDG = pdg;}
- void SetPDG(UShort_t pdg) {fPDG = TMath::Abs(pdg);}
- void SetPDG(Int_t pdg) {fPDG = (UShort_t)TMath::Abs(pdg);}
- void SetPIDweights(const Double_t *pid) {Int_t i;for(i=0;i<AliPID::kSPECIES;i++)fPIDwgt[i]=pid[i];}
- void SetPxPyPz(Double_t px,Double_t py,Double_t pz) {fP[0]=px;fP[1]=py;fP[2]=pz;}
- void SetSign(Char_t value) {fSign = value;}
- void SetSign(Int_t value) {fSign = (Char_t)value;}
- void SetTruePDG(Short_t pdg) {fTruePDG = pdg;}
- void SetVxVyVz(Double_t vx,Double_t vy,Double_t vz) {fV[0]=vx;fV[1]=vy;fV[2]=vz;}
-
- friend AliRsnDaughter operator+(AliRsnDaughter t1, AliRsnDaughter t2);
-
+
+ enum ERefType {
+ kTrack,
+ kV0,
+ kCascade,
+ kNoType
+ };
+
+ enum ESpecies {
+ kElectron,
+ kMuon,
+ kPion,
+ kKaon,
+ kProton,
+ kKaon0,
+ kLambda,
+ kXi,
+ kOmega,
+ kUnknown
+ };
+
+ AliRsnDaughter() : fOK(kFALSE), fLabel(-1), fMotherPDG(0), fRsnID(-1),
+ fPrec(), fPsim(), fRef(0x0), fRefMC(0x0), fOwnerEvent(0x0) { }
+ AliRsnDaughter(const AliRsnDaughter ©);
+ AliRsnDaughter& operator= (const AliRsnDaughter& copy);
+ virtual ~AliRsnDaughter() { /*empty, since pointers must not be deleted*/ }
+
+ // basic getters
+ Bool_t IsOK() const {return fOK;}
+ Int_t GetLabel() const {return fLabel;}
+ Int_t GetMotherPDG() const {return fMotherPDG;}
+ Int_t GetRsnID() const {return fRsnID;}
+ AliVParticle* GetRef() {return fRef;}
+ AliVParticle* GetRefMC() {return fRefMC;}
+ AliRsnEvent* GetOwnerEvent() {return fOwnerEvent;}
+ TLorentzVector& P(Bool_t mc) {return (mc ? fPsim : fPrec);}
+ TLorentzVector& Prec() {return fPrec;}
+ TLorentzVector& Psim() {return fPsim;}
+ Int_t GetPDG();
+ Int_t GetPDGAbs() {return TMath::Abs(GetPDG());}
+ Int_t GetID();
+ Int_t GetMother();
+
+ // basic setters (for data members)
+ void Reset();
+ void SetOK(Bool_t ok) {fOK = ok;}
+ void SetBad() {fOK = kFALSE;}
+ void SetGood() {fOK = kTRUE;}
+ void SetLabel(Int_t label) {fLabel = label;}
+ void SetMotherPDG(Int_t value) {fMotherPDG = value;}
+ void SetRsnID(Int_t id) {fRsnID = id;}
+ void SetRef(AliVParticle *p) {fRef = p;}
+ void SetRefMC(AliVParticle *p) {fRefMC = p;}
+ void SetOwnerEvent(AliRsnEvent *e) {fOwnerEvent = e;}
+
+ // additional functions
+ void FillP(Double_t mass);
+ void Print(Option_t *o = "") const;
+
+ // getters related to charge
+ Bool_t IsPos() const {if (fRef) return (fRef->Charge() > 0); return kFALSE;}
+ Bool_t IsNeg() const {if (fRef) return (fRef->Charge() < 0); return kFALSE;}
+ Bool_t IsCharged() const {if (fRef) return (IsPos() || IsNeg()); return kFALSE;}
+ Bool_t IsNeutral() const {if (fRef) return (!IsCharged()); return kFALSE;}
+ Short_t ChargeS() const {if (IsPos()) return 1 ; else if (IsNeg()) return -1 ; else return 0 ;}
+ Char_t ChargeC() const {if (IsPos()) return '+'; else if (IsNeg()) return '-'; else return '0';}
+
+ // getters which automatically convert refs into allowed types
+ static Bool_t Match(AliVParticle *p, TClass *ref) {if (p) return (p->InheritsFrom(ref)); return kFALSE;}
+ Bool_t MatchRef(TClass *ref) {return Match(fRef, ref);}
+ Bool_t MatchRefMC(TClass *ref) {return Match(fRefMC, ref);}
+ ERefType RefType();
+ Bool_t IsESD();
+ Bool_t IsAOD();
+
+ AliVTrack* Ref2Vtrack() {if (Match(fRef, AliVTrack ::Class())) return static_cast<AliVTrack*> (fRef); return 0x0;}
+ AliESDtrack* Ref2ESDtrack() {if (Match(fRef, AliESDtrack ::Class())) return static_cast<AliESDtrack*> (fRef); return 0x0;}
+ AliAODTrack* Ref2AODtrack() {if (Match(fRef, AliAODTrack ::Class())) return static_cast<AliAODTrack*> (fRef); return 0x0;}
+ AliMCParticle* Ref2MCparticle() {if (Match(fRef, AliMCParticle::Class())) return static_cast<AliMCParticle*> (fRef); return 0x0;}
+ AliAODMCParticle* Ref2AODMCparticle() {if (Match(fRef, AliMCParticle::Class())) return static_cast<AliAODMCParticle*>(fRef); return 0x0;}
+
+ AliESDv0* Ref2ESDv0() {if (Match(fRef, AliESDv0 ::Class())) return static_cast<AliESDv0*>(fRef); return 0x0;}
+ AliAODv0* Ref2AODv0() {if (Match(fRef, AliAODv0 ::Class())) return static_cast<AliAODv0*>(fRef); return 0x0;}
+
+ AliESDcascade* Ref2ESDcascade() {if (Match(fRef, AliESDcascade::Class())) return static_cast<AliESDcascade*>(fRef); return 0x0;}
+ AliAODcascade* Ref2AODcascade() {if (Match(fRef, AliAODcascade::Class())) return static_cast<AliAODcascade*>(fRef); return 0x0;}
+
+ AliMCParticle* RefMC2ESD() {if (Match(fRefMC, AliMCParticle ::Class())) return static_cast<AliMCParticle*> (fRef) ; return 0x0;}
+ AliAODMCParticle* RefMC2AOD() {if (Match(fRefMC, AliAODMCParticle::Class())) return static_cast<AliAODMCParticle*>(fRefMC); return 0x0;}
+
+ // static functions related to internal ESpecies enum
+ static ERefType RefType(ESpecies species);
+ static Bool_t IsCharged(ESpecies species) {return (species <= kProton);}
+ static const char* SpeciesName(ESpecies species);
+ static Int_t SpeciesPDG(ESpecies species);
+ static Double_t SpeciesMass(ESpecies species);
+ static EPARTYPE ToAliPID(ESpecies species);
+ static ESpecies FromAliPID(EPARTYPE species);
+
private:
-
- Char_t fSign; // charge sign
- UShort_t fPDG; // assigned PDG code from PID (0=undefined)
- UShort_t fIndex; // reference index in AliESD container
-
- Double_t fP[3]; // vector momentum
- Double_t fV[3]; // production vertex
- Double_t fMass; // mass
-
- Double_t fPIDwgt[AliPID::kSPECIES]; // particle PID weights
-
- // The following data are useful for simulated events only
- // and can be left blank when using real or 'realistic' data
-
- Int_t fLabel; // GEANT label of corresponding particle
- Short_t fTruePDG; // PDG code of corresponding particle
- Int_t fMother; // GEANT label of mother particle
- Short_t fMotherPDG; // PDG code of mother particle
-
- ClassDef(AliRsnDaughter,1)
+
+ Bool_t fOK; // internal utility flag which is kFALSE when this object should not be used
+ Int_t fLabel; // index of MC particle
+ Int_t fMotherPDG; // PDG code of mother (makes sense only if fRefMC is defined)
+ Int_t fRsnID; // internal ID for monitoring purposes
+
+ TLorentzVector fPrec; // 4-momentum for rec
+ TLorentzVector fPsim; // 4-momentum for MC
+
+ AliVParticle *fRef; // reference to reconstructed object
+ AliVParticle *fRefMC; // reference to corresponding MC particle
+ AliRsnEvent *fOwnerEvent; // pointer to owner event
+
+ ClassDef(AliRsnDaughter, 12)
};
+//__________________________________________________________________________________________________
+inline AliRsnDaughter::ERefType AliRsnDaughter::RefType()
+{
+//
+// Returns the enum value corresponding to the real nature
+// of the object pointed by the fRef data member
+//
+
+ if (Match(fRef, AliESDtrack ::Class())) return kTrack;
+ if (Match(fRef, AliESDv0 ::Class())) return kV0;
+ if (Match(fRef, AliESDcascade::Class())) return kCascade;
+ if (Match(fRef, AliAODTrack ::Class())) return kTrack;
+ if (Match(fRef, AliAODv0 ::Class())) return kV0;
+ if (Match(fRef, AliAODcascade::Class())) return kCascade;
+ if (Match(fRef, AliMCParticle::Class())) return kTrack;
+
+ return kNoType;
+}
+
+//__________________________________________________________________________________________________
+inline Bool_t AliRsnDaughter::IsESD()
+{
+//
+// Tells if the object pointed by fRef data member is ESD
+// NOTE: it is true even when fRef is the MC corresponding
+// object (= AliMCParticle)
+//
+
+ if (Match(fRef, AliESDtrack ::Class())) return kTRUE;
+ if (Match(fRef, AliESDv0 ::Class())) return kTRUE;
+ if (Match(fRef, AliESDcascade::Class())) return kTRUE;
+ if (Match(fRef, AliMCParticle::Class())) return kTRUE;
+
+ return kFALSE;
+}
+
+//__________________________________________________________________________________________________
+inline Bool_t AliRsnDaughter::IsAOD()
+{
+//
+// Tells if the object pointed by fRef data member is AOD
+// NOTE: it is true even when fRef is the MC corresponding
+// object (= AliAODMCParticle)
+//
+
+ if (Match(fRef, AliAODTrack ::Class())) return kTRUE;
+ if (Match(fRef, AliAODv0 ::Class())) return kTRUE;
+ if (Match(fRef, AliAODcascade ::Class())) return kTRUE;
+ if (Match(fRef, AliAODMCParticle::Class())) return kTRUE;
+
+ return kFALSE;
+}
+
+//__________________________________________________________________________________________________
+inline AliRsnDaughter::ERefType AliRsnDaughter::RefType(ESpecies species)
+{
+//
+// Returns the expected object type for a candidate daughter
+// of the given species.
+//
+
+ switch (species) {
+ case kElectron:
+ case kMuon:
+ case kPion:
+ case kKaon:
+ case kProton:
+ return kTrack;
+ case kKaon0:
+ case kLambda:
+ return kV0;
+ case kXi:
+ case kOmega:
+ return kCascade;
+ default:
+ return kNoType;
+ }
+}
+
+//__________________________________________________________________________________________________
+inline void AliRsnDaughter::FillP(Double_t mass)
+{
+//
+// Fills the 4-momentum data member using the values in the
+// AliVParticle pointer data members, choosing according to arguments
+//
+
+ if (fRefMC) fPsim.SetXYZM(fRefMC->Px(), fRefMC->Py(), fRefMC->Pz(), mass);
+ if (fRef) fPrec.SetXYZM(fRef ->Px(), fRef ->Py(), fRef ->Pz(), mass);
+}
+
#endif