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/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   PropagatorPlainOptions(const GeometryContext& gctx,
0069                          const MagneticFieldContext& mctx)
0070       : geoContext(gctx),
0071         magFieldContext(mctx),
0072         stepping(gctx, mctx),
0073         navigation(gctx) {}
0074 
0075   /// The context object for the geometry
0076   std::reference_wrapper<const GeometryContext> geoContext;
0077 
0078   /// The context object for the magnetic field
0079   std::reference_wrapper<const MagneticFieldContext> magFieldContext;
0080 
0081   /// Stepper plain options
0082   StepperPlainOptions stepping;
0083 
0084   /// Navigator plain options
0085   NavigatorPlainOptions navigation;
0086 };
0087 
0088 /// @brief Options for propagate() call
0089 ///
0090 /// @tparam actor_list_t List of action types called after each
0091 ///    propagation step with the current propagation and stepper state
0092 ///
0093 template <typename stepper_options_t, typename navigator_options_t,
0094           typename actor_list_t = ActorList<>>
0095 struct PropagatorOptions : public detail::PurePropagatorPlainOptions {
0096   using stepper_options_type = stepper_options_t;
0097   using navigator_options_type = navigator_options_t;
0098   using actor_list_type = actor_list_t;
0099 
0100   /// PropagatorOptions with context
0101   PropagatorOptions(const GeometryContext& gctx,
0102                     const MagneticFieldContext& mctx)
0103       : geoContext(gctx),
0104         magFieldContext(mctx),
0105         stepping(gctx, mctx),
0106         navigation(gctx) {}
0107 
0108   /// PropagatorOptions with context and plain options
0109   PropagatorOptions(const PropagatorPlainOptions& pOptions)
0110       : geoContext(pOptions.geoContext),
0111         magFieldContext(pOptions.magFieldContext),
0112         stepping(pOptions.geoContext, pOptions.magFieldContext),
0113         navigation(pOptions.geoContext) {
0114     setPlainOptions(pOptions);
0115   }
0116 
0117   /// @brief Convert to plain options
0118   operator PropagatorPlainOptions() const {
0119     PropagatorPlainOptions pOptions(geoContext, magFieldContext);
0120     static_cast<PurePropagatorPlainOptions&>(pOptions) =
0121         static_cast<const PurePropagatorPlainOptions&>(*this);
0122     pOptions.stepping = static_cast<const StepperPlainOptions&>(stepping);
0123     pOptions.navigation = static_cast<const NavigatorPlainOptions&>(navigation);
0124     return pOptions;
0125   }
0126 
0127   /// @brief Expand the options with extended actors
0128   ///
0129   /// @tparam extended_actor_list_t Type of the new actor list
0130   ///
0131   /// @param extendedActorList The new actor list to be used (internally)
0132   template <typename extended_actor_list_t>
0133   PropagatorOptions<stepper_options_t, navigator_options_t,
0134                     extended_actor_list_t>
0135   extend(extended_actor_list_t extendedActorList) const {
0136     PropagatorOptions<stepper_options_t, navigator_options_t,
0137                       extended_actor_list_t>
0138         eoptions(geoContext, magFieldContext);
0139 
0140     // Copy the base options
0141     static_cast<PurePropagatorPlainOptions&>(eoptions) =
0142         static_cast<const PurePropagatorPlainOptions&>(*this);
0143 
0144     // Stepper / Navigator options
0145     eoptions.stepping = stepping;
0146     eoptions.navigation = navigation;
0147 
0148     // Action / Abort list
0149     eoptions.actorList = extendedActorList;
0150 
0151     // And return the options
0152     return eoptions;
0153   }
0154 
0155   /// @brief Set the plain options
0156   ///
0157   /// @param pOptions The plain options
0158   void setPlainOptions(const PropagatorPlainOptions& pOptions) {
0159     static_cast<PurePropagatorPlainOptions&>(*this) =
0160         static_cast<const PurePropagatorPlainOptions&>(pOptions);
0161 
0162     stepping.setPlainOptions(pOptions.stepping);
0163     navigation.setPlainOptions(pOptions.navigation);
0164   }
0165 
0166   /// The context object for the geometry
0167   std::reference_wrapper<const GeometryContext> geoContext;
0168 
0169   /// The context object for the magnetic field
0170   std::reference_wrapper<const MagneticFieldContext> magFieldContext;
0171 
0172   /// Stepper options
0173   stepper_options_t stepping;
0174 
0175   /// Navigator options
0176   navigator_options_t navigation;
0177 
0178   /// List of actions
0179   actor_list_t actorList;
0180 };
0181 
0182 }  // namespace Acts