Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-30 09:27:18

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/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/EventData/BoundTrackParameters.hpp"
0014 #include "Acts/EventData/ParticleHypothesis.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Geometry/GeometryIdentifier.hpp"
0017 #include "Acts/MagneticField/ConstantBField.hpp"
0018 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0019 #include "Acts/Propagator/ActorList.hpp"
0020 #include "Acts/Propagator/DefaultActor.hpp"
0021 #include "Acts/Propagator/EigenStepper.hpp"
0022 #include "Acts/Propagator/Propagator.hpp"
0023 #include "Acts/Propagator/SurfaceCollector.hpp"
0024 #include "Acts/Propagator/TryAllNavigator.hpp"
0025 #include "Acts/Utilities/Logger.hpp"
0026 #include "ActsTests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0027 
0028 #include <cmath>
0029 #include <vector>
0030 
0031 using namespace Acts;
0032 using namespace Acts::UnitLiterals;
0033 
0034 namespace ActsTests {
0035 
0036 BOOST_AUTO_TEST_SUITE(PropagatorSuite)
0037 
0038 // A 25 MeV pion looping through the barrel of the cylindrical test geometry.
0039 // After a step that passes a module, the TryAllNavigator finds the crossing
0040 // on the chord behind and the stepper steps back to it. A step back can stop
0041 // just past the module, outside the on-surface tolerance: the crossing behind
0042 // must stay the target until it is reached, otherwise the next step starts
0043 // past it and the module is lost.
0044 BOOST_AUTO_TEST_CASE(TryAllNavigatorKeepsTargetBehind) {
0045   const auto gctx = GeometryContext::dangerouslyDefaultConstruct();
0046   const MagneticFieldContext mctx;
0047   CylindricalTrackingGeometry cGeometry(gctx);
0048   auto geometry = cGeometry();
0049 
0050   using Stepper = EigenStepper<>;
0051   using TryAll = Experimental::TryAllNavigator;
0052   auto bField = std::make_shared<ConstantBField>(Vector3(0., 0., 2_T));
0053   Propagator<Stepper, TryAll> propagator(
0054       Stepper(bField), TryAll({geometry, true, true, false}),
0055       getDefaultLogger("Prop", Logging::INFO));
0056 
0057   const double pT = 25_MeV;
0058   const double cotTheta = 0.05;
0059   const double theta = std::atan2(1., cotTheta);
0060   const double charge = -1.;
0061   const double phi = 0.3;
0062   const auto start = BoundTrackParameters::createCurvilinear(
0063       Vector4::Zero(), phi, theta, charge * std::sin(theta) / pT, std::nullopt,
0064       ParticleHypothesis::pion());
0065 
0066   using Actors = ActorList<DefaultActor, SurfaceCollector<>>;
0067   Propagator<Stepper, TryAll>::Options<Actors> options(gctx, mctx);
0068   // three turns of the helix (one turn: 262 mm)
0069   options.pathLimit = 787_mm;
0070   options.loopProtection = false;
0071   options.maxSteps = 100000;
0072   auto& collector = options.actor.get<SurfaceCollector<>>();
0073   collector.selector.selectSensitive = true;
0074   collector.selector.selectMaterial = false;
0075 
0076   auto state = propagator.makeState(options);
0077   auto result = propagator.propagate(state, start);
0078   BOOST_REQUIRE(result.ok());
0079   const auto& hits = state.actor.get<SurfaceCollector<>::State>().collected;
0080 
0081   // every module crossing of the helix in order (L0 = layer 2, L1 = layer 4):
0082   // two L0 modules, three L1 modules, back through L0, three times; without
0083   // keeping the target behind, the three crossings of sensitive 253 are lost
0084   auto sensitive = [](GeometryIdentifier::Value layer,
0085                       GeometryIdentifier::Value sen) {
0086     return GeometryIdentifier().withVolume(3).withLayer(layer).withSensitive(
0087         sen);
0088   };
0089   std::vector<GeometryIdentifier> expected = {
0090       sensitive(2, 122), sensitive(2, 106), sensitive(4, 247),
0091       sensitive(4, 248), sensitive(4, 253)};
0092   for (int turn = 0; turn < 2; ++turn) {
0093     expected.insert(expected.end(),
0094                     {sensitive(2, 128), sensitive(2, 122), sensitive(4, 247),
0095                      sensitive(4, 248), sensitive(4, 253)});
0096   }
0097   expected.push_back(sensitive(2, 128));
0098 
0099   std::vector<GeometryIdentifier> collected;
0100   for (const auto& hit : hits) {
0101     collected.push_back(hit.surface->geometryId());
0102   }
0103   BOOST_CHECK_EQUAL_COLLECTIONS(collected.begin(), collected.end(),
0104                                 expected.begin(), expected.end());
0105 }
0106 
0107 BOOST_AUTO_TEST_SUITE_END()
0108 
0109 }  // namespace ActsTests