Skip to content

o2-sim: VecGeom navigation mode for Geant4 - #15865

Merged
sawenzel merged 5 commits into
AliceO2Group:devfrom
sawenzel:swenzel/o2sim-vecgeom-navigation
Oct 1, 2026
Merged

sawenzel merged 5 commits into
AliceO2Group:devfrom
sawenzel:swenzel/o2sim-vecgeom-navigation

Conversation

@sawenzel

Copy link
Copy Markdown
Collaborator

This PR achieves a long-standing goal of navigating ALICE simulations with VecGeom instead of TGeo. With G4.navmode=kVecGeom, Geant4 answers every navigation query from a VecGeom geometry converted from TGeo, while the Geant4 geometry, the materials and the touchables remain those built by g4root, so hits, volume ids and copy numbers are produced as before.

Each VecGeom placement is paired with the chain of g4root volumes it stands for, which keeps the Geant4 touchable and every detector's volume lookup unchanged although assemblies are flattened in VecGeom. Two navigators are provided. kRelocating, the default, relocates at each boundary with the volume just left blocked for the next step, as the navigator of G4VecGeomNav does (https://gitlab.cern.ch/VecGeom/g4vecgeomnav/-/merge_requests/25). kPropagated adopts the state VecGeom propagated during the step, does less work per crossing, and is kept for comparison.

In full pp simulation the VecGeom mode transports faster than TGeo:

mode s / event relative
kTGeo 5.53 1
kVecGeom, kRelocating 5.01 0.906
kVecGeom, kPropagated 4.87 0.880

This costs 5.7 s of initialisation and 0.23 GB of memory.

Note that the physics is not intended to change. 500 paired Pythia8 pp events give the TGeo hit counts and energy deposits within statistics in every detector except FDD, where both VecGeom navigators register about 10 % more hits on the A side; this is being followed up. The mode relies on the geometry stability fixes submitted separately, without which FT0 and TOF lose hits.

The mode is built when TGeo2VecGeom and a VecGeom with the BVH navigator of the VNavigator family (https://gitlab.cern.ch/VecGeom/VecGeom/-/merge_requests/1547) are found; otherwise it is compiled out.

Overall, o2-sim can now be run with VecGeom navigation, reproducing the TGeo-mode hits and saving about 9 % of the transport time.

Assisted by Claude Code.

sawenzel and others added 3 commits September 29, 2026 11:46
This lets GeometryManager set up VecGeom for Geant4 navigation as well as for the material budget.

- buildVecGeomGeometry() converts once and takes the assembly flattening as a parameter; the
  material budget keeps flattening.
- With a VecGeom that has BVHNavigatorV, volumes with more than two daughters get the BVH navigator
  and level locator, and every volume gets an explicit safety estimator.
- Without it the VecGeom v2 setup is unchanged.

https://gitlab.cern.ch/VecGeom/VecGeom/-/merge_requests/1547

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This adds G4.navmode=kVecGeom, in which Geant4 answers every navigation query from VecGeom.

- The geometry, materials and touchables stay the ones g4root builds from TGeo.
- VecGeomG4Map pairs each VecGeom placement with the chain of g4root volumes it stands for, so
  volume ids, copy numbers and CurrentVolOffID are unchanged.
- VecGeomG4Navigator relocates at the boundary locate, with the volume just left blocked for the
  next step and the point pushed across the face by a small depth, as G4VecGeomNav's
  TG4VecGeomNavigator does.
- G4.vecgeomCheckRays, vecgeomCheckLocation and vecgeomCheckVolumes compare VecGeom with TGeo
  before transport.
- It is built only when TGeo2VecGeom and a VecGeom with BVHNavigatorV are found.

https://gitlab.cern.ch/VecGeom/g4vecgeomnav/-/merge_requests/25

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This adds G4.vecgeomNavigator=kPropagated, a second VecGeom navigator kept for comparison.

- It adopts the state VecGeom propagated during the step instead of relocating at the boundary.
- It returns zero safety for the step after a crossing and nudges stuck steps forward.
- The default navigator becomes G4.vecgeomNavigator=kRelocating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sawenzel
sawenzel marked this pull request as ready for review September 30, 2026 05:58
@sawenzel
sawenzel requested review from a team and shahor02 as code owners September 30, 2026 05:58
sawenzel added a commit to sawenzel/alidist that referenced this pull request Sep 30, 2026
This enables the VecGeom and TGeo2VecGeom dependencies of O2 on macOS and
stops requiring Vc where the Scalar backend is used.

- VecGeom and TGeo2VecGeom were excluded from O2 on macOS because Vc was
  not available there.
- vecgeom.sh already builds the Scalar backend on osx_arm64 and aarch64,
  so Vc is now only required on the other architectures.
- The macOS build can then compile the G4.navmode=kVecGeom code of
  AliceO2Group/AliceO2#15865.
sawenzel added a commit to alisw/alidist that referenced this pull request Sep 30, 2026
This enables the VecGeom and TGeo2VecGeom dependencies of O2 on macOS and
stops requiring Vc where the Scalar backend is used.

- VecGeom and TGeo2VecGeom were excluded from O2 on macOS because Vc was
  not available there.
- vecgeom.sh already builds the Scalar backend on osx_arm64 and aarch64,
  so Vc is now only required on the other architectures.
- The macOS build can then compile the G4.navmode=kVecGeom code of
  AliceO2Group/AliceO2#15865.
This fixes tracks entering the volume they just left without seeing its boundary.

- Both VecGeom navigators kept the volume just left blocked for every following step, whatever the direction.
- A track turned back into it at the exit point, as by multiple scattering, crossed it unseen in the mother.
- In the hollow RB24 copper tubes this let shower electrons pass the wall and gave about 10 % more FDD-A hits.
- The volume is now blocked only in the first step after the exit, and only while the direction points away
  from it, as in G4NormalNavigation. This follows the same fix in G4VecGeomNav.

https://gitlab.cern.ch/swenzel/g4vecgeomnav/-/tree/fix/block-and-reflection

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

Copy link
Copy Markdown
Collaborator

Error while checking build/O2/fullCI_slc9 for 132c49d at 2026-09-30 23:26:

No log files found

Full log here.

@sawenzel
sawenzel enabled auto-merge (squash) October 1, 2026 09:22
@sawenzel
sawenzel disabled auto-merge October 1, 2026 09:22
@sawenzel
sawenzel merged commit 60e8cae into AliceO2Group:dev Oct 1, 2026
10 of 11 checks passed
@sawenzel
sawenzel deleted the swenzel/o2sim-vecgeom-navigation branch October 1, 2026 09:22
sawenzel added a commit to alisw/alidist that referenced this pull request Oct 1, 2026
This fixes a problem where o2checkcode passed although clang-tidy reported errors.

- error-log.txt sometimes contains runs of NUL bytes from the clang-tidy output.
- GNU grep then treats it as binary, prints nothing and the check passes.
- grep -a makes both greps read the file as text.

AliceO2Group/AliceO2#15865

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sawenzel added a commit to alisw/alidist that referenced this pull request Oct 1, 2026
This makes o2checkcode report the same on every PR checker.

- PR builds with ALIBUILD_O2_TESTS add -Werror to the compile flags.
- clang-tidy then reports compiler warnings as errors that -checks cannot filter.
- This is why the aarch64 checker failed on warnings the x86 fullCI checker suppressed.
- --extra-arg=-Wno-error restores the filtering.
- --gcc-install-dir was always empty because find got the path with literal quotes.

AliceO2Group/AliceO2#15865

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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