File indexing completed on 2026-05-04 08:01:03
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/EventData/MultiTrajectory.hpp"
0014 #include "Acts/EventData/TrackStatePropMask.hpp"
0015 #include "Acts/EventData/VectorMultiTrajectory.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/TrackFitting/GainMatrixSmoother.hpp"
0018 #include "Acts/Utilities/Result.hpp"
0019 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0020
0021 #include <cmath>
0022 #include <cstddef>
0023 #include <numbers>
0024
0025 namespace {
0026
0027 using namespace Acts;
0028
0029 using ParametersVector = Acts::BoundVector;
0030 using CovarianceMatrix = Acts::BoundMatrix;
0031 using Jacobian = Acts::BoundMatrix;
0032
0033 const Acts::GeometryContext tgContext =
0034 Acts::GeometryContext::dangerouslyDefaultConstruct();
0035
0036 }
0037
0038 namespace ActsTests {
0039
0040 BOOST_AUTO_TEST_SUITE(TrackFittingSuite)
0041
0042 BOOST_AUTO_TEST_CASE(Smooth) {
0043 VectorMultiTrajectory traj;
0044 std::size_t ts_idx = traj.addTrackState(TrackStatePropMask::All);
0045 auto ts = traj.getTrackState(ts_idx);
0046
0047
0048 CovarianceMatrix covTrk;
0049 covTrk.setIdentity();
0050 covTrk.diagonal() << 0.08, 0.3, 1, 1, 1, 1;
0051 BoundVector parValues;
0052 parValues << 0.3, 0.5, std::numbers::pi / 2., 0., 1 / 100., 0.;
0053
0054 ts.predicted() = parValues;
0055 ts.predictedCovariance() = covTrk;
0056
0057 parValues << 0.301, 0.503, std::numbers::pi / 2., 0., 1 / 100., 0.;
0058
0059 ts.filtered() = parValues;
0060 ts.filteredCovariance() = covTrk;
0061 ts.pathLength() = 1.;
0062 ts.jacobian().setIdentity();
0063
0064 ts_idx = traj.addTrackState(TrackStatePropMask::All, ts_idx);
0065 ts = traj.getTrackState(ts_idx);
0066
0067 parValues << 0.2, 0.5, std::numbers::pi / 2., 0., 1 / 100., 0.;
0068 ts.predicted() = parValues;
0069 ts.predictedCovariance() = covTrk;
0070
0071 parValues << 0.27, 0.53, std::numbers::pi / 2., 0., 1 / 100., 0.;
0072 ts.filtered() = parValues;
0073 ts.filteredCovariance() = covTrk;
0074 ts.pathLength() = 2.;
0075 ts.jacobian().setIdentity();
0076
0077 ts_idx = traj.addTrackState(TrackStatePropMask::All, ts_idx);
0078 ts = traj.getTrackState(ts_idx);
0079
0080 parValues << 0.35, 0.49, std::numbers::pi / 2., 0., 1 / 100., 0.;
0081 ts.predicted() = parValues;
0082 ts.predictedCovariance() = covTrk;
0083
0084 parValues << 0.33, 0.43, std::numbers::pi / 2., 0., 1 / 100., 0.;
0085 ts.filtered() = parValues;
0086 ts.filteredCovariance() = covTrk;
0087 ts.pathLength() = 3.;
0088 ts.jacobian().setIdentity();
0089
0090
0091 BOOST_CHECK(GainMatrixSmoother()(tgContext, traj, ts_idx).ok());
0092
0093
0094
0095
0096 auto ts1 = traj.getTrackState(0);
0097 BOOST_CHECK(ts1.hasSmoothed());
0098 BOOST_CHECK_NE(ts1.filtered(), ts1.smoothed());
0099
0100 double tol = 1e-6;
0101
0102 ParametersVector expPars;
0103 expPars << 0.3510000, 0.4730000, 1.5707963, 0.0000000, 0.0100000, 0.0000000;
0104 CovarianceMatrix expCov;
0105 expCov.setIdentity();
0106 expCov.diagonal() << 0.0800000, 0.3000000, 1.0000000, 1.0000000, 1.0000000,
0107 1.0000000;
0108 CHECK_CLOSE_ABS(ts1.smoothed(), expPars, tol);
0109 CHECK_CLOSE_ABS(ts1.smoothedCovariance(), expCov, tol);
0110
0111 auto ts2 = traj.getTrackState(1);
0112 BOOST_CHECK(ts2.hasSmoothed());
0113 BOOST_CHECK_NE(ts2.filtered(), ts2.smoothed());
0114
0115 expPars << 0.2500000, 0.4700000, 1.5707963, 0.0000000, 0.0100000, 0.0000000;
0116 CHECK_CLOSE_ABS(ts2.smoothed(), expPars, tol);
0117 CHECK_CLOSE_ABS(ts2.smoothedCovariance(), expCov, tol);
0118
0119 auto ts3 = traj.getTrackState(2);
0120 BOOST_CHECK(ts3.hasSmoothed());
0121
0122 BOOST_CHECK_EQUAL(ts3.filtered(), ts3.smoothed());
0123
0124 expPars << 0.3300000, 0.4300000, 1.5707963, 0.0000000, 0.0100000, 0.0000000;
0125 CHECK_CLOSE_ABS(ts3.smoothed(), expPars, tol);
0126 CHECK_CLOSE_ABS(ts3.smoothedCovariance(), expCov, tol);
0127 }
0128
0129 BOOST_AUTO_TEST_SUITE_END()
0130
0131 }