File indexing completed on 2026-11-30 09:27:13
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/Units.hpp"
0013 #include "Acts/EventData/BoundTrackParameters.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/TrackingGeometry.hpp"
0016 #include "Acts/Geometry/TrackingVolume.hpp"
0017 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0018 #include "Acts/Propagator/Navigator.hpp"
0019 #include "Acts/Propagator/Propagator.hpp"
0020 #include "Acts/Propagator/PropagatorError.hpp"
0021 #include "Acts/Propagator/StraightLineStepper.hpp"
0022 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0023 #include "Acts/Surfaces/PlaneSurface.hpp"
0024 #include "ActsTests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0025 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0026
0027 #include <cstdint>
0028 #include <optional>
0029
0030 using namespace Acts;
0031 using namespace Acts::UnitLiterals;
0032
0033 namespace ActsTests {
0034
0035 namespace {
0036
0037 const auto gctx = GeometryContext::dangerouslyDefaultConstruct();
0038 const MagneticFieldContext mctx;
0039
0040 using TestPropagator = Propagator<StraightLineStepper, Navigator>;
0041
0042
0043 CylindricalTrackingGeometry geometryBuilder(gctx);
0044 const auto geometry = geometryBuilder();
0045
0046 TestPropagator makePropagator() {
0047 return TestPropagator(StraightLineStepper(), Navigator({geometry}));
0048 }
0049
0050
0051 const BoundTrackParameters start = BoundTrackParameters::createCurvilinear(
0052 Vector4::Zero(), Vector3::UnitX(), 1 / 1_GeV, std::nullopt,
0053 ParticleHypothesis::pion());
0054
0055
0056 constexpr double farPathLimit = 50_m;
0057
0058 double propagatePathLength(const TestPropagator::Options<>& options) {
0059 auto result = makePropagator().propagate(start, options);
0060 BOOST_REQUIRE(result.ok());
0061 return result->pathLength;
0062 }
0063
0064 }
0065
0066 BOOST_AUTO_TEST_SUITE(PropagatorSuite)
0067
0068 BOOST_AUTO_TEST_CASE(DefaultActorPathLimit) {
0069 TestPropagator::Options<> options(gctx, mctx);
0070 options.pathLimit = 10_cm;
0071
0072 CHECK_CLOSE_ABS(propagatePathLength(options), 10_cm, 1_um);
0073 }
0074
0075 BOOST_AUTO_TEST_CASE(DefaultActorEndOfWorld) {
0076 TestPropagator::Options<> options(gctx, mctx);
0077 options.pathLimit = farPathLimit;
0078
0079
0080 BOOST_CHECK_LT(propagatePathLength(options), farPathLimit);
0081
0082 options.stopAtEndOfWorld = false;
0083 CHECK_CLOSE_ABS(propagatePathLength(options), farPathLimit, 1_um);
0084 }
0085
0086 BOOST_AUTO_TEST_CASE(DefaultActorTargetOutsideWorld) {
0087 TestPropagator::Options<> options(gctx, mctx);
0088 options.pathLimit = farPathLimit;
0089
0090
0091 const auto target =
0092 CurvilinearSurface(10_m * Vector3::UnitX(), Vector3::UnitX())
0093 .planeSurface();
0094
0095 auto stopped = makePropagator().propagate(start, *target, options);
0096 BOOST_REQUIRE(!stopped.ok());
0097 BOOST_CHECK(stopped.error() == PropagatorError::TargetNotReached);
0098
0099
0100 const auto propagator = makePropagator();
0101 auto state = propagator.makeState(options);
0102 auto stoppedNoParameters =
0103 propagator.propagate(state, start, target.get(), false);
0104 BOOST_REQUIRE(!stoppedNoParameters.ok());
0105 BOOST_CHECK(stoppedNoParameters.error() == PropagatorError::TargetNotReached);
0106
0107 options.stopAtEndOfWorld = false;
0108 auto reached = makePropagator().propagate(start, *target, options);
0109 BOOST_REQUIRE(reached.ok());
0110 CHECK_CLOSE_ABS(reached->pathLength, 10_m, 1_um);
0111 }
0112
0113 BOOST_AUTO_TEST_CASE(DefaultActorTargetOutsideVolumeConstraint) {
0114 TestPropagator::Options<> options(gctx, mctx);
0115 options.pathLimit = farPathLimit;
0116 options.stopAtEndOfWorld = false;
0117
0118 const auto startVolume =
0119 geometry->resolveLowestTrackingVolume(gctx, start.position(gctx));
0120 BOOST_REQUIRE(startVolume.ok());
0121 options.constrainToVolumeIds = {
0122 static_cast<std::uint32_t>((*startVolume)->geometryId().volume())};
0123
0124
0125 const auto target =
0126 CurvilinearSurface(10_m * Vector3::UnitX(), Vector3::UnitX())
0127 .planeSurface();
0128 auto stopped = makePropagator().propagate(start, *target, options);
0129 BOOST_REQUIRE(!stopped.ok());
0130 BOOST_CHECK(stopped.error() == PropagatorError::TargetNotReached);
0131 }
0132
0133 BOOST_AUTO_TEST_CASE(DefaultActorReusedState) {
0134 TestPropagator::Options<> options(gctx, mctx);
0135 options.pathLimit = 10_cm;
0136
0137 const auto propagator = makePropagator();
0138 auto state = propagator.makeState(options);
0139 auto first = propagator.propagate(state, start);
0140 BOOST_REQUIRE(first.ok());
0141 state.navigation.statistics.nRenavigations = 42;
0142 auto second = propagator.propagate(state, start);
0143 BOOST_REQUIRE(second.ok());
0144
0145
0146 CHECK_CLOSE_ABS(second->pathLength, 10_cm, 1_um);
0147 BOOST_CHECK_EQUAL(second->steps, first->steps);
0148 BOOST_CHECK_EQUAL(second->statistics.stepping.nSuccessfulSteps,
0149 first->statistics.stepping.nSuccessfulSteps);
0150 BOOST_CHECK_EQUAL(second->statistics.navigation.nRenavigations,
0151 first->statistics.navigation.nRenavigations);
0152 }
0153
0154 BOOST_AUTO_TEST_CASE(DefaultActorVolumeConstraint) {
0155 TestPropagator::Options<> options(gctx, mctx);
0156 options.pathLimit = farPathLimit;
0157 const double endOfWorldPathLength = propagatePathLength(options);
0158
0159
0160 const auto startVolume =
0161 geometry->resolveLowestTrackingVolume(gctx, start.position(gctx));
0162 BOOST_REQUIRE(startVolume.ok());
0163 options.constrainToVolumeIds = {
0164 static_cast<std::uint32_t>((*startVolume)->geometryId().volume())};
0165
0166 BOOST_CHECK_LT(propagatePathLength(options), endOfWorldPathLength);
0167 }
0168
0169 BOOST_AUTO_TEST_SUITE_END()
0170
0171 }