Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-06 09:17:03

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/Definitions/Direction.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0015 #include "Acts/Propagator/ActorList.hpp"
0016 #include "Acts/Propagator/NavigatorOptions.hpp"
0017 #include "Acts/Propagator/StepperOptions.hpp"
0018 
0019 #include <limits>
0020 
0021 namespace Acts {
0022 
0023 namespace detail {
0024 
0025 /// @brief Holds the generic pure propagator options
0026 struct PurePropagatorPlainOptions {
0027   /// Propagation direction
0028   Direction direction = Direction::Forward();
0029 
0030   /// Maximum number of steps for one propagate call
0031   ///
0032   /// This ensures that the propagation does not hang in the stepping loop in
0033   /// case of misconfiguration or bugs.
0034   unsigned int maxSteps = 1000;
0035 
0036   /// Maximum number of next target calls for one step
0037   ///
0038   /// This ensures that the propagation does not hang in the target resolution
0039   /// loop in case of misconfiguration or bugs.
0040   unsigned int maxTargetSkipping = 100;
0041 
0042   /// Absolute maximum path length
0043   double pathLimit = std::numeric_limits<double>::max();
0044 
0045   /// Loop protection step, it adapts the pathLimit
0046   bool loopProtection = true;
0047   /// Allowed loop fraction, 1 is a full loop
0048   double loopFraction = 0.5;
0049 
0050   /// Required tolerance to reach surface
0051   double surfaceTolerance = s_onSurfaceTolerance;
0052 
0053   /// Constrain the propagation to selected volumes
0054   /// @note ignored if empty
0055   /// @note requires `VolumeConstraintAborter` aborter
0056   std::vector<std::uint32_t> constrainToVolumeIds;
0057   /// Additional volumes to be considered as end of world
0058   /// @note ignored if empty
0059   /// @note requires `VolumeConstraintAborter` aborter
0060   std::vector<std::uint32_t> endOfWorldVolumeIds;
0061 };
0062 
0063 }  // namespace detail
0064 
0065 /// @brief Holds the generic propagator options
0066 struct PropagatorPlainOptions : public detail::PurePropagatorPlainOptions {
0067   /// PropagatorPlainOptions with context
0068   /// @param gctx Geometry context for propagation
0069   /// @param mctx Magnetic field context for propagation
0070   PropagatorPlainOptions(const GeometryContext& gctx,
0071                          const MagneticFieldContext& mctx)
0072       : geoContext(gctx),
0073         magFieldContext(mctx),
0074         stepping(gctx, mctx),
0075         navigation(gctx) {}
0076 
0077   /// The context object for the geometry
0078   std::reference_wrapper<const GeometryContext> geoContext;
0079 
0080   /// The context object for the magnetic field
0081   std::reference_wrapper<const MagneticFieldContext> magFieldContext;
0082 
0083   /// Stepper plain options
0084   StepperPlainOptions stepping;
0085 
0086   /// Navigator plain options
0087   NavigatorPlainOptions navigation;
0088 };
0089 
0090 /// @brief Options for propagate() call
0091 ///
0092 /// @tparam actor_list_t List of action types called after each
0093 ///    propagation step with the current propagation and stepper state
0094 ///
0095 template <typename stepper_options_t, typename navigator_options_t,
0096           typename actor_list_t = ActorList<>>
0097 struct PropagatorOptions : public detail::PurePropagatorPlainOptions {
0098   /// Type alias for stepper options
0099   using stepper_options_type = stepper_options_t;
0100   /// Type alias for navigator options
0101   using navigator_options_type = navigator_options_t;
0102   /// Type alias for actor list
0103   using actor_list_type = actor_list_t;
0104 
0105   /// PropagatorOptions with context
0106   /// @param gctx Geometry context for propagation
0107   /// @param mctx Magnetic field context for propagation
0108   PropagatorOptions(const GeometryContext& gctx,
0109                     const MagneticFieldContext& mctx)
0110       : geoContext(gctx),
0111         magFieldContext(mctx),
0112         stepping(gctx, mctx),
0113         navigation(gctx) {}
0114 
0115   /// PropagatorOptions with context and plain options
0116   /// @param pOptions Plain options to initialize from
0117   explicit PropagatorOptions(const PropagatorPlainOptions& pOptions)
0118       : geoContext(pOptions.geoContext),
0119         magFieldContext(pOptions.magFieldContext),
0120         stepping(pOptions.geoContext, pOptions.magFieldContext),
0121         navigation(pOptions.geoContext) {
0122     setPlainOptions(pOptions);
0123   }
0124 
0125   /// @brief Convert to plain options
0126   explicit operator PropagatorPlainOptions() const {
0127     PropagatorPlainOptions pOptions(geoContext, magFieldContext);
0128     static_cast<PurePropagatorPlainOptions&>(pOptions) =
0129         static_cast<const PurePropagatorPlainOptions&>(*this);
0130     pOptions.stepping = static_cast<const StepperPlainOptions&>(stepping);
0131     pOptions.navigation = static_cast<const NavigatorPlainOptions&>(navigation);
0132     return pOptions;
0133   }
0134 
0135   /// @brief Expand the options with extended actors
0136   ///
0137   /// @tparam extended_actor_list_t Type of the new actor list
0138   ///
0139   /// @param extendedActorList The new actor list to be used (internally)
0140   /// @return PropagatorOptions with the extended actor list
0141   template <typename extended_actor_list_t>
0142   PropagatorOptions<stepper_options_t, navigator_options_t,
0143                     extended_actor_list_t>
0144   extend(extended_actor_list_t extendedActorList) const {
0145     PropagatorOptions<stepper_options_t, navigator_options_t,
0146                       extended_actor_list_t>
0147         eoptions(geoContext, magFieldContext);
0148 
0149     // Copy the base options
0150     static_cast<PurePropagatorPlainOptions&>(eoptions) =
0151         static_cast<const PurePropagatorPlainOptions&>(*this);
0152 
0153     // Stepper / Navigator options
0154     eoptions.stepping = stepping;
0155     eoptions.navigation = navigation;
0156 
0157     // Action / Abort list
0158     eoptions.actorList = extendedActorList;
0159 
0160     // And return the options
0161     return eoptions;
0162   }
0163 
0164   /// @brief Set the plain options
0165   ///
0166   /// @param pOptions The plain options
0167   void setPlainOptions(const PropagatorPlainOptions& pOptions) {
0168     static_cast<PurePropagatorPlainOptions&>(*this) =
0169         static_cast<const PurePropagatorPlainOptions&>(pOptions);
0170 
0171     stepping.setPlainOptions(pOptions.stepping);
0172     navigation.setPlainOptions(pOptions.navigation);
0173   }
0174 
0175   /// The context object for the geometry
0176   std::reference_wrapper<const GeometryContext> geoContext;
0177 
0178   /// The context object for the magnetic field
0179   std::reference_wrapper<const MagneticFieldContext> magFieldContext;
0180 
0181   /// Stepper options
0182   stepper_options_t stepping;
0183 
0184   /// Navigator options
0185   navigator_options_t navigation;
0186 
0187   /// List of actions
0188   actor_list_t actorList;
0189 };
0190 
0191 }  // namespace Acts