EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingHelper.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SteppingHelper.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 
16 
17 namespace Acts {
18 
19 namespace detail {
20 
31 template <typename stepper_t>
33  const stepper_t& stepper, typename stepper_t::State& state,
34  const Surface& surface, const BoundaryCheck& bcheck) {
35  auto sIntersection =
36  surface.intersect(state.geoContext, stepper.position(state),
37  state.navDir * stepper.direction(state), bcheck);
38 
39  // The intersection is on surface already
40  if (sIntersection.intersection.status == Intersection3D::Status::onSurface) {
41  // Release navigation step size
42  state.stepSize.release(ConstrainedStep::actor);
43  return Intersection3D::Status::onSurface;
44  } else if (sIntersection.intersection or sIntersection.alternative) {
45  // Path and overstep limit checking
46  double pLimit = state.stepSize.value(ConstrainedStep::aborter);
47  double oLimit = stepper.overstepLimit(state);
48  auto checkIntersection = [&](const Intersection3D& intersection) -> bool {
49  double cLimit = intersection.pathLength;
50  bool accept = (cLimit > oLimit and cLimit * cLimit < pLimit * pLimit);
51  if (accept) {
52  stepper.setStepSize(state, state.navDir * cLimit);
53  }
54  return accept;
55  };
56  // If either of the two intersections are viable return reachable
57  if (checkIntersection(sIntersection.intersection) or
58  (sIntersection.alternative and
59  checkIntersection(sIntersection.alternative))) {
60  return Intersection3D::Status::reachable;
61  }
62  }
63  return Intersection3D::Status::unreachable;
64 }
65 
74 template <typename stepper_t, typename object_intersection_t>
75 void updateSingleStepSize(typename stepper_t::State& state,
76  const object_intersection_t& oIntersection,
77  bool release = true) {
78  double stepSize = oIntersection.intersection.pathLength;
79  state.stepSize.update(stepSize, ConstrainedStep::actor, release);
80 }
81 
82 } // namespace detail
83 } // namespace Acts