1 #ifndef ALIRSNDAUGHTER_H
2 #define ALIRSNDAUGHTER_H
5 // Interface to single daughter candidate.
6 // Used for old-version analysis and for
7 // selecting tracks in mini package
11 #include <TLorentzVector.h>
14 #include "AliVTrack.h"
15 #include "AliESDtrack.h"
17 #include "AliESDcascade.h"
18 #include "AliMCParticle.h"
19 #include "AliAODTrack.h"
21 #include "AliAODcascade.h"
22 #include "AliAODMCParticle.h"
26 typedef AliPID::EParticleType EPARTYPE;
28 class AliRsnDaughter : public TObject {
51 AliRsnDaughter() : fOK(kFALSE), fLabel(-1), fMotherPDG(0), fRsnID(-1),
52 fPrec(), fPsim(), fRef(0x0), fRefMC(0x0), fOwnerEvent(0x0) { }
53 AliRsnDaughter(const AliRsnDaughter ©);
54 AliRsnDaughter &operator= (const AliRsnDaughter ©);
55 virtual ~AliRsnDaughter() { /*empty, since pointers must not be deleted*/ }
58 Bool_t IsOK() const {return fOK;}
59 Int_t GetLabel() const {return fLabel;}
60 Int_t GetMotherPDG() const {return fMotherPDG;}
61 Int_t GetRsnID() const {return fRsnID;}
62 AliVParticle *GetRef() {return fRef;}
63 AliVParticle *GetRefMC() {return fRefMC;}
64 AliRsnEvent *GetOwnerEvent() {return fOwnerEvent;}
65 TLorentzVector &P(Bool_t mc) {return (mc ? fPsim : fPrec);}
66 TLorentzVector &Prec() {return fPrec;}
67 TLorentzVector &Psim() {return fPsim;}
69 Int_t GetPDGAbs() {return TMath::Abs(GetPDG());}
73 // basic setters (for data members)
75 void SetOK(Bool_t ok) {fOK = ok;}
76 void SetBad() {fOK = kFALSE;}
77 void SetGood() {fOK = kTRUE;}
78 void SetLabel(Int_t label) {fLabel = label;}
79 void SetMotherPDG(Int_t value) {fMotherPDG = value;}
80 void SetRsnID(Int_t id) {fRsnID = id;}
81 void SetRef(AliVParticle *p) {fRef = p;}
82 void SetRefMC(AliVParticle *p) {fRefMC = p;}
83 void SetOwnerEvent(AliRsnEvent *e) {fOwnerEvent = e;}
85 // additional functions
86 void FillP(Double_t mass);
87 void Print(Option_t *o = "") const;
89 // getters related to charge
90 Bool_t IsPos() const {if (fRef) return (fRef->Charge() > 0); return kFALSE;}
91 Bool_t IsNeg() const {if (fRef) return (fRef->Charge() < 0); return kFALSE;}
92 Bool_t IsCharged() const {if (fRef) return (IsPos() || IsNeg()); return kFALSE;}
93 Bool_t IsNeutral() const {if (fRef) return (!IsCharged()); return kFALSE;}
94 Short_t ChargeS() const {if (IsPos()) return 1 ; else if (IsNeg()) return -1 ; else return 0 ;}
95 Char_t ChargeC() const {if (IsPos()) return '+'; else if (IsNeg()) return '-'; else return '0';}
97 // getters which automatically convert refs into allowed types
98 static Bool_t Match(AliVParticle *p, TClass *ref) {if (p) return (p->InheritsFrom(ref)); return kFALSE;}
99 Bool_t MatchRef(TClass *ref) {return Match(fRef, ref);}
100 Bool_t MatchRefMC(TClass *ref) {return Match(fRefMC, ref);}
105 AliVTrack *Ref2Vtrack() {if (Match(fRef, AliVTrack ::Class())) return static_cast<AliVTrack *> (fRef); return 0x0;}
106 AliESDtrack *Ref2ESDtrack() {if (Match(fRef, AliESDtrack ::Class())) return static_cast<AliESDtrack *> (fRef); return 0x0;}
107 AliAODTrack *Ref2AODtrack() {if (Match(fRef, AliAODTrack ::Class())) return static_cast<AliAODTrack *> (fRef); return 0x0;}
108 AliMCParticle *Ref2MCparticle() {if (Match(fRef, AliMCParticle::Class())) return static_cast<AliMCParticle *> (fRef); return 0x0;}
109 AliAODMCParticle *Ref2AODMCparticle() {if (Match(fRef, AliMCParticle::Class())) return static_cast<AliAODMCParticle *>(fRef); return 0x0;}
111 AliESDv0 *Ref2ESDv0() {if (Match(fRef, AliESDv0 ::Class())) return static_cast<AliESDv0 *>(fRef); return 0x0;}
112 AliAODv0 *Ref2AODv0() {if (Match(fRef, AliAODv0 ::Class())) return static_cast<AliAODv0 *>(fRef); return 0x0;}
114 AliESDcascade *Ref2ESDcascade() {if (Match(fRef, AliESDcascade::Class())) return static_cast<AliESDcascade *>(fRef); return 0x0;}
115 AliAODcascade *Ref2AODcascade() {if (Match(fRef, AliAODcascade::Class())) return static_cast<AliAODcascade *>(fRef); return 0x0;}
117 AliMCParticle *RefMC2ESD() {if (Match(fRefMC, AliMCParticle ::Class())) return static_cast<AliMCParticle *> (fRef) ; return 0x0;}
118 AliAODMCParticle *RefMC2AOD() {if (Match(fRefMC, AliAODMCParticle::Class())) return static_cast<AliAODMCParticle *>(fRefMC); return 0x0;}
120 // static functions related to internal ESpecies enum
121 static ERefType RefType(ESpecies species);
122 static Bool_t IsCharged(ESpecies species) {return (species <= kProton);}
123 static const char *SpeciesName(ESpecies species);
124 static Int_t SpeciesPDG(ESpecies species);
125 static Double_t SpeciesMass(ESpecies species);
126 static EPARTYPE ToAliPID(ESpecies species);
127 static ESpecies FromAliPID(EPARTYPE species);
131 Bool_t fOK; // internal utility flag which is kFALSE when this object should not be used
132 Int_t fLabel; // index of MC particle
133 Int_t fMotherPDG; // PDG code of mother (makes sense only if fRefMC is defined)
134 Int_t fRsnID; // internal ID for monitoring purposes
136 TLorentzVector fPrec; // 4-momentum for rec
137 TLorentzVector fPsim; // 4-momentum for MC
139 AliVParticle *fRef; // reference to reconstructed object
140 AliVParticle *fRefMC; // reference to corresponding MC particle
141 AliRsnEvent *fOwnerEvent; // pointer to owner event
143 ClassDef(AliRsnDaughter, 12)
146 //__________________________________________________________________________________________________
147 inline AliRsnDaughter::ERefType AliRsnDaughter::RefType()
150 // Returns the enum value corresponding to the real nature
151 // of the object pointed by the fRef data member
154 if (Match(fRef, AliESDtrack ::Class())) return kTrack;
155 if (Match(fRef, AliESDv0 ::Class())) return kV0;
156 if (Match(fRef, AliESDcascade::Class())) return kCascade;
157 if (Match(fRef, AliAODTrack ::Class())) return kTrack;
158 if (Match(fRef, AliAODv0 ::Class())) return kV0;
159 if (Match(fRef, AliAODcascade::Class())) return kCascade;
160 if (Match(fRef, AliMCParticle::Class())) return kTrack;
165 //__________________________________________________________________________________________________
166 inline Bool_t AliRsnDaughter::IsESD()
169 // Tells if the object pointed by fRef data member is ESD
170 // NOTE: it is true even when fRef is the MC corresponding
171 // object (= AliMCParticle)
174 if (Match(fRef, AliESDtrack ::Class())) return kTRUE;
175 if (Match(fRef, AliESDv0 ::Class())) return kTRUE;
176 if (Match(fRef, AliESDcascade::Class())) return kTRUE;
177 if (Match(fRef, AliMCParticle::Class())) return kTRUE;
182 //__________________________________________________________________________________________________
183 inline Bool_t AliRsnDaughter::IsAOD()
186 // Tells if the object pointed by fRef data member is AOD
187 // NOTE: it is true even when fRef is the MC corresponding
188 // object (= AliAODMCParticle)
191 if (Match(fRef, AliAODTrack ::Class())) return kTRUE;
192 if (Match(fRef, AliAODv0 ::Class())) return kTRUE;
193 if (Match(fRef, AliAODcascade ::Class())) return kTRUE;
194 if (Match(fRef, AliAODMCParticle::Class())) return kTRUE;
199 //__________________________________________________________________________________________________
200 inline AliRsnDaughter::ERefType AliRsnDaughter::RefType(ESpecies species)
203 // Returns the expected object type for a candidate daughter
204 // of the given species.
225 //__________________________________________________________________________________________________
226 inline void AliRsnDaughter::FillP(Double_t mass)
229 // Fills the 4-momentum data member using the values in the
230 // AliVParticle pointer data members, choosing according to arguments
233 if (fRefMC) fPsim.SetXYZM(fRefMC->Px(), fRefMC->Py(), fRefMC->Pz(), mass);
234 if (fRef) fPrec.SetXYZM(fRef ->Px(), fRef ->Py(), fRef ->Pz(), mass);