[geom] Add cache layer for TGeoParallelWorld safeties in TGeoNavigator #16470
+71
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit provides an (optional) optimization to reduce the cost of safety evaluations associated with TGeoParallelWorld.
The approach consists in the introduction of additional cache-state in TGeoNavigator. This state remembers the last location for which TGeoParallelWorld::Safety was evaluated, together with the corresponding value returned.
Since TGeoNavigator follows the evolution of tracks step-by-step, we have some sort of history-locality. This means that the cache-state has a high-probability of being relevant for multiple track locations in a row.
The optimization proposed here is orthogonal to other improvements. It adds on top of algorithmic improvements within TGeoParallelWorld (bounding volume hierarchies, see separate PR), gaining a few extra percent in speed.
By default, the new feature is not enabled by default for backward compatibility. Once fully verified, we can make it the default mode.
That said, in ALICE simulations, the caching did not modify stepping behaviour and yielded identical results compared to not doing the caching.
Checklist: