use cached safety length to skip navigation for electrons and positrons with no magnetic field - #696
use cached safety length to skip navigation for electrons and positrons with no magnetic field#696ggalgoczi wants to merge 1 commit into
Conversation
…ns with no magnetic field For electrons and positrons transported without magnetic field, skip ComputeStepAndNextVolume when the proposed step is shorter than cached safety and the track is not on a boundary. The navigation state is carried over unchanged. Off by default (kernel option enableApproximateSafetyNavigationSkip, UI command /adept/enableApproximateSafetyNavigationSkip): the skip trusts the safety as a strict lower bound on the distance to the next boundary, which was not guaranteed in all observed cases.
How did you trace this? Do you have a reproducer (point/direction giving bad safety value)? Of course this should never happen, but so far we have mainly shape regressions, not a global one. I should add a regression in VecGeom doing exactly this: generating arbitrary steps, validating if they are within safety, or using the distance to boundary if not. |
|
I have added a regression in VecGeom to fix this: https://gitlab.cern.ch/VecGeom/VecGeom/-/merge_requests/1476 |
Thank you @agheata . This PR did not introduce new caching. I see what the bug is likely to be, I will write it up in few days. |
|
Hi @ggalgoczi, For the current improvement, I agree that something seems to be off if the safety is not safe. Therefore, it would be best to fix that problem, and then make the change directly, without making it just an option. I am still away this week, but happy to discuss next week. |
Summary
AdePT uses cached safety distance to speed up navigation for electrons and positrons during tracking in magnetic fields. (This is achievable because MSC calculates the safety distance anyway so it does not need to be calculated again.) This PR proposes to do the same even when no magnetic field is present.
The underlying optimization is that if the proposed step length is smaller than safety length, then there is no point in doing the geometry lookup of the next volume since we know the particle will stay in the current volume.
Running using Example1 with no magnetic field with 1000 electrons with 10 GeV in full LHCb I see 11.09% event loop time speed up and 2.94% wall time when including physics and geometry init. However the results are not byte identical. From 16 events 10 have identical energy deposition in the whole detector but 6 have different energy deposition. In the worst case the difference was 0.021%. I traced this to cases where VecGeom calculates a too large safety (
ComputeSafetyreturns more than the distance to the next boundary thatComputeStepAndNextVolumefinds from the same position and navigation state), so the electron can actually skip surfaces.Was this observed before? I have minimal experience with VecGeom. I will likely file a separate issue with a reproducer.
Because of this I made it a runtime option that is off by default. This does not help every case, eg. when gammas dominate the simulation (on cms2018 -- with magnetic field off -- the wall time is unchanged within noise).
I understand that this is not useful for LHC experiments, since they do have magnetic field almost everywhere but it will be very useful for DUNE far detector, etc. where there is no magnetic field.
Configuration
The kernel option is:
It defaults to
falseand is exposed through:The value is copied through
AdePTConfiguration,AdePTTransportConfig, andTransportKernelOptionsEnvironment:
d5b15f6sm_89)49d44f1f6),VECGEOM_NAV=tupleReproduce
fullLHCb_skip.mac — remove the /adept/enableApproximateSafetyNavigationSkip line for the baseline
Related AdePT work
Similar features that make use of the same principle: