Skip to content

Add BVH-based navigation functions to TGeoTessellated (Improved version 2)#21409

Open
sawenzel wants to merge 1 commit intoroot-project:masterfrom
sawenzel:swenzel/tessellated-master-v2
Open

Add BVH-based navigation functions to TGeoTessellated (Improved version 2)#21409
sawenzel wants to merge 1 commit intoroot-project:masterfrom
sawenzel:swenzel/tessellated-master-v2

Conversation

@sawenzel
Copy link
Contributor

This commit adds implementations of the navigation interfaces required by TGeoNavigator to TGeoTessellated.

As a result, TGeoTessellated can now be used in applications that rely on this navigator, such as VMC-based GEANT simulations.

The implementation is based on fast Bounding Volume Hierarchy (BVH) queries introduced in a recent TGeoParallelWorld rewrite.

The BVH is only exposed to the internal implementation. It is not streamed to disk for now and therefore needs to be reinitialized when reading from TBuffer. For this reason, a custom streamer for TGeoTessellated is proposed.

The implementation shows very good performance, being multiple times faster than comparable implementations in Geant4 or VecGeom. The latter were also used to validate the algorithms. Navigation functionality has additionally been tested at a high level using VecGeom’s XRayNavigationBenchmarker.

Note that this is an initial implementation and should be considered beta quality. The following limitations and remarks apply:

  • DistFromInside and DistFromOutside do not implement all iact= cases. Only iact == 3 is supported, which is the case actually used by TGeoNavigator.

  • Only triangular faces supported at this stage but generalization is straightforward. (Users can also make sure to only add triangles).

  • The algorithms have not yet been validated in large-scale production environments.

  • Further optimization seem possible and will be done in future commits.

This work is motivated by the need to GEANT-simulate detector prototypes from CAD models in ALICE. ALICE is using TGeo.

Finally, the commit also fixes some minor bugs in the TGeoChecker with respect to bounding box origins, previously not taken into account.

Slight refactoring of TGeoParallelWorld to make use of utility functions used both in TGeoTessellated as well as in TGeoParallelWorld.

@sawenzel sawenzel requested a review from agheata as a code owner February 27, 2026 14:41
@sawenzel
Copy link
Contributor Author

As discussed in #21045, this is a successor PR with cleanups and other small changes in answer to reviewer comments.
As soon as it compiles, I would suggest to merge it as the basis for further commits/functionality to be added by @agheata.

@dpiparo
Copy link
Member

dpiparo commented Feb 28, 2026

Waiting for @agheata , I am starting the builds.

@github-actions
Copy link

Test Results

    15 files      15 suites   1d 16h 9m 43s ⏱️
 3 779 tests  3 778 ✅ 1 💤 0 ❌
50 951 runs  50 942 ✅ 9 💤 0 ❌

Results for commit e2ee0ea.

@sawenzel sawenzel force-pushed the swenzel/tessellated-master-v2 branch from e2ee0ea to 0aff1de Compare February 28, 2026 14:27
@sawenzel
Copy link
Contributor Author

Updated commit to fix compile error on some platforms + clang-format.

This commit adds implementations of the navigation interfaces required
by TGeoNavigator to TGeoTessellated.

As a result, TGeoTessellated can now be used in applications that rely
on this navigator, such as VMC-based GEANT simulations.

The implementation is based on fast Bounding Volume Hierarchy (BVH)
queries introduced in a recent TGeoParallelWorld rewrite.

The BVH is only exposed to the internal implementation. It is not
streamed to disk for now and therefore needs to be reinitialized when
reading from TBuffer. For this reason, a custom streamer for
TGeoTessellated is proposed.

The implementation shows very good performance, being multiple times
faster than comparable implementations in Geant4 or VecGeom. The
latter were also used to validate the algorithms. Navigation
functionality has additionally been tested at a high level using
VecGeom’s XRayNavigationBenchmarker.

Note that this is an initial implementation and should be considered
beta quality. The following limitations and remarks apply:

- DistFromInside and DistFromOutside do not implement all `iact=` cases.
  Only `iact == 3` is supported, which is the case actually used by
  TGeoNavigator.

- Only triangular faces supported at this stage but generalization
  is straightforward. (Users can also make sure to only add triangles).

- The algorithms have not yet been validated in large-scale production
  environments.

- Further optimization seem possible and will be done in future commits.

This work is motivated by the need to GEANT-simulate detector
prototypes from CAD models in ALICE. ALICE is using TGeo.

Finally, the commit also fixes some minor bugs in the TGeoChecker
with respect to bounding box origins, previously not taken into account.

Slight refactoring of TGeoParallelWorld to make use of utility functions
used both in TGeoTessellated as well as in TGeoParallelWorld.
@sawenzel sawenzel force-pushed the swenzel/tessellated-master-v2 branch from 0aff1de to 483cc04 Compare February 28, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants