EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasurementHelpersTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MeasurementHelpersTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 
14 
15 namespace Acts {
16 namespace Test {
17 
18 // Create a test context
20 
22 
23 template <BoundIndices... params>
26 
27 BOOST_AUTO_TEST_CASE(getSurface_test) {
28  auto cylinderBounds = std::make_shared<CylinderBounds>(3, 10);
29 
30  auto cylinder = Surface::makeShared<CylinderSurface>(Transform3D::Identity(),
31  cylinderBounds);
32  auto cylinder2 = Surface::makeShared<CylinderSurface>(Transform3D::Identity(),
33  cylinderBounds);
34 
36  cov << 0.04, 0, 0, 0.1;
38  cylinder, {}, std::move(cov), -0.1, 0.45);
39 
41 
42  BOOST_CHECK_EQUAL(MeasurementHelpers::getSurface(fm), cylinder.get());
43 
45  cylinder2, {}, std::move(cov), -0.1, 0.45);
46  fm = m2;
47  BOOST_CHECK_EQUAL(MeasurementHelpers::getSurface(fm), cylinder2.get());
48 }
49 
50 BOOST_AUTO_TEST_CASE(getSize_test) {
51  auto cylinder =
52  Surface::makeShared<CylinderSurface>(Transform3D::Identity(), 3, 10);
53 
55  cov << 0.04, 0, 0, 0.1;
57  cylinder, {}, std::move(cov), -0.1, 0.45);
58 
60  BOOST_CHECK_EQUAL(MeasurementHelpers::getSize(fm), 2u);
61 
62  ActsSymMatrixD<3> cov3;
63  cov.setRandom();
66  m2(cylinder, {}, std::move(cov3), -0.1, 0.45, 42);
67  fm = m2;
68 
69  BOOST_CHECK_EQUAL(MeasurementHelpers::getSize(fm), 3u);
70 }
71 
72 BOOST_AUTO_TEST_CASE(MinimalSourceLinkTest) {
73  auto cylinder =
74  Surface::makeShared<CylinderSurface>(Transform3D::Identity(), 3, 10);
75 
77  cov << 0.04, 0, 0, 0.1;
79  cylinder, {}, std::move(cov), -0.1, 0.45);
80 
82  MinimalSourceLink msl{&fm};
83 
84  BOOST_CHECK_EQUAL(&msl.referenceSurface(), cylinder.get());
85 
86  MinimalSourceLink msl2{&fm};
87  BOOST_CHECK_EQUAL(msl, msl2);
88 
90  cylinder, {}, std::move(cov), -0.1, 0.45);
91  FittableMeasurement fm2 = m2;
92  MinimalSourceLink msl3{&fm2};
93  BOOST_CHECK_NE(msl, msl3);
94 
95  BOOST_CHECK_EQUAL(&*msl, &fm);
96 }
97 
98 BOOST_AUTO_TEST_CASE(visit_measurement_test) {
99  // Overallocated full size parameter vector and covariance
100  BoundVector parFull = BoundVector::Random();
101  BoundMatrix covFull = BoundMatrix::Random();
102  // constant variants
103  const auto& parFullConst = parFull;
104  const auto& covFullConst = covFull;
105 
106  for (BoundVector::Index dim = 1; dim <= parFull.size(); ++dim) {
107  visit_measurement(parFull, covFull, dim, [&](auto param, auto cov) {
108  BOOST_CHECK_EQUAL(param, parFull.head(dim));
109  BOOST_CHECK_EQUAL(cov, covFull.topLeftCorner(dim, dim));
110  });
111  visit_measurement(parFull, covFull, dim,
112  [&](const auto& param, const auto& cov) {
113  BOOST_CHECK_EQUAL(param, parFull.head(dim));
114  BOOST_CHECK_EQUAL(cov, covFull.topLeftCorner(dim, dim));
115  });
116  visit_measurement(parFullConst, covFullConst, dim,
117  [&](const auto& param, const auto& cov) {
118  BOOST_CHECK_EQUAL(param, parFullConst.head(dim));
119  BOOST_CHECK_EQUAL(cov,
120  covFullConst.topLeftCorner(dim, dim));
121  });
122  }
123 }
124 
125 } // namespace Test
126 } // namespace Acts