Update master to aliroot
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODMCParticle.cxx
CommitLineData
da97a08a 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17//-------------------------------------------------------------------------
18// Realisation of AliVParticle for MC Particles
19// Basically a stripped down AliMCParicle / TParticle
20// with minimum information on MC tracks
21// Author: Christian Klein-Bösing, CERN
22//-------------------------------------------------------------------------
23
24
25#include "AliAODMCParticle.h"
26#include "AliAODEvent.h"
27
28#include "TDatabasePDG.h"
29#include "TParticle.h"
30#include "TClonesArray.h"
31
32
33ClassImp(AliAODMCParticle)
34
35TString AliAODMCParticle::fgkStdBranchName("mcparticles");
36
37AliAODMCParticle::AliAODMCParticle():
38AliVParticle(),
39 fPdgCode(0),
40 fFlag(0),
41 fLabel(0),
42 fMother(0),
43 fPx(0),
44 fPy(0),
45 fPz(0),
46 fE(0),
47 fVx(0),
48 fVy(0),
0b603250 49 fVz(0),
11762dd0 50 fVt(0),
51 fGeneratorIndex(-1)
da97a08a 52{
53 // Default Constructor
54 fDaughter[0] = fDaughter[1] = 0;
55}
56
57
5e6a3170 58AliAODMCParticle::AliAODMCParticle(const AliMCParticle* mcpart, Int_t label,Int_t flag):
e0ff5909 59 AliVParticle(*mcpart),
93836e1b 60 fPdgCode(mcpart->Particle()->GetPdgCode()),
da97a08a 61 fFlag(flag),
62 fLabel(label),
93836e1b 63 fMother(mcpart->GetMother()),
64 fPx(mcpart->Particle()->Px()),
65 fPy(mcpart->Particle()->Py()),
66 fPz(mcpart->Particle()->Pz()),
67 fE(mcpart->Particle()->Energy()),
68 fVx(mcpart->Particle()->Vx()),
69 fVy(mcpart->Particle()->Vy()),
0b603250 70 fVz(mcpart->Particle()->Vz()),
11762dd0 71 fVt(mcpart->Particle()->T()),
72 fGeneratorIndex(mcpart->GetGeneratorIndex())
da97a08a 73{
5e6a3170 74 // Constructor
93836e1b 75 fDaughter[0] = mcpart->GetFirstDaughter();
76 fDaughter[1] = mcpart->GetLastDaughter();
da97a08a 77}
78
79
80AliAODMCParticle::AliAODMCParticle(const AliAODMCParticle& mcPart) :
81 AliVParticle(mcPart),
82 fPdgCode(mcPart.fPdgCode),
83 fFlag(mcPart.fFlag),
84 fLabel(mcPart.fLabel),
85 fMother(mcPart.fMother),
86 fPx(mcPart.fPx),
87 fPy(mcPart.fPy),
88 fPz(mcPart.fPz),
89 fE(mcPart.fE),
90 fVx(mcPart.fVx),
91 fVy(mcPart.fVy),
0b603250 92 fVz(mcPart.fVz),
11762dd0 93 fVt(mcPart.fVt),
94 fGeneratorIndex(-1)
da97a08a 95{
96 // Copy constructor
97 fDaughter[0] = mcPart.fDaughter[0];
98 fDaughter[1] = mcPart.fDaughter[1];
da97a08a 99}
100
101AliAODMCParticle& AliAODMCParticle::operator=(const AliAODMCParticle& mcPart)
102{
5d8eaff6 103 //
104 // assignment operator
105 //
da97a08a 106 if (this!=&mcPart) {
107 AliVParticle::operator=(mcPart);
108 fPdgCode = mcPart.fPdgCode;
109 fFlag = mcPart.fFlag;
110 fLabel = mcPart.fLabel;
111 fMother = mcPart.fMother;
112 fPx = mcPart.fPx;
113 fPy = mcPart.fPy;
114 fPz = mcPart.fPz;
115 fE = mcPart.fE;
116 fVx = mcPart.fVx;
117 fVy = mcPart.fVy;
118 fVz = mcPart.fVz;
0b603250 119 fVt = mcPart.fVt;
11762dd0 120 fGeneratorIndex = mcPart.fGeneratorIndex;
da97a08a 121 fDaughter[0] = mcPart.fDaughter[0];
122 fDaughter[1] = mcPart.fDaughter[1];
123 }
124
125 return *this;
126
127}
128
129Double_t AliAODMCParticle::M() const
130{
5d8eaff6 131 //
132 // return the mass
133 //
da97a08a 134 TParticlePDG* pdg = TDatabasePDG::Instance()->GetParticle(fPdgCode);
135 if (pdg) {
136 return (pdg->Mass());
137 } else {
138 return GetCalcMass();
139 }
140}
141
142
143Short_t AliAODMCParticle::Charge() const
144{
5d8eaff6 145 //
146 // return tha charge
147 //
da97a08a 148 TParticlePDG* pdg = TDatabasePDG::Instance()->GetParticle(fPdgCode);
149 if (pdg) {
150 return (Short_t (pdg->Charge()));
151 } else {
152 return -99;
153 }
154}
155
24ae0874 156void AliAODMCParticle::Print(const Option_t */*opt*/) const {
5e6a3170 157// Print particle information
da97a08a 158 if(TDatabasePDG::Instance()->GetParticle(fPdgCode)){
159 Printf(">>> PDG (%d) : %s",fPdgCode,TDatabasePDG::Instance()->GetParticle(fPdgCode)->GetName());
160 }
161 else{
162 Printf(">>> PDG (%d) : %s",fPdgCode,"Unknown");
163 }
0b603250 164 Printf(">> P(%3.3f,%3.3f,%3.3f) V((%3.3f,%3.3f,%3.3f,%3.3f)",fPx,fPy,fPz,fVx,fVy,fVz,fVt);
6326aeae 165 Printf("> Mother %d, First Daughter %d Last Daughter %d , Status %d, PhysicalPrimary %d",
166 fMother,fDaughter[0],fDaughter[1],GetStatus(),
167 IsPhysicalPrimary());
da97a08a 168}