Improved numerical stability
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliMCParticle.h
CommitLineData
8168d1ea 1#ifndef ALIMCPARTICLE_H
2#define ALIMCPARTICLE_H
415d9f5c 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
93df0e9b 10// Author: Andreas Morsch, CERN
415d9f5c 11//-------------------------------------------------------------------------
12
13#include <Rtypes.h>
415d9f5c 14#include <TParticle.h>
15#include <TParticlePDG.h>
69fcabe8 16#include <TObjArray.h>
415d9f5c 17
93df0e9b 18#include "AliTrackReference.h"
19#include "AliVParticle.h"
415d9f5c 20
93df0e9b 21class AliMCParticle: public AliVParticle {
415d9f5c 22public:
23 AliMCParticle();
69fcabe8 24 AliMCParticle(TParticle* part, TObjArray* rarray = 0, Int_t label=-1);
f1ac8a97 25 virtual ~AliMCParticle();
415d9f5c 26 AliMCParticle(const AliMCParticle& mcPart);
27 AliMCParticle& operator=(const AliMCParticle& mcPart);
28
93df0e9b 29 // Kinematics
415d9f5c 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;
c683ddc2 35 virtual Bool_t PxPyPz(Double_t p[3]) const;
36
415d9f5c 37 virtual Double_t OneOverPt() const;
38 virtual Double_t Phi() const;
39 virtual Double_t Theta() const;
40
7162633f 41 virtual Double_t Xv() const;
42 virtual Double_t Yv() const;
43 virtual Double_t Zv() const;
c683ddc2 44 virtual Bool_t XvYvZv(Double_t x[3]) const;
5e6a3170 45 virtual Double_t T() const;
c683ddc2 46
eee13e8d 47 virtual Double_t E() const;
48 virtual Double_t M() const;
415d9f5c 49
eee13e8d 50 virtual Double_t Eta() const;
51 virtual Double_t Y() const;
415d9f5c 52
eee13e8d 53 virtual Short_t Charge() const;
54
7162633f 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
415d9f5c 60 // PID
61 virtual const Double_t *PID() const {return 0;} // return PID object (to be defined, still)
93df0e9b 62
63 // Track References
5e6a3170 64 Int_t GetNumberOfTrackReferences() const {return fNTrackRef;}
93df0e9b 65 AliTrackReference* GetTrackReference(Int_t i)
f1ac8a97 66 {return dynamic_cast<AliTrackReference*>((*fTrackReferences)[i]);}
7162633f 67
68 // "Trackable" criteria
56a69855 69 Float_t GetTPCTrackLength(Float_t bz, Float_t ptmin, Int_t &counter, Float_t deadWidth, Float_t zMax=230. );
93836e1b 70 // Navigation
71 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
415d9f5c 79 private:
93df0e9b 80 TParticle *fParticle; // The wrapped TParticle
69fcabe8 81 TObjArray *fTrackReferences; // Array to track references
93df0e9b 82 Int_t fNTrackRef; // Number of track references
eee13e8d 83 Int_t fLabel; // fParticle Label in the Stack
93836e1b 84 Int_t fMother; // Mother particles
85 Int_t fFirstDaughter; // First daughter
86 Int_t fLastDaughter; // LastDaughter
415d9f5c 87
88 ClassDef(AliMCParticle,0) // AliVParticle realisation for MCParticles
89};
90
91inline Double_t AliMCParticle::Px() const {return fParticle->Px();}
92inline Double_t AliMCParticle::Py() const {return fParticle->Py();}
93inline Double_t AliMCParticle::Pz() const {return fParticle->Pz();}
94inline Double_t AliMCParticle::Pt() const {return fParticle->Pt();}
95inline Double_t AliMCParticle::P() const {return fParticle->P(); }
96inline Double_t AliMCParticle::OneOverPt() const {return 1. / fParticle->Pt();}
c683ddc2 97inline Bool_t AliMCParticle::PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
415d9f5c 98inline Double_t AliMCParticle::Phi() const {return fParticle->Phi();}
99inline Double_t AliMCParticle::Theta() const {return fParticle->Theta();}
c683ddc2 100inline Double_t AliMCParticle::Xv() const {return fParticle->Vx();}
101inline Double_t AliMCParticle::Yv() const {return fParticle->Vy();}
102inline Double_t AliMCParticle::Zv() const {return fParticle->Vz();}
103inline Bool_t AliMCParticle::XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
5e6a3170 104inline Double_t AliMCParticle::T() const {return fParticle->T();}
415d9f5c 105inline Double_t AliMCParticle::E() const {return fParticle->Energy();}
106inline Double_t AliMCParticle::Eta() const {return fParticle->Eta();}
107
7162633f 108
415d9f5c 109inline Double_t AliMCParticle::M() const
110{
111 TParticlePDG* pdg = fParticle->GetPDG();
112 if (pdg) {
113 return (pdg->Mass());
114 } else {
115 return (fParticle->GetCalcMass());
116 }
117}
118
119
120inline Double_t AliMCParticle::Y() const
121{
122 Double_t e = E();
6a2ade18 123 Double_t pz = Pz();
124
4529174a 125 if ( TMath::Abs(e - pz) > FLT_EPSILON ) {
415d9f5c 126 return 0.5*TMath::Log((e+pz)/(e-pz));
127 } else {
128 return -999.;
129 }
130}
131
132inline Short_t AliMCParticle::Charge() const
133{
134 TParticlePDG* pdg = fParticle->GetPDG();
135 if (pdg) {
136 return (Short_t (pdg->Charge()));
137 } else {
138 return -99;
139 }
140}
141
eee13e8d 142inline Int_t AliMCParticle::Label() const {return fLabel;}
143
415d9f5c 144#endif