Warning, file /include/Acts/Propagator/StepperExtensionList.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/Propagator/detail/Auctioneer.hpp"
0014 #include "Acts/Utilities/detail/Extendable.hpp"
0015 #include "Acts/Utilities/detail/MPL/all_of.hpp"
0016 #include "Acts/Utilities/detail/MPL/has_duplicates.hpp"
0017
0018 #include <array>
0019
0020 namespace Acts {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 template <typename... extensions>
0037 struct StepperExtensionList : private detail::Extendable<extensions...> {
0038 private:
0039
0040 static_assert(!detail::has_duplicates_v<extensions...>,
0041 "same extension type specified several times");
0042
0043 static constexpr unsigned int nExtensions = sizeof...(extensions);
0044
0045 static_assert(nExtensions != 0, "no extension type specified");
0046
0047
0048 using detail::Extendable<extensions...>::tuple;
0049
0050
0051 std::array<bool, nExtensions> validExtensions{};
0052
0053 public:
0054
0055 using detail::Extendable<extensions...>::get;
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 template <typename propagator_state_t, typename stepper_t,
0068 typename navigtor_t>
0069 bool validExtensionForStep(const propagator_state_t& state,
0070 const stepper_t& stepper,
0071 const navigtor_t& navigator) {
0072 const auto bids = std::apply(
0073 [&](const auto&... ext) {
0074 return std::array<int, nExtensions>{
0075 ext.bid(state, stepper, navigator)...};
0076 },
0077 tuple());
0078
0079 validExtensions = state.stepping.auctioneer(std::move(bids));
0080
0081 return (std::find(validExtensions.begin(), validExtensions.end(), true) !=
0082 validExtensions.end());
0083 }
0084
0085
0086
0087
0088
0089 template <typename propagator_state_t, typename stepper_t,
0090 typename navigator_t>
0091 bool k(const propagator_state_t& state, const stepper_t& stepper,
0092 const navigator_t& navigator, Vector3& knew, const Vector3& bField,
0093 std::array<double, 4>& kQoP, const int i, const double h = 0.,
0094 const Vector3& kprev = Vector3::Zero()) {
0095
0096 auto impl = [&, i, h](auto intType, auto& implRef) {
0097 constexpr int N = decltype(intType)::value;
0098
0099 if constexpr (N == 0) {
0100 return true;
0101 } else {
0102
0103 if (!std::get<N - 1>(validExtensions)) {
0104 return implRef(std::integral_constant<int, N - 1>{}, implRef);
0105 }
0106
0107 if (std::get<N - 1>(this->tuple())
0108 .template k(state, stepper, navigator, knew, bField, kQoP, i, h,
0109 kprev)) {
0110 return implRef(std::integral_constant<int, N - 1>{}, implRef);
0111 } else {
0112
0113 return false;
0114 }
0115 }
0116 };
0117
0118 return impl(std::integral_constant<int, nExtensions>{}, impl);
0119 }
0120
0121
0122
0123
0124
0125 template <typename propagator_state_t, typename stepper_t,
0126 typename navigator_t>
0127 bool k1(const propagator_state_t& state, const stepper_t& stepper,
0128 const navigator_t& navigator, Vector3& knew, const Vector3& bField,
0129 std::array<double, 4>& kQoP) {
0130 return k(state, stepper, navigator, knew, bField, kQoP, 0);
0131 }
0132
0133
0134
0135
0136 template <typename propagator_state_t, typename stepper_t,
0137 typename navigator_t>
0138 bool k2(const propagator_state_t& state, const stepper_t& stepper,
0139 const navigator_t& navigator, Vector3& knew, const Vector3& bField,
0140 std::array<double, 4>& kQoP, const double h, const Vector3& kprev) {
0141 return k(state, stepper, navigator, knew, bField, kQoP, 1, h, kprev);
0142 }
0143
0144
0145
0146
0147 template <typename propagator_state_t, typename stepper_t,
0148 typename navigator_t>
0149 bool k3(const propagator_state_t& state, const stepper_t& stepper,
0150 const navigator_t& navigator, Vector3& knew, const Vector3& bField,
0151 std::array<double, 4>& kQoP, const double h, const Vector3& kprev) {
0152 return k(state, stepper, navigator, knew, bField, kQoP, 2, h, kprev);
0153 }
0154
0155
0156
0157
0158 template <typename propagator_state_t, typename stepper_t,
0159 typename navigator_t>
0160 bool k4(const propagator_state_t& state, const stepper_t& stepper,
0161 const navigator_t& navigator, Vector3& knew, const Vector3& bField,
0162 std::array<double, 4>& kQoP, const double h, const Vector3& kprev) {
0163 return k(state, stepper, navigator, knew, bField, kQoP, 3, h, kprev);
0164 }
0165
0166
0167
0168
0169 template <typename propagator_state_t, typename stepper_t,
0170 typename navigator_t>
0171 bool finalize(propagator_state_t& state, const stepper_t& stepper,
0172 const navigator_t& navigator, const double h, FreeMatrix& D) {
0173
0174 auto impl = [&, h](auto intType, auto& implRef) {
0175 constexpr int N = decltype(intType)::value;
0176
0177 if constexpr (N == 0) {
0178 return true;
0179 } else {
0180
0181 if (!std::get<N - 1>(validExtensions)) {
0182 return implRef(std::integral_constant<int, N - 1>{}, implRef);
0183 }
0184
0185 if (std::get<N - 1>(this->tuple())
0186 .finalize(state, stepper, navigator, h, D)) {
0187 return implRef(std::integral_constant<int, N - 1>{}, implRef);
0188 } else {
0189
0190 return false;
0191 }
0192 }
0193 };
0194
0195 return impl(std::integral_constant<int, nExtensions>{}, impl);
0196 }
0197
0198
0199
0200
0201 template <typename propagator_state_t, typename stepper_t,
0202 typename navigator_t>
0203 bool finalize(propagator_state_t& state, const stepper_t& stepper,
0204 const navigator_t& navigator, const double h) {
0205
0206 auto impl = [&, h](auto intType, auto& implRef) {
0207 constexpr int N = decltype(intType)::value;
0208
0209 if constexpr (N == 0) {
0210 return true;
0211 } else {
0212
0213 if (!std::get<N - 1>(validExtensions)) {
0214 return implRef(std::integral_constant<int, N - 1>{}, implRef);
0215 }
0216
0217
0218 if (std::get<N - 1>(this->tuple())
0219 .finalize(state, stepper, navigator, h)) {
0220 return implRef(std::integral_constant<int, N - 1>{}, implRef);
0221 } else {
0222
0223 return false;
0224 }
0225 }
0226 };
0227
0228 return impl(std::integral_constant<int, nExtensions>{}, impl);
0229 }
0230 };
0231
0232 }