High level interfaces¶
The high-level integration classes are the easiest way to add Celeritas to a
Geant4 application. Under the hood, it contains a singleton class instance that
sets up the UI commands (see celeritas::SetupOptionsMessenger),
MPI (if configured), and Celeritas logging (redirecting “world” logging with
celeritas::MakeMTWorldLogger() and “self” logging with
celeritas::MakeMTSelfLogger()) .
-
class IntegrationBase¶
Common interface for integrating Celeritas into user applications.
This implements common functionality for the Celeritas integration classes. The
GetParamsandGetStatemethods may only be used during a run with Celeritas offloading enabled.See also
Subclassed by celeritas::FastSimulationIntegration, celeritas::TrackingManagerIntegration, celeritas::UserActionIntegration
User integration points
-
void SetOptions(SetupOptions &&opts)¶
Set options before starting the run.
This captures the input to indicate that options cannot be modified by the framework after this point.
-
void BeginOfRunAction(G4Run const *run)¶
Start the run.
This handles shared/local setup and calls verify_setup if offload is enabled.
-
void EndOfRunAction(G4Run const *run)¶
End the run.
Low-level Celeritas accessors
-
OffloadMode GetMode() const¶
Access whether Celeritas is set up, enabled, or uninitialized.
This is only legal to call after
SetOptions.
-
CoreParams const &GetParams()¶
Access global Celeritas shared params during a run, if not disabled.
-
CoreStateInterface &GetState()¶
Access thread-local Celeritas core state data for user diagnostics.
This can only be called when Celeritas is enabled (not kill-offload, not disabled).
This cannot be called from the main thread of an MT application.
-
void SetOptions(SetupOptions &&opts)¶
Tracking manager¶
Using Celeritas to “offload” all electrons, photons, and gammas from Geant4 can
be done using the new-ish Geant4 interface G4VTrackingManager
implemented by celeritas::TrackingManager. To set up the tracking
manager correctly, we recommend using this helper class:
-
class TrackingManagerConstructor : public G4VPhysicsConstructor¶
Construct a Celeritas tracking manager that offloads EM tracks.
This should be composed with your physics list after it is constructed, before the simulation begins. By default this uses the
celeritas::TrackingManagerIntegrationhelper:auto* physics_list = new FTFP_BERT; physics_list->RegisterPhysics(new TrackingManagerConstructor{ &TrackingManagerIntegration::Instance()});
but for manual integration it can be constructed with a function to get a reference to the thread-local
LocalTransporterfrom the Geant4 thread ID:auto* physics_list = new FTFP_BERT; physics_list->RegisterPhysics(new TrackingManagerConstructor{ shared_params, [](int){ return &local_transporter; });
Note
If Celeritas is globally disabled, it will not add the track manager. If Celeritas is configured to “kill offload” mode (for testing maximum theoretical performance) then the tracking manager will be added but will not send the tracks to Celeritas: it will simply kill them.
The high-level celeritas::TrackingManagerIntegration class should be used in
addition to the tracking manager constructor to set up and tear down Celeritas.
See Geant4-Celeritas offloading template for a template of adding to a user application.
-
class TrackingManagerIntegration : public celeritas::IntegrationBase¶
Simple interface for G4VTrackingManager-based integration.
This singleton integrates both thread-local and global data with the user application. To use this class in your Geant4 application to offload tracks to Celeritas:
Use the
TrackingManagerConstructorclass to add the Celeritas tracking manager to your physics list.Use
SetOptionsto set up options beforeG4RunManager::Initialize:usually inmainfor simple applications.Call
BeginOfRunActionandEndOfRunActionfromUserRunAction
See further documentation in
celeritas::IntegrationBase.Public Static Functions
-
static TrackingManagerIntegration &Instance()¶
Access the public-facing integration singleton.
Fast simulation¶
It is currently not recommended to offload tracks on a per-region basis, since tracks exiting that region remain in Celeritas and on GPU.
-
class FastSimulationModel : public G4VFastSimulationModel¶
Offload tracks to Celeritas via G4VFastSimulationModel interface.
This class must be constructed locally on each worker thread/task, typically within the application’s concrete implementation of
G4VUserDetectorConstruction::ConstructSDandField().Note that the argument
G4Envelopeis a type alias toG4Region.
-
class FastSimulationIntegration : public celeritas::IntegrationBase¶
Simple interface for G4VTrackingManager-based integration.
This singleton integrates both thread-local and global data with the user application. To use this class in your Geant4 application to offload tracks to Celeritas:
Use
SetOptionsto set up options beforeG4RunManager::Initialize:usually inmainfor simple applications.In your
G4VUserDetectorConstruction::ConstructSDandField, called during initialization, attach theFastSimulationModelto regions of interestCall
BeginOfRunActionandEndOfRunActionfromUserRunAction
See further documentation in
celeritas::IntegrationBase.Public Static Functions
-
static FastSimulationIntegration &Instance()¶
Access the public-facing integration singleton.
User action¶
For compatibility with older versions of Geant4, you may use the following
class to integrate Celeritas by manually intercepting tracks with a
UserTrackingAction.
-
class UserActionIntegration : public celeritas::IntegrationBase¶
Simple interface for G4VUserTrackingAction-based integration.
This singleton integrates both thread-local and global data with the user application. To use this class in your Geant4 application to offload tracks to Celeritas:
Use
SetOptionsto set Celeritas configuration before callingG4RunManager::BeamOnCall
BeginOfRunActionandEndOfRunAction(inIntegrationBase) fromUserRunActionCall
BeginOfEventandEndOfEventfromUserEventActionCall
PreUserTrackingActionfrom yourUserTrackingAction
The method names correspond to methods in Geant4 User Actions and must be called from all threads, both worker and master.
See further documentation in
celeritas::IntegrationBase.Note
Prefer to use
celeritas::TrackingManagerIntegrationinstead of this class, unless you need support for Geant4 earlier than 11.0.Public Functions
-
void BeginOfEventAction(G4Event const *event)¶
Send Celeritas the event ID.
-
void PreUserTrackingAction(G4Track *track)¶
Send tracks to Celeritas if applicable and “StopAndKill” if so.
-
void EndOfEventAction(G4Event const *event)¶
Flush offloaded tracks from Celeritas.
Public Static Functions
-
static UserActionIntegration &Instance()¶
Access the singleton.