Skip to content

o2-sim: Lean crossing locate for VecGeom navigation, and fixes - #16165

Open
sawenzel wants to merge 4 commits into
AliceO2Group:devfrom
sawenzel:swenzel/o2sim-vecgeom-lean
Open

sawenzel wants to merge 4 commits into
AliceO2Group:devfrom
sawenzel:swenzel/o2sim-vecgeom-lean

Conversation

@sawenzel

Copy link
Copy Markdown
Collaborator

This prepares a faster crossing locate for the VecGeom navigator (G4.navmode=kVecGeom) and fixes two problems found while comparing it with the propagating navigator.

The relocating navigator spent most of its extra time per boundary crossing on a push along the face normal and on a loop over flush volumes. A new locate, switched on with G4.vecgeomLeanLocate=true (off by default in this PR), relocates the way VecGeom does: it pushes 1e-6 cm along the step and lets containment and the BVH navigator's leaving rule decide. This cuts the crossing locate from about 4000 to 1800 instructions. Both navigators also update the Geant4 history incrementally now.

The fixes:

  • A track freed by the stuck-track push could be aborted when only chord steps followed it. A new run of zero steps now starts after a push into another volume, at most three times. Note that this also changes the output of the current locate, in a few tracks per hundred pp events.
  • The propagating navigator (G4.vecgeomNavigator=kPropagated) answered safety 0 for the whole first step in every new volume and for every new track. This removed the multiple-scattering displacement and cost 0.43 % of the visible energy of 1 GeV photons in EMCAL. With the fix it agrees with TGeo (1.0003 ± 0.0007). This fix is independent of the rest.

With the switch off, the output is the same as before apart from the restart above. Unit tests cover every case with both locates.

Assisted by Claude Code.

sawenzel and others added 4 commits November 21, 2026 11:56
This makes the VecGeom navigator start a new run of zero steps when a stuck-track push moved the track into a volume the run did not alternate between.

- The new run counts from zero and decides again between chords and momentum steps.
- A run restarts only if the track moved by at least half the push, and at most three times until the next finite step, so a track cannot be held forever.
- The volumes of a run are recorded from its eighth zero step only.
- The 10 um cap and the chord/momentum rule are unchanged.
- This changes the output of the current locate too.
- Two unit test cases cover the restart, the two conditions that prevent it, and the abort after the fourth run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This makes both VecGeom navigators update the Geant4 history incrementally for the three common transitions.

- Entering a daughter of the current volume adds that placement's chain of Geant4 levels.
- Leaving to the mother removes it, and moving into a sibling replaces it.
- Every other change still goes through historyFromState, which walked every level on every crossing.
- The update lives in the base class, so the relocating and the propagating navigator share it.
- The history is the same as before: the levels and their transforms are made by the same NewLevel calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This adds a run-time switch G4.vecgeomLeanLocate (default off) that locates a boundary crossing of the relocating VecGeom navigator the way VecGeom relocates.

- The point is pushed 1e-6 cm along the step direction, VecGeom's own push, instead of one tolerance across the face.
- No face normal is computed for the push, and the flush-volume loop is not run: at that depth containment pops every flush mother.
- An exit no longer records a block for the next step. Every mother with daughters is stepped with BVHNavigatorV, which refuses at zero distance a daughter the ray leaves.
- A parallel world node just left is still refused while the direction leaves it, with the normal computed only for that node.
- The navigator unit test runs every case with both locates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This fixes the safety of the propagating VecGeom navigator (G4.vecgeomNavigator=kPropagated) and adds unit tests.

- ComputeSafety answered 0 at every point until the next within-volume locate after a crossing, so the end point of the first step in a new volume had no safety.
- It now answers 0 only at the point where the crossing was located and at the end point of a step that ends on a boundary, as VecGeomG4Navigator does.
- The locate now consumes fWasLimitedByGeometry as G4Navigator does, so a new track is no longer taken for a crossing with the previous track's flags.
- ResetHierarchyAndLocate now clears the crossing state left by the previous track.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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