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