File indexing completed on 2025-01-18 09:12:34
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/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/Common.hpp"
0014 #include "Acts/Definitions/TrackParametrization.hpp"
0015 #include "Acts/Definitions/Units.hpp"
0016 #include "Acts/EventData/Charge.hpp"
0017 #include "Acts/EventData/GenericFreeTrackParameters.hpp"
0018 #include "Acts/EventData/TrackParameters.hpp"
0019 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0020 #include "Acts/Utilities/UnitVectors.hpp"
0021
0022 #include <limits>
0023 #include <optional>
0024 #include <utility>
0025 #include <vector>
0026
0027 #include "TrackParametersDatasets.hpp"
0028
0029 namespace {
0030
0031 using namespace Acts;
0032 using namespace Acts::UnitLiterals;
0033
0034 constexpr auto eps = 8 * std::numeric_limits<double>::epsilon();
0035 const FreeSquareMatrix cov = FreeSquareMatrix::Identity();
0036
0037 void checkParameters(const FreeTrackParameters& params, const Vector4& pos4,
0038 const Vector3& unitDir, double p, double q) {
0039 const auto qOverP = (q != 0) ? (q / p) : (1 / p);
0040 const auto pos = pos4.segment<3>(ePos0);
0041
0042
0043 CHECK_CLOSE_OR_SMALL(params.template get<eFreePos0>(), pos4[ePos0], eps, eps);
0044 CHECK_CLOSE_OR_SMALL(params.template get<eFreePos1>(), pos4[ePos1], eps, eps);
0045 CHECK_CLOSE_OR_SMALL(params.template get<eFreePos2>(), pos4[ePos2], eps, eps);
0046 CHECK_CLOSE_OR_SMALL(params.template get<eFreeTime>(), pos4[eTime], eps, eps);
0047 CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir0>(), unitDir[eMom0], eps,
0048 eps);
0049 CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir1>(), unitDir[eMom1], eps,
0050 eps);
0051 CHECK_CLOSE_OR_SMALL(params.template get<eFreeDir2>(), unitDir[eMom2], eps,
0052 eps);
0053 CHECK_CLOSE_OR_SMALL(params.template get<eFreeQOverP>(), qOverP, eps, eps);
0054
0055 CHECK_CLOSE_OR_SMALL(params.fourPosition(), pos4, eps, eps);
0056 CHECK_CLOSE_OR_SMALL(params.position(), pos, eps, eps);
0057 CHECK_CLOSE_OR_SMALL(params.time(), pos4[eFreeTime], eps, eps);
0058 CHECK_CLOSE_OR_SMALL(params.direction(), unitDir, eps, eps);
0059 CHECK_CLOSE_OR_SMALL(params.absoluteMomentum(), p, eps, eps);
0060 CHECK_CLOSE_OR_SMALL(params.transverseMomentum(),
0061 p * unitDir.template head<2>().norm(), eps, eps);
0062 CHECK_CLOSE_OR_SMALL(params.momentum(), p * unitDir, eps, eps);
0063 BOOST_CHECK_EQUAL(params.charge(), q);
0064
0065 CHECK_CLOSE_OR_SMALL(params.position(),
0066 params.parameters().template segment<3>(eFreePos0), eps,
0067 eps);
0068 CHECK_CLOSE_OR_SMALL(params.time(), params.template get<eFreeTime>(), eps,
0069 eps);
0070
0071
0072 FreeTrackParameters 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 BOOST_AUTO_TEST_SUITE(CurvilinearTrackParameters)
0083
0084 BOOST_DATA_TEST_CASE(
0085 NeutralConstructFromAngles,
0086 posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps, x, y, z,
0087 time, phi, theta, p) {
0088 Vector4 pos4(x, y, z, time);
0089 Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0090
0091 FreeTrackParameters params(pos4, phi, theta, 1 / p, std::nullopt,
0092 ParticleHypothesis::pion0());
0093 checkParameters(params, pos4, dir, p, 0_e);
0094 BOOST_CHECK(!params.covariance());
0095
0096
0097 params = FreeTrackParameters(pos4, phi, theta, 1 / p, cov,
0098 ParticleHypothesis::pion0());
0099 BOOST_CHECK(params.covariance());
0100 BOOST_CHECK_EQUAL(params.covariance().value(), cov);
0101 }
0102
0103 BOOST_DATA_TEST_CASE(
0104 ChargedConstructFromAngles,
0105 posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
0106 x, y, z, time, phi, theta, p, q) {
0107 Vector4 pos4(x, y, z, time);
0108 Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0109
0110 FreeTrackParameters params(pos4, phi, theta, q / p, std::nullopt,
0111 ParticleHypothesis::pionLike(std::abs(q)));
0112 checkParameters(params, pos4, dir, p, q);
0113 BOOST_CHECK(!params.covariance());
0114
0115
0116 params = FreeTrackParameters(pos4, phi, theta, q / p, cov,
0117 ParticleHypothesis::pionLike(std::abs(q)));
0118 BOOST_CHECK(params.covariance());
0119 BOOST_CHECK_EQUAL(params.covariance().value(), cov);
0120 }
0121
0122 BOOST_DATA_TEST_CASE(
0123 AnyConstructFromAngles,
0124 posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
0125 x, y, z, time, phi, theta, p, q) {
0126 Vector4 pos4(x, y, z, time);
0127 Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0128
0129 FreeTrackParameters params(pos4, phi, theta, q / p, std::nullopt,
0130 ParticleHypothesis::pionLike(std::abs(q)));
0131 checkParameters(params, pos4, dir, p, q);
0132 BOOST_CHECK(!params.covariance());
0133
0134
0135 params = FreeTrackParameters(pos4, phi, theta, q / p, cov,
0136 ParticleHypothesis::pionLike(std::abs(q)));
0137 BOOST_CHECK(params.covariance());
0138 BOOST_CHECK_EQUAL(params.covariance().value(), cov);
0139 }
0140
0141 BOOST_AUTO_TEST_SUITE_END()