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