Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PropagationBentTracks.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PropagationBentTracks.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
19 
20 using namespace Acts::UnitLiterals;
21 
26 
30 
33 
35  double bz) {
36  auto magField = std::make_shared<MagneticField>(Acts::Vector3(0.0, 0.0, bz));
38 
39  navCfg.trackingGeometry = cubicBuilder();
40  Stepper stepper(std::move(magField));
41  Propagator propagator(stepper, Acts::Navigator(navCfg));
42 
43  // Start with a slightly tilted direction that does not hit the surfaces at
44  // x=2000 with 0 B-Field
45  Acts::Vector3 dir = Acts::Vector3{1.0_m, 0.3_m, 0.0_m};
46 
47  // Start a bit in the volume 2, so we do not have any boundary checking for
48  // the volume transition in the log
50  Acts::Vector4(0.01, 0, 0, 0), dir.normalized(), 1 / 1_GeV, std::nullopt,
52 
54  Acts::AbortList<Acts::EndOfWorldReached>>
55  opts(geoCtx, magCtx);
56 
57  auto res = propagator.propagate(start, opts);
58 
59  BOOST_CHECK(res.ok());
60 
61  const auto &stepLog = res->get<Acts::detail::SteppingLogger::result_type>();
62 
63  std::vector<double> xPositions;
64  for (const auto &step : stepLog.steps) {
65  if (step.surface) {
66  xPositions.push_back(step.surface->center(geoCtx)[Acts::ePos0]);
67  }
68  }
69 
70  return xPositions;
71 }
72 
73 BOOST_AUTO_TEST_CASE(with_boundary_check_no_bfield) {
74  auto navCfg = Acts::Navigator::Config{};
75  const auto xPositions = xPositionsOfPassedSurfaces(navCfg, 0.0_T);
76 
77  // without bfield we exit at the side so we don't hit the surfaces at x ~
78  // 2000 and also not the boundary surface at x = 3000, regardless of the
79  // boundary checking
80  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 999.0) == 1);
81  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1001.0) == 1);
82  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1999.0) == 0);
83  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 2001.0) == 0);
84  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 3000.0) == 0);
85 }
86 
87 BOOST_AUTO_TEST_CASE(without_boundary_check_no_bfield) {
88  auto navCfg = Acts::Navigator::Config{};
89  navCfg.boundaryCheckLayerResolving = false;
90  const auto xPositions = xPositionsOfPassedSurfaces(navCfg, 0.0_T);
91 
92  // without bField we exit at the side so we don't hit the surfaces at x ~
93  // 2000 and also not the boundary surface at x = 3000, regardless of the
94  // boundary checking
95  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 999.0) == 1);
96  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1001.0) == 1);
97  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1999.0) == 0);
98  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 2001.0) == 0);
99  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 3000.0) == 0);
100 }
101 
102 BOOST_AUTO_TEST_CASE(with_boundary_check_with_bfield) {
103  auto navCfg = Acts::Navigator::Config{};
104  const auto xPositions = xPositionsOfPassedSurfaces(navCfg, 0.5_T);
105 
106  // With default navigation config we miss the surfaces at x ~ 2000, but hit
107  // the boundary surface at x = 3000
108  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 999.0) == 1);
109  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1001.0) == 1);
110  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1999.0) == 0);
111  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 2001.0) == 0);
112  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 3000.0) == 1);
113 }
114 
115 BOOST_AUTO_TEST_CASE(no_boundary_check_with_bfield) {
116  auto navCfg = Acts::Navigator::Config{};
117  navCfg.boundaryCheckLayerResolving = false;
118  const auto xPositions = xPositionsOfPassedSurfaces(navCfg, 0.5_T);
119 
120  // Without boundary check at layer resolving, we also hit the surfaces at x ~
121  // 2000
122  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 999.0) == 1);
123  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1001.0) == 1);
124  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 1999.0) == 1);
125  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 2001.0) == 1);
126  BOOST_CHECK(std::count(xPositions.begin(), xPositions.end(), 3000.0) == 1);
127 }