]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TUHKMgen/UHKM/Particle.cxx
Coding violations
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / Particle.cxx
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 */
8
9 #include <TMath.h>
10 #ifndef PARTICLE_PDG
11 #include "ParticlePDG.h"
12 #endif
13 #ifndef PARTICLE_INCLUDED
14 #include "Particle.h"
15 #endif
16
17 Particle::Particle(ParticlePDG *prop): 
18   fPosition(),
19   fMomentum(),
20   fLastMotherDecayCoor(),
21   fLastMotherDecayMom(),
22   fParticleProperties(prop),
23   fLastInteractionTime(0.),
24   fInteractionNumber(0),
25   fPythiaStatusCode(-1),
26   fLastMotherPdg(0),
27   fType(0),
28   fIndex(-1),
29   fMotherIndex(-1),
30   fNDaughters(0),
31   fFirstDaughterIndex(-1),
32   fLastDaughterIndex(-1),
33   fDecayed(kFALSE)
34 {
35
36 }
37
38 Particle::Particle(ParticlePDG *prop, const TLorentzVector &pos, 
39                    const TLorentzVector &mom, Double_t lit, Int_t lin, Int_t type):
40   fPosition(pos),
41   fMomentum(mom),
42   fLastMotherDecayCoor(),
43   fLastMotherDecayMom(),
44   fParticleProperties(prop),
45   fLastInteractionTime(lit),
46   fInteractionNumber(lin),
47   fPythiaStatusCode(-1),
48   fLastMotherPdg(0),
49   fType(type),
50   fIndex(-1),
51   fMotherIndex(-1),
52   fNDaughters(0),
53   fFirstDaughterIndex(-1),
54   fLastDaughterIndex(-1),
55   fDecayed(kFALSE)
56 {
57 }
58
59 Particle::Particle(ParticlePDG *prop, const TLorentzVector &pos, const TLorentzVector &mom,
60                    Double_t t, Int_t n, Int_t ty, Int_t motherPdg, const TLorentzVector &mPos, 
61                    const TLorentzVector &mMom):
62   fPosition(pos),
63   fMomentum(mom),
64   fLastMotherDecayCoor(mPos),
65   fLastMotherDecayMom(mMom),
66   fParticleProperties(prop),
67   fLastInteractionTime(t),
68   fInteractionNumber(n),
69   fPythiaStatusCode(-1),
70   fLastMotherPdg(motherPdg),
71   fType(ty),
72   fIndex(-1),
73   fMotherIndex(-1),
74   fNDaughters(0),
75   fFirstDaughterIndex(-1),
76   fLastDaughterIndex(-1),
77   fDecayed(kFALSE)
78 {
79 }
80
81 Particle::Particle(const Particle& copy) :
82   fPosition(copy.Pos()),
83   fMomentum(copy.Mom()),
84   fLastMotherDecayCoor(copy.GetLastMotherDecayCoor()),
85   fLastMotherDecayMom(copy.GetLastMotherDecayMom()),
86   fParticleProperties(copy.Def()),
87   fLastInteractionTime(copy.GetLastInterTime()),
88   fInteractionNumber(copy.GetLastInterNumber()),
89   fPythiaStatusCode(copy.GetPythiaStatusCode()),
90   fLastMotherPdg(copy.GetLastMotherPdg()),
91   fType(copy.GetType()),
92   fIndex(copy.GetIndex()),
93   fMotherIndex(copy.GetMother()),
94   fNDaughters(copy.GetNDaughters()),
95   fFirstDaughterIndex(copy.GetFirstDaughterIndex()),
96   fLastDaughterIndex(copy.GetLastDaughterIndex()),
97   fDecayed(copy.GetDecayed())
98 {
99 }
100
101 Particle & Particle::operator=(const Particle& /*copy*/) {
102   return *this;
103 }
104
105
106 Int_t Particle::Encoding() const {
107   return fParticleProperties->GetPDG();
108 }
109
110 Double_t Particle::TableMass() const {
111   return fParticleProperties->GetMass();
112 }
113
114 Double_t Particle::Eta() const {
115   if(fMomentum.P() != fMomentum.Pz())
116     return 0.5 * TMath::Log((fMomentum.P() + fMomentum.Pz()) / (fMomentum.P()-fMomentum.Pz()));
117   else return 1.e30;
118 }
119
120 Double_t Particle::Rapidity() const {
121   if (fMomentum.E() != fMomentum.Pz())
122     return 0.5 * TMath::Log((fMomentum.E() + fMomentum.Pz()) / (fMomentum.E() - fMomentum.Pz()));
123   else return 1.e30;
124 }
125
126 Double_t Particle::Phi() const {
127   return TMath::Pi()+TMath::ATan2(-fMomentum.Py(), -fMomentum.Px());
128 }
129
130 Double_t Particle::Theta() const {
131   return !fMomentum.Pz() ? TMath::Pi() / 2 : TMath::ACos(fMomentum.Pz() / fMomentum.P());
132 }
133
134 Double_t Particle::Pt() const {
135   return TMath::Sqrt(fMomentum.Px() * fMomentum.Px() + fMomentum.Py() * fMomentum.Py());
136 }
137
138 Double_t S(const TLorentzVector &v1, const TLorentzVector &v2) {
139   return TMath::Power(v1.T() + v2.T(), 2) - TMath::Power(v1.X() + v2.X(), 2) -
140     TMath::Power(v1.Y() + v2.Y(), 2) - TMath::Power(v1.Z() + v2.Z(), 2);
141 }
142
143 Double_t T(const TLorentzVector & v1, const TLorentzVector & v2) {
144   return TMath::Power(v1.T() - v2.T(), 2) - TMath::Power(v1.X() - v2.X(), 2) - 
145     TMath::Power(v1.Y() - v2.Y(), 2) - TMath::Power(v1.Z() - v2.Z(), 2);
146 }
147
148 void ParticleAllocator::AddParticle(const Particle & p, List_t &list) {
149   if(fFreeNodes.empty())
150     list.push_back(p);
151   else {
152     list.splice(list.end(), fFreeNodes, fFreeNodes.begin());
153     list.back() = p;
154   }
155 }
156
157 void ParticleAllocator::FreeListNode(List_t & list, LPIT_t it) {
158   fFreeNodes.splice(fFreeNodes.end(), list, it);      
159 }
160
161 void ParticleAllocator::FreeList(List_t & list) {
162   fFreeNodes.splice(fFreeNodes.end(), list);
163 }