File indexing completed on 2025-12-17 09:21:45
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/TrackParametrization.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/EventData/GenericBoundTrackParameters.hpp"
0015 #include "Acts/EventData/ParticleHypothesis.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include <Acts/EventData/Charge.hpp>
0020 #include <Acts/EventData/MultiComponentTrackParameters.hpp>
0021 #include <Acts/Surfaces/PlaneSurface.hpp>
0022
0023 #include <algorithm>
0024 #include <initializer_list>
0025 #include <memory>
0026 #include <optional>
0027 #include <tuple>
0028 #include <vector>
0029
0030 using namespace Acts;
0031
0032 static const auto particleHypothesis = ParticleHypothesis::pion();
0033
0034 namespace ActsTests {
0035
0036 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0037
0038 BOOST_AUTO_TEST_CASE(test_constructors) {
0039 std::vector<std::tuple<double, BoundVector, BoundSquareMatrix>> a;
0040 a.push_back({1.0, BoundVector::Ones(), BoundSquareMatrix::Identity()});
0041
0042 std::vector<std::tuple<double, BoundVector, std::optional<BoundSquareMatrix>>>
0043 b;
0044 b.push_back({1.0, BoundVector::Ones(), BoundSquareMatrix::Identity()});
0045
0046 std::shared_ptr<PlaneSurface> surface =
0047 CurvilinearSurface(Vector3::Ones(), Vector3::Ones().normalized())
0048 .planeSurface();
0049
0050 const auto ap =
0051 MultiComponentBoundTrackParameters(surface, a, particleHypothesis);
0052 const auto bp =
0053 MultiComponentBoundTrackParameters(surface, b, particleHypothesis);
0054 const auto aps = MultiComponentBoundTrackParameters(
0055 surface, std::get<1>(a.front()), std::get<2>(a.front()),
0056 particleHypothesis);
0057 const auto bps = MultiComponentBoundTrackParameters(
0058 surface, std::get<1>(b.front()), std::get<2>(b.front()),
0059 particleHypothesis);
0060
0061 BOOST_CHECK(b == ap.components());
0062 BOOST_CHECK(ap.components() == bp.components());
0063 BOOST_CHECK(bp.components() == aps.components());
0064 BOOST_CHECK(aps.components() == bps.components());
0065 }
0066
0067 BOOST_AUTO_TEST_CASE(test_accessors) {
0068 using cov_t = std::optional<BoundSquareMatrix>;
0069 for (const auto &cov : {cov_t{}, cov_t{BoundSquareMatrix::Identity()},
0070 cov_t{BoundSquareMatrix::Identity()}}) {
0071 std::shared_ptr<PlaneSurface> surface =
0072 CurvilinearSurface(Vector3::Ones(), Vector3::Ones().normalized())
0073 .planeSurface();
0074
0075 const BoundTrackParameters single_pars(surface, BoundVector::Ones(), cov,
0076 particleHypothesis);
0077
0078 const auto multi_pars = [&]() {
0079 std::vector<
0080 std::tuple<double, BoundVector, std::optional<BoundSquareMatrix>>>
0081 a;
0082 for (int i = 0; i < 4; ++i) {
0083 a.push_back({0.25, single_pars.parameters(), single_pars.covariance()});
0084 }
0085 return MultiComponentBoundTrackParameters(surface, a, particleHypothesis);
0086 }();
0087
0088 BOOST_CHECK_EQUAL(multi_pars.absoluteMomentum(),
0089 single_pars.absoluteMomentum());
0090 BOOST_CHECK_EQUAL(multi_pars.charge(), single_pars.charge());
0091 BOOST_CHECK_EQUAL(multi_pars.fourPosition(GeometryContext{}),
0092 single_pars.fourPosition(GeometryContext{}));
0093 BOOST_CHECK_EQUAL(multi_pars.momentum(), single_pars.momentum());
0094 BOOST_CHECK_EQUAL(multi_pars.parameters(), single_pars.parameters());
0095 BOOST_CHECK_EQUAL(multi_pars.position(GeometryContext{}),
0096 single_pars.position(GeometryContext{}));
0097 BOOST_CHECK_EQUAL(multi_pars.transverseMomentum(),
0098 single_pars.transverseMomentum());
0099 BOOST_CHECK_EQUAL(multi_pars.direction(), single_pars.direction());
0100
0101
0102 if (cov && *cov != BoundSquareMatrix::Zero()) {
0103 BOOST_CHECK_EQUAL(*multi_pars.covariance(), *single_pars.covariance());
0104 } else {
0105 BOOST_CHECK(!multi_pars.covariance());
0106 }
0107 }
0108 }
0109 BOOST_AUTO_TEST_SUITE_END()
0110
0111 }