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