File indexing completed on 2025-12-16 09:24:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/MagneticField/ConstantBField.hpp"
0013 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0014 #include "Acts/Propagator/EigenStepper.hpp"
0015 #include "Acts/Propagator/Navigator.hpp"
0016 #include "Acts/Propagator/Propagator.hpp"
0017 #include "Acts/Propagator/detail/SteppingLogger.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 #include "ActsTests/CommonHelpers/CubicTrackingGeometry.hpp"
0020
0021 using namespace Acts;
0022 using namespace UnitLiterals;
0023 using namespace ActsTests;
0024
0025
0026
0027
0028
0029
0030 using MagneticField = ConstantBField;
0031 using Stepper = EigenStepper<>;
0032 using TestPropagator = Propagator<Stepper, Navigator>;
0033
0034 const GeometryContext geoCtx;
0035 const MagneticFieldContext magCtx;
0036
0037 std::vector<double> xPositionsOfPassedSurfaces(Navigator::Config navCfg,
0038 double bz) {
0039 auto magField = std::make_shared<MagneticField>(Vector3(0.0, 0.0, bz));
0040 CubicTrackingGeometry cubicBuilder(geoCtx);
0041
0042 navCfg.trackingGeometry = cubicBuilder();
0043 Stepper stepper(std::move(magField));
0044 TestPropagator propagator(
0045 stepper, Navigator(navCfg, getDefaultLogger("nav", Logging::VERBOSE)),
0046 getDefaultLogger("nav", Logging::VERBOSE));
0047
0048
0049
0050 Vector3 dir = Vector3{1.0_m, 0.3_m, 0.0_m};
0051
0052
0053
0054 BoundTrackParameters start = BoundTrackParameters::createCurvilinear(
0055 Vector4(0.01, 0, 0, 0), dir.normalized(), 1 / 1_GeV, std::nullopt,
0056 ParticleHypothesis::pion());
0057
0058 TestPropagator::Options<ActorList<detail::SteppingLogger, EndOfWorldReached>>
0059 opts(geoCtx, magCtx);
0060
0061 auto res = propagator.propagate(start, opts);
0062
0063 BOOST_CHECK(res.ok());
0064
0065 const auto &stepLog = res->get<detail::SteppingLogger::result_type>();
0066
0067 std::vector<double> xPositions;
0068 for (const auto &step : stepLog.steps) {
0069 if (step.surface) {
0070 xPositions.push_back(step.surface->center(geoCtx)[ePos0]);
0071 }
0072 }
0073
0074 return xPositions;
0075 }
0076
0077 BOOST_AUTO_TEST_CASE(with_boundary_check_no_bfield) {
0078 auto navCfg = Navigator::Config{};
0079 const auto xPositions = xPositionsOfPassedSurfaces(navCfg, 0.0_T);
0080
0081
0082
0083
0084 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 999.0), 1);
0085 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 1001.0),
0086 1);
0087 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 1999.0),
0088 0);
0089 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 2001.0),
0090 0);
0091 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 3000.0),
0092 0);
0093 }
0094
0095 BOOST_AUTO_TEST_CASE(with_boundary_check_with_bfield) {
0096 auto navCfg = Navigator::Config{};
0097 const auto xPositions = xPositionsOfPassedSurfaces(navCfg, 0.5_T);
0098
0099
0100
0101 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 999.0), 1);
0102 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 1001.0),
0103 1);
0104 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 1999.0),
0105 0);
0106 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 2001.0),
0107 0);
0108 BOOST_CHECK_EQUAL(std::count(xPositions.begin(), xPositions.end(), 3000.0),
0109 1);
0110 }