File indexing completed on 2025-08-06 08:11:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <boost/test/unit_test.hpp>
0011 #include <boost/test/data/test_case.hpp>
0012 #include <boost/test/tools/output_test_stream.hpp>
0013 #include <algorithm>
0014 #include <array>
0015 #include <stdexcept>
0016 #include <vector>
0017
0018
0019 #include "Acts/Definitions/Algebra.hpp"
0020 #include "Acts/Surfaces/AnnulusBounds.hpp"
0021 #include "Acts/Surfaces/BoundaryCheck.hpp"
0022 #include "Acts/Surfaces/SurfaceBounds.hpp"
0023 #include "Acts/Utilities/VectorHelpers.hpp"
0024
0025 namespace Acts {
0026
0027 namespace Test {
0028 BOOST_AUTO_TEST_SUITE(Surfaces)
0029
0030 double minRadius = 7.2;
0031 double maxRadius = 12.0;
0032 double minPhi = 0.74195;
0033 double maxPhi = 1.33970;
0034
0035 Vector2 offset(-2., 2.);
0036
0037
0038 BOOST_AUTO_TEST_CASE(AnnulusBoundsConstruction) {
0039
0040 auto original = AnnulusBounds(minRadius, maxRadius, minPhi, maxPhi, offset);
0041 AnnulusBounds copied(original);
0042 BOOST_CHECK_EQUAL(original, copied);
0043 }
0044
0045
0046 BOOST_AUTO_TEST_CASE(AnnulusBoundsRecreation) {
0047
0048 auto original = AnnulusBounds(minRadius, maxRadius, minPhi, maxPhi, offset);
0049 auto valvector = original.values();
0050 std::array<double, AnnulusBounds::eSize> values{};
0051 std::copy_n(valvector.begin(), AnnulusBounds::eSize, values.begin());
0052 AnnulusBounds recreated(values);
0053 BOOST_CHECK_EQUAL(original, recreated);
0054 }
0055
0056
0057 BOOST_AUTO_TEST_CASE(AnnulusBoundsExcpetion) {
0058
0059 BOOST_CHECK_THROW(AnnulusBounds(-1., maxRadius, minPhi, maxPhi, offset),
0060 std::logic_error);
0061
0062 BOOST_CHECK_THROW(AnnulusBounds(minRadius, -1., minPhi, maxPhi, offset),
0063 std::logic_error);
0064
0065 BOOST_CHECK_THROW(AnnulusBounds(maxRadius, minRadius, minPhi, maxPhi, offset),
0066 std::logic_error);
0067
0068 BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, -4., maxPhi, offset),
0069 std::logic_error);
0070
0071 BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, minPhi, 4., offset),
0072 std::logic_error);
0073
0074 BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, maxPhi, minPhi, offset),
0075 std::logic_error);
0076 }
0077
0078
0079 BOOST_AUTO_TEST_CASE(AnnulusBoundsProperties) {
0080
0081 AnnulusBounds aBounds(minRadius, maxRadius, minPhi, maxPhi, offset);
0082
0083
0084
0085 BOOST_CHECK_EQUAL(aBounds.type(), SurfaceBounds::eAnnulus);
0086
0087
0088
0089 Vector2 inSurfaceXY(7., 7.);
0090 Vector2 outsideXY1(5., 5.);
0091 Vector2 outsideXY2(10., 3.);
0092 Vector2 outsideXY3(10., 10.);
0093 Vector2 outsideXY4(4., 10.);
0094 std::vector<Vector2> testPoints = {inSurfaceXY, outsideXY1, outsideXY2,
0095 outsideXY3, outsideXY4};
0096
0097 auto toStripFrame = [&](const Vector2& xy) -> Vector2 {
0098 auto shifted = xy + offset;
0099 double r = VectorHelpers::perp(shifted);
0100 double phi = VectorHelpers::phi(shifted);
0101 return Vector2(r, phi);
0102 };
0103
0104 BOOST_CHECK(aBounds.inside(toStripFrame(inSurfaceXY), BoundaryCheck(true)));
0105 BOOST_CHECK(!aBounds.inside(toStripFrame(outsideXY1), BoundaryCheck(true)));
0106 BOOST_CHECK(!aBounds.inside(toStripFrame(outsideXY2), BoundaryCheck(true)));
0107 BOOST_CHECK(!aBounds.inside(toStripFrame(outsideXY3), BoundaryCheck(true)));
0108 BOOST_CHECK(!aBounds.inside(toStripFrame(outsideXY4), BoundaryCheck(true)));
0109
0110
0111 BOOST_CHECK(!aBounds.insideRadialBounds(0.5));
0112 BOOST_CHECK(aBounds.insideRadialBounds(9.));
0113 BOOST_CHECK(!aBounds.insideRadialBounds(18.));
0114
0115
0116 BOOST_CHECK_EQUAL(aBounds.get(AnnulusBounds::eMinR), minRadius);
0117
0118 BOOST_CHECK_EQUAL(aBounds.get(AnnulusBounds::eMaxR), maxRadius);
0119
0120 BOOST_CHECK_EQUAL(aBounds.get(AnnulusBounds::eMinPhiRel), minPhi);
0121
0122 BOOST_CHECK_EQUAL(aBounds.get(AnnulusBounds::eMaxPhiRel), maxPhi);
0123 }
0124
0125 BOOST_AUTO_TEST_SUITE_END()
0126
0127 }
0128
0129 }