Internal Generator
The internal GEMC generator is configured with two cumulative options.
gparticle defines inline particle sources. Each entry adds one particle (or a group of
identical copies) to every event. Multiple entries can be combined in the same list.
gparticlefile loads event records from a file. The built-in reader supports the
LUND format.
When both options are present, every generated event receives all particles from gparticle
plus all particles from the matching event record in each gparticlefile source.
Both options can be set from the YAML steering card or the command line:
# YAML steering card
gparticle:
- name: e-
p: 2300
theta: 23.0
# equivalent command-line form
gemc -gparticle="[{name: e-, p: 2300, theta: 23.0}]"
gparticle
Fields
name and p are required. All other fields are optional.
| Field | Default | Description |
|---|---|---|
name |
required | Geant4 particle name, e.g. e-, proton, gamma, pi+ |
p |
required | Nominal momentum magnitude, interpreted with punit |
multiplicity |
1 |
Number of copies generated per event; each copy is independently randomized |
punit |
MeV |
Unit for p and delta_p. Use MeV or GeV |
delta_p |
0 |
Momentum spread around p |
randomMomentumModel |
uniform |
uniform: flat in [p − delta_p, p + delta_p]; gaussian: Gaussian with sigma delta_p |
theta |
0 |
Nominal polar angle (from the z-axis) |
delta_theta |
0 |
Polar-angle spread around theta |
randomThetaModel |
uniform |
uniform: flat in [θ − Δθ, θ + Δθ]; gaussian: Gaussian sigma delta_theta; cosine: cos(θ) uniform, with rejection sampling within the window (see note below) |
phi |
0 |
Nominal azimuthal angle |
delta_phi |
0 |
Azimuthal-angle spread. Always applied with the uniform model — there is no randomPhiModel |
aunit |
deg |
Unit for theta, delta_theta, phi, delta_phi. Use deg or rad |
vx |
0 |
Nominal vertex x |
vy |
0 |
Nominal vertex y |
vz |
0 |
Nominal vertex z |
delta_vx |
0 |
Vertex x spread |
delta_vy |
0 |
Vertex y spread |
delta_vz |
0 |
Vertex z spread |
vunit |
cm |
Unit for vertex positions and spreads |
randomVertexModel |
uniform |
uniform: each component flat in [v − δv, v + δv]; gaussian: Gaussian sigma per component; sphere: uniform sampling within a spherical volume (see note below) |
Note
cosine theta model — samples θ such that cos(θ) is uniform using rejection sampling
within [theta − delta_theta, theta + delta_theta]. For narrow windows the acceptance rate
can be low. This model is most efficient when delta_theta covers a large fraction of
the full range [0, 180°].
Note
sphere vertex model — generates vertices uniformly within a spherical volume centred on
the nominal vertex. Set delta_vx, delta_vy, delta_vz all equal to the desired sphere
radius. Using different values for the three components changes the effective sampling sphere
size.
Examples
One 2.3 GeV electron at 23°
gparticle:
- name: e-
p: 2300
theta: 23.0
Analyzer command:
python3 -m analyzer generated_tracked.csv theta --kind csv --bins 50 --linear-y
Explicit units with theta spread of 0.2 rad
gparticle:
- name: e-
p: 2.3
punit: GeV
theta: 0.4
delta_theta: 0.2
aunit: rad
Analyzer command:
python3 -m analyzer generated_tracked.csv theta --kind csv --bins 50 --linear-y
10 protons per event, uniform in φ
gparticle:
- name: proton
multiplicity: 10
p: 1200
theta: 14.0
delta_phi: 180.0
Analyzer command:
python3 -m analyzer generated_tracked.csv phi --kind csv --bins 50 --linear-y
Momentum spread — uniform
gparticle:
- name: e-
p: 2300
delta_p: 100
randomMomentumModel: uniform
Analyzer command:
python3 -m analyzer generated_tracked.csv p --kind csv --bins 50 --linear-y
Momentum spread — Gaussian
gparticle:
- name: e-
p: 2300
delta_p: 100
randomMomentumModel: gaussian
Analyzer command:
python3 -m analyzer generated_tracked.csv p --kind csv --bins 50 --linear-y
Cosine theta sampling
gparticle:
- name: e-
p: 2300
theta: 23.0
delta_theta: 5.0
randomThetaModel: cosine
Analyzer command:
python3 -m analyzer generated_tracked.csv theta --kind csv --bins 50 --linear-y
Azimuthal-angle spread
gparticle:
- name: e-
p: 2300
phi: 45.0
delta_phi: 20.0
Analyzer command:
python3 -m analyzer generated_tracked.csv phi --kind csv --bins 50 --linear-y
Fixed vertex position
gparticle:
- name: e-
p: 2300
vx: 0.0
vy: 0.0
vz: -10.0
vunit: cm
Analyzer command:
python3 -m analyzer generated_tracked.csv vz --kind csv --bins 50 --linear-y
Vertex z spread — uniform
gparticle:
- name: e-
p: 2300
vz: 0.0
delta_vz: 2.0
vunit: cm
randomVertexModel: uniform
Analyzer command:
python3 -m analyzer generated_tracked.csv vz --kind csv --bins 50 --linear-y
Vertex spread — Gaussian
gparticle:
- name: e-
p: 2300
delta_vx: 1.0
delta_vy: 1.0
delta_vz: 5.0
vunit: mm
randomVertexModel: gaussian
Analyzer command:
python3 -m analyzer generated_tracked.csv vz --kind csv --bins 50 --linear-y
Multiple particle definitions
Each entry is an independent source; all contribute to every event. Here one electron (fixed angle) and two protons (smeared angle) are generated per event:
gparticle:
- name: e-
p: 2300
theta: 23.0
- name: proton
multiplicity: 2
p: 1200
theta: 14.0
delta_theta: 10.0
Analyzer command:
python3 -m analyzer generated_tracked.csv theta --kind csv --bins 50 --linear-y
gparticlefile
gparticlefile loads particle definitions from a file. Each entry specifies a format
and a filename:
| Field | Description |
|---|---|
format |
File format reader name. The built-in reader is lund (case-insensitive). |
filename |
Path to the input file containing event records. |
gparticlefile:
- format: lund
filename: events.lund
Event records are matched by index: file event 0 is used for GEMC event 0, file event 1 for GEMC event 1, and so on. In multi-threaded mode Geant4 distributes event IDs to worker threads; each file event is still assigned to exactly one GEMC event.
Multiple sources can be combined — events from all files are merged by index:
gparticlefile:
- format: lund
filename: beam_background.lund
- format: lund
filename: signal.lund
See the LUND format documentation for the file structure, column definitions, and unit conventions.