Changed scripts for new TrainSetup
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnDaughter.h
CommitLineData
a62a2d82 1#ifndef ALIRSNDAUGHTER_H
2#define ALIRSNDAUGHTER_H
3
7356f978 4//
b63357a0 5// Interface to single daughter candidate.
6// Used for old-version analysis and for
7// selecting tracks in mini package
7356f978 8//
7356f978 9
f34f960b 10#include <TMath.h>
2dab9030 11#include <TLorentzVector.h>
7c2974c8 12
7356f978 13#include "AliPID.h"
5f1c287d 14#include "AliVTrack.h"
4fbb2459 15#include "AliESDtrack.h"
2dab9030 16#include "AliESDv0.h"
32992791 17#include "AliESDcascade.h"
4fbb2459 18#include "AliMCParticle.h"
a378358c 19#include "AliAODTrack.h"
20#include "AliAODv0.h"
32992791 21#include "AliAODcascade.h"
ec927a7d 22#include "AliAODMCParticle.h"
a62a2d82 23
d7712d44 24class AliRsnEvent;
25
2dab9030 26typedef AliPID::EParticleType EPARTYPE;
27
2a1c7696 28class AliRsnDaughter : public TObject {
29public:
30
31 enum ERefType {
d7712d44 32 kTrack,
2dab9030 33 kV0,
32992791 34 kCascade,
2dab9030 35 kNoType
2a1c7696 36 };
61f275d1 37
7356f978 38 enum ESpecies {
39 kElectron,
40 kMuon,
41 kPion,
42 kKaon,
43 kProton,
44 kKaon0,
45 kLambda,
46 kXi,
47 kOmega,
48 kUnknown
49 };
2a1c7696 50
f34f960b 51 AliRsnDaughter() : fOK(kFALSE), fLabel(-1), fMotherPDG(0), fRsnID(-1),
61f275d1 52 fPrec(), fPsim(), fRef(0x0), fRefMC(0x0), fOwnerEvent(0x0) { }
2a1c7696 53 AliRsnDaughter(const AliRsnDaughter &copy);
61f275d1 54 AliRsnDaughter &operator= (const AliRsnDaughter &copy);
5f1c287d 55 virtual ~AliRsnDaughter() { /*empty, since pointers must not be deleted*/ }
2a1c7696 56
f34f960b 57 // basic getters
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;}
61f275d1 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;}
f34f960b 68 Int_t GetPDG();
69 Int_t GetPDGAbs() {return TMath::Abs(GetPDG());}
70 Int_t GetID();
71 Int_t GetMother();
2a1c7696 72
73 // basic setters (for data members)
f34f960b 74 void Reset();
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;}
61f275d1 84
f34f960b 85 // additional functions
86 void FillP(Double_t mass);
87 void Print(Option_t *o = "") const;
61f275d1 88
f34f960b 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';}
61f275d1 96
97 // getters which automatically convert refs into allowed types
f34f960b 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);}
d7712d44 101 ERefType RefType();
102 Bool_t IsESD();
103 Bool_t IsAOD();
f34f960b 104
61f275d1 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;}
110
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;}
113
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;}
116
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;}
119
f34f960b 120 // static functions related to internal ESpecies enum
7356f978 121 static ERefType RefType(ESpecies species);
122 static Bool_t IsCharged(ESpecies species) {return (species <= kProton);}
61f275d1 123 static const char *SpeciesName(ESpecies species);
7356f978 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);
2a1c7696 128
129private:
130
131 Bool_t fOK; // internal utility flag which is kFALSE when this object should not be used
f34f960b 132 Int_t fLabel; // index of MC particle
2a1c7696 133 Int_t fMotherPDG; // PDG code of mother (makes sense only if fRefMC is defined)
7356f978 134 Int_t fRsnID; // internal ID for monitoring purposes
61f275d1 135
f34f960b 136 TLorentzVector fPrec; // 4-momentum for rec
137 TLorentzVector fPsim; // 4-momentum for MC
2a1c7696 138
7356f978 139 AliVParticle *fRef; // reference to reconstructed object
2a1c7696 140 AliVParticle *fRefMC; // reference to corresponding MC particle
d7712d44 141 AliRsnEvent *fOwnerEvent; // pointer to owner event
2a1c7696 142
f34f960b 143 ClassDef(AliRsnDaughter, 12)
a62a2d82 144};
145
f34f960b 146//__________________________________________________________________________________________________
d7712d44 147inline AliRsnDaughter::ERefType AliRsnDaughter::RefType()
148{
149//
150// Returns the enum value corresponding to the real nature
151// of the object pointed by the fRef data member
152//
153
f34f960b 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;
61f275d1 161
d7712d44 162 return kNoType;
163}
164
f34f960b 165//__________________________________________________________________________________________________
d7712d44 166inline Bool_t AliRsnDaughter::IsESD()
167{
168//
169// Tells if the object pointed by fRef data member is ESD
61f275d1 170// NOTE: it is true even when fRef is the MC corresponding
f34f960b 171// object (= AliMCParticle)
d7712d44 172//
173
f34f960b 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;
61f275d1 178
d7712d44 179 return kFALSE;
180}
181
f34f960b 182//__________________________________________________________________________________________________
d7712d44 183inline Bool_t AliRsnDaughter::IsAOD()
184{
185//
186// Tells if the object pointed by fRef data member is AOD
61f275d1 187// NOTE: it is true even when fRef is the MC corresponding
f34f960b 188// object (= AliAODMCParticle)
d7712d44 189//
190
f34f960b 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;
61f275d1 195
d7712d44 196 return kFALSE;
197}
125c0528 198
f34f960b 199//__________________________________________________________________________________________________
200inline AliRsnDaughter::ERefType AliRsnDaughter::RefType(ESpecies species)
201{
202//
203// Returns the expected object type for a candidate daughter
204// of the given species.
205//
206
207 switch (species) {
208 case kElectron:
209 case kMuon:
210 case kPion:
211 case kKaon:
212 case kProton:
213 return kTrack;
214 case kKaon0:
215 case kLambda:
216 return kV0;
217 case kXi:
218 case kOmega:
219 return kCascade;
220 default:
221 return kNoType;
222 }
223}
224
225//__________________________________________________________________________________________________
226inline void AliRsnDaughter::FillP(Double_t mass)
227{
228//
229// Fills the 4-momentum data member using the values in the
230// AliVParticle pointer data members, choosing according to arguments
231//
232
233 if (fRefMC) fPsim.SetXYZM(fRefMC->Px(), fRefMC->Py(), fRefMC->Pz(), mass);
234 if (fRef) fPrec.SetXYZM(fRef ->Px(), fRef ->Py(), fRef ->Pz(), mass);
235}
125c0528 236
a62a2d82 237#endif