EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GainMatrixUpdaterTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GainMatrixUpdaterTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2019 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 
18 
19 #include <memory>
20 
21 #include <boost/optional/optional_io.hpp>
22 
23 namespace Acts {
24 namespace Test {
25 
26 using Jacobian = BoundMatrix;
28 using SourceLink = MinimalSourceLink;
29 template <BoundIndices... params>
31 
32 // Create a test context
34 
35 BOOST_AUTO_TEST_CASE(gain_matrix_updater) {
36  // Make dummy measurement
37  auto cylinder =
38  Surface::makeShared<CylinderSurface>(Transform3D::Identity(), 3, 10);
39 
41  cov << 0.04, 0, 0, 0.1;
44  cylinder, {}, std::move(cov), -0.1, 0.45));
45 
46  // Make dummy track parameter
47  Covariance covTrk;
48  covTrk.setZero();
49  covTrk.diagonal() << 0.08, 0.3, 1, 1, 1, 0;
50  BoundVector parValues;
51  parValues << 0.3, 0.5, 0.5 * M_PI, 0.3 * M_PI, 0.01, 0.;
52 
54  traj.addTrackState(TrackStatePropMask::All);
55  auto ts = traj.getTrackState(0);
56 
57  ts.uncalibrated() = SourceLink{&meas};
58  // "calibrate"
59  std::visit([&](const auto& m) { ts.setCalibrated(m); }, meas);
60 
61  ts.predicted() = parValues;
62  ts.predictedCovariance() = covTrk;
63  ts.pathLength() = 0.;
64 
65  // Gain matrix update and filtered state
67 
68  BOOST_CHECK(ts.hasFiltered());
69  BOOST_CHECK(ts.hasCalibrated());
70  BOOST_CHECK(gmu(tgContext, ts).ok());
71  // ref surface is same on measurements and parameters
72  BOOST_CHECK_EQUAL(&ts.referenceSurface(), cylinder.get());
73 
74  // Check for regression. This does NOT test if the math is correct, just that
75  // the result is the same as when the test was written.
76 
77  Covariance expCov;
78  expCov.setZero();
79  expCov.diagonal() << 0.0266667, 0.0750000, 1.0000000, 1.0000000, 1.0000000,
80  0.0000000;
81 
82  BoundVector expPar;
83  expPar << 0.0333333, 0.4625000, 1.5707963, 0.9424778, 0.0100000, 0.0000000;
84 
85  Vector3D expPosition;
86  expPosition << 2.9998148, 0.0333326, 0.4625000;
87 
88  Vector3D expMomentum;
89  expMomentum << 0.0000000, 80.9016994, 58.7785252;
90 
91  BoundTrackParameters filtered(cylinder, ts.filtered(),
92  ts.filteredCovariance());
93 
94  double expChi2 = 1.33958;
95 
96  double tol = 1e-6;
97 
98  CHECK_CLOSE_ABS(expCov, *filtered.covariance(), tol);
99  CHECK_CLOSE_ABS(expPar, filtered.parameters(), tol);
100  CHECK_CLOSE_ABS(expPosition, filtered.position(tgContext), tol);
101  CHECK_CLOSE_ABS(expMomentum, filtered.momentum(), tol);
102  CHECK_CLOSE_ABS(expChi2, ts.chi2(), 1e-4);
103 }
104 
105 } // namespace Test
106 } // namespace Acts