]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TUHKMgen/UHKM/Particle.cxx
add method to check if some cuts where on
[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 //   Implementation of class Particle
8 //   Contains particle PDG, 4-coordinates and 4-momentum vectors, history information
9
10 #include <TMath.h>
11 #include "ParticlePDG.h"
12 #include "Particle.h"
13
14 //___________________________________________________________________
15 Particle::Particle(ParticlePDG *prop): 
16   fPosition(),
17   fMomentum(),
18   fLastMotherDecayCoor(),
19   fLastMotherDecayMom(),
20   fParticleProperties(prop),
21   fLastInteractionTime(0.),
22   fInteractionNumber(0),
23   fPythiaStatusCode(-1),
24   fLastMotherPdg(0),
25   fType(0),
26   fIndex(-1),
27   fMotherIndex(-1),
28   fNDaughters(0),
29   fFirstDaughterIndex(-1),
30   fLastDaughterIndex(-1),
31   fDecayed(kFALSE)
32 {
33 //
34 // constructor
35 //
36 }
37
38 //___________________________________________________________________
39 Particle::Particle(ParticlePDG *prop, const TLorentzVector &pos, 
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),
48   fPythiaStatusCode(-1),
49   fLastMotherPdg(0),
50   fType(type),
51   fIndex(-1),
52   fMotherIndex(-1),
53   fNDaughters(0),
54   fFirstDaughterIndex(-1),
55   fLastDaughterIndex(-1),
56   fDecayed(kFALSE)
57 {
58   //
59   // constructor
60   //
61 }
62
63 //___________________________________________________________________
64 Particle::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, 
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),
74   fPythiaStatusCode(-1),
75   fLastMotherPdg(motherPdg),
76   fType(ty),
77   fIndex(-1),
78   fMotherIndex(-1),
79   fNDaughters(0),
80   fFirstDaughterIndex(-1),
81   fLastDaughterIndex(-1),
82   fDecayed(kFALSE)
83 {
84   //
85   // constructor
86   //
87 }
88
89 //___________________________________________________________________
90 Particle::Particle(const Particle& copy) :
91   fPosition(copy.Pos()),
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())
107 {
108   //
109   // copy constructor
110   //
111 }
112
113 //___________________________________________________________________
114 Particle & Particle::operator=(const Particle& /*copy*/) {
115   //
116   // assignment operator
117   //
118   return *this;
119 }
120
121 //___________________________________________________________________
122 Int_t Particle::Encoding() const {
123   //
124   // particle code
125   //
126   return fParticleProperties->GetPDG();
127 }
128
129 //___________________________________________________________________
130 Double_t Particle::TableMass() const {
131   //
132   // particle mass
133   //
134   return fParticleProperties->GetMass();
135 }
136
137 //___________________________________________________________________
138 Double_t Particle::Eta() const {
139   //
140   // pseudo-rapidity
141   //
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
147 //___________________________________________________________________
148 Double_t Particle::Rapidity() const {
149   //
150   // rapidity
151   //
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
157 //___________________________________________________________________
158 Double_t Particle::Phi() const {
159   //
160   // azimuthal angle
161   //
162   return TMath::Pi()+TMath::ATan2(-fMomentum.Py(), -fMomentum.Px());
163 }
164
165 //___________________________________________________________________
166 Double_t Particle::Theta() const {
167   //
168   // polar angle
169   //
170   return !fMomentum.Pz() ? TMath::Pi() / 2 : TMath::ACos(fMomentum.Pz() / fMomentum.P());
171 }
172
173 //___________________________________________________________________
174 Double_t Particle::Pt() const {
175   //
176   // pt
177   //
178   return TMath::Sqrt(fMomentum.Px() * fMomentum.Px() + fMomentum.Py() * fMomentum.Py());
179 }
180
181 //___________________________________________________________________
182 Double_t S(const TLorentzVector &v1, const TLorentzVector &v2) {
183   //
184   // Mandelstam s
185   //
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
190 //___________________________________________________________________
191 Double_t T(const TLorentzVector & v1, const TLorentzVector & v2) {
192   //
193   //  Mandelstam t
194   //
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
199 //___________________________________________________________________
200 void ParticleAllocator::AddParticle(const Particle & p, List_t &list) {
201   //
202   // Add a particle to the list
203   //
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
212 //___________________________________________________________________
213 void ParticleAllocator::FreeListNode(List_t & list, LPIT_t it) {
214   //
215   // remove a particle from list
216   //
217   fFreeNodes.splice(fFreeNodes.end(), list, it);      
218 }
219
220 //___________________________________________________________________
221 void ParticleAllocator::FreeList(List_t & list) {
222   //
223   // free all list
224   //
225   fFreeNodes.splice(fFreeNodes.end(), list);
226 }