Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:24:41

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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 /// This tests intend to check the behaviour of the navigator in cases where the
0026 /// straight-line approach for the layer resolval can fail. This is in
0027 /// particular the case with bent tracks in telesocpe-like geometries, and can
0028 /// be fixed by not doing the bounds check in the initial resolving.
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   // Start with a slightly tilted direction that does not hit the surfaces at
0049   // x=2000 with 0 B-Field
0050   Vector3 dir = Vector3{1.0_m, 0.3_m, 0.0_m};
0051 
0052   // Start a bit in the volume 2, so we do not have any boundary checking for
0053   // the volume transition in the log
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   // without bfield we exit at the side so we don't hit the surfaces at x ~
0082   // 2000 and also not the boundary surface at x = 3000, regardless of the
0083   // boundary checking
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   // With default navigation config we miss the surfaces at x ~ 2000, but hit
0100   // the boundary surface at x = 3000
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 }