-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better use of safety. #322
base: master
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
Implementing two safety features: 1. Safety caching: the tracks hold the point where safety is computed, and the safety value in that point. When safety is needed in a different point, the method track.GetSafety(new_point) will subtract from the cached value and return the positive remainder or zero otherwise. The GetSafety method can take an accurate limit value, and when the remainder is smaller than this limit the returned safety is zero. It is the user responsibility to call track.SetSafety(pos, safety) whenever the safety is fully recomputed in a new position. 2. Safety calculation usses a new surface model feature to only compute safety accurately when close to boundaries, and only use the aligned bounding box safety when far away. The distance limit is passed as third parameter to AdePTNavigator::ComputeSafety, and must be typically equal to the discrete interaction step.
In this mode the electrons will still do the full physics, but secondaries are supressed. Useful in particular for debugging safety for a single track.
40ab623
to
9004567
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR breaks this mac:
example1_ttbar.txt
It simply stalls and does not proceed, while on master it runs through.
Additionally, could the DEBUG_NO_SECONDARY 1
things be removed?
vecgeom::Vector3D<Precision> pos; ///< track position | ||
vecgeom::Vector3D<Precision> dir; ///< track direction | ||
vecgeom::Vector3D<float> safetyPos; ///< last position where the safety was computed | ||
float safety{0}; ///< last computed safety value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float safety{0}; ///< last computed safety value | |
float safety{0.f}; ///< last computed safety value |
/// @param accurate_limit Only return non-zero if the recomputed safety if larger than the accurate_limit | ||
/// @return Recomputed safety. | ||
__host__ __device__ VECGEOM_FORCE_INLINE | ||
float GetSafety(vecgeom::Vector3D<Precision> const &new_pos, float accurate_limit = 0) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float GetSafety(vecgeom::Vector3D<Precision> const &new_pos, float accurate_limit = 0) const | |
float GetSafety(vecgeom::Vector3D<Precision> const &new_pos, float accurate_limit = 0.f) const |
float GetSafety(vecgeom::Vector3D<Precision> const &new_pos, float accurate_limit = 0) const | ||
{ | ||
float dsafe = safety - accurate_limit; | ||
if (dsafe <= 0) return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (dsafe <= 0) return 0; | |
if (dsafe <= 0.f) return 0.f; |
float dsafe = safety - accurate_limit; | ||
if (dsafe <= 0) return 0; | ||
float distSq = (vecgeom::Vector3D<float>(new_pos) - safetyPos).Mag2(); | ||
if (dsafe * dsafe < distSq) return 0.; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (dsafe * dsafe < distSq) return 0.; | |
if (dsafe * dsafe < distSq) return 0.f; |
Implementing two safety features:
Safety caching: the tracks hold the point where safety is computed, and the safety value in that point. When safety is needed in a different point, the method track.GetSafety(new_point) will subtract from the cached value and return the positive remainder or zero otherwise. The GetSafety method can take an accurate limit value, and when the remainder is smaller than this limit the returned safety is zero. It is the user responsibility to call track.SetSafety(pos, safety) whenever the safety is fully recomputed in a new position.
Safety calculation uses a new surface model feature only to compute safety accurately when close to boundaries, and only use the aligned bounding box safety when far away. The distance limit is passed as a third parameter to
AdePTNavigator::ComputeSafety
, and must be typically equal to the discrete interaction step.