From 11834f30b49c280553dd9ea141f43c5be2ada587 Mon Sep 17 00:00:00 2001 From: andiwand Date: Sat, 18 Nov 2023 12:14:36 +0100 Subject: [PATCH 1/2] fix trapezoid tolerance inside check --- .../include/Acts/Surfaces/TrapezoidBounds.hpp | 1 - Core/src/Surfaces/TrapezoidBounds.cpp | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp index 502caa9ad91..6c95f24e63e 100644 --- a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp +++ b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp @@ -30,7 +30,6 @@ namespace Acts { /// @image html TrapezoidBounds.gif /// /// @todo can be speed optimized by calculating kappa/delta and caching it - class TrapezoidBounds : public PlanarBounds { public: enum BoundValues { diff --git a/Core/src/Surfaces/TrapezoidBounds.cpp b/Core/src/Surfaces/TrapezoidBounds.cpp index 369dae9813d..e39a69d388b 100644 --- a/Core/src/Surfaces/TrapezoidBounds.cpp +++ b/Core/src/Surfaces/TrapezoidBounds.cpp @@ -32,18 +32,25 @@ bool Acts::TrapezoidBounds::inside(const Acts::Vector2& lposition, double tolX = bcheck.tolerance()[eBoundLoc0]; double tolY = bcheck.tolerance()[eBoundLoc1]; - if (std::abs(y) - hlY > tolY) { - // outside y range + // check outside x range + tolerance + if (std::abs(x) - std::max(hlXnY, hlXpY) > tolX) { return false; } - if (std::abs(x) - std::max(hlXnY, hlXpY) > tolX) { - // outside x range + // check outside y range + tolerance + if (std::abs(y) - hlY > tolY) { return false; } - if (std::abs(x) - std::min(hlXnY, hlXpY) <= tolX) { - // inside x range + // check inside x range + tolerance, inside y range + if ((std::abs(x) - std::min(hlXnY, hlXpY) <= tolX) && + (std::abs(y) - hlY <= 0)) { + return true; + } + + // check inside x range, inside y range + tolerance + if ((std::abs(x) - std::min(hlXnY, hlXpY) <= 0) && + (std::abs(y) - hlY <= tolY)) { return true; } } From a6e2432185597dbba4cab305d5e5a7a2f8f21833 Mon Sep 17 00:00:00 2001 From: andiwand Date: Sat, 18 Nov 2023 14:20:43 +0100 Subject: [PATCH 2/2] simplify checks --- Core/src/Surfaces/TrapezoidBounds.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Core/src/Surfaces/TrapezoidBounds.cpp b/Core/src/Surfaces/TrapezoidBounds.cpp index e39a69d388b..a15a3fe32c1 100644 --- a/Core/src/Surfaces/TrapezoidBounds.cpp +++ b/Core/src/Surfaces/TrapezoidBounds.cpp @@ -32,25 +32,31 @@ bool Acts::TrapezoidBounds::inside(const Acts::Vector2& lposition, double tolX = bcheck.tolerance()[eBoundLoc0]; double tolY = bcheck.tolerance()[eBoundLoc1]; - // check outside x range + tolerance - if (std::abs(x) - std::max(hlXnY, hlXpY) > tolX) { + double distY = std::abs(y) - hlY; + + // check outside y range + tolerance + if (distY > tolY) { return false; } - // check outside y range + tolerance - if (std::abs(y) - hlY > tolY) { + // distance x to outer rectangle + double distOuterX = std::abs(x) - std::max(hlXnY, hlXpY); + + // check outside x range + tolerance + if (distOuterX > tolX) { return false; } - // check inside x range + tolerance, inside y range - if ((std::abs(x) - std::min(hlXnY, hlXpY) <= tolX) && - (std::abs(y) - hlY <= 0)) { + // distance x to inner rectangle + double distInnerX = std::abs(x) - std::min(hlXnY, hlXpY); + + // check inside x range, inside y range + tolerance (already checked above) + if (distInnerX <= 0) { return true; } - // check inside x range, inside y range + tolerance - if ((std::abs(x) - std::min(hlXnY, hlXpY) <= 0) && - (std::abs(y) - hlY <= tolY)) { + // check inside x range + tolerance, inside y range + if ((distInnerX <= tolX) && (distY <= 0)) { return true; } }