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
G4SingleParticleSource.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4SingleParticleSource.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
28
//
29
// MODULE: G4SingleParticleSource.hh
30
//
31
// Version: 1.0
32
// Date: 5/02/04
33
// Author: Fan Lei
34
// Organisation: QinetiQ ltd.
35
// Customer: ESA/ESTEC
36
//
38
//
39
// CHANGE HISTORY
40
// --------------
41
//
42
// Version 1.0, 05/02/2004, Fan Lei, Created.
43
// Based on the G4GeneralParticleSource class in Geant4 v6.0
44
//
46
//
47
// Class Description:
48
//
49
// The Single Particle Source is designed to extend the functionality of the
50
// G4ParticleGun class. It is designed to allow specification of input
51
// particles in terms of position, direction (or angular) and energy
52
// distributions. It is used by the General Particle source class
53
// and it is derived from G4VPrimaryGenerator.
54
//
55
// Note on thread safety:
56
// G4SingleParticleSource instances can be shared among threads. GeneratePrimaryVertex
57
// is protected via a mutex because underlying generators are not assumed to be thread-safe.
58
// Note that internal status of this class is assumed to be changed by master thread (typically
59
// via UI commands).
60
//
62
//
63
// MEMBER FUNCTIONS
64
// ----------------
65
//
66
// G4SingleParticleSource ()
67
// Constructor: Initializes variables and instantiates the
68
// Messenger and Navigator classes
69
//
70
// ~G4SingleParticleSource ()
71
// Destructor: deletes Messenger and prints out run information.
72
//
73
// void GeneratePrimaryVertex(G4Event *evt)
74
// Generate the particles initial parameters.
75
//
76
// G4SPSPosDistribution* GetPosDist()
77
// Return a pointer to the position distribution generator
78
//
79
// G4SPSAngDistribution* GetAngDist()
80
// Return a pointer to the angular distribution generator
81
//
82
// G4SPSEneDistribution* GetEneDist()
83
// Return a pointer to the energy distribution generator
84
//
85
// G4SPSRandomGenerator* GetBiasRndm() {return biasRndm;};
86
// Return a pointer to the biased random number generator
87
//
88
// void SetVerbosity(G4int);
89
// Set the verbosity level.
90
//
91
// void SetParticleDefinition ();
92
// G4ParticleDefinition * GetParticleDefinition ()
93
// Get/Set the particle definition of the primary track
94
//
95
// void SetParticleCharge(G4double aCharge)
96
// set the charge state of the primary track
97
//
98
// inline void SetParticlePolarization (G4ThreeVector aVal)
99
// inline G4ThreeVector GetParticlePolarization ()
100
// Set/Get the polarization state of the primary track
101
//
102
// inline void SetParticleTime(G4double aTime) { particle_time = aTime; };
103
// inline G4double GetParticleTime() { return particle_time; };
104
// Set/Get the Time.
105
//
106
// inline void SetNumberOfParticles(G4int i)
107
// inline G4int GetNumberOfParticles()
108
// set/get the number of particles to be generated in the primary track
109
//
110
// inline G4ThreeVector GetParticlePosition()
111
// inline G4ThreeVector GetParticleMomentumDirection()
112
// inline G4double GetParticleEnergy()
113
// get the position, direction, and energy of the current particle
114
//
116
//
117
#ifndef G4SingleParticleSource_h
118
#define G4SingleParticleSource_h 1
119
120
#include "
G4VPrimaryGenerator.hh
"
121
#include "
G4ParticleMomentum.hh
"
122
#include "
G4ParticleDefinition.hh
"
123
//
124
#include "
G4SPSPosDistribution.hh
"
125
#include "
G4SPSAngDistribution.hh
"
126
#include "
G4SPSEneDistribution.hh
"
127
#include "
G4SPSRandomGenerator.hh
"
128
#include "
G4Threading.hh
"
129
#include "
G4Cache.hh
"
130
141
class
G4SingleParticleSource
:
public
G4VPrimaryGenerator
{
142
public
:
143
G4SingleParticleSource
();
144
~G4SingleParticleSource
();
145
146
void
GeneratePrimaryVertex
(
G4Event
*evt);
147
//
148
149
G4SPSPosDistribution
*
GetPosDist
()
const
{
150
return
posGenerator
;
151
}
152
;
153
G4SPSAngDistribution
*
GetAngDist
()
const
{
154
return
angGenerator
;
155
}
156
;
157
G4SPSEneDistribution
*
GetEneDist
()
const
{
158
return
eneGenerator
;
159
}
160
;
161
G4SPSRandomGenerator
*
GetBiasRndm
()
const
{
162
return
biasRndm
;
163
}
164
;
165
166
// Set the verbosity level.
167
void
SetVerbosity
(
G4int
);
168
169
// Set the particle species
170
void
SetParticleDefinition
(
G4ParticleDefinition
* aParticleDefinition);
171
inline
G4ParticleDefinition
*
GetParticleDefinition
()
const
{
172
return
definition
;
173
}
174
;
175
176
inline
void
SetParticleCharge
(
G4double
aCharge) {
177
charge
= aCharge;
178
}
179
;
180
181
// Set polarization
182
inline
void
SetParticlePolarization
(
G4ThreeVector
aVal) {
183
polarization
= aVal;
184
}
185
;
186
inline
G4ThreeVector
GetParticlePolarization
()
const
{
187
return
polarization
;
188
}
189
;
190
191
// Set Time.
192
inline
void
SetParticleTime
(
G4double
aTime) {
193
time
= aTime;
194
}
195
;
196
inline
G4double
GetParticleTime
()
const
{
197
return
time
;
198
}
199
;
200
201
inline
void
SetNumberOfParticles
(
G4int
i) {
202
NumberOfParticlesToBeGenerated
= i;
203
}
204
;
205
//
206
inline
G4int
GetNumberOfParticles
()
const
{
207
return
NumberOfParticlesToBeGenerated
;
208
}
209
;
210
inline
G4ThreeVector
GetParticlePosition
()
const
{
211
return
ParticleProperties
.
Get
().position;
212
}
213
;
214
inline
G4ThreeVector
GetParticleMomentumDirection
()
const
{
215
return
ParticleProperties
.
Get
().momentum_direction;
216
}
217
;
218
inline
G4double
GetParticleEnergy
()
const
{
219
return
ParticleProperties
.
Get
().energy;
220
}
221
;
222
223
private
:
224
225
G4SPSPosDistribution
*
posGenerator
;
226
G4SPSAngDistribution
*
angGenerator
;
227
G4SPSEneDistribution
*
eneGenerator
;
228
G4SPSRandomGenerator
*
biasRndm
;
229
//
230
// Other particle properties
231
//These need to be thread-local because
232
//a getter for them exits
233
struct
part_prop_t
{
234
G4ParticleMomentum
momentum_direction
;
235
G4double
energy
;
236
G4ThreeVector
position
;
237
//G4double weight;
238
part_prop_t
();
239
};
240
G4Cache<part_prop_t>
ParticleProperties
;
241
G4int
NumberOfParticlesToBeGenerated
;
242
G4ParticleDefinition
*
definition
;
243
G4double
charge
;
244
G4double
time
;
245
G4ThreeVector
polarization
;
246
247
// Verbosity
248
G4int
verbosityLevel
;
249
250
//This can be a shared resource, this mutex is used in GeneratePrimaryVertex
251
G4Mutex
mutex
;
252
};
253
254
#endif
255
geant4
tree
geant4-10.6-release
source
event
include
G4SingleParticleSource.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:13
using
1.8.2 with
ECCE GitHub integration