diff --git a/VecGeom/base/Math.h b/VecGeom/base/Math.h index 78ab6f931f567a636de5fe22ba4ec914c3939dcc..adbeb282e2b1d7bf86f13b82596eee15093e0edd 100644 --- a/VecGeom/base/Math.h +++ b/VecGeom/base/Math.h @@ -17,12 +17,14 @@ inline namespace VECGEOM_IMPL_NAMESPACE { #ifdef VECGEOM_FLOAT_PRECISION using Precision = float; VECGEOM_CONST Precision kTolerance = 1e-3; +VECGEOM_CONST Precision kSqrtTolerance = 3.1622777e-2; VECGEOM_CONST Precision kAngTolerance = 1e-2; VECGEOM_CONST Precision kConeTolerance = 1e-3; VECGEOM_CONST Precision kFarAway = 1e5; #else using Precision = double; VECGEOM_CONST Precision kTolerance = 1e-9; +VECGEOM_CONST Precision kSqrtTolerance = 3.1622777e-5; VECGEOM_CONST Precision kAngTolerance = 1e-9; VECGEOM_CONST Precision kConeTolerance = 1e-7; VECGEOM_CONST Precision kFarAway = 1e10; diff --git a/VecGeom/volumes/SphereUtilities.h b/VecGeom/volumes/SphereUtilities.h index 598aa4d3ea9d13e339fe0bf43ae45be1c1b433c8..7081337c2c30300ed2656896453f5fc0bc52979b 100644 --- a/VecGeom/volumes/SphereUtilities.h +++ b/VecGeom/volumes/SphereUtilities.h @@ -146,18 +146,18 @@ typename vecCore::Mask_v IsPointOnRadialSurfaceAndMovingOut(UnplacedStru Vector3D const &point, Vector3D const &dir) { - + // Rays from rmax+tolerance or rmin-tolerance can be moving out even if not going fully "backward" if (MovingOut) { if (ForInnerRadius) { - return IsPointOnInnerRadius(unplaced, point) && (dir.Dot(-point) > Real_v(0.)); + return IsPointOnInnerRadius(unplaced, point) && (dir.Dot(-point) > Real_v(kSqrtTolerance)); } else { - return IsPointOnOuterRadius(unplaced, point) && (dir.Dot(point) > Real_v(0.)); + return IsPointOnOuterRadius(unplaced, point) && (dir.Dot(point) > Real_v(kSqrtTolerance)); } } else { if (ForInnerRadius) { - return IsPointOnInnerRadius(unplaced, point) && (dir.Dot(-point) < Real_v(0.)); + return IsPointOnInnerRadius(unplaced, point) && (dir.Dot(-point) < Real_v(-kSqrtTolerance)); } else - return IsPointOnOuterRadius(unplaced, point) && (dir.Dot(point) < Real_v(0.)); + return IsPointOnOuterRadius(unplaced, point) && (dir.Dot(point) < Real_v(-kSqrtTolerance)); } }