Open drbenmorgan opened 3 weeks ago
Ah, I guess I didn't know that multiple "beam on" could be run per execution 😅 The intended behavior for SharedParams
is to be set up once and torn down once. We don't want to recreate the VecGeom geometry every time we run a beam, for example. If begin/end of run is potentially called multiple times per execution, what's the right way to "initialize on startup" and "finalize on teardown"?
It depends... Between runs, Geant4 is in its "idle" state and so the geometry can completely change, the physics can change in certain aspects like parameters and (de)activation of some models (but it's much more limited). I'll have a look through the examples for the relevant cases and what/how gets triggered to rebuild.
However, would a useful first step be to simply allow multiple runs under the assumption that there are no changes in geometry/physics? The canonical use case is simply changing the particle gun configuration between runs and nothing else.
Huh, I didn't know the physics or geometry could change after the program started... it certainly seems like you can't change anything after closing the run manager which is where my misconception comes from.
I only spotted this in testing Celeritas in the celer-adept integration exercise. Offloading Geant4 tracks to Celeritas using any of the offload interfaces (
Simple/FastSimulation/TrackingManager
) results in a fatal exception from celeritas on the second invocation ofG4RunManager::BeamOn
:If the device activation is only once per program execution, then can we make it safe to call more than once, e.g. first call wins?