File indexing completed on 2026-09-12 08:22:32
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 "ActsTests/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 using namespace Acts;
0035
0036 namespace ActsTests {
0037
0038 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0039
0040 const double alpha = std::numbers::pi / 8.;
0041 const double zMin = 3.;
0042 const double zMax = 6.;
0043 const double halfPhi = std::numbers::pi / 4.;
0044 const double averagePhi = 0.;
0045 const bool symmetric = false;
0046
0047
0048 BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) {
0049
0050
0051
0052 BOOST_TEST_CHECKPOINT("Four parameter constructor (last two at default)");
0053 ConeBounds defaultConeBounds(alpha, symmetric);
0054 BOOST_CHECK_EQUAL(defaultConeBounds.type(), SurfaceBounds::eCone);
0055
0056 BOOST_TEST_CHECKPOINT("Four parameter constructor");
0057 ConeBounds fourParameterConstructed(alpha, symmetric, halfPhi, averagePhi);
0058 BOOST_CHECK_EQUAL(fourParameterConstructed.type(), SurfaceBounds::eCone);
0059
0060 BOOST_TEST_CHECKPOINT("Five parameter constructor (last two at default)");
0061 ConeBounds defaulted5ParamConeBounds(alpha, zMin, zMax);
0062 BOOST_CHECK_EQUAL(defaulted5ParamConeBounds.type(), SurfaceBounds::eCone);
0063
0064 BOOST_TEST_CHECKPOINT("Five parameter constructor)");
0065 ConeBounds fiveParamConstructedConeBounds(alpha, zMin, zMax, halfPhi,
0066 averagePhi);
0067 BOOST_CHECK_EQUAL(fiveParamConstructedConeBounds.type(),
0068 SurfaceBounds::eCone);
0069
0070 BOOST_TEST_CHECKPOINT("Copy constructor");
0071 ConeBounds copyConstructedConeBounds(fiveParamConstructedConeBounds);
0072 BOOST_CHECK_EQUAL(copyConstructedConeBounds, fiveParamConstructedConeBounds);
0073 }
0074
0075
0076 BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) {
0077 ConeBounds original(alpha, zMin, zMax, halfPhi, averagePhi);
0078 auto valvector = original.values();
0079 std::array<double, ConeBounds::eSize> values{};
0080 std::copy_n(valvector.begin(), ConeBounds::eSize, values.begin());
0081 ConeBounds recreated(values);
0082
0083 BOOST_CHECK_EQUAL(recreated, original);
0084 }
0085
0086
0087 BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) {
0088
0089 BOOST_CHECK_THROW(ConeBounds(-alpha, zMin, zMax, halfPhi, averagePhi),
0090 std::logic_error);
0091
0092
0093 BOOST_CHECK_THROW(
0094 ConeBounds(std::numbers::pi, zMin, zMax, halfPhi, averagePhi),
0095 std::logic_error);
0096
0097
0098 BOOST_CHECK_THROW(ConeBounds(alpha, zMax, zMin, halfPhi, averagePhi),
0099 std::logic_error);
0100
0101
0102 BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, -halfPhi, averagePhi),
0103 std::logic_error);
0104
0105
0106 BOOST_CHECK_THROW(
0107 ConeBounds(alpha, zMin, zMax, std::numbers::pi + 0.1, averagePhi),
0108 std::logic_error);
0109
0110
0111 BOOST_CHECK_THROW(
0112 ConeBounds(alpha, zMin, zMax, halfPhi, 2 * std::numbers::pi),
0113 std::logic_error);
0114 }
0115
0116
0117 BOOST_AUTO_TEST_CASE(ConeBoundsProperties) {
0118 const Vector2 origin(0, 0);
0119 const Vector2 somewhere(4., 4.);
0120 ConeBounds coneBoundsObject(alpha, zMin, zMax, halfPhi, averagePhi);
0121
0122
0123 BOOST_CHECK_EQUAL(coneBoundsObject.type(), SurfaceBounds::eCone);
0124
0125
0126 BOOST_CHECK(!coneBoundsObject.inside(origin));
0127
0128
0129 CHECK_CLOSE_REL(coneBoundsObject.r(zMin), zMin * std::tan(alpha), 1e-6);
0130
0131
0132 CHECK_CLOSE_REL(coneBoundsObject.tanAlpha(), std::tan(alpha), 1e-6);
0133
0134
0135 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eAlpha), alpha, 1e-6);
0136
0137
0138 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMinZ), zMin, 1e-6);
0139
0140
0141 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMaxZ), zMax, 1e-6);
0142
0143
0144 CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eHalfPhiSector), halfPhi,
0145 1e-6);
0146
0147
0148 boost::test_tools::output_test_stream dumpOutput;
0149 coneBoundsObject.toStream(dumpOutput);
0150 BOOST_CHECK(dumpOutput.is_equal(
0151 "Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, averagePhi) = "
0152 "(0.4142136, 3.0000000, 6.0000000, 0.7853982, 0.0000000)"));
0153 }
0154
0155
0156 BOOST_AUTO_TEST_CASE(ConeBoundsAssignment) {
0157 ConeBounds originalConeBounds(alpha, zMin, zMax, halfPhi, averagePhi);
0158 ConeBounds assignedConeBounds(0.1, 2.3, 4.5, 1.2, 2.1);
0159 assignedConeBounds = originalConeBounds;
0160
0161 BOOST_CHECK_EQUAL(assignedConeBounds, originalConeBounds);
0162 }
0163
0164 BOOST_AUTO_TEST_CASE(ConeBoundsCenter) {
0165
0166 ConeBounds cone(alpha, zMin, zMax, halfPhi, averagePhi);
0167 Vector2 center = cone.center();
0168
0169 double expectedZ = 0.5 * (zMin + zMax);
0170 BOOST_CHECK_EQUAL(center.x(), averagePhi);
0171 BOOST_CHECK_EQUAL(center.y(), expectedZ);
0172
0173
0174 const double avgPhiOffset = std::numbers::pi / 6.;
0175 ConeBounds coneOffset(alpha, zMin, zMax, halfPhi, avgPhiOffset);
0176 Vector2 centerOffset = coneOffset.center();
0177 BOOST_CHECK_EQUAL(centerOffset.x(), avgPhiOffset);
0178 BOOST_CHECK_EQUAL(centerOffset.y(), expectedZ);
0179 }
0180
0181 BOOST_AUTO_TEST_SUITE_END()
0182
0183 }