Project
Loading...
Searching...
No Matches
FairParticle.cxx
Go to the documentation of this file.
1/********************************************************************************
2 * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3 * *
4 * This software is distributed under the terms of the *
5 * GNU Lesser General Public Licence (LGPL) version 3, *
6 * copied verbatim in the file "LICENSE" *
7 ********************************************************************************/
8// -------------------------------------------------------------------------
9// ----- FairParticle source file -----
10// ----- Created 06/01/04 by M. Al-Turany -----
11// -------------------------------------------------------------------------
12
13// Extended TParticle with pointers to mother and daughters particles
14
15#include "FairParticle.h"
16
17#include <TDatabasePDG.h> // for TDatabasePDG
18#include <TMCParticleType.h> // for TMCParticleType::kPTIon, etc
19#include <TParticle.h> // for TParticle
20#include <TParticlePDG.h> // for TParticlePDG
21#include <iostream> // for operator<<, basic_ostream, etc
22
23using std::cout;
24using std::endl;
25
27
28FairParticle::FairParticle(Int_t id, TParticle* particle)
29 : TObject()
30 , fpdg(id)
31 , fParticle(particle)
32 , fMother(0)
33 , fDaughters(0)
34 , fname(particle->GetName())
35 , fmcType(kPTIon)
36 , fmass(particle->GetMass())
37 , fcharge(particle->GetPDG()->Charge())
38 , fDecayTime(particle->GetPDG()->Lifetime())
39 , fpType("Ion")
40 , fwidth(particle->GetPDG()->Width())
41 , fiSpin(static_cast<Int_t>(particle->GetPDG()->Spin()))
42 , fiParity(particle->GetPDG()->Parity())
43 , fiConjugation(0)
44 , fiIsospin(static_cast<Int_t>(particle->GetPDG()->Isospin()))
45 , fiIsospinZ(0)
46 , fgParity(0)
47 , flepton(0)
48 , fbaryon(0)
49 , fstable(particle->GetPDG()->Stable())
50{}
51
53 Int_t z,
54 Int_t a,
55 Int_t s,
56 Double_t mass,
57 Int_t q,
58 Bool_t stable,
59 Double_t decaytime)
60 : TObject()
61 , fpdg(1000000000 + 10000000 * s + 10000 * z + 10 * a)
62 , fParticle(0)
63 , fMother(0)
64 , fDaughters(0)
65 , fname(name)
66 , fmcType(kPTIon)
67 , fmass(0)
68 , fcharge(0)
69 , fDecayTime(decaytime)
70 , fpType("Ion")
71 , fwidth(0)
72 , fiSpin(0)
73 , fiParity(0)
74 , fiConjugation(0)
75 , fiIsospin(0)
76 , fiIsospinZ(0)
77 , fgParity(0)
78 , flepton(0)
79 , fbaryon(0)
80 , fstable(stable)
81{
82
83 TDatabasePDG* pdgDB = TDatabasePDG::Instance();
84 if (!pdgDB->GetParticle(fpdg)) {
85 if (mass == 0) {
86 TParticlePDG* kProton = pdgDB->GetParticle(2212);
87 Double_t kProtonMass = kProton->Mass();
88 mass = a * kProtonMass;
89 }
90 pdgDB->AddParticle(name, name, mass, stable, 0, q, "kPTHadron", fpdg);
91 }
92
93 fParticle = new TParticle();
94 fParticle->SetPdgCode(fpdg);
95
96 fmcType = kPTHadron;
97 fmass = mass;
98 fcharge = fParticle->GetPDG()->Charge();
99 fDecayTime = decaytime;
100 fwidth = fParticle->GetPDG()->Width();
101 fiSpin = static_cast<Int_t>(fParticle->GetPDG()->Spin());
102 fiParity = fParticle->GetPDG()->Parity();
103 fiConjugation = 0;
104 fiIsospin = static_cast<Int_t>(fParticle->GetPDG()->Isospin());
105 fiIsospinZ = 0;
106 fgParity = 0;
107 flepton = 0;
108 fbaryon = 0;
109 fstable = fParticle->GetPDG()->Stable();
110}
111
113 Int_t z,
114 Int_t a,
115 Double_t mass,
116 Int_t q,
117 Bool_t stable,
118 Double_t decaytime)
119 : TObject()
120 , fpdg(10000000 + 10000 * z + 10 * a)
121 , fParticle(0)
122 , fMother(0)
123 , fDaughters(0)
124 , fname(name)
125 , fmcType(kPTIon)
126 , fmass(0)
127 , fcharge(0)
128 , fDecayTime(decaytime)
129 , fpType("Ion")
130 , fwidth(0)
131 , fiSpin(0)
132 , fiParity(0)
133 , fiConjugation(0)
134 , fiIsospin(0)
135 , fiIsospinZ(0)
136 , fgParity(0)
137 , flepton(0)
138 , fbaryon(0)
139 , fstable(stable)
140{
141 // fpdg= 10000000+10000* z +10 * a;
142
143 // fDecayTime= decaytime;
144 TDatabasePDG* pdgDB = TDatabasePDG::Instance();
145
146 if (!pdgDB->GetParticle(fpdg)) {
147 if (mass == 0) {
148 TParticlePDG* kProton = pdgDB->GetParticle(2212);
149 Double_t kProtonMass = kProton->Mass();
150 mass = a * kProtonMass;
151 }
152 pdgDB->AddParticle(name, name, mass, stable, 0, q, "kPTHadron", fpdg);
153 }
154
155 fParticle = new TParticle();
156 fParticle->SetPdgCode(fpdg);
157
158 fmcType = kPTHadron;
159 fmass = mass;
160 fcharge = fParticle->GetPDG()->Charge();
161 fDecayTime = decaytime;
162 fwidth = fParticle->GetPDG()->Width();
163 fiSpin = static_cast<Int_t>(fParticle->GetPDG()->Spin());
164 fiParity = fParticle->GetPDG()->Parity();
165 fiConjugation = 0;
166 fiIsospin = static_cast<Int_t>(fParticle->GetPDG()->Isospin());
167 fiIsospinZ = 0;
168 fgParity = 0;
169 flepton = 0;
170 fbaryon = 0;
171 fstable = fParticle->GetPDG()->Stable();
172}
173
174FairParticle::FairParticle(Int_t id, TParticle* particle, FairParticle* mother)
175 : TObject()
176 , fpdg(id)
177 , fParticle(particle)
178 , fMother(mother)
179 , fDaughters()
180 , fname(particle->GetName())
181 , fmcType(kPTIon)
182 , fmass(0)
183 , fcharge(0)
184 , fDecayTime(0)
185 , fpType("Ion")
186 , fwidth(0)
187 , fiSpin(0)
188 , fiParity(0)
189 , fiConjugation(0)
190 , fiIsospin(0)
191 , fiIsospinZ(0)
192 , fgParity(0)
193 , flepton(0)
194 , fbaryon(0)
195 , fstable(kTRUE)
196
197{}
198
200 const TString name,
201 TMCParticleType mcType,
202 Double_t mass,
203 Double_t charge,
204 Double_t lifetime,
205 const TString pType,
206 Double_t width,
207 Int_t iSpin,
208 Int_t iParity,
209 Int_t iConjugation,
210 Int_t iIsospin,
211 Int_t iIsospinZ,
212 Int_t gParity,
213 Int_t lepton,
214 Int_t baryon,
215 Bool_t stable)
216 : TObject()
217 , fpdg(pdg)
218 , fParticle(new TParticle())
219 , fMother(0)
220 , fDaughters(0)
221 , fname(name)
222 , fmcType(mcType)
223 , fmass(mass)
224 , fcharge(charge)
225 , fDecayTime(lifetime)
226 , fpType(pType)
227 , fwidth(width)
228 , fiSpin(iSpin)
229 , fiParity(iParity)
230 , fiConjugation(iConjugation)
231 , fiIsospin(iIsospin)
232 , fiIsospinZ(iIsospinZ)
233 , fgParity(gParity)
234 , flepton(lepton)
235 , fbaryon(baryon)
236 , fstable(stable)
237{
238
239 if (!TDatabasePDG::Instance()->GetParticle(fpdg)) {
240 TDatabasePDG::Instance()->AddParticle(fname, fname, fmass, fstable, fwidth, fcharge, pType, fpdg);
241 }
242
243 fParticle->SetPdgCode(fpdg);
244}
245
247 : TObject()
248 , fpdg(0)
249 , fParticle(0)
250 , fMother(0)
251 , fDaughters()
252 , fname("ion")
253 , fmcType(kPTIon)
254 , fmass(0)
255 , fcharge(0)
256 , fDecayTime(0)
257 , fpType("Ion")
258 , fwidth(0)
259 , fiSpin(0)
260 , fiParity(0)
261 , fiConjugation(0)
262 , fiIsospin(0)
263 , fiIsospinZ(0)
264 , fgParity(0)
265 , flepton(0)
266 , fbaryon(0)
267 , fstable(kTRUE)
268{}
269
270FairParticle::~FairParticle() { delete fParticle; }
271
272//
273// public methods
274//
275
277{
278 // Adds particles daughter
279 // ---
280
281 fMother.SetObject(particle);
282}
283
285{
286 // Adds particles daughter
287 // ---
288
289 fDaughters.Add(particle);
290}
291
292void FairParticle::Print(Option_t*) const
293{
294 // Prints particle properties.
295 // ---
296 // return;
297
298 cout << "Particle: " << fParticle->GetName() << " with ID: " << fpdg << endl;
299
300 // fParticle->Print();
301
302 if (GetMother()) {
303 cout << "Mother: " << GetMother()->GetParticle()->GetName() << " with ID: " << GetMother()->GetPDG()
304 << endl;
305 } else {
306 cout << "Primary " << endl;
307 }
308
309 cout << "Number of daughters: " << GetNofDaughters() << endl;
310 cout << endl;
311}
312
314{
315 // Prints particles daughters.
316 // ---
317
318 for (Int_t i = 0; i < GetNofDaughters(); i++) {
319 cout << i << "th daughter: " << endl;
320 GetDaughter(i)->Print();
321 }
322}
323
325{
326 // Returs particle ID.
327 // ---
328
329 return fpdg;
330}
331
333{
334 // Returns particle definition (TParticle).
335 // ---
336
337 return fParticle;
338}
339
341{
342 // Returns particle definition (TParticle).
343 // ---
344
345 return static_cast<FairParticle*>(fMother.GetObject());
346}
347
349{
350 // Returns number of daughters.
351 // ---
352
353 return fDaughters.GetEntriesFast();
354}
355
357{
358 // Returns i-th daughter.
359 // ---
360
361 if (i < 0 || i >= GetNofDaughters()) {
362 Fatal("GetDaughter", "Index out of range");
363 }
364
365 return static_cast<FairParticle*>(fDaughters.At(i));
366}
int16_t charge
Definition RawEventData.h:5
ClassImp(FairParticle)
int32_t i
void PrintDaughters() const
Int_t GetPDG() const
FairParticle * GetDaughter(Int_t i) const
virtual ~FairParticle()
void AddDaughter(FairParticle *particle)
void SetMother(FairParticle *particle)
FairParticle * GetMother() const
TParticle * GetParticle() const
Int_t GetNofDaughters() const
virtual void Print(Option_t *option="") const
GLuint const GLchar * name
Definition glcorearb.h:781
GLint GLsizei width
Definition glcorearb.h:270
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
Lifetime
Possible Lifetime of objects being exchanged by the DPL.
Definition Lifetime.h:18