File indexing completed on 2025-07-09 07:49:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp"
0012 #include "Acts/Propagator/detail/CovarianceEngine.hpp"
0013 #include "Acts/Surfaces/Surface.hpp"
0014 #include "Acts/Utilities/Result.hpp"
0015
0016 #include <optional>
0017 #include <type_traits>
0018
0019 namespace Acts::detail {
0020
0021
0022
0023 template <typename stepping_t, typename navigation_t, typename options_t,
0024 typename geoctx_t>
0025 struct SinglePropState {
0026 stepping_t& stepping;
0027 navigation_t& navigation;
0028 options_t& options;
0029 geoctx_t& geoContext;
0030
0031 SinglePropState(stepping_t& s, navigation_t& n, options_t& o, geoctx_t& g)
0032 : stepping(s), navigation(n), options(o), geoContext(g) {}
0033 };
0034
0035
0036
0037
0038 template <typename component_t, typename loop_stepper_t>
0039 struct LoopComponentProxyBase {
0040 using SingleStepper = typename loop_stepper_t::SingleStepper;
0041 using SingleState = typename loop_stepper_t::SingleState;
0042
0043 static_assert(std::is_same_v<std::remove_const_t<component_t>,
0044 typename loop_stepper_t::State::Component>);
0045
0046 component_t& cmp;
0047
0048 explicit LoopComponentProxyBase(component_t& c) : cmp(c) {}
0049
0050
0051
0052 const auto& state() const { return cmp.state; }
0053 auto status() const { return cmp.status; }
0054 auto weight() const { return cmp.weight; }
0055 auto pathAccumulated() const { return cmp.state.pathAccumulated; }
0056 const auto& pars() const { return cmp.state.pars; }
0057 const auto& derivative() const { return cmp.state.derivative; }
0058 const auto& jacTransport() const { return cmp.state.jacTransport; }
0059 const auto& cov() const { return cmp.state.cov; }
0060 const auto& jacobian() const { return cmp.state.jacobian; }
0061 const auto& jacToGlobal() const { return cmp.state.jacToGlobal; }
0062
0063 template <typename propagator_state_t>
0064 auto singleState(const propagator_state_t& state) const {
0065 using DeducedStepping = decltype(state.stepping.components.front().state);
0066 static_assert(std::is_same_v<SingleState, DeducedStepping>);
0067
0068 return SinglePropState<const SingleState, const decltype(state.navigation),
0069 const decltype(state.options),
0070 const decltype(state.geoContext)>(
0071 cmp.state, state.navigation, state.options, state.geoContext);
0072 }
0073
0074 const auto& singleStepper(const loop_stepper_t& stepper) const {
0075 return static_cast<const SingleStepper&>(stepper);
0076 }
0077 };
0078
0079
0080
0081
0082
0083 template <typename component_t, typename loop_stepper_t>
0084 struct LoopComponentProxy
0085 : LoopComponentProxyBase<component_t, loop_stepper_t> {
0086 using State = typename loop_stepper_t::State;
0087 using Base = LoopComponentProxyBase<component_t, loop_stepper_t>;
0088
0089 using SingleState = typename loop_stepper_t::SingleState;
0090 using SingleStepper = typename loop_stepper_t::SingleStepper;
0091 using Covariance = typename loop_stepper_t::Covariance;
0092
0093
0094 using Base::cmp;
0095 using Base::cov;
0096 using Base::derivative;
0097 using Base::jacobian;
0098 using Base::jacToGlobal;
0099 using Base::jacTransport;
0100 using Base::pars;
0101 using Base::pathAccumulated;
0102 using Base::singleState;
0103 using Base::singleStepper;
0104 using Base::state;
0105 using Base::status;
0106 using Base::weight;
0107
0108
0109 const State& all_state;
0110
0111 LoopComponentProxy(typename State::Component& c, const State& s)
0112 : Base(c), all_state(s) {}
0113
0114
0115
0116 auto& state() { return cmp.state; }
0117 auto& status() { return cmp.status; }
0118 auto& weight() { return cmp.weight; }
0119 auto& pathAccumulated() { return cmp.state.pathAccumulated; }
0120 auto& pars() { return cmp.state.pars; }
0121 auto& derivative() { return cmp.state.derivative; }
0122 auto& jacTransport() { return cmp.state.jacTransport; }
0123 auto& cov() { return cmp.state.cov; }
0124 auto& jacobian() { return cmp.state.jacobian; }
0125 auto& jacToGlobal() { return cmp.state.jacToGlobal; }
0126
0127 template <typename propagator_state_t>
0128 auto singleState(propagator_state_t& state) {
0129 using DeducedStepping = decltype(state.stepping.components.front().state);
0130 static_assert(std::is_same_v<SingleState, DeducedStepping>);
0131
0132 return SinglePropState<SingleState, decltype(state.navigation),
0133 decltype(state.options), decltype(state.geoContext)>(
0134 cmp.state, state.navigation, state.options, state.geoContext);
0135 }
0136
0137 Result<typename SingleStepper::BoundState> boundState(
0138 const Surface& surface, bool transportCov,
0139 const FreeToBoundCorrection& freeToBoundCorrection) {
0140 return detail::boundState(
0141 all_state.options.geoContext, surface, cov(), jacobian(),
0142 jacTransport(), derivative(), jacToGlobal(), std::nullopt, pars(),
0143 all_state.particleHypothesis, all_state.covTransport && transportCov,
0144 cmp.state.pathAccumulated, freeToBoundCorrection);
0145 }
0146
0147 void update(const FreeVector& freeParams, const BoundVector& boundParams,
0148 const Covariance& covariance, const Surface& surface) {
0149 cmp.state.pars = freeParams;
0150 cmp.state.cov = covariance;
0151 cmp.state.jacToGlobal =
0152 surface.boundToFreeJacobian(all_state.geoContext, boundParams);
0153 }
0154 };
0155
0156 }