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 GetParams and GetState methods may only be used during a run with Celeritas offloading enabled.

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.

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::TrackingManagerIntegration helper:

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 LocalTransporter from 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 TrackingManagerConstructor class to add the Celeritas tracking manager to your physics list.

  • Use SetOptions to set up options before G4RunManager::Initialize: usually in main for simple applications.

  • Call BeginOfRunAction and EndOfRunAction from UserRunAction

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 G4Envelope is a type alias to G4Region.

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 SetOptions to set up options before G4RunManager::Initialize: usually in main for simple applications.

  • In your G4VUserDetectorConstruction::ConstructSDandField, called during initialization, attach the FastSimulationModel to regions of interest

  • Call BeginOfRunAction and EndOfRunAction from UserRunAction

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 SetOptions to set Celeritas configuration before calling G4RunManager::BeamOn

  • Call BeginOfRunAction and EndOfRunAction (in IntegrationBase) from UserRunAction

  • Call BeginOfEvent and EndOfEvent from UserEventAction

  • Call PreUserTrackingAction from your UserTrackingAction

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::TrackingManagerIntegration instead 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.