File indexing completed on 2025-01-18 09:12:52
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 <numbers>
0020 #include <stdexcept>
0021 #include <vector>
0022
0023 namespace Acts::Test {
0024
0025 BOOST_AUTO_TEST_SUITE(Surfaces)
0026
0027 const double rMin = 1.;
0028 const double rMax = 5.;
0029 const double halfPhiSector = std::numbers::pi / 8.;
0030 const double avgPhi = 0.1;
0031
0032
0033 BOOST_AUTO_TEST_CASE(RadialBoundsConstruction) {
0034
0035
0036
0037
0038 BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax).type(), SurfaceBounds::eDisc);
0039
0040
0041 BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax, halfPhiSector).type(),
0042 SurfaceBounds::eDisc);
0043
0044
0045 RadialBounds original(rMin, rMax);
0046 RadialBounds copied(original);
0047 BOOST_CHECK_EQUAL(copied, original);
0048 }
0049
0050
0051 BOOST_AUTO_TEST_CASE(RadialBoundsRecreation) {
0052 RadialBounds original(rMin, rMax, 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
0064 BOOST_CHECK_THROW(RadialBounds(-rMin, rMax, halfPhiSector, avgPhi),
0065 std::logic_error);
0066
0067
0068 BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, halfPhiSector, avgPhi),
0069 std::logic_error);
0070
0071
0072 BOOST_CHECK_THROW(RadialBounds(-rMin, -rMax, halfPhiSector, avgPhi),
0073 std::logic_error);
0074
0075
0076 BOOST_CHECK_THROW(RadialBounds(rMax, rMin, halfPhiSector, avgPhi),
0077 std::logic_error);
0078
0079
0080 BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, -5., avgPhi), std::logic_error);
0081
0082
0083 BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, halfPhiSector, 5.),
0084 std::logic_error);
0085 }
0086
0087
0088 BOOST_AUTO_TEST_CASE(RadialBoundsProperties) {
0089
0090 RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector);
0091 BOOST_CHECK_EQUAL(radialBoundsObject.type(), SurfaceBounds::eDisc);
0092
0093
0094 Vector2 outside(30., 0.);
0095 Vector2 inSurface(2., 0.);
0096
0097
0098 boost::test_tools::output_test_stream dumpOutput;
0099 radialBoundsObject.toStream(dumpOutput);
0100 BOOST_CHECK(
0101 dumpOutput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, "
0102 "hPhiSector, averagePhi) = (1.0000000, "
0103 "5.0000000, 0.3926991, 0.0000000)"));
0104
0105
0106 BOOST_CHECK(radialBoundsObject.inside(inSurface, BoundaryTolerance::None()));
0107 BOOST_CHECK(!radialBoundsObject.inside(outside, BoundaryTolerance::None()));
0108
0109
0110 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMinR), rMin);
0111
0112
0113 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), rMax);
0114
0115
0116 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.);
0117
0118
0119 BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eHalfPhiSector),
0120 halfPhiSector);
0121 }
0122
0123 BOOST_AUTO_TEST_CASE(RadialBoundsAssignment) {
0124 RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector);
0125
0126
0127
0128
0129
0130 RadialBounds assignedRadialBoundsObject(10.1, 123.);
0131 assignedRadialBoundsObject = radialBoundsObject;
0132 BOOST_CHECK_EQUAL(assignedRadialBoundsObject, radialBoundsObject);
0133 }
0134
0135 BOOST_AUTO_TEST_SUITE_END()
0136
0137 }