Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-20 09:46:42

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Surfaces/Surface.hpp"
0012 
0013 #include <type_traits>
0014 
0015 namespace Acts::detail {
0016 
0017 /// A helper struct to store a reference to a single-component state and its
0018 /// associated navigation state and options
0019 template <typename stepping_t, typename navigation_t, typename options_t,
0020           typename geoctx_t>
0021 struct SinglePropState {
0022   stepping_t& stepping;
0023   navigation_t& navigation;
0024   options_t& options;
0025   geoctx_t& geoContext;
0026 
0027   SinglePropState(stepping_t& s, navigation_t& n, options_t& o, geoctx_t& g)
0028       : stepping(s), navigation(n), options(o), geoContext(g) {}
0029 };
0030 
0031 /// A template class which contains all const member functions, that should be
0032 /// available both in the mutable ComponentProxy and the ConstComponentProxy.
0033 /// @tparam component_t Must be a const or mutable State::Component.
0034 template <typename component_t, typename loop_stepper_t>
0035 struct LoopComponentProxyBase {
0036   using SingleStepper = typename loop_stepper_t::SingleStepper;
0037   using SingleState = typename loop_stepper_t::SingleState;
0038 
0039   static_assert(std::is_same_v<std::remove_const_t<component_t>,
0040                                typename loop_stepper_t::State::Component>);
0041 
0042   component_t& cmp;
0043 
0044   explicit LoopComponentProxyBase(component_t& c) : cmp(c) {}
0045 
0046   // These are the const accessors, which are shared between the mutable
0047   // ComponentProxy and the ConstComponentProxy
0048   const auto& state() const { return cmp.state; }
0049   auto status() const { return cmp.status; }
0050   auto weight() const { return cmp.weight; }
0051   auto pathAccumulated() const { return cmp.state.pathAccumulated; }
0052   const auto& pars() const { return cmp.state.pars; }
0053   const auto& derivative() const { return cmp.state.derivative; }
0054   const auto& cov() const { return cmp.state.cov; }
0055   const auto& jacobian() const { return cmp.state.jacobian; }
0056   const auto& jacToGlobal() const { return cmp.state.jacToGlobal; }
0057 
0058   template <typename propagator_state_t>
0059   auto singleState(const propagator_state_t& state) const {
0060     using DeducedStepping = decltype(state.stepping.components.front().state);
0061     static_assert(std::is_same_v<SingleState, DeducedStepping>);
0062 
0063     return SinglePropState<const SingleState, const decltype(state.navigation),
0064                            const decltype(state.options),
0065                            const decltype(state.geoContext)>(
0066         cmp.state, state.navigation, state.options, state.geoContext);
0067   }
0068 
0069   const SingleStepper& singleStepper(const loop_stepper_t& stepper) const {
0070     return stepper.singleStepper();
0071   }
0072 };
0073 
0074 /// A proxy struct which allows access to a single component of the
0075 /// multi-component state. It has the semantics of a mutable reference, i.e.
0076 /// it requires a mutable reference of the single-component state it
0077 /// represents
0078 template <typename component_t, typename loop_stepper_t>
0079 struct LoopComponentProxy
0080     : LoopComponentProxyBase<component_t, loop_stepper_t> {
0081   using State = typename loop_stepper_t::State;
0082   using Base = LoopComponentProxyBase<component_t, loop_stepper_t>;
0083 
0084   using SingleState = typename loop_stepper_t::SingleState;
0085   using SingleStepper = typename loop_stepper_t::SingleStepper;
0086   using Covariance = typename loop_stepper_t::Covariance;
0087 
0088   // Import the const accessors from ComponentProxyBase
0089   using Base::cmp;
0090   using Base::cov;
0091   using Base::derivative;
0092   using Base::jacobian;
0093   using Base::jacToGlobal;
0094   using Base::pars;
0095   using Base::pathAccumulated;
0096   using Base::singleState;
0097   using Base::singleStepper;
0098   using Base::state;
0099   using Base::status;
0100   using Base::weight;
0101 
0102   // The multi-component state of the stepper
0103   const State& all_state;
0104 
0105   LoopComponentProxy(typename State::Component& c, const State& s)
0106       : Base(c), all_state(s) {}
0107 
0108   // These are the mutable accessors, the const ones are inherited from the
0109   // ComponentProxyBase
0110   auto& state() { return cmp.state; }
0111   auto& status() { return cmp.status; }
0112   auto& weight() { return cmp.weight; }
0113   auto& pathAccumulated() { return cmp.state.pathAccumulated; }
0114   auto& pars() { return cmp.state.pars; }
0115   auto& derivative() { return cmp.state.derivative; }
0116   auto& cov() { return cmp.state.cov; }
0117   auto& jacobian() { return cmp.state.jacobian; }
0118   auto& jacToGlobal() { return cmp.state.jacToGlobal; }
0119 
0120   template <typename propagator_state_t>
0121   auto singleState(propagator_state_t& state) {
0122     using DeducedStepping = decltype(state.stepping.components.front().state);
0123     static_assert(std::is_same_v<SingleState, DeducedStepping>);
0124 
0125     return SinglePropState<SingleState, decltype(state.navigation),
0126                            decltype(state.options), decltype(state.geoContext)>(
0127         cmp.state, state.navigation, state.options, state.geoContext);
0128   }
0129 
0130   void update(const FreeVector& freeParams, const BoundVector& boundParams,
0131               const Covariance& covariance, const Surface& surface) {
0132     cmp.state.pars = freeParams;
0133     cmp.state.cov = covariance;
0134     cmp.state.jacToGlobal =
0135         surface.boundToFreeJacobian(all_state.geoContext, boundParams);
0136   }
0137 };
0138 
0139 }  // namespace Acts::detail