add common abstract interface classes for flat and fat ESDs
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODMCParticle.h
CommitLineData
5d8eaff6 1#ifndef AliAODMCPARTICLE_H
2#define AliAODMCPARTICLE_H
da97a08a 3/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6
7//-------------------------------------------------------------------------
8// AliVParticle realisation for MC Particles in the AOD
9// Stripped dow AliMCParticle
10// Author: Christian Klein Bösing, CERN
11//-------------------------------------------------------------------------
12
13#include <Rtypes.h>
14#include <TParticlePDG.h>
15#include <TExMap.h>
16#include <TString.h>
17
18
19#include "AliTrackReference.h"
20#include "AliVParticle.h"
93836e1b 21#include "AliMCParticle.h"
da97a08a 22
23class AliAODEvent;
24class TParticle;
25class TClonesArray;
26
27class AliAODMCParticle: public AliVParticle {
28 public:
29 AliAODMCParticle();
5e6a3170 30 AliAODMCParticle(const AliMCParticle* part, Int_t label=0,Int_t flag = 0);
da97a08a 31 virtual ~AliAODMCParticle(){};
32 AliAODMCParticle(const AliAODMCParticle& mcPart);
33 AliAODMCParticle& operator=(const AliAODMCParticle& mcPart);
34
35 // Kinematics
36 virtual Double_t Px() const;
37 virtual Double_t Py() const;
38 virtual Double_t Pz() const;
39 virtual Double_t Pt() const;
40 virtual Double_t P() const;
41 virtual Bool_t PxPyPz(Double_t p[3]) const;
42
43 virtual Double_t OneOverPt() const;
44 virtual Double_t Phi() const;
45 virtual Double_t Theta() const;
46
47 virtual Double_t Xv() const;
48 virtual Double_t Yv() const;
49 virtual Double_t Zv() const;
50 virtual Bool_t XvYvZv(Double_t x[3]) const;
0b603250 51 virtual Double_t T() const;
da97a08a 52
53 virtual Double_t E() const;
54 virtual Double_t M() const;
55
56 virtual Double_t Eta() const;
57 virtual Double_t Y() const;
58
59 virtual Short_t Charge() const;
60
0b603250 61 virtual Int_t Label() const;
62 virtual Int_t GetLabel() const {return Label();}
da97a08a 63
64 // PID
65 virtual const Double_t *PID() const {return 0;} // return PID object (to be defined, still)
66
67 //
68 virtual Double_t GetCalcMass() const;
69 virtual void SetDaughter(Int_t i,Int_t id){if(i<2)fDaughter[i] = id;}
32d02725 70 virtual Int_t GetDaughter(Int_t i) const {if(i<2)return fDaughter[i];else return -1;}
71 virtual Int_t GetNDaughters () const { return fDaughter[1]>0 ? fDaughter[1]-fDaughter[0]+1 : (fDaughter[0]>0 ? 1:0 ) ;}
da97a08a 72 virtual void SetMother(Int_t im){fMother = im;}
73 virtual Int_t GetMother() const {return fMother;}
74 virtual void Print(const Option_t *opt = "") const;
75 virtual Int_t GetPdgCode() const { return fPdgCode;}
6a8e543a 76 virtual Int_t PdgCode() const { return GetPdgCode();}
77
6a9d52e4 78 enum { kPrimary = 1<<0, kPhysicalPrim = 1<<1, kSecondaryFromWeakDecay = 1<<2, kSecondaryFromMaterial = 1 <<3}; // use only the first 8bits!
79 void SetFlag(UInt_t flag){fFlag = flag;} // carefull flag encodes three different types of information
6326aeae 80 UInt_t GetFlag() const {return fFlag;}
81
82
83 // for the status we use the upper 16 bits/2 bytes of the flag word
84 void SetStatus(Int_t status){
6a9d52e4 85 if(status<0)return; // a TParticle can have a negative status, catch this here and do nothing
5d8eaff6 86 fFlag &= 0xffff; // reset the upper bins keep the lower bins
87 fFlag |= (((UInt_t)status)<<16); // bit shift by 16
6326aeae 88 }
50ff8c36 89 ULong_t GetStatus() const {
6326aeae 90 // bit shift by 16
50ff8c36 91 return ULong_t(fFlag>>16);
6326aeae 92 }
da97a08a 93
94 // Bitwise operations
95 void SetPrimary(Bool_t b = kTRUE){
96 if(b)fFlag |= kPrimary;
97 else fFlag &= ~kPrimary;
98 }
99 Bool_t IsPrimary() const {return ((fFlag&kPrimary)==kPrimary);}
100
101 void SetPhysicalPrimary(Bool_t b = kTRUE){
102 if(b)fFlag |= kPhysicalPrim;
103 else fFlag &= ~kPhysicalPrim;
104 }
105 Bool_t IsPhysicalPrimary() const {return ((fFlag&kPhysicalPrim)==kPhysicalPrim);}
6a9d52e4 106
107 void SetSecondaryFromWeakDecay(Bool_t b = kTRUE){
108 if(b)fFlag |= kSecondaryFromWeakDecay;
109 else fFlag &= ~kSecondaryFromWeakDecay;
110 }
111 Bool_t IsSecondaryFromWeakDecay() const {return ((fFlag&kSecondaryFromWeakDecay)==kSecondaryFromWeakDecay);}
112
113 void SetSecondaryFromMaterial(Bool_t b = kTRUE){
114 if(b)fFlag |= kSecondaryFromMaterial;
115 else fFlag &= ~kSecondaryFromMaterial;
116 }
117 Bool_t IsSecondaryFromMaterial() const {return ((fFlag&kSecondaryFromMaterial)==kSecondaryFromMaterial);}
118
119
120 void SetMCProcessCode(UInt_t mcProcess){
121 if(mcProcess>1<<7)return; // should not be larger than 46 (see TMCProcess) allow up to 128
122 fFlag &= 0xffff00ff; // keep the upper bins and the lower bins just reset 9-16
123 fFlag |= (mcProcess<<8); // bit shift by 8
124 }
125
126 UInt_t GetMCProcessCode(){
32d02725 127 return ((fFlag&0xff00)>>8); // just return bit shifted bits 9-16
6a9d52e4 128 }
129
130
131
132
133
da97a08a 134 static const char* StdBranchName(){return fgkStdBranchName.Data();}
135
136 private:
137
138 static TString fgkStdBranchName; // Standard branch name
139
140
141 Int_t fPdgCode; // PDG code of the particle
6a9d52e4 142 UInt_t fFlag; // Flag for indication of primary etc, Status code in the upper 16 bits 17-32, MC process id (AKA UniqueID) in bins 16-9)
da97a08a 143 Int_t fLabel; // Label of the original MCParticle
144 Int_t fMother; // Index of the mother particles
145 Int_t fDaughter[2]; // Indices of the daughter particles
1d8ad855 146 Double32_t fPx; // x component of momentum
147 Double32_t fPy; // y component of momentum
148 Double32_t fPz; // z component of momentum
9ce038a5 149 Double32_t fE; // Energy
da97a08a 150
151 Double32_t fVx; // [0.,0.,12] x of production vertex
152 Double32_t fVy; // [0.,0.,12] y of production vertex
153 Double32_t fVz; // [0.,0.,12] z of production vertex
0b603250 154 Double32_t fVt; // [0.,0.,12] t of production vertex
da97a08a 155
156 // Copy the uniquID to another data member? unique ID is correctly handled
157 // via TOBject Copy construct but not by AliVParticle ctor (no passing of
6326aeae 158 // TParticles
da97a08a 159 // Need a flag for primaries?
160
161 /*
162 const TMCProcess kMCprocesses[kMaxMCProcess] =
163 {
164 kPNoProcess, kPMultipleScattering, kPEnergyLoss, kPMagneticFieldL,
165 kPDecay, kPPair, kPCompton, kPPhotoelectric, kPBrem, kPDeltaRay,
166 kPAnnihilation, kPHadronic, kPNoProcess, kPEvaporation, kPNuclearFission,
167 kPNuclearAbsorption, kPPbarAnnihilation, kPNCapture, kPHElastic,
168 kPHInhelastic, kPMuonNuclear, kPTOFlimit,kPPhotoFission, kPNoProcess,
169 kPRayleigh, kPNoProcess, kPNoProcess, kPNoProcess, kPNull, kPStop
170 };
171 */
172
32d02725 173 ClassDef(AliAODMCParticle,7) // AliVParticle realisation for AODMCParticles
da97a08a 174
175};
176
177inline Double_t AliAODMCParticle::Px() const {return fPx;}
178inline Double_t AliAODMCParticle::Py() const {return fPy;}
179inline Double_t AliAODMCParticle::Pz() const {return fPz;}
180inline Double_t AliAODMCParticle::Pt() const {return TMath::Sqrt(fPx*fPx+fPy*fPy);}
181inline Double_t AliAODMCParticle::P() const {return TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz); }
182inline Double_t AliAODMCParticle::OneOverPt() const {return 1. / Pt();}
183inline Bool_t AliAODMCParticle::PxPyPz(Double_t p[3]) const { p[0] = fPx; p[1] = fPy; p[2] = fPz; return kTRUE; }
0b603250 184inline Double_t AliAODMCParticle::Phi() const {return TMath::Pi()+TMath::ATan2(-fPy,-fPx); } // note that Phi() returns an angle between 0 and 2pi
185inline Double_t AliAODMCParticle::Theta() const {return (fPz==0)?TMath::PiOver2():TMath::ACos(fPz/P()); }
da97a08a 186inline Double_t AliAODMCParticle::Xv() const {return fVx;}
187inline Double_t AliAODMCParticle::Yv() const {return fVy;}
188inline Double_t AliAODMCParticle::Zv() const {return fVz;}
189inline Bool_t AliAODMCParticle::XvYvZv(Double_t x[3]) const { x[0] = fVx; x[1] = fVy; x[2] = fVz; return kTRUE; }
0b603250 190inline Double_t AliAODMCParticle::T() const {return fVt;}
da97a08a 191inline Double_t AliAODMCParticle::E() const {return fE;}
192inline Double_t AliAODMCParticle::Eta() const {
193 Double_t pmom = P();
194 if (pmom != TMath::Abs(fPz)) return 0.5*TMath::Log((pmom+fPz)/(pmom-fPz));
195 else return 1.e30;
196}
197
198
199inline Double_t AliAODMCParticle::Y() const
200{
201 Double_t e = E();
202 Double_t pz = Pz();
203
5e5ebe83 204 if (e > TMath::Abs(pz)) {
da97a08a 205 return 0.5*TMath::Log((e+pz)/(e-pz));
206 } else {
207 return -999.;
208 }
209}
210
211inline Int_t AliAODMCParticle::Label() const {return fLabel;}
212
213inline Double_t AliAODMCParticle::GetCalcMass() const {
214
215 Double_t m2 = E()*E()-Px()*Px()-Py()*Py()-Pz()*Pz();
216 if(m2<0)return 0;
217 return TMath::Sqrt(m2);
218}
219
220
221#endif