EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LoopProtection.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LoopProtection.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 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 namespace detail {
16 
17 template <typename path_arborter_t>
26  template <typename propagator_state_t, typename stepper_t>
27  void operator()(propagator_state_t& state, const stepper_t& stepper) const {
28  const auto& logger = state.options.logger;
29  // Estimate the loop protection limit
30  if (state.options.loopProtection) {
31  // Get the field at the start position
32  Vector3D field =
33  stepper.getField(state.stepping, stepper.position(state.stepping));
34  const double B = field.norm();
35  if (B != 0.) {
36  // Transverse component at start is taken for the loop protection
37  const double p = stepper.momentum(state.stepping);
38  // Calculate the full helix path
39  const double helixPath = state.stepping.navDir * 2 * M_PI * p / B;
40  // And set it as the loop limit if it overwrites the internal limit
41  auto& pathAborter =
42  state.options.abortList.template get<path_arborter_t>();
43  double loopLimit = state.options.loopFraction * helixPath;
44  double pathLimit = pathAborter.internalLimit;
45  if (loopLimit * loopLimit < pathLimit * pathLimit) {
46  pathAborter.internalLimit = loopLimit;
47 
48  ACTS_VERBOSE("Path aborter limit set to "
49  << loopLimit << " (full helix = " << helixPath << ")");
50  }
51  }
52  }
53  }
54 };
55 
56 } // namespace detail
57 } // namespace Acts