Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiComponentBoundTrackParametersTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MultiComponentBoundTrackParametersTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
21 
22 #include <algorithm>
23 #include <initializer_list>
24 #include <memory>
25 #include <optional>
26 #include <tuple>
27 #include <vector>
28 
29 using namespace Acts;
30 
32 
34  std::vector<std::tuple<double, BoundVector, BoundSquareMatrix>> a;
35  a.push_back({1.0, BoundVector::Ones(), BoundSquareMatrix::Identity()});
36 
37  std::vector<std::tuple<double, BoundVector, std::optional<BoundSquareMatrix>>>
38  b;
39  b.push_back({1.0, BoundVector::Ones(), BoundSquareMatrix::Identity()});
40 
41  auto surface = Acts::Surface::makeShared<Acts::PlaneSurface>(
42  Vector3::Ones(), Vector3::Ones().normalized());
43 
44  const auto ap =
46  const auto bp =
48  const auto aps = MultiComponentBoundTrackParameters(
49  surface, std::get<1>(a.front()), std::get<2>(a.front()),
51  const auto bps = MultiComponentBoundTrackParameters(
52  surface, std::get<1>(b.front()), std::get<2>(b.front()),
54 
55  BOOST_CHECK(b == ap.components());
56  BOOST_CHECK(ap.components() == bp.components());
57  BOOST_CHECK(bp.components() == aps.components());
58  BOOST_CHECK(aps.components() == bps.components());
59 }
60 
61 BOOST_AUTO_TEST_CASE(test_accessors) {
62  using cov_t = std::optional<BoundSquareMatrix>;
63  for (const auto &cov : {cov_t{}, cov_t{BoundSquareMatrix::Identity()},
64  cov_t{BoundSquareMatrix::Identity()}}) {
65  auto surface = Acts::Surface::makeShared<Acts::PlaneSurface>(
66  Vector3::Ones(), Vector3::Ones().normalized());
67 
68  const BoundTrackParameters single_pars(surface, BoundVector::Ones(), cov,
70 
71  const auto multi_pars = [&]() {
72  std::vector<
73  std::tuple<double, BoundVector, std::optional<BoundSquareMatrix>>>
74  a;
75  for (int i = 0; i < 4; ++i) {
76  a.push_back({0.25, single_pars.parameters(), single_pars.covariance()});
77  }
79  }();
80 
81  BOOST_CHECK_EQUAL(multi_pars.absoluteMomentum(),
82  single_pars.absoluteMomentum());
83  BOOST_CHECK_EQUAL(multi_pars.charge(), single_pars.charge());
84  BOOST_CHECK_EQUAL(multi_pars.fourPosition(GeometryContext{}),
85  single_pars.fourPosition(GeometryContext{}));
86  BOOST_CHECK_EQUAL(multi_pars.momentum(), single_pars.momentum());
87  BOOST_CHECK_EQUAL(multi_pars.parameters(), single_pars.parameters());
88  BOOST_CHECK_EQUAL(multi_pars.position(GeometryContext{}),
89  single_pars.position(GeometryContext{}));
90  BOOST_CHECK_EQUAL(multi_pars.transverseMomentum(),
91  single_pars.transverseMomentum());
92  BOOST_CHECK_EQUAL(multi_pars.direction(), single_pars.direction());
93 
94  // Check the behaviour for std::nullopt or zero covariance
95  if (cov && *cov != BoundSquareMatrix::Zero()) {
96  BOOST_CHECK_EQUAL(*multi_pars.covariance(), *single_pars.covariance());
97  } else {
98  BOOST_CHECK(not multi_pars.covariance());
99  }
100  }
101 }