Fix Coverity reports
[u/mrichter/AliRoot.git] / TTherminator / Therminator / Particle.cxx
CommitLineData
2e967919 1/******************************************************************************
2 * T H E R M I N A T O R *
3 * THERMal heavy-IoN generATOR *
4 * version 1.0 *
5 * *
6 * Authors of the model: Wojciech Broniowski, Wojciech.Broniowski@ifj.edu.pl, *
7 * Wojciech Florkowski, Wojciech.Florkowski@ifj.edu.pl *
8 * Authors of the code: Adam Kisiel, kisiel@if.pw.edu.pl *
9 * Tomasz Taluc, ttaluc@if.pw.edu.pl *
10 * Code designers: Adam Kisiel, Tomasz Taluc, Wojciech Broniowski, *
11 * Wojciech Florkowski *
12 * *
13 * For the detailed description of the program and furhter references *
14 * to the description of the model plesase refer to: nucl-th/0504047, *
15 * accessibile at: http://www.arxiv.org/nucl-th/0504047 *
16 * *
17 * Homepage: http://hirg.if.pw.edu.pl/en/therminator/ *
18 * *
19 * This code can be freely used and redistributed. However if you decide to *
20 * make modifications to the code, please contact the authors, especially *
21 * if you plan to publish the results obtained with such modified code. *
22 * Any publication of results obtained using this code must include the *
23 * reference to nucl-th/0504047 and the published version of it, when *
24 * available. *
25 * *
26 *****************************************************************************/
27#include "Particle.h"
28#include "ParticleType.h"
29#include <TMath.h>
30#define FIELDWIDTH 15
31
32Particle::Particle()
33{
f12dabf0 34 mPartType = 0;
2e967919 35}
36
37Particle::Particle(double aRapidity, double aPt, double aPhip,
38 double aAlfam, double aRho, double aPhis, double aTau,
39 ParticleType *aType)
40{
41 mPartType = aType;
42 mDecayed = 0;
43 mHasFather = -1;
44
45 px = aPt*TMath::Cos(aPhip);
46 py = aPt*TMath::Sin(aPhip);
47 double tMt = TMath::Hypot(GetMass(),aPt);
48 pz = tMt*TMath::SinH(aRapidity);
49
50 rx = aRho*TMath::Cos(aPhis);
51 ry = aRho*TMath::Sin(aPhis);
52
53// New method of calculating rz, rt
54 rz = aTau*TMath::SinH(aAlfam);
55 rt = aTau*TMath::CosH(aAlfam);
56}
57
58Particle::Particle(ParticleType *aType,
59 double aPx, double aPy, double aPz,
60 double aRx, double aRy, double aRz,
61 double aTime)
62{
63 mPartType = aType;
64 mDecayed = 0;
65 mHasFather = -1;
66
67 px = aPx;
68 py = aPy;
69 pz = aPz;
70
71 rx = aRx;
72 ry = aRy;
73 rz = aRz;
74 rt = aTime;
75}
76
77
78Particle::Particle(const Particle& aParticle)
79{
80 mPartType = aParticle.GetParticleType();
81 mDecayed = 0;
82 mHasFather = aParticle.GetFather();
83
84 px = aParticle.px;
85 py = aParticle.py;
86 pz = aParticle.pz;
87
88 rx = aParticle.rx;
89 ry = aParticle.ry;
90 rz = aParticle.rz;
91 rt = aParticle.rt;
92}
93
94Particle::~Particle()
95{
96 /* no-op */
97}
98
99void
100Particle::WriteParticle(ostream *aOuts)
101{
102 aOuts->flags(ios::left | ios::scientific);
103 aOuts->width(10);
104 (*aOuts) << mPartType->GetPDGCode();
105 aOuts->width(FIELDWIDTH);
106 (*aOuts) << px;
107 aOuts->width(FIELDWIDTH);
108 (*aOuts) << py;
109 aOuts->width(FIELDWIDTH);
110 (*aOuts) << pz;
111 aOuts->width(FIELDWIDTH);
112 (*aOuts) << GetEnergy();
113 aOuts->width(FIELDWIDTH);
114 (*aOuts) << GetMass();
115 aOuts->width(FIELDWIDTH);
116 (*aOuts) << rx;
117 aOuts->width(FIELDWIDTH);
118 (*aOuts) << ry;
119 aOuts->width(FIELDWIDTH);
120 (*aOuts) << rz;
121 aOuts->width(FIELDWIDTH);
122 (*aOuts) << rt;
123// (*aOuts) << mPartType->GetCharge() << " ";
124// if (mHasFather>-1) (*aOuts) << mHasFather << " ";
125 aOuts->width(6);
126 (*aOuts) << (mHasFather);
127 aOuts->width(2);
128 (*aOuts) << (mDecayed);
129}
130
131
132double
133Particle::Pt()
134{
135 return TMath::Hypot(px, py);
136}
137
138double
139Particle::Rapidity()
140{
141 double tE = TMath::Sqrt(px*px+py*py+pz*pz+GetMass()*GetMass());
142 return 0.5*TMath::Log((tE-pz)/(tE+pz));
143}
144
145ParticleType*
146Particle::GetParticleType() const
147{
148 return mPartType;
149}
150
151int
152Particle::HadDecayed()
153{
154 return mDecayed;
155}
156
157double
158Particle::GetMass()
159{
160 return mPartType->GetMass();
161}
162
163double
164Particle::GetEnergy()
165{
166 return TMath::Sqrt(GetMass()*GetMass()+px*px+py*py+pz*pz);
167}
168
169
170double
171Particle::GetI3()
172{
173 return mPartType->GetI3();
174}
175
176double
177Particle::GetBarionN()
178{
179 return mPartType->GetBarionN();
180}
181
182double
183Particle::GetStrangeness()
184{
185 return mPartType->GetStrangeness();
186}
187
188void
189Particle::SetDecayed()
190{
191 mDecayed = 1;
192}
193
194void
195Particle::SetFather(int aFather)
196{
197 mHasFather = aFather;
198}
199
200int
201Particle::GetFather() const
202{
203 return mHasFather;
204}
205