EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasurementTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MeasurementTests.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 
15 
16 #include <random>
17 
18 namespace Acts {
19 namespace Test {
20 
21 using SourceLink = MinimalSourceLink;
22 
23 template <BoundIndices... params>
25 
28 BOOST_AUTO_TEST_CASE(measurement_initialization) {
29  auto cylinder =
30  Surface::makeShared<CylinderSurface>(Transform3D::Identity(), 3, 10);
31 
33  cov << 0.04, 0, 0, 0.1;
35  cylinder, {}, cov, -0.1, 0.45);
36 
38  cylinder, {}, cov, {-0.1, 0.45});
39 
40  std::default_random_engine generator(42);
41 
42  // Create a measurement on a cylinder
43  SymMatrix2D covc;
44  covc << 0.04, 0, 0, 0.1;
46  cylinder, {}, std::move(covc), -0.1, 0.45);
47 
48  // Check the copy constructor
49  auto mcCopy(mc);
50 
51  // The surface should be not null and point to the same
52  const Surface* sfCopy = &mcCopy.referenceObject();
53  BOOST_CHECK_NE(sfCopy, nullptr);
54  BOOST_CHECK_EQUAL(sfCopy, cylinder.get());
55  // The parameters should be identical though
56  BOOST_CHECK_EQUAL(mc.parameters(), mcCopy.parameters());
57 
58  // check the assignment operator
59  auto mcAssigned = mc;
60 
61  // The surface should be not null and point to the same
62  const Surface* sfAssigned = &mcAssigned.referenceObject();
63  BOOST_CHECK_NE(sfAssigned, nullptr);
64  BOOST_CHECK_EQUAL(sfAssigned, cylinder.get());
65  // The parameters should be identical though
66  BOOST_CHECK_EQUAL(mc.parameters(), mcAssigned.parameters());
67 
70  caMeasurements{std::move(mcCopy), std::move(mcAssigned)};
71 
72  auto plane = Surface::makeShared<PlaneSurface>(Vector3D(0., 0., 0.),
73  Vector3D(1., 0., 0.));
74  ActsSymMatrixD<1> covp;
75  covp << 0.01;
76  MeasurementType<BoundIndices::eBoundLoc0> mp(plane, {}, std::move(covp), 0.1);
77 
78  SymMatrix2D covpp;
79  covpp << 0.01, 0., 0., 0.02;
81  plane, {}, std::move(covpp), 0.1, 0.2);
82 
83  std::vector<FittableMeasurement<SourceLink>> measurements{
84  std::move(mc), std::move(mp), std::move(mpp)};
85 }
86 } // namespace Test
87 } // namespace Acts