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/DiscTrapezoidBounds.hpp"
0015 #include "Acts/Surfaces/SurfaceBounds.hpp"
0016 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0017
0018 #include <algorithm>
0019 #include <array>
0020 #include <stdexcept>
0021 #include <vector>
0022
0023 namespace Acts::Test {
0024
0025 BOOST_AUTO_TEST_SUITE(Surfaces)
0026
0027 const double minHalfX = 1.;
0028 const double maxHalfX = 5.;
0029 const double rMin = 2.;
0030 const double rMax = 6.;
0031 const double averagePhi = 0.;
0032 const double stereo = 0.1;
0033
0034
0035 BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsConstruction) {
0036
0037 BOOST_CHECK_EQUAL(
0038 DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, rMax, averagePhi).type(),
0039 SurfaceBounds::eDiscTrapezoid);
0040
0041
0042 BOOST_CHECK_EQUAL(
0043 DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo)
0044 .type(),
0045 SurfaceBounds::eDiscTrapezoid);
0046
0047
0048 DiscTrapezoidBounds original(minHalfX, maxHalfX, rMin, rMax, averagePhi);
0049 DiscTrapezoidBounds copied(original);
0050 BOOST_CHECK_EQUAL(copied.type(), SurfaceBounds::eDiscTrapezoid);
0051 }
0052
0053
0054 BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsRecreation) {
0055 DiscTrapezoidBounds original(minHalfX, maxHalfX, rMin, rMax, averagePhi,
0056 stereo);
0057 auto valvector = original.values();
0058 std::array<double, DiscTrapezoidBounds::eSize> values{};
0059 std::copy_n(valvector.begin(), DiscTrapezoidBounds::eSize, values.begin());
0060 DiscTrapezoidBounds recreated(values);
0061 BOOST_CHECK_EQUAL(recreated, original);
0062 }
0063
0064
0065 BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsExceptions) {
0066
0067 BOOST_CHECK_THROW(
0068 DiscTrapezoidBounds(-minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo),
0069 std::logic_error);
0070
0071
0072 BOOST_CHECK_THROW(
0073 DiscTrapezoidBounds(minHalfX, -maxHalfX, rMin, rMax, averagePhi, stereo),
0074 std::logic_error);
0075
0076
0077 BOOST_CHECK_THROW(
0078 DiscTrapezoidBounds(-minHalfX, -maxHalfX, rMin, rMax, averagePhi, stereo),
0079 std::logic_error);
0080
0081
0082 BOOST_CHECK_THROW(
0083 DiscTrapezoidBounds(minHalfX, maxHalfX, -rMin, rMax, averagePhi, stereo),
0084 std::logic_error);
0085
0086
0087 BOOST_CHECK_THROW(
0088 DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, -rMax, averagePhi, stereo),
0089 std::logic_error);
0090
0091
0092 BOOST_CHECK_THROW(
0093 DiscTrapezoidBounds(minHalfX, maxHalfX, -rMin, -rMax, averagePhi, stereo),
0094 std::logic_error);
0095
0096
0097 BOOST_CHECK_THROW(
0098 DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, rMax, 4., stereo),
0099 std::logic_error);
0100 }
0101
0102
0103 BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsProperties) {
0104
0105 DiscTrapezoidBounds DiscTrapezoidBoundsObject(minHalfX, maxHalfX, rMin, rMax,
0106 averagePhi);
0107
0108
0109 BOOST_CHECK_EQUAL(DiscTrapezoidBoundsObject.type(),
0110 SurfaceBounds::eDiscTrapezoid);
0111
0112
0113 Vector2 origin(0., 0.);
0114 Vector2 outside(30., 0.);
0115 Vector2 inSurface(2.5, 0.);
0116
0117
0118 boost::test_tools::output_test_stream dumpOutput;
0119 DiscTrapezoidBoundsObject.toStream(dumpOutput);
0120 BOOST_CHECK(dumpOutput.is_equal(
0121 "Acts::DiscTrapezoidBounds: (innerRadius, outerRadius, halfLengthXminR, "
0122 "halfLengthXmaxR, halfLengthY, halfPhiSector, averagePhi, rCenter, "
0123 "stereo) = "
0124 "(2.0000000, 6.0000000, 1.0000000, 5.0000000, 0.7922870, 0.9851108, "
0125 "0.0000000, 2.5243378, 0.0000000)"));
0126
0127
0128 BOOST_CHECK(
0129 DiscTrapezoidBoundsObject.inside(inSurface, BoundaryTolerance::None()));
0130 BOOST_CHECK(
0131 !DiscTrapezoidBoundsObject.inside(outside, BoundaryTolerance::None()));
0132
0133
0134 CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rMin(), rMin, 1e-6);
0135
0136
0137 CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rMax(), rMax, 1e-6);
0138
0139
0140 CHECK_SMALL(DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eAveragePhi),
0141 1e-9);
0142
0143
0144 CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rCenter(), 2.524337798, 1e-6);
0145
0146
0147 CHECK_SMALL(DiscTrapezoidBoundsObject.stereo(), 1e-6);
0148
0149
0150 CHECK_CLOSE_REL(
0151 DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eHalfLengthXminR),
0152 minHalfX, 1e-6);
0153
0154
0155 CHECK_CLOSE_REL(
0156 DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eHalfLengthXmaxR),
0157 maxHalfX, 1e-6);
0158
0159
0160 CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.halfLengthY(), 0.792286991, 1e-6);
0161 }
0162
0163 BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsAssignment) {
0164 DiscTrapezoidBounds DiscTrapezoidBoundsObject(minHalfX, maxHalfX, rMin, rMax,
0165 averagePhi, stereo);
0166
0167
0168
0169
0170
0171 DiscTrapezoidBounds assignedDiscTrapezoidBoundsObject(2.1, 6.6, 3.4, 4.2, 0.3,
0172 0.);
0173 assignedDiscTrapezoidBoundsObject = DiscTrapezoidBoundsObject;
0174 BOOST_CHECK_EQUAL(assignedDiscTrapezoidBoundsObject,
0175 DiscTrapezoidBoundsObject);
0176 }
0177
0178 BOOST_AUTO_TEST_SUITE_END()
0179
0180 }