Celeritas 0.7+7c39d13
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
StateDependent.hh File Reference
#include <functional>
#include <G4VStateDependent.hh>
#include "corecel/Macros.hh"
#include "corecel/sys/ThreadId.hh"

Classes

class  celeritas::StateDependent
 Receive notifications when the Geant4 application state changes. More...
 

Typedefs

using celeritas::LocalGeantStateChangeFunc = std::function< void(StreamId, GeantStateChange)>
 

Enumerations

enum class  celeritas::GeantStateChange {
  begin_program , initialize , begin_init , internal_init ,
  end_init , begin_run , begin_event , end_event ,
  end_run , end_program , unknown , size_
}
 Encode a meaningful Geant4 state transition for user callbacks. More...
 

Functions

char constceleritas::to_cstring (GeantStateChange value)
 Get a string corresponding to a Geant4 state change.
 

Enumeration Type Documentation

◆ GeantStateChange

enum class celeritas::GeantStateChange
strong

Encode a meaningful Geant4 state transition for user callbacks.

The transitions are encoded as GeantStateChange values according to the following table (previous -> requested):

Previous State Requested State Change
none G4State_PreInit begin_program
G4State_PreInit G4State_Init initialize
G4State_Idle G4State_Init begin_init
G4State_Init G4State_Init internal_init
G4State_Init G4State_Idle end_init
G4State_Idle G4State_GeomClosed begin_run
G4State_GeomClosed G4State_EventProc begin_event
G4State_EventProc G4State_GeomClosed end_event
G4State_GeomClosed G4State_Idle end_run
any G4State_Quit end_program
any G4State_Abort end_program
other other unknown
Notes:
  • begin_program is called during the G4RunManagerKernel constructor, so it will only register if your state dependent is constructed very early and on the main thread.
  • We ignore all but the first Initialize state (from "pre-init")
  • In MT mode, RunManager::Initialize actually calls begin/end run for each thread, including master.
  • end_program is called by the G4RunManager and G4RunManagerKernel destructor during normal execution (via G4State_Quit).
  • end_program is called by G4Exception when a fatal error occurred (via G4State_Abort).