File indexing completed on 2025-08-06 08:11:29
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/tools/output_test_stream.hpp>
0011 #include <boost/test/unit_test.hpp>
0012
0013 #include "Acts/Definitions/Algebra.hpp"
0014 #include "Acts/Surfaces/BoundaryCheck.hpp"
0015 #include "Acts/Surfaces/RadialBounds.hpp"
0016 #include "Acts/Surfaces/SurfaceBounds.hpp"
0017
0018 #include <algorithm>
0019 #include <array>
0020 #include <cmath>
0021 #include <stdexcept>
0022 #include <vector>
0023
0024 namespace Acts {
0025
0026 namespace Test {
0027 BOOST_AUTO_TEST_SUITE(Surfaces)
0028
0029
0030 BOOST_AUTO_TEST_CASE(RadialBoundsConstruction) {
0031 double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0);
0032
0033
0034
0035
0036 BOOST_CHECK_EQUAL(RadialBounds(minRadius, maxRadius).type(),
0037 SurfaceBounds::eDisc);
0038
0039
0040 BOOST_CHECK_EQUAL(RadialBounds(minRadius, maxRadius, halfPhiSector).type(),
0041 SurfaceBounds::eDisc);
0042
0043
0044 RadialBounds original(minRadius, maxRadius);
0045 RadialBounds copied(original);
0046 BOOST_CHECK_EQUAL(copied, original);
0047 }
0048
0049
0050 BOOST_AUTO_TEST_CASE(RadialBoundsRecreation) {
0051 double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0), avgPhi(0.1);
0052 RadialBounds original(minRadius, maxRadius, halfPhiSector, avgPhi);
0053
0054 auto valvector = original.values();
0055 std::array<double, RadialBounds::eSize> values{};
0056 std::copy_n(valvector.begin(), RadialBounds::eSize, values.begin());
0057 RadialBounds recreated(values);
0058 BOOST_CHECK_EQUAL(original, recreated);
0059 }
0060
0061
0062 BOOST_AUTO_TEST_CASE(RadialBoundsException) {
0063 double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0), avgPhi(0.1);
0064
0065
0066 BOOST_CHECK_THROW(RadialBounds(-minRadius, maxRadius, halfPhiSector, avgPhi),
0067 std::logic_error);
0068
0069
0070 BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, halfPhiSector, avgPhi),
0071 std::logic_error);
0072
0073
0074 BOOST_CHECK_THROW(RadialBounds(-minRadius, -maxRadius, halfPhiSector, avgPhi),
0075 std::logic_error);
0076
0077
0078 BOOST_CHECK_THROW(RadialBounds(maxRadius, minRadius, halfPhiSector, avgPhi),
0079 std::logic_error);
0080
0081
0082 BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, -5., avgPhi),
0083 std::logic_error);
0084
0085
0086 BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, halfPhiSector, 5.),
0087 std::logic_error);
0088 }
0089
0090
0091 BOOST_AUTO_TEST_CASE(RadialBoundsProperties) {
0092 double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0);
0093
0094 RadialBounds radialBoundsObject(minRadius, maxRadius, halfPhiSector);
0095 BOOST_CHECK_EQUAL(radialBoundsObject.type(), SurfaceBounds::eDisc);
0096
0097
0098 Vector2 outside(30., 0.);
0099 Vector2 inSurface(2., 0.0);
0100
0101
0102 boost::test_tools::output_test_stream dumpOuput;
0103 radialBoundsObject.toStream(dumpOuput);
0104 BOOST_CHECK(
0105 dumpOuput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, "
0106 "hPhiSector, averagePhi) = (1.0000000, "
0107 "5.0000000, 0.3926991, 0.0000000)"));
0108
0109
0110 BOOST_CHECK(radialBoundsObject.inside(inSurface, BoundaryCheck(true)));
0111 BOOST_CHECK(!radialBoundsObject.inside(outside, BoundaryCheck(true)));
0112
0113
0114 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMinR), minRadius);
0115
0116
0117 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), maxRadius);
0118
0119
0120 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.0);
0121
0122
0123 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eHalfPhiSector),
0124 halfPhiSector);
0125 }
0126
0127 BOOST_AUTO_TEST_CASE(RadialBoundsAssignment) {
0128 double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0);
0129 RadialBounds radialBoundsObject(minRadius, maxRadius, halfPhiSector);
0130
0131
0132
0133 RadialBounds assignedRadialBoundsObject(10.1, 123.);
0134 assignedRadialBoundsObject = radialBoundsObject;
0135 BOOST_CHECK_EQUAL(assignedRadialBoundsObject, radialBoundsObject);
0136 }
0137
0138 BOOST_AUTO_TEST_SUITE_END()
0139
0140 }
0141
0142 }