File indexing completed on 2026-11-09 09:29:01
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/Definitions/Units.hpp"
0014 #include "Acts/EventData/BoundTrackParameters.hpp"
0015 #include "Acts/EventData/SourceLink.hpp"
0016 #include "Acts/EventData/VectorMultiTrajectory.hpp"
0017 #include "Acts/EventData/detail/TestSourceLink.hpp"
0018 #include "Acts/Propagator/EigenStepper.hpp"
0019 #include "Acts/Propagator/Navigator.hpp"
0020 #include "Acts/Propagator/Propagator.hpp"
0021 #include "Acts/TrackFitting/GainMatrixUpdater.hpp"
0022 #include "Acts/TrackFitting/MbfSmoother.hpp"
0023 #include "Acts/TrackFitting/ReferenceTrajectoryBuilder.hpp"
0024 #include "Acts/Utilities/CalibrationContext.hpp"
0025 #include "Acts/Utilities/Result.hpp"
0026 #include "Acts/Utilities/TrackHelpers.hpp"
0027
0028 #include <random>
0029 #include <ranges>
0030
0031 #include "FitterTestsCommon.hpp"
0032
0033 using namespace Acts;
0034 using namespace Acts::detail::Test;
0035 using namespace Acts::UnitLiterals;
0036
0037 namespace ActsTests {
0038
0039 using ConstantFieldStepper = EigenStepper<>;
0040 using ConstantFieldPropagator = Propagator<ConstantFieldStepper, Navigator>;
0041 using ReferenceTrajectoryBuilder =
0042 Experimental::ReferenceTrajectoryBuilder<ConstantFieldPropagator,
0043 VectorMultiTrajectory>;
0044
0045
0046 BoundTrackParameters makeParameters(
0047 const ParticleHypothesis& particleHypothesis) {
0048
0049 BoundVector stddev;
0050 stddev[eBoundLoc0] = 100_um;
0051 stddev[eBoundLoc1] = 100_um;
0052 stddev[eBoundTime] = 25_ns;
0053 stddev[eBoundPhi] = 2_degree;
0054 stddev[eBoundTheta] = 2_degree;
0055 stddev[eBoundQOverP] = 1 / 100_GeV;
0056 BoundMatrix cov = stddev.cwiseProduct(stddev).asDiagonal();
0057
0058 Vector4 mPos4(-3_m, 0., 0., 42_ns);
0059 return BoundTrackParameters::createCurvilinear(
0060 mPos4, 0_degree, 90_degree, 1_e / 1_GeV, cov, particleHypothesis);
0061 }
0062
0063
0064 const FitterTester tester;
0065
0066
0067
0068
0069 struct ReferenceTrajectoryFitter {
0070 ReferenceTrajectoryBuilder builder;
0071 GainMatrixUpdater updater;
0072 MbfSmoother smoother;
0073
0074 template <typename source_link_iterator_t, typename track_container_t>
0075 Result<typename track_container_t::TrackProxy> fit(
0076 source_link_iterator_t begin, source_link_iterator_t end,
0077 const BoundTrackParameters& start,
0078 const ReferenceTrajectoryBuilder::Options& options,
0079 track_container_t& tracks) const {
0080 auto buildResult = builder.build(start, options, tracks);
0081 if (!buildResult.ok()) {
0082 return buildResult.error();
0083 }
0084 auto track = *buildResult;
0085
0086 SourceLinkSurfaceAccessor surfaceAccessor;
0087 surfaceAccessor.connect<&TestSourceLink::SurfaceAccessor::operator()>(
0088 &tester.surfaceAccessor);
0089 builder.attachSourceLinks(track, std::ranges::subrange(begin, end),
0090 surfaceAccessor);
0091
0092 ReferenceTrajectoryBuilder::Calibrator calibrator;
0093 calibrator.connect<&testSourceLinkCalibrator<VectorMultiTrajectory>>();
0094 builder.calibrateMeasurements(options.geoContext, tester.calCtx, track,
0095 calibrator);
0096
0097 ReferenceTrajectoryBuilder::Updater updaterDelegate;
0098 updaterDelegate
0099 .connect<&GainMatrixUpdater::operator()<VectorMultiTrajectory>>(
0100 &updater);
0101 if (auto res = builder.filter(options.geoContext, track, updaterDelegate);
0102 !res.ok()) {
0103 return res.error();
0104 }
0105
0106 if (auto res = smoother(options.geoContext, tracks.trackStateContainer(),
0107 track.tipIndex());
0108 !res.ok()) {
0109 return res.error();
0110 }
0111
0112 calculateTrackQuantities(track);
0113
0114 return track;
0115 }
0116 };
0117
0118 const ReferenceTrajectoryFitter rtFitter{
0119 ReferenceTrajectoryBuilder(
0120 makeConstantFieldPropagator<ConstantFieldStepper>(tester.geometry,
0121 0_T)),
0122 {},
0123 {}};
0124
0125 std::default_random_engine rng(42);
0126
0127 ReferenceTrajectoryBuilder::Options makeDefaultOptions() {
0128 return ReferenceTrajectoryBuilder::Options(
0129 tester.geoCtx, tester.magCtx,
0130 PropagatorPlainOptions(tester.geoCtx, tester.magCtx));
0131 }
0132
0133 BOOST_AUTO_TEST_SUITE(TrackFittingSuite)
0134
0135 BOOST_AUTO_TEST_CASE(OutputTrackParticleHypothesis) {
0136 auto start = makeParameters(ParticleHypothesis::muon());
0137 auto options = makeDefaultOptions();
0138
0139 tester.test_ParticleHypothesis(rtFitter, options, start, rng);
0140 }
0141
0142 BOOST_AUTO_TEST_SUITE_END()
0143
0144 }