]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliMCParticle.h
SetFlag GetFlag lifted to interface
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliMCParticle.h
1 #ifndef ALIMCPARTICLE_H
2 #define ALIMCPARTICLE_H
3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //-------------------------------------------------------------------------
9 //     AliVParticle realisation for MC Particles
10 //     Author: Andreas Morsch, CERN
11 //-------------------------------------------------------------------------
12
13 #include <Rtypes.h>
14 #include <TParticle.h>
15 #include <TParticlePDG.h>
16 #include <TObjArray.h>
17
18 #include "AliTrackReference.h"
19 #include "AliVParticle.h"
20
21 class AliMCParticle: public AliVParticle {
22 public:
23     AliMCParticle();
24     AliMCParticle(TParticle* part, TObjArray* rarray = 0, Int_t label=-1);
25     virtual ~AliMCParticle();
26     AliMCParticle(const AliMCParticle& mcPart); 
27     AliMCParticle& operator=(const AliMCParticle& mcPart);
28     
29     // Kinematics
30     virtual Double_t Px()        const;
31     virtual Double_t Py()        const;
32     virtual Double_t Pz()        const;
33     virtual Double_t Pt()        const;
34     virtual Double_t P()         const;
35     virtual Bool_t   PxPyPz(Double_t p[3]) const;
36    
37     virtual Double_t OneOverPt() const;
38     virtual Double_t Phi()       const;
39     virtual Double_t Theta()     const;
40     
41     virtual Double_t Xv()        const;
42     virtual Double_t Yv()        const;
43     virtual Double_t Zv()        const;
44     virtual Bool_t   XvYvZv(Double_t x[3]) const;  
45     virtual Double_t T()         const;
46
47     virtual Double_t E()          const;
48     virtual Double_t M()          const;
49     
50     virtual Double_t Eta()        const;
51     virtual Double_t Y()          const;
52     
53     virtual Short_t Charge()      const;
54
55     virtual Int_t    Label()         const;
56     virtual Int_t    GetLabel()      const {return Label();}
57     virtual Int_t    PdgCode()       const {return fParticle->GetPdgCode();}
58     virtual TParticle* Particle() const {return fParticle;}
59     
60     // PID
61     virtual const Double_t *PID() const {return 0;} // return PID object (to be defined, still)
62
63     // Track References
64     Int_t              GetNumberOfTrackReferences() const {return fNTrackRef;}
65     AliTrackReference* GetTrackReference(Int_t i)
66       {return dynamic_cast<AliTrackReference*>((*fTrackReferences)[i]);}
67
68     // "Trackable" criteria
69     Float_t  GetTPCTrackLength(Float_t bz, Float_t ptmin, Int_t &counter, Float_t deadWidth, Float_t zMax=230. );
70     // Navigation
71     virtual Int_t GetMother()        const {return fMother;}
72     Int_t GetFirstDaughter() const {return fFirstDaughter;}
73     Int_t GetLastDaughter()  const {return fLastDaughter;}
74     void  SetMother(Int_t idx)        {fMother        = idx;}
75     void  SetFirstDaughter(Int_t idx) {fFirstDaughter = idx;}
76     void  SetLastDaughter(Int_t idx)  {fLastDaughter  = idx;}
77     void  SetLabel(Int_t label)       {fLabel         = label;}
78     virtual void    SetGeneratorIndex(Short_t i) {fGeneratorIndex = i;}
79     virtual Short_t GetGeneratorIndex() const {return fGeneratorIndex;}
80     
81  private:
82     TParticle *fParticle;             // The wrapped TParticle
83     TObjArray *fTrackReferences;      // Array to track references
84     Int_t      fNTrackRef;            // Number of track references
85     Int_t      fLabel;                // fParticle Label in the Stack
86     Int_t      fMother;               // Mother particles
87     Int_t      fFirstDaughter;        // First daughter
88     Int_t      fLastDaughter;         // LastDaughter
89     Short_t    fGeneratorIndex;       // !Generator index in cocktail  
90   ClassDef(AliMCParticle,0)  // AliVParticle realisation for MCParticles
91 };
92
93 inline Double_t AliMCParticle::Px()        const {return fParticle->Px();}
94 inline Double_t AliMCParticle::Py()        const {return fParticle->Py();}
95 inline Double_t AliMCParticle::Pz()        const {return fParticle->Pz();}
96 inline Double_t AliMCParticle::Pt()        const {return fParticle->Pt();}
97 inline Double_t AliMCParticle::P()         const {return fParticle->P(); }
98 inline Double_t AliMCParticle::OneOverPt() const {return 1. / fParticle->Pt();}
99 inline Bool_t   AliMCParticle::PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
100 inline Double_t AliMCParticle::Phi()       const {return fParticle->Phi();}
101 inline Double_t AliMCParticle::Theta()     const {return fParticle->Theta();}
102 inline Double_t AliMCParticle::Xv()        const {return fParticle->Vx();}
103 inline Double_t AliMCParticle::Yv()        const {return fParticle->Vy();}
104 inline Double_t AliMCParticle::Zv()        const {return fParticle->Vz();}
105 inline Bool_t   AliMCParticle::XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
106 inline Double_t AliMCParticle::T()        const {return fParticle->T();}
107 inline Double_t AliMCParticle::E()         const {return fParticle->Energy();}
108 inline Double_t AliMCParticle::Eta()       const {return fParticle->Eta();}
109
110
111 inline Double_t AliMCParticle::M()         const
112 {
113     TParticlePDG* pdg = fParticle->GetPDG();
114     if (pdg) {
115         return (pdg->Mass());
116     } else {
117         return (fParticle->GetCalcMass());
118     }
119 }
120
121
122 inline Double_t AliMCParticle::Y()         const 
123 {
124     Double_t e  = E();
125     Double_t pz = Pz();
126     
127     if ( TMath::Abs(e - TMath::Abs(pz)) > FLT_EPSILON ) {
128         return 0.5*TMath::Log((e+pz)/(e-pz));
129     } else { 
130         return -999.;
131     }
132 }
133
134 inline Short_t AliMCParticle::Charge()     const
135 {
136     TParticlePDG* pdg = fParticle->GetPDG();
137     if (pdg) {
138         return (Short_t (pdg->Charge()));
139     } else {
140         return -99;
141     }
142 }
143
144 inline Int_t AliMCParticle::Label()       const {return fLabel;}
145
146 #endif