1.3. Geant4 Simulation Structure
Table of Contents
Run
A Geant4 simulation is organized hierarchically, and the run is the top of this hierarchy inside a single execution of your program. A run groups together many events that are all simulated with the same configuration. This means that the geometry, physics list, primary particle setup, and most user settings must be fixed before the run starts and stay unchanged until the run ends.
You typically start a run with a command such as /run/beamOn N, where $N$ is the number of events. During the run, Geant4 creates events one by one, transports particles, and records all requested information. At the beginning of a run, any BeginOfRunAction code you define is executed, which is the correct place to reset global counters, open output files, or initialize analysis objects. At the end of the run, EndOfRunAction is called, and you usually finalize histograms, write files, and print summary statistics.
A run is a set of events simulated with a fixed geometry and physics configuration. Changing geometry or physics inside a run is not supported and leads to undefined results.
Runs also provide the natural unit for accumulating and reporting simulation statistics, such as total number of primaries, total deposited dose in a volume, or overall efficiency. When you need to compare two different configurations, such as two materials or two physics lists, you generally perform two separate runs.
Event
Inside a run, Geant4 simulates one event at a time. An event represents a single occurrence of the physical process you study, such as one primary particle entering your detector, one radioactive decay, or one collision. Each call to the primary generator creates the primary particles for that event, and all the resulting particle transport, interactions, and secondaries belong to the same event.
From the user point of view, G4Event is the object that holds everything related to one event. It contains the primary vertices and particles, and it can store collections of hits or trajectories created during tracking. You can access the event in EventAction to perform tasks such as resetting per event variables at the beginning, and computing per event quantities like total energy deposition in a detector at the end.
An event is considered complete when all tracks created from its primaries have reached a final state, such as being stopped, absorbed, killed by tracking cuts, or leaving the world volume. After that, Geant4 calls your EndOfEventAction code, you can access hits and other data, and then the event object can be discarded before the next event begins.
An event is the independent unit of physics simulation. All particles created from a single primary interaction form one event, and event level results must be computed before the next event starts.
Track
During an event, Geant4 represents the motion of each particle with a track. A track corresponds to one particle as it moves through space and time until it stops or is removed from the simulation. Each primary particle starts its life as a track. When interactions create secondary particles, each secondary becomes a new track with its own track ID and parent ID.
The G4Track object stores the current state of the particle: position, momentum, kinetic energy, time, and the medium it is currently in. It also carries identity information such as particle type, charge, track ID, parent ID, and track status. As the particle advances, the same G4Track object is updated step by step until the track is finished.
You can inspect tracks and react to tracking events by implementing a TrackingAction. This allows you to perform operations such as storing the initial state of tracks, counting the number of specific particles produced, or applying custom logic when tracks start or end.
A track is one particle history within an event, identified by a unique track ID and a parent ID that links it to its creator.
Step
Geant4 does not move a particle continuously. Instead, it advances a track in small segments called steps. A step is the part of a trajectory between two points where something notable may happen, such as a boundary crossing between volumes, an interaction with matter, or a point at which a tracking limit is applied. This discretization allows Geant4 to calculate energy loss and to detect changes in geometry accurately.
The G4Step object describes a single step. It has two key points, the pre step point and the post step point, which store information such as position, material, kinetic energy, and physical volume at the beginning and at the end of the step. The step also contains quantities that belong to that segment, for example the total energy deposited in this step in the current volume.
Steps are the natural level at which Geant4 computes energy deposition and other local quantities. Sensitive detectors use steps to create hits, and your SteppingAction can inspect each step to implement custom logic, such as rejecting tracks that enter a certain region, recording step positions, or accumulating quantities per event or per volume.
A step is the smallest simulation unit of particle motion. Most local detector responses, such as energy deposition in a volume, are computed per step.
Geometry
The simulation structure described so far, from run to step, only defines how the simulation proceeds in time. For the simulation to have physical meaning, you need a spatial description of where particles move and interact. This is provided by the geometry: a hierarchy of volumes that fill space, define materials, and represent your detector, shield, phantom, or experimental setup.
At the top level there is the world volume, a large container that encloses all other volumes. Inside the world, you place additional volumes to represent components like detectors, shielding layers, or supports. Each volume has a shape, a size, a position and orientation, and a material. Geant4 uses this geometry to find which material a track is in at each step, when it crosses a boundary, and which volume is currently active.
The geometry does not directly belong to a particular run, event, or track, but it is used by all of them. During each step, the pre and post step points contain pointers to the physical and logical volumes that the particle moves through. Sensitive detectors are also attached to geometry components, which creates a direct link between steps and detector response.
The geometry defines where particles propagate and which materials they traverse. All tracking, stepping, and detector responses depend on this spatial structure.
Physics
While the geometry tells Geant4 where particles are, the physics list tells it what can happen to them. The physics configuration defines which particles exist in the simulation and which physical processes affect them. These processes include electromagnetic interactions, hadronic interactions, decays, and many others.
During tracking, the physics processes attached to a particle type compete to determine the next interaction and the step length. For each step, Geant4 calculates how far the particle can move before the next interaction or geometric boundary. It then selects the shortest allowed step, updates the track, and, if an interaction occurs, creates secondary tracks and energy deposition according to the chosen physics model.
Physics is configured once, before a run begins, through the physics list. Inside a run, for each event, track, and step, the same physics configuration is applied consistently. This guarantees that all events within a run are simulated under the same physical conditions.
The physics list defines which particles are tracked and which processes act on them. Every step is the result of the combined effect of geometry and physics.
Primary particles
Each event starts with one or more primary particles. These are the initial particles that you define through your primary generator, either with a simple particle gun or with the General Particle Source. Primary particles represent your beam, your radioactive source, or any initial conditions required for the scenario you want to study.
For every event, the primary generator builds one or more primary vertices, each with a position, a time, and a set of primary particles with given directions, energies, and types. Geant4 converts these primaries into initial tracks with parent ID equal to zero. All secondary particles created later in the event will have parent IDs referring back to these primaries or to other secondaries.
The structure from event to track allows you to distinguish between the original primaries and all secondaries produced along the way. This is important for analysis, for example when you want to know how much energy comes directly from the beam compared to background particles produced inside your geometry.
Primary particles define the initial state of each event. They are the only tracks with parent ID equal to zero and are created by the user defined primary generator.
Sensitive detectors
In a real experiment, you never see microscopic steps directly. Instead, you observe signals in detectors. In Geant4, sensitive detectors are the bridge between the underlying tracking and the detector level response that you want to analyze.
A sensitive detector is attached to one or more logical volumes. Whenever a step occurs in a volume that has a sensitive detector, Geant4 calls the detector’s ProcessHits method with the current step information. Inside this method, you examine quantities such as energy deposition, step position, or time, and you convert them into hits that represent your detector’s response. These hits are stored in hit collections for each event.
Sensitive detectors operate at the step level but are organized per event. At the beginning of each event, hit collections are empty. As tracks move and steps occur, sensitive detectors fill these collections with hits. At the end of the event, you can access all hits, sum them into energy spectra, count triggered channels, or perform any other event level analysis you need.
A sensitive detector connects steps in specific volumes to detector signals. It creates hits from step information and organizes them into collections per event.
Overall, the Geant4 simulation structure forms a clear hierarchy: runs contain events, events contain tracks, tracks are advanced in steps, steps occur within geometry volumes, physics defines what happens from step to step, primary particles start each event, and sensitive detectors turn steps into measurable detector responses. Understanding how these pieces fit together is essential before you begin writing your own Geant4 applications.
Views: 9
KAHIBARO