]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnDaughter.h
Implementation of all needed changes in the package in order to speed-up the executio...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.h
1 #ifndef ALIRSNDAUGHTER_H
2 #define ALIRSNDAUGHTER_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6  
7 //
8 //  Interface to single daughter candidate.
9 //
10
11 #include <TLorentzVector.h>
12
13 #include "AliPID.h"
14 #include "AliVTrack.h"
15 #include "AliESDtrack.h"
16 #include "AliESDv0.h"
17 #include "AliESDcascade.h"
18 #include "AliMCParticle.h"
19 #include "AliAODTrack.h"
20 #include "AliAODv0.h"
21 #include "AliAODcascade.h"
22 #include "AliAODMCParticle.h"
23
24 class AliRsnEvent;
25
26 typedef AliPID::EParticleType EPARTYPE;
27
28 class AliRsnDaughter : public TObject {
29 public:
30
31    enum ERefType {
32       kTrack,
33       kV0,
34       kCascade,
35       kNoType
36    };
37    
38    enum ESpecies {
39       kElectron,
40       kMuon,
41       kPion,
42       kKaon,
43       kProton,
44       kKaon0,
45       kLambda,
46       kXi,
47       kOmega,
48       kUnknown
49    };
50
51    AliRsnDaughter();
52    AliRsnDaughter(const AliRsnDaughter &copy);
53    AliRsnDaughter& operator= (const AliRsnDaughter& copy);
54    virtual ~AliRsnDaughter() { /*empty, since pointers must not be deleted*/ }
55
56    // basic getters (for data members)
57    Bool_t          IsOK()         const {return fOK;}
58    Int_t           GetLabel()     const {return fLabel;}
59    Int_t           GetMotherPDG() const {return fMotherPDG;}
60    Int_t           GetRsnID()     const {return fRsnID;}
61    TLorentzVector& Prec()               {return fPrec;}
62    TLorentzVector& Psim()               {return fPsim;}
63    TLorentzVector& P(Bool_t mc)         {return (mc ? fPsim : fPrec);}
64    AliVParticle*   GetRef()             {return fRef;}
65    AliVParticle*   GetRefMC()           {return fRefMC;}
66    AliRsnEvent*    GetOwnerEvent()      {return fOwnerEvent;}
67
68    // basic setters (for data members)
69    void    SetBad()                      {fOK = kFALSE;}
70    void    SetGood()                     {fOK = kTRUE;}
71    void    SetLabel(Int_t label)         {fLabel = label;}
72    void    SetRsnID(Int_t id)            {fRsnID = id;}
73    void    SetMotherPDG(Int_t value)     {fMotherPDG = value;}
74    void    SetOwnerEvent(AliRsnEvent *e) {fOwnerEvent = e;}
75    void    SetRef(AliVParticle *p);
76    void    SetRefMC(AliVParticle *p);
77    void    SetMass(Double_t mass)        {fPsim.SetVectM(fPsim.Vect(), mass); fPrec.SetVectM(fPrec.Vect(), mass);}
78    
79    // utilities
80    void    Reset();
81    Int_t   GetPDG(Bool_t abs = kTRUE);
82    Int_t   GetID();
83    Bool_t  IsKinkDaughter();
84    Bool_t  IsPos()             const {if (fRef) return (fRef->Charge() > 0); return kFALSE;}
85    Bool_t  IsNeg()             const {if (fRef) return (fRef->Charge() < 0); return kFALSE;}
86    Bool_t  IsNeutral()         const {if (fRef) return (!IsPos() && !IsNeg()); return kFALSE;}
87    Bool_t  IsSign(Char_t sign) const {if (sign == '+') return IsPos(); else if (sign == '-') return IsNeg(); else return IsNeutral();}
88    Short_t ChargeS()           const {if (IsPos()) return  1 ; else if (IsNeg()) return -1 ; else return  0 ;}
89    Char_t  ChargeC()           const {if (IsPos()) return '+'; else if (IsNeg()) return '-'; else return '0';}
90    void    Print(Option_t *o="") const;
91
92    // getters which automatically convert refs into allowed types
93    AliVTrack*        GetRefVtrack()     {if (ClassMatchRef  (AliVTrack       ::Class())) return static_cast<AliVTrack*>       (fRef)  ; return 0x0;}
94    AliESDtrack*      GetRefESDtrack()   {if (ClassMatchRef  (AliESDtrack     ::Class())) return static_cast<AliESDtrack*>     (fRef)  ; return 0x0;}
95    AliESDv0*         GetRefESDv0()      {if (ClassMatchRef  (AliESDv0        ::Class())) return static_cast<AliESDv0*>        (fRef)  ; return 0x0;}
96    AliESDcascade*    GetRefESDcascade() {if (ClassMatchRef  (AliESDcascade   ::Class())) return static_cast<AliESDcascade*>   (fRef)  ; return 0x0;}
97    AliAODTrack*      GetRefAODtrack()   {if (ClassMatchRef  (AliAODTrack     ::Class())) return static_cast<AliAODTrack*>     (fRef)  ; return 0x0;}
98    AliAODv0*         GetRefAODv0()      {if (ClassMatchRef  (AliAODv0        ::Class())) return static_cast<AliAODv0*>        (fRef)  ; return 0x0;}
99    AliAODcascade*    GetRefAODcascade() {if (ClassMatchRef  (AliAODcascade   ::Class())) return static_cast<AliAODcascade*>   (fRef)  ; return 0x0;}
100    AliMCParticle*    GetRefMCtrack()    {if (ClassMatchRef  (AliMCParticle   ::Class())) return static_cast<AliMCParticle*>   (fRef)  ; return 0x0;}
101    AliMCParticle*    GetRefMCESD()      {if (ClassMatchRefMC(AliMCParticle   ::Class())) return static_cast<AliMCParticle*>   (fRefMC); return 0x0;}
102    AliAODMCParticle* GetRefMCAOD()      {if (ClassMatchRefMC(AliAODMCParticle::Class())) return static_cast<AliAODMCParticle*>(fRefMC); return 0x0;}
103    Bool_t            ClassMatchRef  (TClass *ref) {if (fRef  ) return (fRef  ->InheritsFrom(ref)); return kFALSE;}
104    Bool_t            ClassMatchRefMC(TClass *ref) {if (fRefMC) return (fRefMC->InheritsFrom(ref)); return kFALSE;}
105    ERefType          RefType();
106    Bool_t            IsESD();
107    Bool_t            IsAOD();
108    Bool_t            IsPureMC() {return (!IsESD() && !IsAOD());}
109    
110    // static utilities
111    static ERefType    RefType(ESpecies species);
112    static Bool_t      IsCharged(ESpecies species) {return (species <= kProton);}
113    static const char* SpeciesName(ESpecies species);
114    static Int_t       SpeciesPDG(ESpecies species);
115    static Double_t    SpeciesMass(ESpecies species);
116    static EPARTYPE    ToAliPID(ESpecies species);
117    static ESpecies    FromAliPID(EPARTYPE species);
118
119 private:
120
121    Bool_t         fOK;          // internal utility flag which is kFALSE when this object should not be used
122    Int_t          fLabel;       // GEANT label of corresponding MC particle
123    Int_t          fMotherPDG;   // PDG code of mother (makes sense only if fRefMC is defined)
124    Int_t          fRsnID;       // internal ID for monitoring purposes
125
126    TLorentzVector fPrec;        // 4-vector filled with track info from default ref (if present)
127    TLorentzVector fPsim;        // 4-vector filled with track info from MC ref (if present)
128
129    AliVParticle  *fRef;         // reference to reconstructed object
130    AliVParticle  *fRefMC;       // reference to corresponding MC particle
131    AliRsnEvent   *fOwnerEvent;  // pointer to owner event
132
133    ClassDef(AliRsnDaughter, 10)
134 };
135
136 inline AliRsnDaughter::ERefType AliRsnDaughter::RefType()
137 {
138 //
139 // Returns the enum value corresponding to the real nature
140 // of the object pointed by the fRef data member
141 //
142
143    if (ClassMatchRef(AliESDtrack  ::Class())) return kTrack;
144    if (ClassMatchRef(AliESDv0     ::Class())) return kV0;
145    if (ClassMatchRef(AliESDcascade::Class())) return kCascade;
146    if (ClassMatchRef(AliAODTrack  ::Class())) return kTrack;
147    if (ClassMatchRef(AliAODv0     ::Class())) return kV0;
148    if (ClassMatchRef(AliAODcascade::Class())) return kCascade;
149    if (ClassMatchRef(AliMCParticle::Class())) return kTrack;
150    
151    return kNoType;
152 }
153
154 inline Bool_t AliRsnDaughter::IsESD()
155 {
156 //
157 // Tells if the object pointed by fRef data member is ESD
158 //
159
160    if (ClassMatchRef(AliESDtrack  ::Class())) return kTRUE;
161    if (ClassMatchRef(AliESDv0     ::Class())) return kTRUE;
162    if (ClassMatchRef(AliESDcascade::Class())) return kTRUE;
163    
164    return kFALSE;
165 }
166
167 inline Bool_t AliRsnDaughter::IsAOD()
168 {
169 //
170 // Tells if the object pointed by fRef data member is AOD
171 //
172
173    if (ClassMatchRef(AliAODTrack  ::Class())) return kTRUE;
174    if (ClassMatchRef(AliAODv0     ::Class())) return kTRUE;
175    if (ClassMatchRef(AliAODcascade::Class())) return kTRUE;
176    
177    return kFALSE;
178 }
179
180
181 #endif