Skip to content

Initial setup for G4 FastSim hooks - #15698

Open
sawenzel wants to merge 5 commits into
AliceO2Group:devfrom
sawenzel:sawenzel/abso-fastsim-toy
Open

Initial setup for G4 FastSim hooks#15698
sawenzel wants to merge 5 commits into
AliceO2Group:devfrom
sawenzel:sawenzel/abso-fastsim-toy

Conversation

@sawenzel

@sawenzel sawenzel commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

This development makes it possible to register and use per-region fast simulation hooks with the Geant4 engine.
A toy demonstrator is added, showing this for the ALICE Absorber. This provides the grounding to hook a ML-model for the Absorber at a later stage.

**WIP : Not to be merged yet **

This adds a dedicated air material and medium for AFaM so that the front
absorber can be addressed as a single region.

- AFaM shared ABSO_AIR_C0 with AFaAcc, which is one of its own daughters.
- Geant4-VMC selects fast-simulation regions by material name and puts every
  volume of that material into the region, so a volume can only be a region of
  its own if its material is its own.
- ABSO_AIR_ENVELOPE0$ has the composition and density of ABSO_AIR0$ and takes
  the same global cuts and processes, so the physics is unchanged.
- No other code refers to ABSO medium index 20.
This commit provides the fast-simulation hook that O2 was missing, in a new
Detectors/FastSim module, plus one toy model that exercises it end to end. The
feature does nothing unless G4.fastSimModels names a model.

- o2::fastsim::G4RunConfiguration overrides CreateUserFastSimulation, which is
  the only piece geant4_vmc needed and O2 did not supply.
- TG4FastSimulationPhysics is already registered unconditionally by
  TG4SpecialPhysicsList, so the specialProcess string is unchanged.
- FastSimModel::DoIt is shared plumbing: it measures the distance to the
  envelope surface, kills the incident particle, stacks what comes back and
  books the energy difference as a deposit.
- A model implements sample(), which maps the particle that entered to the
  particles that leave.
- ToyAbsorberFastSim returns one particle carrying on in the incident direction
  with an exponentially attenuated energy.
- Regions are named as tracking media in G4.fastSimRegions.
- With G4.fastSimModels empty the run configuration returns nullptr and the
  behaviour is identical to before.

Usage:

  o2-sim -n 10 -g pythia8pp -e TGeant4 -m PIPE ABSO \
    --configKeyValues "G4.fastSimModels=toyAbsorber;G4.fastSimRegions=ABSO_AIR_ENVELOPE"

The steps inside the region disappear from the step log, which is the saving:
a fast step defaults to AvoidHitInvocation, so Geant4 does not call the
sensitive detector and TVirtualMCApplication::Stepping() is not invoked. That
is correct for a passive envelope, which has no hits to lose.
This adds run/SimExamples/FastSim_Absorber, which runs the same five events
through PIPE and ABSO twice, once with detailed transport and once with the
toy model, and compares the number of tracks.

- run.sh performs both simulations and the comparison.
- countTracks.macro reports tracks per event of an o2-sim output.
- README.md says how the feature is switched on, what the toy model does and
  why the region is named after a tracking medium.
This adds the numbers from a first run of the example, and says what they do
and do not show.

- Five pp events with PIPE and ABSO: 3544 tracks per event with detailed
  transport, 3160 with the toy model.
- Transport time is 29.8 s against 28.0 s, which is not a performance claim:
  only the forward cone of a minimum-bias pp event enters the absorber, so most
  of the transport in this setup happens outside the region.
- The geant4_vmc line confirming that the tracking medium resolved to its
  material is quoted, because a wrong medium name fails silently.
This documents a limitation found by running the example, and withdraws the
reading of its track counts.

- ABSO_AIR_ENVELOPE selects a region containing AFaM and nothing else: the VMC
  special cuts make every logical volume a root of its own material's region,
  and Geant4 stops propagating a region at any such daughter.
- AFaM's daughters touch its surface, so a track entering the absorber lands in
  a daughter and never has AFaM as its volume.
- A 20 GeV muon with /tracking/verbose 1 steps through the absorber identically
  with and without the fast simulation, showing only muIoni, eIoni,
  Transportation and specialCutForElectron.
- The two runs' random sequences diverge before the absorber, so the track
  counts previously recorded do not measure the model.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant