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
G4ParticleGun.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4ParticleGun.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
#ifndef G4ParticleGun_h
30
#define G4ParticleGun_h 1
31
32
33
#include "
globals.hh
"
34
#include "
G4VPrimaryGenerator.hh
"
35
#include "
G4ThreeVector.hh
"
36
#include "
G4ParticleDefinition.hh
"
37
#include "
G4PrimaryVertex.hh
"
38
#include "
G4ParticleMomentum.hh
"
39
40
class
G4Event
;
41
class
G4ParticleGunMessenger
;
42
43
// class description:
44
//
45
// This is a concrete class of G4VPrimaryGenerator. It shoots a particle of given type
46
// into a given direction with either a given kinetic energy or momentum.
47
// The position and time of the primary particle must be set by the corresponding
48
// set methods of G4VPrimaryGenerator base class, otherwise zero will be set.
49
//
50
// The FAQ to this class is for randomizing position/direction/kinetic energy of primary
51
// particle. But, G4ParticleGun does NOT have any way of randomization. Instead, the user's
52
// concrete implementation of G4VUserPrimaryGeneratorAction which transmits G4Event object
53
// to this particle gun can randomize these quantities and set to this particle gun before
54
// invoking GeneratePrimaryVertex() method.
55
// Note that, even if the particle gun shoots more than one particles at one invokation of
56
// GeneratePrimaryVertex() method, all particles have the same physical quantities. If the
57
// user wants to shoot two particles with different momentum, position, etc., invoke
58
// GeneratePrimaryVertex() method twice and set quantities on demand to the particle gun.
59
//
60
61
class
G4ParticleGun
:
public
G4VPrimaryGenerator
62
{
63
public
:
// with description
64
G4ParticleGun
();
65
G4ParticleGun
(
G4int
numberofparticles);
66
G4ParticleGun
(
G4ParticleDefinition
* particleDef,
67
G4int
numberofparticles = 1);
68
// costructors. "numberofparticles" is number of particles to be shoot at one invokation
69
// of GeneratePrimaryVertex() method. All paricles are shot with the same physical
70
// quantities.
71
72
public
:
73
virtual
~G4ParticleGun
();
74
75
private
:
76
G4ParticleGun
(
const
G4ParticleGun
&) =
delete
;
77
const
G4ParticleGun
&
operator=
(
const
G4ParticleGun
&) =
delete
;
78
G4bool
operator==
(
const
G4ParticleGun
&)
const
=
delete
;
79
G4bool
operator!=
(
const
G4ParticleGun
&)
const
=
delete
;
80
81
public
:
// with description
82
virtual
void
GeneratePrimaryVertex
(
G4Event
* evt);
83
// Creates a primary vertex at the given point and put primary particles to it.
84
// Followings are set methods for the particle properties.
85
// SetParticleDefinition should be called first.
86
// By using SetParticleMomentum(), both particle_momentum_direction and
87
// particle_energy(Kinetic Energy) are set.
88
//
89
void
SetParticleDefinition
90
(
G4ParticleDefinition
* aParticleDefinition);
91
void
SetParticleEnergy
(
G4double
aKineticEnergy);
92
void
SetParticleMomentum
(
G4double
aMomentum);
93
void
SetParticleMomentum
(
G4ParticleMomentum
aMomentum);
94
void
SetParticleMomentumDirection
95
(
G4ParticleMomentum
aMomentumDirection)
96
{
particle_momentum_direction
= aMomentumDirection.
unit
(); }
97
void
SetParticleCharge
(
G4double
aCharge)
98
{
particle_charge
= aCharge; }
99
void
SetParticlePolarization
(
G4ThreeVector
aVal)
100
{
particle_polarization
= aVal; }
101
void
SetNumberOfParticles
(
G4int
i)
102
{
NumberOfParticlesToBeGenerated
= i; }
103
104
public
:
105
G4ParticleDefinition
*
GetParticleDefinition
()
const
106
{
return
particle_definition
; }
107
G4ParticleMomentum
GetParticleMomentumDirection
()
const
108
{
return
particle_momentum_direction
; }
109
G4double
GetParticleEnergy
()
const
110
{
return
particle_energy
; }
111
G4double
GetParticleMomentum
()
const
112
{
return
particle_momentum
; }
113
G4double
GetParticleCharge
()
const
114
{
return
particle_charge
; }
115
G4ThreeVector
GetParticlePolarization
()
const
116
{
return
particle_polarization
; }
117
G4int
GetNumberOfParticles
()
const
118
{
return
NumberOfParticlesToBeGenerated
; }
119
120
protected
:
121
virtual
void
SetInitialValues
();
122
123
G4int
NumberOfParticlesToBeGenerated
;
124
G4ParticleDefinition
*
particle_definition
;
125
G4ParticleMomentum
particle_momentum_direction
;
126
G4double
particle_energy
;
127
G4double
particle_momentum
;
128
G4double
particle_charge
;
129
G4ThreeVector
particle_polarization
;
130
131
private
:
132
G4ParticleGunMessenger
*
theMessenger
;
133
};
134
135
#endif
136
137
138
139
140
141
142
geant4
tree
geant4-10.6-release
source
event
include
G4ParticleGun.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:13
using
1.8.2 with
ECCE GitHub integration