ECCE @ 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/optional/optional_io.hpp>
10 #include <boost/test/unit_test.hpp>
11 
12 #include <memory>
13 
22 
23 namespace Acts {
24 namespace Test {
25 
28 
29 using SourceLink = MinimalSourceLink;
30 
31 template <ParID_t... params>
32 using MeasurementType = Measurement<SourceLink, params...>;
33 using TrackState = TrackState<SourceLink, BoundParameters>;
34 
35 // Create a test context
37 
38 BOOST_AUTO_TEST_CASE(gain_matrix_updater) {
39  // Make dummy measurement
40  auto cylinder = Surface::makeShared<CylinderSurface>(nullptr, 3, 10);
41 
43  cov << 0.04, 0, 0, 0.1;
46  cylinder, {}, std::move(cov), -0.1, 0.45));
47 
48  // Make dummy track parameter
49  Covariance covTrk;
50  covTrk.setZero();
51  covTrk.diagonal() << 0.08, 0.3, 1, 1, 1, 0;
52  BoundVector parValues;
53  parValues << 0.3, 0.5, 0.5 * M_PI, 0.3 * M_PI, 0.01, 0.;
54 
57  auto ts = traj.getTrackState(0);
58 
59  ts.uncalibrated() = SourceLink{&meas};
60  // "calibrate"
61  std::visit([&](const auto& m) { ts.setCalibrated(m); }, meas);
62 
63  ts.predicted() = parValues;
64  ts.predictedCovariance() = covTrk;
65  ts.pathLength() = 0.;
66 
67  // Gain matrix update and filtered state
69 
70  BOOST_CHECK(ts.hasFiltered());
71  BOOST_CHECK(ts.hasCalibrated());
72  BOOST_CHECK(gmu(tgContext, ts).ok());
73  // ref surface is same on measurements and parameters
74  BOOST_CHECK_EQUAL(&ts.referenceSurface(), cylinder.get());
75 
76  // Check for regression. This does NOT test if the math is correct, just that
77  // the result is the same as when the test was written.
78 
79  Covariance expCov;
80  expCov.setZero();
81  expCov.diagonal() << 0.0266667, 0.0750000, 1.0000000, 1.0000000, 1.0000000,
82  0.0000000;
83 
84  BoundVector expPar;
85  expPar << 0.0333333, 0.4625000, 1.5707963, 0.9424778, 0.0100000, 0.0000000;
86 
87  Vector3D expPosition;
88  expPosition << 2.9998148, 0.0333326, 0.4625000;
89 
90  Vector3D expMomentum;
91  expMomentum << 0.0000000, 80.9016994, 58.7785252;
92 
93  BoundParameters filtered(tgContext, ts.filteredCovariance(), ts.filtered(),
94  cylinder);
95 
96  double expChi2 = 1.33958;
97 
98  double tol = 1e-6;
99 
100  CHECK_CLOSE_ABS(expCov, *filtered.covariance(), tol);
101  CHECK_CLOSE_ABS(expPar, filtered.parameters(), tol);
102  CHECK_CLOSE_ABS(expPosition, filtered.position(), tol);
103  CHECK_CLOSE_ABS(expMomentum, filtered.momentum(), tol);
104  CHECK_CLOSE_ABS(expChi2, ts.chi2(), 1e-4);
105 }
106 
107 } // namespace Test
108 } // namespace Acts