|
gparticle
|
The gparticle module implements a simple mechanism to define one or more primary particles from structured options and then shoot them into a G4Event using a G4ParticleGun.
The central class is Gparticle, which encapsulates:
Option parsing is performed via the functions in the gparticle namespace. Those functions translate structured option nodes, such as -gparticle=... and -gparticlefile=..., into inline particles, file-backed event particles, and output-bank records.
For uniform theta sampling, delta_theta is the half-width around the nominal theta value:
![\[ \theta_{sampled} \in [\theta - \Delta\theta,\; \theta + \Delta\theta]
\]](form_0.png)
The full angular sector therefore spans 
theta=40*deg and delta_theta=12*deg, giving an interval from 28 to 52 degrees.
The interpretation of a delta depends on the selected randomization model:
uniform: flat sampling inside the center-plus-or-minus-delta interval.gaussian: delta is one standard deviation and does not impose a hard boundary.cosine: theta is sampled uniformly in 
sphere: vertex offsets are sampled inside a sphere whose radius is derived from delta_v.The -gparticlefile option configures one or more generated-particle files:
Each file source has a format token and a filename. Built-in readers are registered statically, while external formats can be provided by dynamic plugins named gparticle_<format>_plugin that export GParticleReaderFactory.
Readers expose two related views of the same input:
G4ParticleTable.For Lund files, rows with type == 1 are propagated in Geant4. All parsed rows are preserved in the record view.
During event generation GEMC publishes two generated-particle banks:
generated : inline -gparticle definitions plus all particles parsed from -gparticlefile sources, including rows not propagated in Geant4.generated_tracked : inline -gparticle definitions plus only the file-backed particles propagated in Geant4, normally rows with type == 1.Both banks carry particle name, pid, source type, multiplicity, momentum, theta, phi, and vertex coordinates.
gparticle uses logging through GLogger. When the logger verbosity is:
G4RunManager with a basic physics list.The following excerpt shows how the example program builds the options and retrieves particles: