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