Skip to content

Make the VecGeom navigation mode of o2-sim faster with safety bounds and MultiUnions - #15887

Open
sawenzel wants to merge 3 commits into
AliceO2Group:devfrom
sawenzel:swenzel/o2sim-vecgeom-safety-boolean
Open

sawenzel wants to merge 3 commits into
AliceO2Group:devfrom
sawenzel:swenzel/o2sim-vecgeom-safety-boolean

Conversation

@sawenzel

@sawenzel sawenzel commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

This PR speeds up the G4.navmode=kVecGeom mode introduced in #15865 and fixes a stale exit block in its relocating navigator. It ports findings of a study done on the G4VecGeomNav plugin (https://gitlab.cern.ch/VecGeom/g4vecgeomnav/-/merge_requests/27).

Two changes reduce the cost per step. The stand-alone safety now honours the bound Geant4 passes with the query and reuses the last safety within its sphere, as Geant4's own voxel safety does. In addition, VecGeom's BooleanFactory rewrites Boolean solids of 8 or more components into MultiUnions; in ALICE this concerns 170 composite shapes, among them the MFT disk supports and the ITS end wheels. The third commit clears an exit block that entering a daughter carried over from the previous crossing; it made seven of 50000 geantino rays through the ITS outer-barrel services see too much copper.

Transport time per event, same events in every mode (Run 3 detector without ZDC, no alignment, VecGeom master, serial, 160–200 pp and 20 minimum-bias Pb-Pb events per mode, 95 % intervals):

mode pp Pb-Pb
kTGeo 1 1
kVecGeom, kRelocating, before 0.886 ± 0.016 0.896 ± 0.014
kVecGeom, kRelocating, this PR 0.816 ± 0.013 0.833 ± 0.013*
kVecGeom, kPropagated, before 0.858 ± 0.019 0.868 ± 0.010
kVecGeom, kPropagated, this PR 0.807 ± 0.013 0.821 ± 0.013

* measured with three further locate changes that leave every hit unchanged and are not part of this PR; they made kRelocating about 1 % faster in pp.

Note that the changes are not intended to alter the physics. With up to 2000 paired pp events, hits and energy deposits per detector agree with the previous VecGeom navigation within 2σ, and the ray and location cross-checks against TGeo are unchanged by the MultiUnions. Two differences to kTGeo that exist already before this PR remain under study: about 2 % fewer EMCAL hits with the same energy deposit, and a few per cent more TOF energy. G4.vecgeomBooleanThreshold=0 restores the converted solids.

Overall, VecGeom navigation now saves about 18 % of the transport time compared with TGeo, for pp and Pb-Pb alike.

Assisted by Claude Code.

This lets VecGeom's BooleanFactory rewrite Boolean solids of at least 8 components into MultiUnions in the kVecGeom mode.

- In the ALICE geometry 170 composite shapes are rewritten, among them the MFT disk supports and the ITS end wheels.
- G4.vecgeomBooleanThreshold sets the threshold; 0 keeps the solids as converted.
- Other users of buildVecGeomGeometry keep the solids as converted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sawenzel and others added 2 commits October 2, 2026 12:21
This makes the stand-alone ComputeSafety of both VecGeom navigators cheaper, as Geant4's own navigator does.

- The caller's proposedMaxLength now limits the BVH search: the value is exact below it and a valid lower bound above it, as in G4VoxelSafety.
- A query at distance d from the last safety origin returns s0 - d when that covers the bound, without a computation. Every locate drops this cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This fixes a stale exit block in the relocating VecGeom navigator.

- Entering a daughter adopted the state of the step, which could still carry the block of the volume the previous crossing left, so that volume stayed blocked one step longer than Geant4's rule allows.
- Seven of 50000 geantino rays through the ITS outer-barrel services saw up to 9 X0 too much copper because of it; they now agree with TGeo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sawenzel
sawenzel force-pushed the swenzel/o2sim-vecgeom-safety-boolean branch from 6dc8313 to 2beea34 Compare October 2, 2026 10:21
@sawenzel
sawenzel marked this pull request as ready for review October 2, 2026 10:21
@sawenzel
sawenzel requested review from a team and shahor02 as code owners October 2, 2026 10:21
@alibuild

alibuild commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Error while checking build/O2/fullCI_slc9 for 2beea34 at 2026-10-02 12:25:

No log files found

Full log here.

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.

2 participants