Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GainMatrixSmootherTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GainMatrixSmootherTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-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 
20 
21 #include <cmath>
22 #include <cstddef>
23 
24 namespace {
25 
26 using namespace Acts;
27 using namespace Acts::Test;
28 
29 using ParametersVector = Acts::BoundVector;
30 using CovarianceMatrix = Acts::BoundSquareMatrix;
32 
34 
35 } // namespace
36 
37 BOOST_AUTO_TEST_SUITE(TrackFittingGainMatrixSmoother)
38 
41  size_t ts_idx = traj.addTrackState(TrackStatePropMask::All);
42  auto ts = traj.getTrackState(ts_idx);
43 
44  // Make dummy track parameter
45  CovarianceMatrix covTrk;
46  covTrk.setIdentity();
47  covTrk.diagonal() << 0.08, 0.3, 1, 1, 1, 1;
48  BoundVector parValues;
49  parValues << 0.3, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.;
50 
51  ts.predicted() = parValues;
52  ts.predictedCovariance() = covTrk;
53 
54  parValues << 0.301, 0.503, 0.5 * M_PI, 0., 1 / 100., 0.;
55 
56  ts.filtered() = parValues;
57  ts.filteredCovariance() = covTrk;
58  ts.pathLength() = 1.;
59  ts.jacobian().setIdentity();
60 
61  ts_idx = traj.addTrackState(TrackStatePropMask::All, ts_idx);
62  ts = traj.getTrackState(ts_idx);
63 
64  parValues << 0.2, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.;
65  ts.predicted() = parValues;
66  ts.predictedCovariance() = covTrk;
67 
68  parValues << 0.27, 0.53, 0.5 * M_PI, 0., 1 / 100., 0.;
69  ts.filtered() = parValues;
70  ts.filteredCovariance() = covTrk;
71  ts.pathLength() = 2.;
72  ts.jacobian().setIdentity();
73 
74  ts_idx = traj.addTrackState(TrackStatePropMask::All, ts_idx);
75  ts = traj.getTrackState(ts_idx);
76 
77  parValues << 0.35, 0.49, 0.5 * M_PI, 0., 1 / 100., 0.;
78  ts.predicted() = parValues;
79  ts.predictedCovariance() = covTrk;
80 
81  parValues << 0.33, 0.43, 0.5 * M_PI, 0., 1 / 100., 0.;
82  ts.filtered() = parValues;
83  ts.filteredCovariance() = covTrk;
84  ts.pathLength() = 3.;
85  ts.jacobian().setIdentity();
86 
87  // "smooth" these three track states
88  BOOST_CHECK(GainMatrixSmoother()(tgContext, traj, ts_idx).ok());
89 
90  // Regression tests, only tests very basic correctness of the math, but tests
91  // for regressions in the result.
92 
93  auto ts1 = traj.getTrackState(0);
94  BOOST_CHECK(ts1.hasSmoothed());
95  BOOST_CHECK_NE(ts1.filtered(), ts1.smoothed());
96 
97  double tol = 1e-6;
98 
99  ParametersVector expPars;
100  expPars << 0.3510000, 0.4730000, 1.5707963, 0.0000000, 0.0100000, 0.0000000;
101  CovarianceMatrix expCov;
102  expCov.setIdentity();
103  expCov.diagonal() << 0.0800000, 0.3000000, 1.0000000, 1.0000000, 1.0000000,
104  1.0000000;
105  CHECK_CLOSE_ABS(ts1.smoothed(), expPars, tol);
106  CHECK_CLOSE_ABS(ts1.smoothedCovariance(), expCov, tol);
107 
108  auto ts2 = traj.getTrackState(1);
109  BOOST_CHECK(ts2.hasSmoothed());
110  BOOST_CHECK_NE(ts2.filtered(), ts2.smoothed());
111 
112  expPars << 0.2500000, 0.4700000, 1.5707963, 0.0000000, 0.0100000, 0.0000000;
113  CHECK_CLOSE_ABS(ts2.smoothed(), expPars, tol);
114  CHECK_CLOSE_ABS(ts2.smoothedCovariance(), expCov, tol);
115 
116  auto ts3 = traj.getTrackState(2);
117  BOOST_CHECK(ts3.hasSmoothed());
118  // last one, smoothed == filtered
119  BOOST_CHECK_EQUAL(ts3.filtered(), ts3.smoothed());
120 
121  expPars << 0.3300000, 0.4300000, 1.5707963, 0.0000000, 0.0100000, 0.0000000;
122  CHECK_CLOSE_ABS(ts3.smoothed(), expPars, tol);
123  CHECK_CLOSE_ABS(ts3.smoothedCovariance(), expCov, tol);
124 }
125 
126 BOOST_AUTO_TEST_SUITE_END()