Warning, file /acts/Tests/UnitTests/Core/EventData/CurvilinearTrackParametersTests.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Definitions/TrackParametrization.hpp"
0014 #include "Acts/Definitions/Units.hpp"
0015 #include "Acts/EventData/TrackParameters.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Surfaces/PlaneSurface.hpp"
0018 #include "Acts/Utilities/UnitVectors.hpp"
0019 #include "Acts/Utilities/detail/periodic.hpp"
0020 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0021
0022 #include <cmath>
0023 #include <limits>
0024 #include <numbers>
0025
0026 #include "TrackParametersDatasets.hpp"
0027
0028 namespace {
0029
0030 using namespace Acts;
0031 using namespace Acts::UnitLiterals;
0032
0033 constexpr auto eps = 8 * std::numeric_limits<double>::epsilon();
0034 const GeometryContext geoCtx;
0035 const BoundSquareMatrix cov = BoundSquareMatrix::Identity();
0036
0037 void checkParameters(const BoundTrackParameters& params, double phi,
0038 double theta, double p, double q, const Vector4& pos4,
0039 const Vector3& unitDir) {
0040 const auto qOverP = (q != 0) ? (q / p) : (1 / p);
0041 const auto pos = pos4.segment<3>(ePos0);
0042
0043 const auto* referenceSurface =
0044 dynamic_cast<const PlaneSurface*>(¶ms.referenceSurface());
0045 BOOST_REQUIRE_MESSAGE(referenceSurface != nullptr,
0046 "Reference surface is not a plane");
0047
0048
0049 CHECK_SMALL(params.template get<eBoundLoc0>(), eps);
0050 CHECK_SMALL(params.template get<eBoundLoc1>(), eps);
0051 CHECK_CLOSE_OR_SMALL(params.template get<eBoundTime>(), pos4[eTime], eps,
0052 eps);
0053 CHECK_CLOSE_OR_SMALL(detail::radian_sym(params.template get<eBoundPhi>()),
0054 detail::radian_sym(phi), eps, eps);
0055 CHECK_CLOSE_OR_SMALL(params.template get<eBoundTheta>(), theta, eps, eps);
0056 CHECK_CLOSE_OR_SMALL(params.template get<eBoundQOverP>(), qOverP, eps, eps);
0057
0058 CHECK_CLOSE_OR_SMALL(params.fourPosition(geoCtx), pos4, eps, eps);
0059 CHECK_CLOSE_OR_SMALL(params.position(geoCtx), pos, eps, eps);
0060 CHECK_CLOSE_OR_SMALL(params.time(), pos4[eTime], eps, eps);
0061 CHECK_CLOSE_OR_SMALL(params.direction(), unitDir, eps, eps);
0062 CHECK_CLOSE_OR_SMALL(params.absoluteMomentum(), p, eps, eps);
0063 CHECK_CLOSE_OR_SMALL(params.transverseMomentum(), p * std::sin(theta), eps,
0064 eps);
0065 CHECK_CLOSE_OR_SMALL(params.momentum(), p * unitDir, eps, eps);
0066 BOOST_CHECK_EQUAL(params.charge(), q);
0067
0068 CHECK_CLOSE_OR_SMALL(referenceSurface->center(geoCtx), pos, eps, eps);
0069 CHECK_CLOSE_OR_SMALL(referenceSurface->normal(geoCtx), unitDir, eps, eps);
0070
0071
0072 BoundTrackParameters reflectedParams = params;
0073 reflectedParams.reflectInPlace();
0074 CHECK_CLOSE_OR_SMALL(params.reflect().parameters(),
0075 reflectedParams.parameters(), eps, eps);
0076 CHECK_CLOSE_OR_SMALL(reflectedParams.reflect().parameters(),
0077 params.parameters(), eps, eps);
0078
0079
0080 }
0081
0082 }
0083
0084 namespace ActsTests {
0085
0086 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0087
0088 BOOST_DATA_TEST_CASE(
0089 NeutralConstruct,
0090 posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps, x, y, z,
0091 time, phiInput, theta, p) {
0092
0093 const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.;
0094 const Vector4 pos4(x, y, z, time);
0095 const Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0096
0097 BoundTrackParameters params = BoundTrackParameters::createCurvilinear(
0098 pos4, dir, 1 / p, std::nullopt, ParticleHypothesis::pion0());
0099 checkParameters(params, phi, theta, p, 0_e, pos4, dir);
0100 BOOST_CHECK(!params.covariance());
0101
0102
0103 params = BoundTrackParameters::createCurvilinear(pos4, dir, 1 / p, cov,
0104 ParticleHypothesis::pion0());
0105 BOOST_CHECK(params.covariance());
0106 BOOST_CHECK_EQUAL(params.covariance().value(), cov);
0107 }
0108
0109 BOOST_DATA_TEST_CASE(
0110 ChargedConstruct,
0111 posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
0112 x, y, z, time, phiInput, theta, p, q) {
0113
0114 const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.;
0115 const Vector4 pos4(x, y, z, time);
0116 const Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0117
0118 BoundTrackParameters params = BoundTrackParameters::createCurvilinear(
0119 pos4, dir, q / p, std::nullopt,
0120 ParticleHypothesis::pionLike(std::abs(q)));
0121 checkParameters(params, phi, theta, p, q, pos4, dir);
0122 BOOST_CHECK(!params.covariance());
0123
0124
0125 params = BoundTrackParameters::createCurvilinear(
0126 pos4, dir, q / p, cov, ParticleHypothesis::pionLike(std::abs(q)));
0127 BOOST_CHECK(params.covariance());
0128 BOOST_CHECK_EQUAL(params.covariance().value(), cov);
0129 }
0130
0131 BOOST_DATA_TEST_CASE(
0132 AnyConstruct,
0133 posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsAny, x, y,
0134 z, time, phiInput, theta, p, q) {
0135
0136 const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.;
0137 const Vector4 pos4(x, y, z, time);
0138 const Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0139
0140 auto particleHypothesis = ParticleHypothesis::pionLike(std::abs(q));
0141 auto qOverP = particleHypothesis.qOverP(p, q);
0142
0143 BoundTrackParameters params = BoundTrackParameters::createCurvilinear(
0144 pos4, dir, qOverP, std::nullopt, particleHypothesis);
0145 checkParameters(params, phi, theta, p, q, pos4, dir);
0146 BOOST_CHECK(!params.covariance());
0147
0148
0149 params = BoundTrackParameters::createCurvilinear(pos4, dir, qOverP, cov,
0150 particleHypothesis);
0151 BOOST_CHECK(params.covariance());
0152 BOOST_CHECK_EQUAL(params.covariance().value(), cov);
0153 }
0154
0155 BOOST_AUTO_TEST_SUITE_END()
0156
0157 }