|
||||
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 // clang-format off 0012 // Workaround for building on clang+libstdc++. Must be the first include. 0013 #include "Acts/Utilities/detail/ReferenceWrapperAnyCompat.hpp" 0014 // clang-format on 0015 0016 #include "Acts/EventData/TrackParameters.hpp" 0017 #include "Acts/EventData/TrackParametersConcept.hpp" 0018 #include "Acts/Propagator/ActorList.hpp" 0019 #include "Acts/Propagator/PropagatorOptions.hpp" 0020 #include "Acts/Propagator/PropagatorResult.hpp" 0021 #include "Acts/Propagator/PropagatorState.hpp" 0022 #include "Acts/Propagator/PropagatorTraits.hpp" 0023 #include "Acts/Propagator/StandardAborters.hpp" 0024 #include "Acts/Propagator/StepperConcept.hpp" 0025 #include "Acts/Propagator/VoidNavigator.hpp" 0026 #include "Acts/Propagator/detail/ParameterTraits.hpp" 0027 #include "Acts/Utilities/Logger.hpp" 0028 #include "Acts/Utilities/Result.hpp" 0029 0030 namespace Acts { 0031 0032 /// Common simplified base interface for propagators. 0033 /// 0034 /// This class only supports propagation from start bound parameters to a target 0035 /// surface and returns only the end bound parameters. 0036 /// Navigation is performed if the underlying propagator is configured with an 0037 /// appropriate navigator. No custom actors or aborters are supported. 0038 class BasePropagator { 0039 public: 0040 /// Base propagator options 0041 using Options = PropagatorPlainOptions; 0042 0043 /// Method to propagate start bound track parameters to a target surface. 0044 /// @param start The start bound track parameters. 0045 /// @param target The target surface. 0046 /// @param options The propagation options. 0047 /// @return The end bound track parameters. 0048 virtual Result<BoundTrackParameters> propagateToSurface( 0049 const BoundTrackParameters& start, const Surface& target, 0050 const Options& options) const = 0; 0051 0052 virtual ~BasePropagator() = default; 0053 }; 0054 0055 namespace detail { 0056 class PropagatorStub {}; 0057 0058 template <typename derived_t> 0059 class BasePropagatorHelper : public BasePropagator { 0060 public: 0061 Result<BoundTrackParameters> propagateToSurface( 0062 const BoundTrackParameters& start, const Surface& target, 0063 const Options& options) const override; 0064 }; 0065 } // namespace detail 0066 0067 /// @brief Propagator for particles (optionally in a magnetic field) 0068 /// 0069 /// The Propagator works with a state objects given at function call 0070 /// This state object contains the thread local state objects 0071 /// - Navigator::state_type for object navigation and screen output 0072 /// - Stepper::state_type state for the actual transport caching 0073 /// (pos,dir,field) 0074 /// 0075 /// @tparam stepper_t Type of stepper implementation of the propagation 0076 /// @tparam naviagor_t Type of the navigator (optional) 0077 /// 0078 /// This Propagator class serves as high-level steering code for propagating 0079 /// track parameters. The actual implementation of the propagation has to be 0080 /// implemented in the stepper_t object, which has to provide the following: 0081 /// 0082 /// - a function for performing a single propagation step 0083 /// - a type mapping for: initial track parameter type -> type of final track 0084 /// parameters 0085 /// - a type mapping for: (initial track parameter type and destination 0086 /// surface type) -> type of final track parameters 0087 /// - a type mapping for: initial track parameter type -> type of internal 0088 /// state object 0089 /// - a type mapping for: (initial track parameter type and destination 0090 /// surface type) -> type of internal state object 0091 /// 0092 template <typename stepper_t, typename navigator_t = VoidNavigator> 0093 class Propagator final 0094 : public std::conditional_t< 0095 SupportsBoundParameters_v<stepper_t, navigator_t>, 0096 detail::BasePropagatorHelper<Propagator<stepper_t, navigator_t>>, 0097 detail::PropagatorStub> { 0098 /// Re-define bound track parameters dependent on the stepper 0099 using StepperBoundTrackParameters = 0100 detail::stepper_bound_parameters_type_t<stepper_t>; 0101 static_assert(BoundTrackParametersConcept<StepperBoundTrackParameters>, 0102 "Stepper bound track parameters do not fulfill bound " 0103 "parameters concept."); 0104 0105 /// Re-define curvilinear track parameters dependent on the stepper 0106 using StepperCurvilinearTrackParameters = 0107 detail::stepper_curvilinear_parameters_type_t<stepper_t>; 0108 static_assert(BoundTrackParametersConcept<StepperCurvilinearTrackParameters>, 0109 "Stepper bound track parameters do not fulfill bound " 0110 "parameters concept."); 0111 0112 using Jacobian = BoundMatrix; 0113 using BoundState = std::tuple<StepperBoundTrackParameters, Jacobian, double>; 0114 using CurvilinearState = 0115 std::tuple<StepperCurvilinearTrackParameters, Jacobian, double>; 0116 0117 static_assert(StepperStateConcept<typename stepper_t::State>, 0118 "Stepper does not fulfill stepper concept."); 0119 static_assert(StepperConcept<stepper_t>, 0120 "Stepper does not fulfill stepper concept."); 0121 0122 public: 0123 /// Type of the stepper in use for public scope 0124 using Stepper = stepper_t; 0125 0126 /// Type of the navigator in use for public scope 0127 using Navigator = navigator_t; 0128 0129 /// Type of state object used by the propagation implementation 0130 using StepperState = typename Stepper::State; 0131 0132 /// Typedef the navigator state 0133 using NavigatorState = typename navigator_t::State; 0134 0135 template <typename propagator_options_t, typename... extension_state_t> 0136 using State = PropagatorState<propagator_options_t, StepperState, 0137 NavigatorState, extension_state_t...>; 0138 0139 using StepperOptions = typename stepper_t::Options; 0140 0141 using NavigatorOptions = typename navigator_t::Options; 0142 0143 template <typename actor_list_t = ActorList<>> 0144 using Options = 0145 PropagatorOptions<StepperOptions, NavigatorOptions, actor_list_t>; 0146 0147 /// Constructor from implementation object 0148 /// 0149 /// @param stepper The stepper implementation is moved to a private member 0150 /// @param navigator The navigator implementation, moved to a private member 0151 /// @param _logger a logger instance 0152 explicit Propagator(stepper_t stepper, navigator_t navigator = navigator_t(), 0153 std::shared_ptr<const Logger> _logger = 0154 getDefaultLogger("Propagator", Acts::Logging::INFO)) 0155 : m_stepper(std::move(stepper)), 0156 m_navigator(std::move(navigator)), 0157 m_logger{std::move(_logger)} {} 0158 0159 private: 0160 /// @brief Helper struct determining the state's type 0161 /// 0162 /// @tparam propagator_options_t Propagator options type 0163 /// @tparam actor_list_t List of propagation action types 0164 /// 0165 /// This helper struct provides type definitions to extract the correct 0166 /// propagation state type from a given TrackParameter type and an 0167 /// ActorList. 0168 /// 0169 template <typename propagator_options_t, typename actor_list_t> 0170 struct state_type_helper { 0171 /// @brief Propagation state type for an arbitrary list of additional 0172 /// propagation states 0173 /// 0174 /// @tparam args Parameter pack specifying additional propagation states 0175 /// 0176 template <typename... args> 0177 using this_state_type = State<propagator_options_t, args...>; 0178 0179 /// @brief Propagation result type derived from a given action list 0180 using type = typename actor_list_t::template result_type<this_state_type>; 0181 }; 0182 0183 /// @brief Helper struct determining the result's type 0184 /// 0185 /// @tparam parameters_t Type of final track parameters 0186 /// @tparam actor_list_t List of propagation action types 0187 /// 0188 /// This helper struct provides type definitions to extract the correct 0189 /// propagation result type from a given TrackParameter type and an 0190 /// ActorList. 0191 /// 0192 template <typename parameters_t, typename actor_list_t> 0193 struct result_type_helper { 0194 /// @brief Propagation result type for an arbitrary list of additional 0195 /// propagation results 0196 /// 0197 /// @tparam args Parameter pack specifying additional propagation results 0198 /// 0199 template <typename... args> 0200 using this_result_type = PropagatorResult<parameters_t, args...>; 0201 0202 /// @brief Propagation result type derived from a given action list 0203 using type = typename actor_list_t::template result_type<this_result_type>; 0204 }; 0205 0206 public: 0207 /// @brief Short-hand type definition for propagation state derived from 0208 /// an action list 0209 /// 0210 /// @tparam actor_list_t List of propagation action types 0211 /// 0212 template <typename propagator_options_t, typename actor_list_t> 0213 using actor_list_t_state_t = 0214 typename state_type_helper<propagator_options_t, actor_list_t>::type; 0215 0216 /// @brief Short-hand type definition for propagation result derived from 0217 /// an action list 0218 /// 0219 /// @tparam parameters_t Type of the final track parameters 0220 /// @tparam actor_list_t List of propagation action types 0221 /// 0222 template <typename parameters_t, typename actor_list_t> 0223 using actor_list_t_result_t = 0224 typename result_type_helper<parameters_t, actor_list_t>::type; 0225 0226 /// @brief Propagate track parameters 0227 /// 0228 /// This function performs the propagation of the track parameters using the 0229 /// internal stepper implementation, until at least one abort condition is 0230 /// fulfilled or the maximum number of steps/path length provided in the 0231 /// propagation options is reached. 0232 /// 0233 /// @tparam parameters_t Type of initial track parameters to propagate 0234 /// @tparam propagator_options_t Type of the propagator options 0235 /// @tparam path_aborter_t The path aborter type to be added 0236 /// 0237 /// @param [in] start initial track parameters to propagate 0238 /// @param [in] options Propagation options, type Options<,> 0239 /// @param [in] makeCurvilinear Produce curvilinear parameters at the end of the propagation 0240 /// 0241 /// @return Propagation result containing the propagation status, final 0242 /// track parameters, and output of actions (if they produce any) 0243 /// 0244 template <typename parameters_t, typename propagator_options_t, 0245 typename path_aborter_t = PathLimitReached> 0246 Result<actor_list_t_result_t<StepperCurvilinearTrackParameters, 0247 typename propagator_options_t::actor_list_type>> 0248 propagate(const parameters_t& start, const propagator_options_t& options, 0249 bool makeCurvilinear = true) const; 0250 0251 /// @brief Propagate track parameters - User method 0252 /// 0253 /// This function performs the propagation of the track parameters according 0254 /// to the internal implementation object until at least one abort condition 0255 /// is fulfilled, the destination surface is hit or the maximum number of 0256 /// steps/path length as given in the propagation options is reached. 0257 /// 0258 /// @tparam parameters_t Type of initial track parameters to propagate 0259 /// @tparam propagator_options_t Type of the propagator options 0260 /// @tparam target_aborter_t The target aborter type to be added 0261 /// @tparam path_aborter_t The path aborter type to be added 0262 /// 0263 /// @param [in] start Initial track parameters to propagate 0264 /// @param [in] target Target surface of to propagate to 0265 /// @param [in] options Propagation options 0266 /// 0267 /// @return Propagation result containing the propagation status, final 0268 /// track parameters, and output of actions (if they produce any) 0269 template <typename parameters_t, typename propagator_options_t, 0270 typename target_aborter_t = SurfaceReached, 0271 typename path_aborter_t = PathLimitReached> 0272 Result<actor_list_t_result_t<StepperBoundTrackParameters, 0273 typename propagator_options_t::actor_list_type>> 0274 propagate(const parameters_t& start, const Surface& target, 0275 const propagator_options_t& options) const; 0276 0277 /// @brief Builds the propagator state object 0278 /// 0279 /// This function creates the propagator state object from the initial track 0280 /// parameters and the propagation options. 0281 /// 0282 /// @note This will also initialize the state 0283 /// 0284 /// @tparam parameters_t Type of initial track parameters to propagate 0285 /// @tparam propagator_options_t Type of the propagator options 0286 /// @tparam path_aborter_t The path aborter type to be added 0287 /// 0288 /// @param [in] start Initial track parameters to propagate 0289 /// @param [in] options Propagation options 0290 /// 0291 /// @return Propagator state object 0292 template <typename parameters_t, typename propagator_options_t, 0293 typename path_aborter_t = PathLimitReached> 0294 auto makeState(const parameters_t& start, 0295 const propagator_options_t& options) const; 0296 0297 /// @brief Builds the propagator state object 0298 /// 0299 /// This function creates the propagator state object from the initial track 0300 /// parameters, the target surface, and the propagation options. 0301 /// 0302 /// @note This will also initialize the state 0303 /// 0304 /// @tparam parameters_t Type of initial track parameters to propagate 0305 /// @tparam propagator_options_t Type of the propagator options 0306 /// @tparam target_aborter_t The target aborter type to be added 0307 /// @tparam path_aborter_t The path aborter type to be added 0308 /// 0309 /// @param [in] start Initial track parameters to propagate 0310 /// @param [in] target Target surface of to propagate to 0311 /// @param [in] options Propagation options 0312 /// 0313 /// @return Propagator state object 0314 template <typename parameters_t, typename propagator_options_t, 0315 typename target_aborter_t = SurfaceReached, 0316 typename path_aborter_t = PathLimitReached> 0317 auto makeState(const parameters_t& start, const Surface& target, 0318 const propagator_options_t& options) const; 0319 0320 /// @brief Propagate track parameters 0321 /// 0322 /// This function performs the propagation of the track parameters according 0323 /// to the internal implementation object until at least one abort condition 0324 /// is fulfilled, the destination surface is hit or the maximum number of 0325 /// steps/path length as given in the propagation options is reached. 0326 /// 0327 /// @note Does not (yet) convert into the return_type of the propagation 0328 /// 0329 /// @tparam propagator_state_t Type of the propagator state with options 0330 /// 0331 /// @param [in,out] state the propagator state object 0332 /// 0333 /// @return Propagation result 0334 template <typename propagator_state_t> 0335 Result<void> propagate(propagator_state_t& state) const; 0336 0337 /// @brief Builds the propagator result object 0338 /// 0339 /// This function creates the propagator result object from the propagator 0340 /// state object. The `result` is passed to pipe a potential error from the 0341 /// propagation call. The `options` are used to determine the type of the 0342 /// result object. The `makeCurvilinear` flag is used to determine if the 0343 /// result should contain curvilinear track parameters. 0344 /// 0345 /// @tparam propagator_state_t Type of the propagator state object 0346 /// @tparam propagator_options_t Type of the propagator options 0347 /// 0348 /// @param [in] state Propagator state object 0349 /// @param [in] result Result of the propagation 0350 /// @param [in] options Propagation options 0351 /// @param [in] makeCurvilinear Produce curvilinear parameters at the end of the propagation 0352 /// 0353 /// @return Propagation result 0354 template <typename propagator_state_t, typename propagator_options_t> 0355 Result<actor_list_t_result_t<StepperCurvilinearTrackParameters, 0356 typename propagator_options_t::actor_list_type>> 0357 makeResult(propagator_state_t state, Result<void> result, 0358 const propagator_options_t& options, bool makeCurvilinear) const; 0359 0360 /// @brief Builds the propagator result object 0361 /// 0362 /// This function creates the propagator result object from the propagator 0363 /// state object. The `result` is passed to pipe a potential error from the 0364 /// propagation call. The `options` are used to determine the type of the 0365 /// result object. 0366 /// 0367 /// @tparam propagator_state_t Type of the propagator state object 0368 /// @tparam propagator_options_t Type of the propagator options 0369 /// 0370 /// @param [in] state Propagator state object 0371 /// @param [in] result Result of the propagation 0372 /// @param [in] target Target surface of to propagate to 0373 /// @param [in] options Propagation options 0374 /// 0375 /// @return Propagation result 0376 template <typename propagator_state_t, typename propagator_options_t> 0377 Result<actor_list_t_result_t<StepperBoundTrackParameters, 0378 typename propagator_options_t::actor_list_type>> 0379 makeResult(propagator_state_t state, Result<void> result, 0380 const Surface& target, const propagator_options_t& options) const; 0381 0382 const stepper_t& stepper() const { return m_stepper; } 0383 0384 const navigator_t& navigator() const { return m_navigator; } 0385 0386 private: 0387 const Logger& logger() const { return *m_logger; } 0388 0389 template <typename propagator_state_t, typename path_aborter_t> 0390 void initialize(propagator_state_t& state) const; 0391 0392 template <typename propagator_state_t, typename result_t> 0393 void moveStateToResult(propagator_state_t& state, result_t& result) const; 0394 0395 /// Implementation of propagation algorithm 0396 stepper_t m_stepper; 0397 0398 /// Implementation of navigator 0399 navigator_t m_navigator; 0400 0401 std::shared_ptr<const Logger> m_logger; 0402 }; 0403 0404 } // namespace Acts 0405 0406 #include "Acts/Propagator/Propagator.ipp"
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |