File indexing completed on 2026-08-27 08:34:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0014 #include "Acts/Surfaces/RadialBounds.hpp"
0015 #include "Acts/Surfaces/SurfaceBounds.hpp"
0016
0017 #include <algorithm>
0018 #include <array>
0019 #include <cmath>
0020 #include <numbers>
0021 #include <stdexcept>
0022 #include <vector>
0023
0024 using namespace Acts;
0025
0026 namespace ActsTests {
0027
0028 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0029
0030 const double rMin = 1.;
0031 const double rMax = 5.;
0032 const double halfPhiSector = std::numbers::pi / 8.;
0033 const double avgPhi = 0.1;
0034
0035
0036 BOOST_AUTO_TEST_CASE(RadialBoundsConstruction) {
0037
0038
0039
0040
0041 BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax).type(), SurfaceBounds::eDisc);
0042
0043
0044 BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax, halfPhiSector).type(),
0045 SurfaceBounds::eDisc);
0046
0047
0048 RadialBounds original(rMin, rMax);
0049 RadialBounds copied(original);
0050 BOOST_CHECK_EQUAL(copied, original);
0051 }
0052
0053
0054 BOOST_AUTO_TEST_CASE(RadialBoundsRecreation) {
0055 RadialBounds original(rMin, rMax, halfPhiSector, avgPhi);
0056
0057 auto valvector = original.values();
0058 std::array<double, RadialBounds::eSize> values{};
0059 std::copy_n(valvector.begin(), RadialBounds::eSize, values.begin());
0060 RadialBounds recreated(values);
0061 BOOST_CHECK_EQUAL(original, recreated);
0062 }
0063
0064
0065 BOOST_AUTO_TEST_CASE(RadialBoundsException) {
0066
0067 BOOST_CHECK_THROW(RadialBounds(-rMin, rMax, halfPhiSector, avgPhi),
0068 std::logic_error);
0069
0070
0071 BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, halfPhiSector, avgPhi),
0072 std::logic_error);
0073
0074
0075 BOOST_CHECK_THROW(RadialBounds(-rMin, -rMax, halfPhiSector, avgPhi),
0076 std::logic_error);
0077
0078
0079 BOOST_CHECK_THROW(RadialBounds(rMax, rMin, halfPhiSector, avgPhi),
0080 std::logic_error);
0081
0082
0083 BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, -5., avgPhi), std::logic_error);
0084
0085
0086 BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, halfPhiSector, 5.),
0087 std::logic_error);
0088 }
0089
0090
0091 BOOST_AUTO_TEST_CASE(RadialBoundsProperties) {
0092
0093 RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector);
0094 BOOST_CHECK_EQUAL(radialBoundsObject.type(), SurfaceBounds::eDisc);
0095
0096
0097 Vector2 outside(30., 0.);
0098 Vector2 inSurface(2., 0.);
0099
0100
0101 boost::test_tools::output_test_stream dumpOutput;
0102 radialBoundsObject.toStream(dumpOutput);
0103 BOOST_CHECK(
0104 dumpOutput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, "
0105 "hPhiSector, averagePhi) = (1.0000000, "
0106 "5.0000000, 0.3926991, 0.0000000)"));
0107
0108
0109 BOOST_CHECK(radialBoundsObject.inside(inSurface, BoundaryTolerance::None()));
0110 BOOST_CHECK(!radialBoundsObject.inside(outside, BoundaryTolerance::None()));
0111
0112
0113 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMinR), rMin);
0114
0115
0116 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), rMax);
0117
0118
0119 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.);
0120
0121
0122 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eHalfPhiSector),
0123 halfPhiSector);
0124 }
0125
0126 BOOST_AUTO_TEST_CASE(RadialBoundsAssignment) {
0127 RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector);
0128
0129
0130
0131
0132
0133 RadialBounds assignedRadialBoundsObject(10.1, 123.);
0134 assignedRadialBoundsObject = radialBoundsObject;
0135 BOOST_CHECK_EQUAL(assignedRadialBoundsObject, radialBoundsObject);
0136 }
0137
0138 BOOST_AUTO_TEST_CASE(RadialBoundsCenter) {
0139
0140 RadialBounds radial(rMin, rMax);
0141 Vector2 center = radial.center();
0142 double expectedR = 0.5 * (rMin + rMax);
0143 BOOST_CHECK_EQUAL(center.x(), expectedR);
0144 BOOST_CHECK_EQUAL(center.y(), 0.0);
0145
0146
0147 RadialBounds radialOffset(rMin, rMax, halfPhiSector, avgPhi);
0148 Vector2 centerOffset = radialOffset.center();
0149 BOOST_CHECK_EQUAL(centerOffset.x(), expectedR);
0150 BOOST_CHECK_EQUAL(centerOffset.y(), avgPhi);
0151 }
0152
0153 BOOST_AUTO_TEST_CASE(RadialBoundsCoversFullAzimuth) {
0154
0155 BOOST_CHECK(RadialBounds(rMin, rMax).coversFullAzimuth());
0156 BOOST_CHECK(RadialBounds(rMin, rMax, std::numbers::pi).coversFullAzimuth());
0157
0158
0159
0160 BOOST_CHECK(RadialBounds(rMin, rMax, std::nextafter(std::numbers::pi, 0.))
0161 .coversFullAzimuth());
0162
0163
0164 BOOST_CHECK(!RadialBounds(rMin, rMax, halfPhiSector).coversFullAzimuth());
0165 BOOST_CHECK(
0166 !RadialBounds(rMin, rMax, std::numbers::pi / 2.).coversFullAzimuth());
0167 }
0168
0169 BOOST_AUTO_TEST_SUITE_END()
0170
0171 }