File indexing completed on 2025-01-18 09:12:34
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 BOOST_AUTO_TEST_CASE(test_constructors) {
0035 std::vector<std::tuple<double, BoundVector, BoundSquareMatrix>> a;
0036 a.push_back({1.0, BoundVector::Ones(), BoundSquareMatrix::Identity()});
0037
0038 std::vector<std::tuple<double, BoundVector, std::optional<BoundSquareMatrix>>>
0039 b;
0040 b.push_back({1.0, BoundVector::Ones(), BoundSquareMatrix::Identity()});
0041
0042 auto surface =
0043 CurvilinearSurface(Vector3::Ones(), Vector3::Ones().normalized())
0044 .planeSurface();
0045
0046 const auto ap =
0047 MultiComponentBoundTrackParameters(surface, a, particleHypothesis);
0048 const auto bp =
0049 MultiComponentBoundTrackParameters(surface, b, particleHypothesis);
0050 const auto aps = MultiComponentBoundTrackParameters(
0051 surface, std::get<1>(a.front()), std::get<2>(a.front()),
0052 particleHypothesis);
0053 const auto bps = MultiComponentBoundTrackParameters(
0054 surface, std::get<1>(b.front()), std::get<2>(b.front()),
0055 particleHypothesis);
0056
0057 BOOST_CHECK(b == ap.components());
0058 BOOST_CHECK(ap.components() == bp.components());
0059 BOOST_CHECK(bp.components() == aps.components());
0060 BOOST_CHECK(aps.components() == bps.components());
0061 }
0062
0063 BOOST_AUTO_TEST_CASE(test_accessors) {
0064 using cov_t = std::optional<BoundSquareMatrix>;
0065 for (const auto &cov : {cov_t{}, cov_t{BoundSquareMatrix::Identity()},
0066 cov_t{BoundSquareMatrix::Identity()}}) {
0067 auto surface =
0068 CurvilinearSurface(Vector3::Ones(), Vector3::Ones().normalized())
0069 .planeSurface();
0070
0071 const BoundTrackParameters single_pars(surface, BoundVector::Ones(), cov,
0072 particleHypothesis);
0073
0074 const auto multi_pars = [&]() {
0075 std::vector<
0076 std::tuple<double, BoundVector, std::optional<BoundSquareMatrix>>>
0077 a;
0078 for (int i = 0; i < 4; ++i) {
0079 a.push_back({0.25, single_pars.parameters(), single_pars.covariance()});
0080 }
0081 return MultiComponentBoundTrackParameters(surface, a, particleHypothesis);
0082 }();
0083
0084 BOOST_CHECK_EQUAL(multi_pars.absoluteMomentum(),
0085 single_pars.absoluteMomentum());
0086 BOOST_CHECK_EQUAL(multi_pars.charge(), single_pars.charge());
0087 BOOST_CHECK_EQUAL(multi_pars.fourPosition(GeometryContext{}),
0088 single_pars.fourPosition(GeometryContext{}));
0089 BOOST_CHECK_EQUAL(multi_pars.momentum(), single_pars.momentum());
0090 BOOST_CHECK_EQUAL(multi_pars.parameters(), single_pars.parameters());
0091 BOOST_CHECK_EQUAL(multi_pars.position(GeometryContext{}),
0092 single_pars.position(GeometryContext{}));
0093 BOOST_CHECK_EQUAL(multi_pars.transverseMomentum(),
0094 single_pars.transverseMomentum());
0095 BOOST_CHECK_EQUAL(multi_pars.direction(), single_pars.direction());
0096
0097
0098 if (cov && *cov != BoundSquareMatrix::Zero()) {
0099 BOOST_CHECK_EQUAL(*multi_pars.covariance(), *single_pars.covariance());
0100 } else {
0101 BOOST_CHECK(!multi_pars.covariance());
0102 }
0103 }
0104 }