Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:41:28

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/EventData/TrackParameters.hpp"
0012 #include "Acts/Propagator/ActorList.hpp"
0013 #include "Acts/Propagator/PropagatorOptions.hpp"
0014 #include "Acts/Propagator/PropagatorResult.hpp"
0015 #include "Acts/Propagator/VoidNavigator.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 
0018 namespace Acts {
0019 
0020 template <typename propagator_t, typename actor_list_t = ActorList<>>
0021 struct RiddersPropagatorOptions
0022     : public propagator_t::template Options<actor_list_t> {
0023   using base_type = propagator_t::template Options<actor_list_t>;
0024 
0025   using stepper_options_type = typename base_type::stepper_options_type;
0026   using navigator_options_type = typename base_type::navigator_options_type;
0027   using actor_list_type = actor_list_t;
0028 
0029   /// PropagatorOptions with context
0030   RiddersPropagatorOptions(const GeometryContext& gctx,
0031                            const MagneticFieldContext& mctx)
0032       : base_type(gctx, mctx) {}
0033 
0034   /// PropagatorOptions with context and plain options
0035   explicit RiddersPropagatorOptions(const PropagatorPlainOptions& pOptions)
0036       : base_type(pOptions) {}
0037 
0038   using base_type::operator PropagatorPlainOptions;
0039 
0040   /// @brief Expand the options with extended actors
0041   ///
0042   /// @tparam extended_actor_list_t Type of the new actor list
0043   ///
0044   /// @param extendedActorList The new actor list to be used (internally)
0045   template <typename extended_actor_list_t>
0046   RiddersPropagatorOptions<propagator_t, extended_actor_list_t> extend(
0047       extended_actor_list_t extendedActorList) const {
0048     RiddersPropagatorOptions<propagator_t, extended_actor_list_t> eoptions(
0049         base_type::geoContext, base_type::magFieldContext);
0050 
0051     static_cast<decltype(eoptions)::base_type&>(eoptions) =
0052         base_type::extend(std::move(extendedActorList));
0053 
0054     return eoptions;
0055   }
0056 
0057   using base_type::setPlainOptions;
0058 
0059   /// Initial scale for the deviation of the individual bound track parameters
0060   BoundVector deviationScale = {1e-4, 1e-4, 1e-4, 1e-4, 1e-4, 1e-4};
0061 
0062   /// Different factors applied to the initial scale to create the
0063   /// deviations of the individual bound track parameters. The resulting
0064   /// function value deviations are then fitted to a line to determine the
0065   /// first order derivatives of the final parameters wrt. the initial
0066   /// parameters.
0067   std::vector<double> deviationFactors = {-2, -1, 1, 2};
0068 };
0069 
0070 /// @brief This class performs the Ridders algorithm to estimate the propagation
0071 /// of the covariance to a certain point in space.
0072 ///
0073 /// The algorithm is based on the small deviations of the start parameters based
0074 /// on their uncertainty at the beginning of the propgation. This deviation is
0075 /// represented here by a vector of relative deviations of these parameters and
0076 /// fix for all parameters. So, a common choice has to be found that is able to
0077 /// actually fit into the order of magnitude of the uncertainty of each
0078 /// parameter. Using these deviations, the propagation is repeated multiple
0079 /// times and the final covariance matrix at a given target surface is
0080 /// afterwards evaluated by first order derivatives of the final state
0081 /// parameters wrt. the initial parameters. Therefore this evaluation represents
0082 /// a first order approximation of the transport jacobian. Since performing
0083 /// multiple propagations and a numerical evaluation of the covariance requires
0084 /// more time than a single propagation towards a target + a common propagation
0085 /// of the covariance, this class just serves to verify the results of the
0086 /// latter classes.
0087 template <typename propagator_t>
0088 class RiddersPropagator {
0089   ///
0090   /// @note The result_type_helper struct and the actor_list_t_result_t are
0091   /// here to allow a look'n'feel of this class like the Propagator itself
0092   ///
0093 
0094   /// @brief Helper struct determining the result's type
0095   ///
0096   /// @tparam parameters_t Type of final track parameters
0097   /// @tparam actor_list_t    List of propagation action types
0098   ///
0099   /// This helper struct provides type definitions to extract the correct
0100   /// propagation result type from a given TrackParameter type and an
0101   /// ActorList.
0102   ///
0103   template <typename parameters_t, typename actor_list_t>
0104   struct result_type_helper {
0105     /// @brief Propagation result type for an arbitrary list of additional
0106     ///        propagation results
0107     ///
0108     /// @tparam args Parameter pack specifying additional propagation results
0109     ///
0110     template <typename... args>
0111     using this_result_type = PropagatorResult<parameters_t, args...>;
0112 
0113     /// @brief Propagation result type derived from a given action list
0114     using type = typename actor_list_t::template result_type<this_result_type>;
0115   };
0116 
0117   /// @brief Short-hand type definition for propagation result derived from
0118   ///        an action list
0119   ///
0120   /// @tparam parameters_t Type of the final track parameters
0121   /// @tparam actor_list_t List of propagation action types
0122   ///
0123   template <typename parameters_t, typename actor_list_t>
0124   using actor_list_t_result_t =
0125       typename result_type_helper<parameters_t, actor_list_t>::type;
0126 
0127  public:
0128   /// Type of the stepper in use for public scope
0129   using Stepper = typename propagator_t::Stepper;
0130 
0131   /// Type of the navigator in use for public scope
0132   using Navigator = typename propagator_t::Navigator;
0133 
0134   /// Type of state object used by the propagation implementation
0135   using StepperState = typename Stepper::State;
0136 
0137   /// Typedef the navigator state
0138   using NavigatorState = typename Navigator::State;
0139 
0140   /// Type alias for propagator state
0141   template <typename propagator_options_t, typename... extension_state_t>
0142   using State = typename propagator_t::template State<
0143       propagator_options_t, StepperState, NavigatorState, extension_state_t...>;
0144 
0145   /// Type alias for stepper options
0146   using StepperOptions = typename Stepper::Options;
0147 
0148   /// Type alias for navigator options
0149   using NavigatorOptions = typename Navigator::Options;
0150 
0151   /// Type alias for Ridders propagator options
0152   template <typename actor_list_t = ActorList<>>
0153   using Options = RiddersPropagatorOptions<propagator_t, actor_list_t>;
0154 
0155   /// @brief Constructor using a propagator
0156   ///
0157   /// @param [in] propagator The propagator to use
0158   explicit RiddersPropagator(propagator_t propagator)
0159       : m_propagator(std::move(propagator)) {}
0160 
0161   /// @brief Propagation method targeting curvilinear parameters
0162   ///
0163   /// @tparam parameters_t Type of the start parameters
0164   /// @tparam propagator_options_t Type of the propagator options
0165   ///
0166   /// @param [in] start Start parameters
0167   /// @param [in] options Options of the propagations
0168   ///
0169   /// @return Result of the propagation
0170   template <typename parameters_t, typename propagator_options_t>
0171   Result<actor_list_t_result_t<BoundTrackParameters,
0172                                typename propagator_options_t::actor_list_type>>
0173   propagate(const parameters_t& start,
0174             const propagator_options_t& options) const;
0175 
0176   /// @brief Propagation method targeting bound parameters
0177   ///
0178   /// @tparam parameters_t Type of the start parameters
0179   /// @tparam propagator_options_t Type of the propagator options
0180   ///
0181   /// @param [in] start Start parameters
0182   /// @param [in] target The target surface
0183   /// @param [in] options Options of the propagations
0184   ///
0185   /// @return Result of the propagation
0186   /// @note If the target surface is a disc, the resulting covariance may be
0187   /// inconsistent. In this case a zero matrix is returned.
0188   template <typename parameters_t, typename propagator_options_t>
0189   Result<actor_list_t_result_t<BoundTrackParameters,
0190                                typename propagator_options_t::actor_list_type>>
0191   propagate(const parameters_t& start, const Surface& target,
0192             const propagator_options_t& options) const;
0193 
0194  private:
0195   /// Does the actual ridders propagation by wiggling the parameters and
0196   /// propagating again. This function is called from the different
0197   /// propagation overloads in order to deduplicate code.
0198   ///
0199   /// @param [in] options Options of the propagations
0200   /// @param [in] start Start parameters
0201   /// @param [in] nominalResult The result of the nominal propagation
0202   template <typename parameters_t, typename propagator_options_t>
0203   BoundMatrix wiggleAndCalculateJacobian(
0204       const parameters_t& start, const propagator_options_t& options,
0205       const actor_list_t_result_t<
0206           BoundTrackParameters, typename propagator_options_t::actor_list_type>&
0207           nominalResult) const;
0208 
0209   /// @brief This function wiggles one dimension of the starting parameters,
0210   /// performs the propagation to a surface and collects for each change of the
0211   /// start parameters the slope
0212   ///
0213   /// @tparam options_t PropagatorOptions object
0214   /// @tparam parameters_t Type of the parameters to start the propagation with
0215   ///
0216   /// @param [in] options Options do define how to wiggle
0217   /// @param [in] start Start parameters which will be modified
0218   /// @param [in] param Index to get the parameter that will be modified
0219   /// @param [in] target Target surface
0220   /// @param [in] nominal Nominal end parameters
0221   /// @param [in] deviations Vector of deviations
0222   ///
0223   /// @return Vector containing each slope
0224   template <typename propagator_options_t, typename parameters_t>
0225   std::vector<BoundVector> wiggleParameter(
0226       const propagator_options_t& options, const parameters_t& start,
0227       unsigned int param, const Surface& target, const BoundVector& nominal,
0228       const std::vector<double>& deviations) const;
0229 
0230   propagator_t m_propagator;
0231 };
0232 
0233 }  // namespace Acts
0234 
0235 #include "Acts/Propagator/RiddersPropagator.ipp"