ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4PrimaryParticle.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4PrimaryParticle.hh
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
27
//
28
//
29
30
31
#ifndef G4PrimaryParticle_h
32
#define G4PrimaryParticle_h 1
33
34
#include "
globals.hh
"
35
#include "
G4Allocator.hh
"
36
#include "
G4ThreeVector.hh
"
37
38
#include "
pwdefs.hh
"
39
40
class
G4ParticleDefinition
;
41
class
G4VUserPrimaryParticleInformation
;
42
43
// class description:
44
//
45
// This is a class which represents a primary particle.
46
// This is completely deferent class from G4Track or G4DynamicParticle.
47
// This class is designed with taking into account the possibility of
48
// making this class persistent, i.e. kept with G4Event class object
49
// to ODBMS. Thus this class is almost free from any other Geant4 classes.
50
// The only exception is a pointer to G4ParticleDefinition but it can be
51
// rebuilt by the PDGcode.
52
//
53
// Primary particles are stored in G4PrimaryVertex object with a form
54
// of linked list. Also, an object of this PrimaryParticle class can have
55
// one or more objects of this class as its daughters with a form of
56
// linked list.
57
// A parimary particle represented by this class object needs not to be
58
// a particle of type which Geant4 can simulate.
59
// case a) mother particle is not a particle Geant4 can simulate
60
// daughters associated to the mother will be examined.
61
// case b) mother particle is a perticle Geant4 can simulate
62
// daughters associated to the mother will be converted to G4Dynamic
63
// particle and be set to the mother G4Track. For this case, dauthers
64
// are used as the "pre-fixed" decay channel.
65
//
66
67
class
G4PrimaryParticle
68
{
69
public
:
70
inline
void
*
operator
new
(size_t);
71
inline
void
operator
delete
(
void
*aStackedTrack);
72
73
public
:
// with description
74
G4PrimaryParticle
();
75
G4PrimaryParticle
(
G4int
Pcode);
76
G4PrimaryParticle
(
G4int
Pcode,
77
G4double
px,
G4double
py,
G4double
pz);
78
G4PrimaryParticle
(
G4int
Pcode,
79
G4double
px,
G4double
py,
G4double
pz,
G4double
E
);
80
G4PrimaryParticle
(
const
G4ParticleDefinition
* Gcode);
81
G4PrimaryParticle
(
const
G4ParticleDefinition
* Gcode,
82
G4double
px,
G4double
py,
G4double
pz);
83
G4PrimaryParticle
(
const
G4ParticleDefinition
* Gcode,
84
G4double
px,
G4double
py,
G4double
pz,
G4double
E);
85
86
public
:
87
virtual
~G4PrimaryParticle
();
88
89
// copy constructor and assignment operator
90
// nextParticle and daughterParticle is copied by object (i.e. deep copy)
91
// userInfo will nt be copied
92
G4PrimaryParticle
(
const
G4PrimaryParticle
&
right
);
93
G4PrimaryParticle
&
operator=
(
const
G4PrimaryParticle
&right);
94
95
// equal operator returns 'true' only if the same object (i.e comarison by pointer value)
96
G4bool
operator==
(
const
G4PrimaryParticle
&right)
const
;
97
G4bool
operator!=
(
const
G4PrimaryParticle
&right)
const
;
98
99
public
:
// with description
100
void
Print
()
const
;
101
// Print the properties of the particle.
102
103
104
public
:
// with description
105
// followings are get/set methods available.
106
// "trackID" will be set if this particle is sent to G4EventManager
107
// and converted to G4Track. Otherwise = -1.
108
// The mass and charge in G4ParticleDefinition will be used in default.
109
// "SetMass" and "SetCharge" methods are used to set dynamical mass and charge
110
// G4DynamicParticle."GetMass" and "GetCharge" methods will return
111
// those in G4ParticleDefinition if users do not set dynamical ones.
112
113
G4int
GetPDGcode
()
const
;
114
void
SetPDGcode
(
G4int
Pcode);
115
G4ParticleDefinition
*
GetG4code
()
const
;
116
void
SetG4code
(
const
G4ParticleDefinition
* Gcode);
117
const
G4ParticleDefinition
*
GetParticleDefinition
()
const
;
118
void
SetParticleDefinition
(
const
G4ParticleDefinition
* pdef);
119
G4double
GetMass
()
const
;
120
void
SetMass
(
G4double
mas);
121
G4double
GetCharge
()
const
;
122
void
SetCharge
(
G4double
chg);
123
G4double
GetKineticEnergy
()
const
;
124
void
SetKineticEnergy
(
G4double
eKin);
125
const
G4ThreeVector
&
GetMomentumDirection
()
const
;
126
void
SetMomentumDirection
(
const
G4ThreeVector
&
p
);
127
G4double
GetTotalMomentum
()
const
;
128
void
Set4Momentum
(
G4double
px,
G4double
py,
G4double
pz,
G4double
E);
129
G4double
GetTotalEnergy
()
const
;
130
void
SetTotalEnergy
(
G4double
eTot );
131
G4ThreeVector
GetMomentum
()
const
;
132
void
SetMomentum
(
G4double
px,
G4double
py,
G4double
pz);
133
G4double
GetPx
()
const
;
134
G4double
GetPy
()
const
;
135
G4double
GetPz
()
const
;
136
G4PrimaryParticle
*
GetNext
()
const
;
137
void
SetNext
(
G4PrimaryParticle
* np);
138
void
ClearNext
();
139
G4PrimaryParticle
*
GetDaughter
()
const
;
140
void
SetDaughter
(
G4PrimaryParticle
* np);
141
G4int
GetTrackID
()
const
;
142
void
SetTrackID
(
G4int
id
);
143
G4ThreeVector
GetPolarization
()
const
;
144
void
SetPolarization
(
const
G4ThreeVector
& pol);
145
void
SetPolarization
(
G4double
px,
G4double
py,
G4double
pz);
146
G4double
GetPolX
()
const
;
147
G4double
GetPolY
()
const
;
148
G4double
GetPolZ
()
const
;
149
G4double
GetWeight
()
const
;
150
void
SetWeight
(
G4double
w
);
151
G4double
GetProperTime
()
const
;
152
void
SetProperTime
(
G4double
t
);
153
G4VUserPrimaryParticleInformation
*
GetUserInformation
()
const
;
154
void
SetUserInformation
(
G4VUserPrimaryParticleInformation
* anInfo);
155
156
private
:
157
G4int
PDGcode
;
158
const
G4ParticleDefinition
*
G4code
;
159
160
G4ThreeVector
direction
;
161
G4double
kinE
;
162
163
G4PrimaryParticle
*
nextParticle
;
164
G4PrimaryParticle
*
daughterParticle
;
165
166
G4int
trackID
;
// This will be set if this particle is
167
// sent to G4EventManager and converted to
168
// G4Track. Otherwise = -1.
169
170
G4double
mass
;
171
G4double
charge
;
172
G4double
polX
;
173
G4double
polY
;
174
G4double
polZ
;
175
G4double
Weight0
;
176
G4double
properTime
;
177
G4VUserPrimaryParticleInformation
*
userInfo
;
178
179
};
180
181
extern
G4PART_DLL
G4Allocator<G4PrimaryParticle>
*&
aPrimaryParticleAllocator
();
182
183
inline
void
* G4PrimaryParticle::operator
new
(size_t)
184
{
185
if
(!
aPrimaryParticleAllocator
())
186
{
187
aPrimaryParticleAllocator
() =
new
G4Allocator<G4PrimaryParticle>
;
188
}
189
return
(
void
*)
aPrimaryParticleAllocator
()->MallocSingle();
190
}
191
192
inline
void
G4PrimaryParticle::operator
delete
(
void
* aPrimaryParticle)
193
{
194
aPrimaryParticleAllocator
()->FreeSingle((
G4PrimaryParticle
*) aPrimaryParticle);
195
}
196
197
inline
G4double
G4PrimaryParticle::GetMass
()
const
198
{
return
mass
; }
199
200
inline
G4double
G4PrimaryParticle::GetCharge
()
const
201
{
return
charge
; }
202
203
inline
G4int
G4PrimaryParticle::GetPDGcode
()
const
204
{
return
PDGcode
; }
205
206
inline
G4ParticleDefinition
*
G4PrimaryParticle::GetG4code
()
const
207
{
return
const_cast<
G4ParticleDefinition
*
>
(
G4code
); }
208
209
inline
const
G4ParticleDefinition
*
G4PrimaryParticle::GetParticleDefinition
()
const
210
{
return
G4code
; }
211
212
inline
G4double
G4PrimaryParticle::GetTotalMomentum
()
const
213
{
214
if
(
mass
<0.)
return
kinE
;
215
else
return
std::sqrt(
kinE
*(
kinE
+2.*
mass
));
216
}
217
218
inline
G4ThreeVector
G4PrimaryParticle::GetMomentum
()
const
219
{
return
GetTotalMomentum
()*
direction
;}
220
221
inline
const
G4ThreeVector
&
G4PrimaryParticle::GetMomentumDirection
()
const
222
{
return
direction
;}
223
224
inline
void
G4PrimaryParticle::SetMomentumDirection
(
const
G4ThreeVector
&
p
)
225
{
direction
=
p
;}
226
227
inline
G4double
G4PrimaryParticle::GetPx
()
const
228
{
return
GetTotalMomentum
()*
direction
.
x
();}
229
230
inline
G4double
G4PrimaryParticle::GetPy
()
const
231
{
return
GetTotalMomentum
()*
direction
.
y
();}
232
233
inline
G4double
G4PrimaryParticle::GetPz
()
const
234
{
return
GetTotalMomentum
()*
direction
.
z
();}
235
236
inline
G4double
G4PrimaryParticle::GetTotalEnergy
()
const
237
{
238
if
(
mass
<0.)
return
kinE
;
239
else
return
kinE
+
mass
;
240
}
241
242
inline
void
G4PrimaryParticle::SetTotalEnergy
(
G4double
eTot )
243
{
244
if
(
mass
<0.)
kinE
= eTot;
245
else
kinE
= eTot -
mass
;
246
}
247
248
inline
G4double
G4PrimaryParticle::GetKineticEnergy
()
const
249
{
return
kinE
; }
250
251
inline
void
G4PrimaryParticle::SetKineticEnergy
(
G4double
eKin)
252
{
kinE
= eKin; }
253
254
inline
G4PrimaryParticle
*
G4PrimaryParticle::GetNext
()
const
255
{
return
nextParticle
; }
256
257
inline
G4PrimaryParticle
*
G4PrimaryParticle::GetDaughter
()
const
258
{
return
daughterParticle
; }
259
260
inline
G4int
G4PrimaryParticle::GetTrackID
()
const
261
{
return
trackID
; }
262
263
inline
G4ThreeVector
G4PrimaryParticle::GetPolarization
()
const
264
{
return
G4ThreeVector
(
polX
,
polY
,
polZ
); }
265
266
inline
G4double
G4PrimaryParticle::GetPolX
()
const
267
{
return
polX
; }
268
269
inline
G4double
G4PrimaryParticle::GetPolY
()
const
270
{
return
polY
; }
271
272
inline
G4double
G4PrimaryParticle::GetPolZ
()
const
273
{
return
polZ
; }
274
275
inline
G4double
G4PrimaryParticle::GetWeight
()
const
276
{
return
Weight0
; }
277
278
inline
void
G4PrimaryParticle::SetWeight
(
G4double
w
)
279
{
Weight0
=
w
; }
280
281
inline
void
G4PrimaryParticle::SetProperTime
(
G4double
t
)
282
{
properTime
=
t
; }
283
284
inline
G4double
G4PrimaryParticle::GetProperTime
()
const
285
{
return
properTime
; }
286
287
inline
void
G4PrimaryParticle::SetUserInformation
(
G4VUserPrimaryParticleInformation
* anInfo)
288
{
userInfo
= anInfo; }
289
290
inline
G4VUserPrimaryParticleInformation
*
G4PrimaryParticle::GetUserInformation
()
const
291
{
return
userInfo
; }
292
293
inline
void
G4PrimaryParticle::SetG4code
(
const
G4ParticleDefinition
* Gcode)
294
{
295
SetParticleDefinition
(Gcode);
296
}
297
298
inline
void
G4PrimaryParticle::SetNext
(
G4PrimaryParticle
* np)
299
{
300
if
(
nextParticle
== 0) {
nextParticle
= np; }
301
else
{
nextParticle
->
SetNext
(np); }
302
}
303
304
inline
void
G4PrimaryParticle::ClearNext
()
305
{
306
nextParticle
=
nullptr
;
307
}
308
309
inline
void
G4PrimaryParticle::SetDaughter
(
G4PrimaryParticle
* np)
310
{
311
if
(
daughterParticle
== 0) {
daughterParticle
= np; }
312
else
{
daughterParticle
->
SetNext
(np); }
313
}
314
315
inline
void
G4PrimaryParticle::SetTrackID
(
G4int
id
)
316
{
trackID
= id; }
317
318
inline
void
G4PrimaryParticle::SetMass
(
G4double
mas)
319
{
mass
= mas; }
320
321
inline
void
G4PrimaryParticle::SetCharge
(
G4double
chg)
322
{
charge
= chg; }
323
324
inline
void
G4PrimaryParticle::SetPolarization
(
G4double
px,
G4double
py,
G4double
pz)
325
{
326
polX
= px;
327
polY
= py;
328
polZ
= pz;
329
}
330
331
inline
void
G4PrimaryParticle::SetPolarization
(
const
G4ThreeVector
& pol)
332
{
333
polX
= pol.
x
();
334
polY
= pol.
y
();
335
polZ
= pol.
z
();
336
}
337
338
#endif
geant4
tree
geant4-10.6-release
source
particles
management
include
G4PrimaryParticle.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:24
using
1.8.2 with
ECCE GitHub integration