File indexing completed on 2025-01-18 09:12:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0013 #include "Acts/Utilities/AngleHelpers.hpp"
0014
0015 #include <cmath>
0016 #include <numbers>
0017
0018 namespace bd = boost::unit_test::data;
0019
0020 using Acts::AngleHelpers::etaFromTheta;
0021 using Acts::AngleHelpers::EtaThetaConversionTraits;
0022 using Acts::AngleHelpers::thetaFromEta;
0023
0024 BOOST_AUTO_TEST_SUITE(AngleHelpers)
0025
0026 BOOST_AUTO_TEST_CASE(EtaThetaConversion) {
0027 CHECK_CLOSE_ABS(0.0, etaFromTheta(std::numbers::pi / 2), 1e-6);
0028 CHECK_CLOSE_ABS(1.0, etaFromTheta(thetaFromEta(1.0)), 1e-6);
0029 CHECK_CLOSE_ABS(1.0, thetaFromEta(etaFromTheta(1.0)), 1e-6);
0030 }
0031
0032 BOOST_DATA_TEST_CASE(EtaFromThetaRobustness, bd::xrange(0, 1000, 1), exponent) {
0033 {
0034
0035
0036 float thetaRight = exponent < 30 ? std::pow(10.0f, -1.0f * exponent) : 0.0f;
0037
0038 float etaRight = etaFromTheta<float>(thetaRight);
0039 BOOST_CHECK(!std::isnan(etaRight));
0040
0041
0042
0043 float thetaLeft = std::numbers::pi_v<float> - thetaRight;
0044
0045 float etaLeft = etaFromTheta<float>(thetaLeft);
0046 BOOST_CHECK(!std::isnan(etaLeft));
0047 }
0048
0049 {
0050
0051
0052 double thetaRight = exponent < 300 ? std::pow(10.0, -1.0 * exponent) : 0.0;
0053
0054 double etaRight = etaFromTheta<double>(thetaRight);
0055 BOOST_CHECK(!std::isnan(etaRight));
0056
0057
0058
0059 double thetaLeft = std::numbers::pi - thetaRight;
0060
0061 double etaLeft = etaFromTheta<double>(thetaLeft);
0062 BOOST_CHECK(!std::isnan(etaLeft));
0063 }
0064 }
0065
0066 BOOST_DATA_TEST_CASE(ThetaFromEtaRobustness, bd::xrange(1.0, 1000.0, 1.0),
0067 etaRight) {
0068 {
0069
0070
0071 float thetaRight = thetaFromEta<float>(etaRight);
0072 BOOST_CHECK(!std::isnan(thetaRight));
0073
0074
0075
0076 float etaLeft = -etaRight;
0077
0078 float thetaLeft = thetaFromEta<float>(etaLeft);
0079 BOOST_CHECK(!std::isnan(thetaLeft));
0080 }
0081
0082 {
0083
0084
0085 double thetaRight = thetaFromEta<double>(etaRight);
0086 BOOST_CHECK(!std::isnan(thetaRight));
0087
0088
0089
0090 double etaLeft = -etaRight;
0091
0092 double thetaLeft = thetaFromEta<double>(etaLeft);
0093 BOOST_CHECK(!std::isnan(thetaLeft));
0094 }
0095 }
0096
0097 BOOST_AUTO_TEST_SUITE_END()