]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TUHKMgen/UHKM/Particle.cxx
coverity bug fix
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / Particle.cxx
CommitLineData
03896fc4 1//
2//
3// Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
4// amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru
5// November. 2, 2005
6//
7// Implementation of class Particle
8// Contains particle PDG, 4-coordinates and 4-momentum vectors, history information
b1c2e580 9
10#include <TMath.h>
b1c2e580 11#include "ParticlePDG.h"
b1c2e580 12#include "Particle.h"
b1c2e580 13
03896fc4 14//___________________________________________________________________
786056a2 15Particle::Particle(ParticlePDG *prop):
16 fPosition(),
17 fMomentum(),
18 fLastMotherDecayCoor(),
19 fLastMotherDecayMom(),
20 fParticleProperties(prop),
21 fLastInteractionTime(0.),
22 fInteractionNumber(0),
3fa37a65 23 fPythiaStatusCode(-1),
786056a2 24 fLastMotherPdg(0),
25 fType(0),
26 fIndex(-1),
27 fMotherIndex(-1),
3fa37a65 28 fNDaughters(0),
29 fFirstDaughterIndex(-1),
30 fLastDaughterIndex(-1),
31 fDecayed(kFALSE)
b1c2e580 32{
03896fc4 33//
34// constructor
35//
b1c2e580 36}
37
03896fc4 38//___________________________________________________________________
b1c2e580 39Particle::Particle(ParticlePDG *prop, const TLorentzVector &pos,
786056a2 40 const TLorentzVector &mom, Double_t lit, Int_t lin, Int_t type):
41 fPosition(pos),
42 fMomentum(mom),
43 fLastMotherDecayCoor(),
44 fLastMotherDecayMom(),
45 fParticleProperties(prop),
46 fLastInteractionTime(lit),
47 fInteractionNumber(lin),
3fa37a65 48 fPythiaStatusCode(-1),
786056a2 49 fLastMotherPdg(0),
50 fType(type),
51 fIndex(-1),
52 fMotherIndex(-1),
3fa37a65 53 fNDaughters(0),
54 fFirstDaughterIndex(-1),
55 fLastDaughterIndex(-1),
56 fDecayed(kFALSE)
b1c2e580 57{
03896fc4 58 //
59 // constructor
60 //
b1c2e580 61}
62
03896fc4 63//___________________________________________________________________
b1c2e580 64Particle::Particle(ParticlePDG *prop, const TLorentzVector &pos, const TLorentzVector &mom,
65 Double_t t, Int_t n, Int_t ty, Int_t motherPdg, const TLorentzVector &mPos,
786056a2 66 const TLorentzVector &mMom):
67 fPosition(pos),
68 fMomentum(mom),
69 fLastMotherDecayCoor(mPos),
70 fLastMotherDecayMom(mMom),
71 fParticleProperties(prop),
72 fLastInteractionTime(t),
73 fInteractionNumber(n),
3fa37a65 74 fPythiaStatusCode(-1),
786056a2 75 fLastMotherPdg(motherPdg),
76 fType(ty),
77 fIndex(-1),
78 fMotherIndex(-1),
3fa37a65 79 fNDaughters(0),
80 fFirstDaughterIndex(-1),
81 fLastDaughterIndex(-1),
82 fDecayed(kFALSE)
b1c2e580 83{
03896fc4 84 //
85 // constructor
86 //
b1c2e580 87}
88
03896fc4 89//___________________________________________________________________
7b7936e9 90Particle::Particle(const Particle& copy) :
91 fPosition(copy.Pos()),
3fa37a65 92 fMomentum(copy.Mom()),
93 fLastMotherDecayCoor(copy.GetLastMotherDecayCoor()),
94 fLastMotherDecayMom(copy.GetLastMotherDecayMom()),
95 fParticleProperties(copy.Def()),
96 fLastInteractionTime(copy.GetLastInterTime()),
97 fInteractionNumber(copy.GetLastInterNumber()),
98 fPythiaStatusCode(copy.GetPythiaStatusCode()),
99 fLastMotherPdg(copy.GetLastMotherPdg()),
100 fType(copy.GetType()),
101 fIndex(copy.GetIndex()),
102 fMotherIndex(copy.GetMother()),
103 fNDaughters(copy.GetNDaughters()),
104 fFirstDaughterIndex(copy.GetFirstDaughterIndex()),
105 fLastDaughterIndex(copy.GetLastDaughterIndex()),
106 fDecayed(copy.GetDecayed())
7b7936e9 107{
03896fc4 108 //
109 // copy constructor
110 //
7b7936e9 111}
112
03896fc4 113//___________________________________________________________________
7b7936e9 114Particle & Particle::operator=(const Particle& /*copy*/) {
03896fc4 115 //
116 // assignment operator
117 //
7b7936e9 118 return *this;
119}
120
03896fc4 121//___________________________________________________________________
b1c2e580 122Int_t Particle::Encoding() const {
03896fc4 123 //
124 // particle code
125 //
b1c2e580 126 return fParticleProperties->GetPDG();
127}
128
03896fc4 129//___________________________________________________________________
b1c2e580 130Double_t Particle::TableMass() const {
03896fc4 131 //
132 // particle mass
133 //
b1c2e580 134 return fParticleProperties->GetMass();
135}
136
03896fc4 137//___________________________________________________________________
b1c2e580 138Double_t Particle::Eta() const {
03896fc4 139 //
140 // pseudo-rapidity
141 //
b1c2e580 142 if(fMomentum.P() != fMomentum.Pz())
143 return 0.5 * TMath::Log((fMomentum.P() + fMomentum.Pz()) / (fMomentum.P()-fMomentum.Pz()));
144 else return 1.e30;
145}
146
03896fc4 147//___________________________________________________________________
b1c2e580 148Double_t Particle::Rapidity() const {
03896fc4 149 //
150 // rapidity
151 //
b1c2e580 152 if (fMomentum.E() != fMomentum.Pz())
153 return 0.5 * TMath::Log((fMomentum.E() + fMomentum.Pz()) / (fMomentum.E() - fMomentum.Pz()));
154 else return 1.e30;
155}
156
03896fc4 157//___________________________________________________________________
b1c2e580 158Double_t Particle::Phi() const {
03896fc4 159 //
160 // azimuthal angle
161 //
b1c2e580 162 return TMath::Pi()+TMath::ATan2(-fMomentum.Py(), -fMomentum.Px());
163}
164
03896fc4 165//___________________________________________________________________
b1c2e580 166Double_t Particle::Theta() const {
03896fc4 167 //
168 // polar angle
169 //
b1c2e580 170 return !fMomentum.Pz() ? TMath::Pi() / 2 : TMath::ACos(fMomentum.Pz() / fMomentum.P());
171}
172
03896fc4 173//___________________________________________________________________
b1c2e580 174Double_t Particle::Pt() const {
03896fc4 175 //
176 // pt
177 //
b1c2e580 178 return TMath::Sqrt(fMomentum.Px() * fMomentum.Px() + fMomentum.Py() * fMomentum.Py());
179}
180
03896fc4 181//___________________________________________________________________
b1c2e580 182Double_t S(const TLorentzVector &v1, const TLorentzVector &v2) {
03896fc4 183 //
184 // Mandelstam s
185 //
b1c2e580 186 return TMath::Power(v1.T() + v2.T(), 2) - TMath::Power(v1.X() + v2.X(), 2) -
187 TMath::Power(v1.Y() + v2.Y(), 2) - TMath::Power(v1.Z() + v2.Z(), 2);
188}
189
03896fc4 190//___________________________________________________________________
b1c2e580 191Double_t T(const TLorentzVector & v1, const TLorentzVector & v2) {
03896fc4 192 //
193 // Mandelstam t
194 //
b1c2e580 195 return TMath::Power(v1.T() - v2.T(), 2) - TMath::Power(v1.X() - v2.X(), 2) -
196 TMath::Power(v1.Y() - v2.Y(), 2) - TMath::Power(v1.Z() - v2.Z(), 2);
197}
198
03896fc4 199//___________________________________________________________________
b1c2e580 200void ParticleAllocator::AddParticle(const Particle & p, List_t &list) {
03896fc4 201 //
202 // Add a particle to the list
203 //
b1c2e580 204 if(fFreeNodes.empty())
205 list.push_back(p);
206 else {
207 list.splice(list.end(), fFreeNodes, fFreeNodes.begin());
208 list.back() = p;
209 }
210}
211
03896fc4 212//___________________________________________________________________
b1c2e580 213void ParticleAllocator::FreeListNode(List_t & list, LPIT_t it) {
03896fc4 214 //
215 // remove a particle from list
216 //
b1c2e580 217 fFreeNodes.splice(fFreeNodes.end(), list, it);
218}
219
03896fc4 220//___________________________________________________________________
b1c2e580 221void ParticleAllocator::FreeList(List_t & list) {
03896fc4 222 //
223 // free all list
224 //
b1c2e580 225 fFreeNodes.splice(fFreeNodes.end(), list);
226}