Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiStepperAborters.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MultiStepperAborters.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 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 #pragma once
10 
13 
14 namespace Acts {
15 
18  MultiStepperSurfaceReached() = default;
19 
23  bool averageOnSurface = true;
24 
29 
40  template <typename propagator_state_t, typename stepper_t,
41  typename navigator_t>
42  bool operator()(propagator_state_t& state, const stepper_t& stepper,
43  const navigator_t& navigator, const Logger& logger) const {
44  return (*this)(state, stepper, navigator,
45  *navigator.targetSurface(state.navigation), logger);
46  }
47 
59  template <typename propagator_state_t, typename stepper_t,
60  typename navigator_t>
61  bool operator()(propagator_state_t& state, const stepper_t& stepper,
62  const navigator_t& navigator, const Surface& targetSurface,
63  const Logger& logger) const {
64  bool reached = true;
65  const auto oldCurrentSurface = navigator.currentSurface(state.navigation);
66 
67  for (auto cmp : stepper.componentIterable(state.stepping)) {
68  auto singleState = cmp.singleState(state);
69  const auto& singleStepper = cmp.singleStepper(stepper);
70 
71  if (!SurfaceReached{}(singleState, singleStepper, navigator,
72  targetSurface, logger)) {
73  reached = false;
74  } else {
75  cmp.status() = Acts::Intersection3D::Status::onSurface;
76  }
77  }
78 
79  // However, if mean of all is on surface, we are happy as well
80  if (averageOnSurface) {
81  const auto sIntersection =
82  targetSurface
83  .intersect(
84  state.geoContext, stepper.position(state.stepping),
85  state.options.direction * stepper.direction(state.stepping),
87  .closest();
88 
89  if (sIntersection.status() == Intersection3D::Status::onSurface) {
90  ACTS_VERBOSE("Reached target in average mode");
91  navigator.currentSurface(state.navigation, &targetSurface);
92  navigator.targetReached(state.navigation, true);
93 
94  for (auto cmp : stepper.componentIterable(state.stepping)) {
95  cmp.status() = Intersection3D::Status::onSurface;
96  }
97 
98  return true;
99  }
100  }
101 
102  // These values are changed by the single component aborters but must be
103  // reset if not all components are on the target
104  if (!reached) {
105  navigator.currentSurface(state.navigation, oldCurrentSurface);
106  navigator.targetReached(state.navigation, false);
107  }
108 
109  return reached;
110  }
111 };
112 } // namespace Acts