File indexing completed on 2025-01-18 09:12:50
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/ConeBounds.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0016
0017 #include <algorithm>
0018 #include <array>
0019 #include <cmath>
0020 #include <numbers>
0021 #include <stdexcept>
0022 #include <vector>
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 namespace Acts::Test {
0035
0036 BOOST_AUTO_TEST_SUITE(Surfaces)
0037
0038 const double alpha = std::numbers::pi / 8.;
0039 const double zMin = 3.;
0040 const double zMax = 6.;
0041 const double halfPhi = std::numbers::pi / 4.;
0042 const double averagePhi = 0.;
0043 const bool symmetric = false;
0044
0045
0046 BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) {
0047
0048
0049
0050 BOOST_TEST_CHECKPOINT("Four parameter constructor (last two at default)");
0051 ConeBounds defaultConeBounds(alpha, symmetric);
0052 BOOST_CHECK_EQUAL(defaultConeBounds.type(), SurfaceBounds::eCone);
0053
0054 BOOST_TEST_CHECKPOINT("Four parameter constructor");
0055 ConeBounds fourParameterConstructed(alpha, symmetric, halfPhi, averagePhi);
0056 BOOST_CHECK_EQUAL(fourParameterConstructed.type(), SurfaceBounds::eCone);
0057
0058 BOOST_TEST_CHECKPOINT("Five parameter constructor (last two at default)");
0059 ConeBounds defaulted5ParamConeBounds(alpha, zMin, zMax);
0060 BOOST_CHECK_EQUAL(defaulted5ParamConeBounds.type(), SurfaceBounds::eCone);
0061
0062 BOOST_TEST_CHECKPOINT("Five parameter constructor)");
0063 ConeBounds fiveParamConstructedConeBounds(alpha, zMin, zMax, halfPhi,
0064 averagePhi);
0065 BOOST_CHECK_EQUAL(fiveParamConstructedConeBounds.type(),
0066 SurfaceBounds::eCone);
0067
0068 BOOST_TEST_CHECKPOINT("Copy constructor");
0069 ConeBounds copyConstructedConeBounds(fiveParamConstructedConeBounds);
0070 BOOST_CHECK_EQUAL(copyConstructedConeBounds, fiveParamConstructedConeBounds);
0071 }
0072
0073
0074 BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) {
0075 ConeBounds original(alpha, zMin, zMax, halfPhi, averagePhi);
0076 auto valvector = original.values();
0077 std::array<double, ConeBounds::eSize> values{};
0078 std::copy_n(valvector.begin(), ConeBounds::eSize, values.begin());
0079 ConeBounds recreated(values);
0080
0081 BOOST_CHECK_EQUAL(recreated, original);
0082 }
0083
0084
0085 BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) {
0086
0087 BOOST_CHECK_THROW(ConeBounds(-alpha, zMin, zMax, halfPhi, averagePhi),
0088 std::logic_error);
0089
0090
0091 BOOST_CHECK_THROW(
0092 ConeBounds(std::numbers::pi, zMin, zMax, halfPhi, averagePhi),
0093 std::logic_error);
0094
0095
0096 BOOST_CHECK_THROW(ConeBounds(alpha, zMax, zMin, halfPhi, averagePhi),
0097 std::logic_error);
0098
0099
0100 BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, -halfPhi, averagePhi),
0101 std::logic_error);
0102
0103
0104 BOOST_CHECK_THROW(
0105 ConeBounds(alpha, zMin, zMax, halfPhi, 2 * std::numbers::pi),
0106 std::logic_error);
0107 }
0108
0109
0110 BOOST_AUTO_TEST_CASE(ConeBoundsProperties) {
0111 const Vector2 origin(0, 0);
0112 const Vector2 somewhere(4., 4.);
0113 ConeBounds coneBoundsObject(alpha, zMin, zMax, halfPhi, averagePhi);
0114
0115
0116 BOOST_CHECK_EQUAL(coneBoundsObject.type(), SurfaceBounds::eCone);
0117
0118
0119 BOOST_CHECK(!coneBoundsObject.inside(origin));
0120
0121
0122 CHECK_CLOSE_REL(coneBoundsObject.r(zMin), zMin * std::tan(alpha), 1e-6);
0123
0124
0125 CHECK_CLOSE_REL(coneBoundsObject.tanAlpha(), std::tan(alpha), 1e-6);
0126
0127
0128 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eAlpha), alpha, 1e-6);
0129
0130
0131 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMinZ), zMin, 1e-6);
0132
0133
0134 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMaxZ), zMax, 1e-6);
0135
0136
0137 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eHalfPhiSector), halfPhi,
0138 1e-6);
0139
0140
0141 boost::test_tools::output_test_stream dumpOutput;
0142 coneBoundsObject.toStream(dumpOutput);
0143 BOOST_CHECK(dumpOutput.is_equal(
0144 "Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, averagePhi) = "
0145 "(0.4142136, 3.0000000, 6.0000000, 0.7853982, 0.0000000)"));
0146 }
0147
0148
0149 BOOST_AUTO_TEST_CASE(ConeBoundsAssignment) {
0150 ConeBounds originalConeBounds(alpha, zMin, zMax, halfPhi, averagePhi);
0151 ConeBounds assignedConeBounds(0.1, 2.3, 4.5, 1.2, 2.1);
0152 assignedConeBounds = originalConeBounds;
0153
0154 BOOST_CHECK_EQUAL(assignedConeBounds, originalConeBounds);
0155 }
0156
0157 BOOST_AUTO_TEST_SUITE_END()
0158
0159 }