Analysis Software
Documentation for sPHENIX simulation 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-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 
23 
24 #include <algorithm>
25 #include <cmath>
26 #include <utility>
27 
28 namespace {
29 
30 using namespace Acts;
31 using namespace Acts::Test;
32 
33 using ParametersVector = Acts::BoundVector;
34 using CovarianceMatrix = Acts::BoundSquareMatrix;
36 
37 constexpr double tol = 1e-6;
39 
40 } // namespace
41 
42 BOOST_AUTO_TEST_SUITE(TrackFittingGainMatrixUpdater)
43 
45  // Make dummy measurement
46  Vector2 measPar(-0.1, 0.45);
47  SquareMatrix2 measCov = Vector2(0.04, 0.1).asDiagonal();
48  auto sourceLink = TestSourceLink(eBoundLoc0, eBoundLoc1, measPar, measCov);
49 
50  // Make dummy track parameters
51  ParametersVector trkPar;
52  trkPar << 0.3, 0.5, 0.5 * M_PI, 0.3 * M_PI, 0.01, 0.;
53  CovarianceMatrix trkCov = CovarianceMatrix::Zero();
54  trkCov.diagonal() << 0.08, 0.3, 1, 1, 1, 0;
55 
56  // Make trajectory w/ one state
58  auto idx = traj.addTrackState(TrackStatePropMask::All);
59  auto ts = traj.getTrackState(idx);
60 
61  // Fill the state w/ the dummy information
62  ts.predicted() = trkPar;
63  ts.predictedCovariance() = trkCov;
64  ts.pathLength() = 0.;
65  BOOST_CHECK(!ts.hasUncalibratedSourceLink());
66  testSourceLinkCalibrator<VectorMultiTrajectory>(
67  tgContext, CalibrationContext{}, SourceLink{std::move(sourceLink)}, ts);
68  BOOST_CHECK(ts.hasUncalibratedSourceLink());
69 
70  // Check that the state has storage available
71  BOOST_CHECK(ts.hasPredicted());
72  BOOST_CHECK(ts.hasFiltered());
73  BOOST_CHECK(ts.hasCalibrated());
74 
75  // Gain matrix update and filtered state
76  BOOST_CHECK(GainMatrixUpdater()
77  .
78  operator()<VectorMultiTrajectory>(tgContext, ts)
79  .ok());
80 
81  // Check for regression. This does NOT test if the math is correct, just that
82  // the result is the same as when the test was written.
83 
84  ParametersVector expPar;
85  expPar << 0.0333333, 0.4625000, 1.5707963, 0.9424778, 0.0100000, 0.0000000;
86  CHECK_CLOSE_ABS(ts.filtered(), expPar, tol);
87 
88  CovarianceMatrix expCov = CovarianceMatrix::Zero();
89  expCov.diagonal() << 0.0266667, 0.0750000, 1.0000000, 1.0000000, 1.0000000,
90  0.0000000;
91  CHECK_CLOSE_ABS(ts.filteredCovariance(), expCov, tol);
92 
93  CHECK_CLOSE_ABS(ts.chi2(), 1.33958, 1e-4);
94 }
95 
96 BOOST_AUTO_TEST_SUITE_END()