Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:58

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/Propagator/Propagator.hpp"
0012 #include "Acts/Surfaces/Surface.hpp"
0013 
0014 namespace Acts {
0015 
0016 /// @brief This class performs the Ridders algorithm to estimate the propagation
0017 /// of the covariance to a certain point in space.
0018 ///
0019 /// The algorithm is based on the small deviations of the start parameters based
0020 /// on their uncertainty at the beginning of the propgation. This deviation is
0021 /// represented here by a vector of relative deviations of these parameters and
0022 /// fix for all parameters. So, a common choice has to be found that is able to
0023 /// actually fit into the order of magnitude of the uncertainty of each
0024 /// parameter. Using these deviations, the propagation is repeated multiple
0025 /// times and the final covariance matrix at a given target surface is
0026 /// afterwards evaluated by first order derivatives of the final state
0027 /// parameters wrt. the initial parameters. Therefore this evaluation represents
0028 /// a first order approximation of the transport jacobian. Since performing
0029 /// multiple propagations and a numerical evaluation of the covariance requires
0030 /// more time than a single propagation towards a target + a common propagation
0031 /// of the covariance, this class just serves to verify the results of the
0032 /// latter classes.
0033 template <typename propagator_t>
0034 class RiddersPropagator {
0035   using Jacobian = BoundMatrix;
0036   using Covariance = BoundSquareMatrix;
0037 
0038   ///
0039   /// @note The result_type_helper struct and the actor_list_t_result_t are
0040   /// here to allow a look'n'feel of this class like the Propagator itself
0041   ///
0042 
0043   /// @brief Helper struct determining the result's type
0044   ///
0045   /// @tparam parameters_t Type of final track parameters
0046   /// @tparam actor_list_t    List of propagation action types
0047   ///
0048   /// This helper struct provides type definitions to extract the correct
0049   /// propagation result type from a given TrackParameter type and an
0050   /// ActorList.
0051   ///
0052   template <typename parameters_t, typename actor_list_t>
0053   struct result_type_helper {
0054     /// @brief Propagation result type for an arbitrary list of additional
0055     ///        propagation results
0056     ///
0057     /// @tparam args Parameter pack specifying additional propagation results
0058     ///
0059     template <typename... args>
0060     using this_result_type = PropagatorResult<parameters_t, args...>;
0061 
0062     /// @brief Propagation result type derived from a given action list
0063     using type = typename actor_list_t::template result_type<this_result_type>;
0064   };
0065 
0066   /// @brief Short-hand type definition for propagation result derived from
0067   ///        an action list
0068   ///
0069   /// @tparam parameters_t Type of the final track parameters
0070   /// @tparam actor_list_t List of propagation action types
0071   ///
0072   template <typename parameters_t, typename actor_list_t>
0073   using actor_list_t_result_t =
0074       typename result_type_helper<parameters_t, actor_list_t>::type;
0075 
0076  public:
0077   struct Config {
0078     /// Set of deltas which will be added to the nominal track parameters
0079     std::vector<double> deviations = {-4e-4, -2e-4, 2e-4, 4e-4};
0080     /// See `deviations` - these are applied for disc surfaces
0081     std::vector<double> deviationsDisc = {-3e-5, -1e-5, 1e-5, 3e-5};
0082   };
0083 
0084   template <typename actor_list_t = ActorList<>>
0085   using Options = typename propagator_t::template Options<actor_list_t>;
0086 
0087   /// @brief Constructor using a propagator
0088   ///
0089   /// @param [in] propagator Underlying propagator that will be used
0090   /// @param [in] config Config for the Ridders propagation
0091   RiddersPropagator(propagator_t propagator, Config config = {})
0092       : m_propagator(std::move(propagator)), m_config(std::move(config)) {}
0093 
0094   /// @brief Constructor building a propagator
0095   ///
0096   /// @tparam stepper_t Type of the stepper
0097   /// @tparam navigator_t Type of the navigator
0098   ///
0099   /// @param [in] stepper Stepper that will be used
0100   /// @param [in] navigator Navigator that will be used
0101   /// @param [in] config Config for the Ridders propagation
0102   template <typename stepper_t, typename navigator_t = VoidNavigator>
0103   RiddersPropagator(stepper_t stepper, navigator_t navigator = navigator_t(),
0104                     Config config = {})
0105       : m_propagator(std::move(stepper), std::move(navigator)),
0106         m_config(std::move(config)) {}
0107 
0108   /// @brief Propagation method targeting curvilinear parameters
0109   ///
0110   /// @tparam parameters_t Type of the start parameters
0111   /// @tparam propagator_options_t Type of the propagator options
0112   ///
0113   /// @param [in] start Start parameters
0114   /// @param [in] options Options of the propagations
0115   ///
0116   /// @return Result of the propagation
0117   template <typename parameters_t, typename propagator_options_t>
0118   Result<actor_list_t_result_t<CurvilinearTrackParameters,
0119                                typename propagator_options_t::actor_list_type>>
0120   propagate(const parameters_t& start,
0121             const propagator_options_t& options) const;
0122 
0123   /// @brief Propagation method targeting bound parameters
0124   ///
0125   /// @tparam parameters_t Type of the start parameters
0126   /// @tparam propagator_options_t Type of the propagator options
0127   ///
0128   /// @param [in] start Start parameters
0129   /// @param [in] target The target surface
0130   /// @param [in] options Options of the propagations
0131   ///
0132   /// @return Result of the propagation
0133   /// @note If the target surface is a disc, the resulting covariance may be
0134   /// inconsistent. In this case a zero matrix is returned.
0135   template <typename parameters_t, typename propagator_options_t>
0136   Result<actor_list_t_result_t<BoundTrackParameters,
0137                                typename propagator_options_t::actor_list_type>>
0138   propagate(const parameters_t& start, const Surface& target,
0139             const propagator_options_t& options) const;
0140 
0141  private:
0142   /// Does the actual ridders propagation by wiggling the parameters and
0143   /// propagating again. This function is called from the different propagation
0144   /// overloads in order to deduplicate code.
0145   ///
0146   /// @param [in] options Options of the propagations
0147   /// @param [in] start Start parameters
0148   /// @param [in] nominalResult The result of the nominal propagation
0149   template <typename propagator_options_t, typename parameters_t,
0150             typename result_t>
0151   Jacobian wiggleAndCalculateJacobian(const propagator_options_t& options,
0152                                       const parameters_t& start,
0153                                       result_t& nominalResult) const;
0154 
0155   /// @brief This function tests whether the variations on a disc as target
0156   /// surface lead to results on different sides wrt the center of the disc.
0157   /// This would lead to a flip of the phi value on the surface and therewith to
0158   /// a huge variance in that parameter. It can only occur in this algorithm
0159   /// since the ridders algorithm is unaware of the target surface.
0160   ///
0161   /// @param [in] derivatives Derivatives of a single parameter
0162   ///
0163   /// @return Boolean result whether a phi jump occurred
0164   static bool inconsistentDerivativesOnDisc(
0165       const std::vector<BoundVector>& derivatives);
0166 
0167   /// @brief This function wiggles one dimension of the starting parameters,
0168   /// performs the propagation to a surface and collects for each change of the
0169   /// start parameters the slope
0170   ///
0171   /// @tparam options_t PropagatorOptions object
0172   /// @tparam parameters_t Type of the parameters to start the propagation with
0173   ///
0174   /// @param [in] options Options do define how to wiggle
0175   /// @param [in] start Start parameters which will be modified
0176   /// @param [in] param Index to get the parameter that will be modified
0177   /// @param [in] target Target surface
0178   /// @param [in] nominal Nominal end parameters
0179   /// @param [in] deviations Vector of deviations
0180   ///
0181   /// @return Vector containing each slope
0182   template <typename propagator_options_t, typename parameters_t>
0183   std::vector<BoundVector> wiggleParameter(
0184       const propagator_options_t& options, const parameters_t& start,
0185       unsigned int param, const Surface& target, const BoundVector& nominal,
0186       const std::vector<double>& deviations) const;
0187 
0188   /// @brief This function fits the jacobian with the deviations and derivatives as input.
0189   ///
0190   /// @param [in] deviations Vector of deviations
0191   /// @param [in] derivatives Slopes of each modification of the parameters
0192   ///
0193   /// @return Propagated jacobian matrix
0194   static Jacobian calculateJacobian(
0195       const std::vector<double>& deviations,
0196       const std::array<std::vector<BoundVector>, eBoundSize>& derivatives);
0197 
0198   /// @brief This function fits a linear function through the final state
0199   /// parametrisations
0200   ///
0201   /// @param [in] deviations Vector of deviations
0202   /// @param [in] derivatives Vector of resulting derivatives
0203   ///
0204   /// @return Vector containing the linear fit
0205   static BoundVector fitLinear(const std::vector<double>& deviations,
0206                                const std::vector<BoundVector>& derivatives);
0207 
0208   propagator_t m_propagator;
0209   Config m_config;
0210 };
0211 }  // namespace Acts
0212 
0213 #include "Acts/Propagator/RiddersPropagator.ipp"