Jump to content

Understanding the Function Hierarchy

From Luter 345 Experiments
Revision as of 17:59, 24 December 2024 by Brash99 (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Summary[edit | edit source]

A Geant4 program has an underlying class structure that must be understood to manipulate a program successfully. These components correspond to their own classes; Namely, these are the Run Action, Event Action, and Stepping Action. These, like most other aspects of a Geant4 simulation can be manipulated, but they must exist and understanding their relationships with each other is crucial. Due to the complexity of Geant's Function Hierarchy, I will simply highlight its essential functions and basic uses. For further documentation, please refer to CERN's Geant4 User Guide:


Runs[edit | edit source]

A run is the highest level of a Geant4 simulation. It is made up of one or more events. A user can define actions taken at the beginning and end of each event in the run action class file. Typically creating and saving the Ntuple used in the simulation occurs at the run level. The detector construction and generator action are also run level classes, even though they are only executed in the main. This means they are executed once per run, and they cannot change during a simulation.

When running a simulation with the visualization package, the command to execute the simulation is run/beamOn <number>. The number is actually the number of events you wish to occur in this run. In effect, this command occurs at the run level as well.

Events[edit | edit source]

An event is a subunit of a run, and is comprised of steps. Just like with a run, users define what actions should take place at the beginning and end of each event in the event action file. These actions are highly variable between applications, but common event level actions are saving initial conditions of the event and saving some final result.

As a rule of thumb, the event should be one instance of whatever the simulation is meant to study. For example, if you wanted to simulate what happens to skin when exposed to sunlight, the event might be shooting an equivalent number of particles from one hour of sunlight at simulated skin. The idea would be to repeat this to come to a conclusion, so it would be a good step.

Steps[edit | edit source]

A step is the lowest level of a Geant4 simulation. Just like with runs and events, steps can be manipulated greatly by a user. This occurs in the stepping action file. Steps are a small period of time, entering or exiting a volume, and any kind of particle decay. The simulation actually breaks events into steps without having to define anything, however the user must define what to do at each step. Often this is recording some piece of data, like the energy of the particle.

It is important to remember that there are multiple steps within a single event, so if values are added during each step to an Ntuple, it will be difficult to identify the beginning or end of each event. It may be beneficial to flag your data in some way so it can be separated later by a ROOT macro. For example, if you have a column called energy that gets recorded at each step, it may be helpful to add an entry of negative one at the beginning of each event. Then in your ROOT macro, a simple if statement can be used to check for this flag and save the next set of data as belonging to a different event.