File indexing completed on 2025-01-18 09:12:51
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/EllipseBounds.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/SurfaceBounds.hpp"
0017
0018 #include <algorithm>
0019 #include <array>
0020 #include <cmath>
0021 #include <numbers>
0022 #include <stdexcept>
0023 #include <vector>
0024
0025 namespace Acts::Test {
0026
0027 BOOST_AUTO_TEST_SUITE(Surfaces)
0028
0029 const double innerRx = 10.;
0030 const double innerRy = 15.;
0031 const double phiSector = std::numbers::pi / 2.;
0032 const double averagePhi = 0.;
0033
0034
0035 BOOST_AUTO_TEST_CASE(EllipseBoundsConstruction) {
0036 const double outerRx = 25.;
0037 const double outerRy = 30.;
0038
0039
0040
0041
0042
0043 BOOST_CHECK_EQUAL(
0044 EllipseBounds(innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi)
0045 .type(),
0046 SurfaceBounds::eEllipse);
0047
0048
0049 EllipseBounds original(innerRx, innerRy, outerRx, outerRy, phiSector,
0050 averagePhi);
0051 EllipseBounds copied(original);
0052 BOOST_CHECK_EQUAL(copied, original);
0053 }
0054
0055
0056 BOOST_AUTO_TEST_CASE(EllipseBoundsRecreation) {
0057 const double outerRx = 25.;
0058 const double outerRy = 30.;
0059
0060 EllipseBounds original(innerRx, innerRy, outerRx, outerRy, phiSector,
0061 averagePhi);
0062 auto valvector = original.values();
0063 std::array<double, EllipseBounds::eSize> values{};
0064 std::copy_n(valvector.begin(), EllipseBounds::eSize, values.begin());
0065 EllipseBounds recreated(values);
0066 BOOST_CHECK_EQUAL(recreated, original);
0067 }
0068
0069
0070 BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) {
0071 const double outerRx = 25.;
0072 const double outerRy = 30.;
0073
0074
0075 BOOST_CHECK_THROW(
0076 EllipseBounds(-innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi),
0077 std::logic_error);
0078
0079
0080 BOOST_CHECK_THROW(
0081 EllipseBounds(innerRx, -innerRy, outerRx, outerRy, phiSector, averagePhi),
0082 std::logic_error);
0083
0084
0085 BOOST_CHECK_THROW(EllipseBounds(-innerRx, -innerRy, outerRx, outerRy,
0086 phiSector, averagePhi),
0087 std::logic_error);
0088
0089
0090 BOOST_CHECK_THROW(
0091 EllipseBounds(innerRx, innerRy, 0., outerRy, phiSector, averagePhi),
0092 std::logic_error);
0093
0094
0095 BOOST_CHECK_THROW(
0096 EllipseBounds(innerRx, innerRy, outerRx, 0., phiSector, averagePhi),
0097 std::logic_error);
0098
0099
0100 BOOST_CHECK_THROW(EllipseBounds(innerRx, innerRy, -outerRx, -outerRy,
0101 phiSector, averagePhi),
0102 std::logic_error);
0103
0104
0105 BOOST_CHECK_THROW(
0106 EllipseBounds(outerRx, innerRy, innerRx, outerRy, phiSector, averagePhi),
0107 std::logic_error);
0108
0109
0110 BOOST_CHECK_THROW(
0111 EllipseBounds(innerRx, outerRy, outerRx, innerRy, phiSector, averagePhi),
0112 std::logic_error);
0113
0114
0115 BOOST_CHECK_THROW(
0116 EllipseBounds(innerRx, innerRy, outerRx, outerRy, -phiSector, averagePhi),
0117 std::logic_error);
0118
0119
0120 BOOST_CHECK_THROW(
0121 EllipseBounds(innerRx, innerRy, outerRx, outerRy, phiSector, 4.),
0122 std::logic_error);
0123 }
0124
0125
0126 BOOST_AUTO_TEST_CASE(EllipseBoundsProperties) {
0127 const double outerRx = 15.;
0128 const double outerRy = 20.;
0129
0130
0131 EllipseBounds ellipseBoundsObject(innerRx, innerRy, outerRx, outerRy,
0132 phiSector, averagePhi);
0133
0134
0135 BOOST_CHECK_EQUAL(ellipseBoundsObject.type(), SurfaceBounds::eEllipse);
0136
0137
0138 Vector2 origin{0., 0.};
0139 Vector2 outsideBy15{0., 30.};
0140 Vector2 inRectangle{17., 11.};
0141
0142
0143 BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eInnerRx), innerRx);
0144
0145
0146 BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eOuterRx), outerRx);
0147
0148
0149 BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eInnerRy), innerRy);
0150
0151
0152 BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eOuterRy), outerRy);
0153
0154
0155 BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eAveragePhi),
0156 averagePhi);
0157
0158
0159
0160
0161
0162
0163
0164
0165 BOOST_CHECK_EQUAL(ellipseBoundsObject.boundingBox(),
0166 RectangleBounds(15., 20.));
0167
0168
0169 BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eHalfPhiSector),
0170 std::numbers::pi / 2.);
0171
0172
0173 boost::test_tools::output_test_stream dumpOutput;
0174 ellipseBoundsObject.toStream(dumpOutput);
0175 BOOST_CHECK(dumpOutput.is_equal(
0176 "Acts::EllipseBounds: (innerRadius0, outerRadius0, innerRadius1, "
0177 "outerRadius1, hPhiSector, averagePhi) = (10.0000000, 15.0000000, "
0178 "15.0000000, 20.0000000, 0.0000000, 1.5707963, 0.0000000)"));
0179
0180
0181 BOOST_CHECK(
0182 !ellipseBoundsObject.inside(inRectangle, BoundaryTolerance::None()));
0183
0184 BOOST_CHECK(
0185 !ellipseBoundsObject.inside(outsideBy15, BoundaryTolerance::None()));
0186 }
0187
0188 BOOST_AUTO_TEST_CASE(EllipseBoundsAssignment) {
0189 const double outerRx = 15.;
0190 const double outerRy = 20.;
0191
0192 EllipseBounds ellipseBoundsObject(innerRx, outerRx, innerRy, outerRy,
0193 averagePhi, phiSector);
0194 EllipseBounds similarlyConstructeEllipseBoundsObject(
0195 innerRx, outerRx, innerRy, outerRy, averagePhi, phiSector);
0196
0197 BOOST_CHECK_EQUAL(ellipseBoundsObject,
0198 similarlyConstructeEllipseBoundsObject);
0199
0200
0201 EllipseBounds assignedEllipseBoundsObject(11., 12., 17., 18., 1.);
0202
0203 assignedEllipseBoundsObject = ellipseBoundsObject;
0204 BOOST_CHECK_EQUAL(assignedEllipseBoundsObject, ellipseBoundsObject);
0205 }
0206
0207 BOOST_AUTO_TEST_SUITE_END()
0208
0209 }