Skip to content

Commit

Permalink
cleanup, few extra test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Dec 19, 2024
1 parent b4817ab commit eacfa62
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 51 deletions.
1 change: 0 additions & 1 deletion Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/detail/VerticesHelper.hpp"

#include <iostream>
#include <span>

namespace Acts::detail {
Expand Down
28 changes: 2 additions & 26 deletions Core/src/Surfaces/BoundaryTolerance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,7 @@ BoundaryTolerance::ToleranceMode BoundaryTolerance::toleranceMode() const {
return None;
}

// std::cout << absoluteBound->tolerance0 << " "
// << std::copysign(1., absoluteBound->tolerance0) << std::endl;
// std::cout << absoluteBound->tolerance1 << " "
// << std::copysign(1., absoluteBound->tolerance1) << std::endl;

if (std::copysign(1., absoluteBound->tolerance0) !=
std::copysign(1., absoluteBound->tolerance1)) {
throw std::logic_error("Inconsistent tolerance signs are not supported");
}

if (absoluteBound->tolerance0 > 0. || absoluteBound->tolerance1 > 0.) {
return Extend;
} else {
return Shrink;
}
return Extend;
}

if (const auto* absoluteCartesian = getVariantPtr<AbsoluteCartesian>();
Expand All @@ -100,17 +86,7 @@ BoundaryTolerance::ToleranceMode BoundaryTolerance::toleranceMode() const {
return None;
}

if (std::copysign(1., absoluteCartesian->tolerance0) !=
std::copysign(1., absoluteCartesian->tolerance1)) {
throw std::logic_error("Inconsistent tolerance signs are not supported");
}

if (absoluteCartesian->tolerance0 > 0. ||
absoluteCartesian->tolerance1 > 0.) {
return Extend;
} else {
return Shrink;
}
return Extend;
}

if (const auto* absoluteEuclidean = getVariantPtr<AbsoluteEuclidean>();
Expand Down
24 changes: 0 additions & 24 deletions Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,11 @@ BOOST_AUTO_TEST_CASE(AnnulusBoundsVertices) {
}

BOOST_AUTO_TEST_CASE(AnnulusBoundsNegativeTolerance) {
using namespace Acts::UnitLiterals;
AnnulusBounds aBounds(minRadius, maxRadius, minPhi, maxPhi, offset);
double phiAverage = (minPhi + maxPhi) / 2;

auto check = [&](const BoundaryTolerance& tolerance, const Vector2& point) {
Vector2 pointAverage(point[0], phiAverage + point[1]);

std::cout << "[" << pointAverage[0] << ", " << pointAverage[1] << "],"
<< std::endl;
return aBounds.inside(pointAverage, tolerance);
};

Expand Down Expand Up @@ -243,26 +239,6 @@ BOOST_AUTO_TEST_CASE(AnnulusBoundsNegativeTolerance) {
BOOST_CHECK(check(tolerance, {midRadius, hlPhi * 0.8}));
BOOST_CHECK(check(tolerance, {midRadius, hlPhi * 1.1}));
BOOST_CHECK(!check(tolerance, {midRadius, hlPhi * 1.5}));
// mc(tolerance);
// mc(BoundaryTolerance::Chi2Bound(SquareMatrix2::Identity(), 0.1));

// Test points near radial boundaries
// BOOST_CHECK(!check(tolerance, {minRadius - 0.2, 0}));
// BOOST_CHECK(!check(tolerance, {minRadius + 0.2, 0}));
// BOOST_CHECK(check(tolerance, {minRadius + 0.4, 0}));
// BOOST_CHECK(!check(tolerance, {maxRadius - 0.2, 0}));
// BOOST_CHECK(!check(tolerance, {maxRadius + 0.2, 0}));
// BOOST_CHECK(check(tolerance, {maxRadius - 0.4, 0}));

// // Test points near angular boundaries
// BOOST_CHECK(!check(tolerance, {(minRadius + maxRadius) / 2, minPhi -
// 0.2})); BOOST_CHECK(!check(tolerance, {(minRadius + maxRadius) / 2,
// minPhi + 0.2})); BOOST_CHECK(check(tolerance, {(minRadius + maxRadius) /
// 2, minPhi + 0.4})); BOOST_CHECK(!check(tolerance, {(minRadius +
// maxRadius) / 2, maxPhi - 0.2})); BOOST_CHECK(!check(tolerance,
// {(minRadius + maxRadius) / 2, maxPhi + 0.2}));
// BOOST_CHECK(check(tolerance, {(minRadius + maxRadius) / 2, maxPhi -
// 0.4}));
}

{
Expand Down
22 changes: 22 additions & 0 deletions Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@ namespace Acts::Test {
BOOST_AUTO_TEST_SUITE(Surfaces)

BOOST_AUTO_TEST_CASE(BoundaryToleranceConstructors) {
using enum BoundaryTolerance::ToleranceMode;
{
// Test None constructor
BoundaryTolerance tolerance = BoundaryTolerance::None();
BOOST_CHECK(tolerance.toleranceMode() == None);
}

// Test AbsoluteBound constructor
{
// Valid positive tolerances
auto tolerance = BoundaryTolerance::AbsoluteBound(1.0, 2.0);
BOOST_CHECK_EQUAL(tolerance.tolerance0, 1.0);
BOOST_CHECK_EQUAL(tolerance.tolerance1, 2.0);
BOOST_CHECK(BoundaryTolerance{tolerance}.toleranceMode() == Extend);
BOOST_CHECK(BoundaryTolerance{BoundaryTolerance::AbsoluteBound(0.0, 0.0)}
.toleranceMode() == None);

// Negative tolerances should throw
BOOST_CHECK_THROW(BoundaryTolerance::AbsoluteBound(-1.0, 2.0),
Expand All @@ -47,10 +57,14 @@ BOOST_AUTO_TEST_CASE(BoundaryToleranceConstructors) {
// Valid positive tolerance
auto tolerance = BoundaryTolerance::AbsoluteEuclidean(1.0);
BOOST_CHECK_EQUAL(tolerance.tolerance, 1.0);
BOOST_CHECK(BoundaryTolerance{tolerance}.toleranceMode() == Extend);
BOOST_CHECK(BoundaryTolerance{BoundaryTolerance::AbsoluteEuclidean(0.0)}
.toleranceMode() == None);

// Valid negative tolerance
tolerance = BoundaryTolerance::AbsoluteEuclidean(-1.0);
BOOST_CHECK_EQUAL(tolerance.tolerance, -1.0);
BOOST_CHECK(BoundaryTolerance{tolerance}.toleranceMode() == Shrink);
}

// Test AbsoluteCartesian constructor
Expand All @@ -59,6 +73,10 @@ BOOST_AUTO_TEST_CASE(BoundaryToleranceConstructors) {
auto tolerance = BoundaryTolerance::AbsoluteCartesian(1.0, 2.0);
BOOST_CHECK_EQUAL(tolerance.tolerance0, 1.0);
BOOST_CHECK_EQUAL(tolerance.tolerance1, 2.0);
BOOST_CHECK(BoundaryTolerance{tolerance}.toleranceMode() == Extend);
BOOST_CHECK(
BoundaryTolerance{BoundaryTolerance::AbsoluteCartesian(0.0, 0.0)}
.toleranceMode() == None);

// Negative tolerances should throw
BOOST_CHECK_THROW(BoundaryTolerance::AbsoluteCartesian(-1.0, 2.0),
Expand All @@ -75,10 +93,14 @@ BOOST_AUTO_TEST_CASE(BoundaryToleranceConstructors) {
// Valid positive chi2 bound
auto tolerance = BoundaryTolerance::Chi2Bound(cov, 3.0);
BOOST_CHECK_EQUAL(tolerance.maxChi2, 3.0);
BOOST_CHECK(BoundaryTolerance{tolerance}.toleranceMode() == Extend);
BOOST_CHECK(BoundaryTolerance{BoundaryTolerance::Chi2Bound(cov, 0.0)}
.toleranceMode() == None);

// Valid negative chi2 bound
tolerance = BoundaryTolerance::Chi2Bound(cov, -3.0);
BOOST_CHECK_EQUAL(tolerance.maxChi2, -3.0);
BOOST_CHECK(BoundaryTolerance{tolerance}.toleranceMode() == Shrink);
}

// Test None constructor
Expand Down

0 comments on commit eacfa62

Please sign in to comment.