ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StepperExtensionList.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file StepperExtensionList.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 
16 
17 namespace Acts {
18 
33 template <typename... extensions>
34 struct StepperExtensionList : private detail::Extendable<extensions...> {
35  private:
36  // Checkout for duplicates in the extensions
37  static_assert(not detail::has_duplicates_v<extensions...>,
38  "same extension type specified several times");
39 
40  static constexpr unsigned int nExtensions = sizeof...(extensions);
41 
42  static_assert(nExtensions != 0, "no extension type specified");
43 
44  // Access to all extensions
45  using detail::Extendable<extensions...>::tuple;
46 
48 
49  // Vector of valid extensions for a step
50  std::array<bool, nExtensions> validExtensions;
51 
52  public:
53  // Access to an extension
54  using detail::Extendable<extensions...>::get;
55 
63  template <typename propagator_state_t, typename stepper_t>
64  bool validExtensionForStep(const propagator_state_t& state,
65  const stepper_t& stepper) {
66  std::array<int, nExtensions> bids;
67  // Ask all extensions for a boolean statement of their validity
68  impl::bid(tuple(), state, stepper, bids);
69  // Post-process the vector in an auctioneer
70  validExtensions = state.stepping.auctioneer(std::move(bids));
71 
72  return (std::find(validExtensions.begin(), validExtensions.end(), true) !=
73  validExtensions.end());
74  }
75 
80  template <typename propagator_state_t, typename stepper_t>
81  bool k1(const propagator_state_t& state, const stepper_t& stepper,
82  Vector3D& knew, const Vector3D& bField, std::array<double, 4>& kQoP) {
83  return impl::k(tuple(), state, stepper, knew, bField, kQoP,
85  }
86 
90  template <typename propagator_state_t, typename stepper_t>
91  bool k2(const propagator_state_t& state, const stepper_t& stepper,
92  Vector3D& knew, const Vector3D& bField, std::array<double, 4>& kQoP,
93  const double h, const Vector3D& kprev) {
94  return impl::k(tuple(), state, stepper, knew, bField, kQoP, validExtensions,
95  1, h, kprev);
96  }
97 
101  template <typename propagator_state_t, typename stepper_t>
102  bool k3(const propagator_state_t& state, const stepper_t& stepper,
103  Vector3D& knew, const Vector3D& bField, std::array<double, 4>& kQoP,
104  const double h, const Vector3D& kprev) {
105  return impl::k(tuple(), state, stepper, knew, bField, kQoP, validExtensions,
106  2, h, kprev);
107  }
108 
112  template <typename propagator_state_t, typename stepper_t>
113  bool k4(const propagator_state_t& state, const stepper_t& stepper,
114  Vector3D& knew, const Vector3D& bField, std::array<double, 4>& kQoP,
115  const double h, const Vector3D& kprev) {
116  return impl::k(tuple(), state, stepper, knew, bField, kQoP, validExtensions,
117  3, h, kprev);
118  }
119 
123  template <typename propagator_state_t, typename stepper_t>
124  bool finalize(propagator_state_t& state, const stepper_t& stepper,
125  const double h, FreeMatrix& D) {
126  return impl::finalize(tuple(), state, stepper, h, D, validExtensions);
127  }
128 
132  template <typename propagator_state_t, typename stepper_t>
133  bool finalize(propagator_state_t& state, const stepper_t& stepper,
134  const double h) {
135  return impl::finalize(tuple(), state, stepper, h, validExtensions);
136  }
137 };
138 
139 } // namespace Acts