Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 08:19:05

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/StandardAborters.hpp"
0012 #include "Acts/Surfaces/Surface.hpp"
0013 #include "Acts/Utilities/Intersection.hpp"
0014 
0015 namespace Acts {
0016 
0017 /// Aborter that stops when all components reach the target surface.
0018 struct MultiStepperSurfaceReached : public ForcedSurfaceReached {
0019   /// If this is set, we are also happy if the mean of the components is on the
0020   /// surface. How the averaging is performed depends on the stepper
0021   /// implementation
0022   bool averageOnSurface = true;
0023 
0024   /// A configurable tolerance within which distance to the intersection we
0025   /// consider the surface as reached. Has no effect if averageOnSurface is
0026   /// false
0027   double averageOnSurfaceTolerance = 0.2;
0028 
0029   MultiStepperSurfaceReached() = default;
0030 
0031   /// boolean operator for abort condition without using the result
0032   ///
0033   /// @tparam propagator_state_t Type of the propagator state
0034   /// @tparam stepper_t Type of the stepper
0035   /// @tparam navigator_t Type of the navigator
0036   ///
0037   /// @param [in,out] state The propagation state object
0038   /// @param [in] stepper Stepper used for propagation
0039   /// @param [in] navigator Navigator used for the propagation
0040   /// @param logger a logger instance
0041   /// @return True if the abort condition is met, false otherwise
0042   template <typename propagator_state_t, typename stepper_t,
0043             typename navigator_t>
0044   bool checkAbort(propagator_state_t& state, const stepper_t& stepper,
0045                   const navigator_t& navigator, const Logger& logger) const {
0046     if (surface == nullptr) {
0047       ACTS_VERBOSE(
0048           "MultiStepperSurfaceReached aborter | "
0049           "No target surface set.");
0050       return false;
0051     }
0052 
0053     // However, if mean of all is on surface, we are happy as well
0054     if (averageOnSurface) {
0055       const Intersection3D intersection =
0056           surface
0057               ->intersect(
0058                   state.geoContext, stepper.position(state.stepping),
0059                   state.options.direction * stepper.direction(state.stepping),
0060                   BoundaryTolerance(boundaryTolerance),
0061                   averageOnSurfaceTolerance)
0062               .closest();
0063 
0064       if (intersection.status() == IntersectionStatus::onSurface) {
0065         ACTS_VERBOSE(
0066             "MultiStepperSurfaceReached aborter | "
0067             "Reached target in average mode");
0068         for (auto cmp : stepper.componentIterable(state.stepping)) {
0069           cmp.status() = IntersectionStatus::onSurface;
0070         }
0071 
0072         return true;
0073       }
0074 
0075       ACTS_VERBOSE(
0076           "MultiStepperSurfaceReached aborter | Average distance to target: "
0077           << intersection.pathLength());
0078     }
0079 
0080     bool reached = true;
0081 
0082     for (auto cmp : stepper.componentIterable(state.stepping)) {
0083       // note that this is not copying anything heavy
0084       auto singleState = cmp.singleState(state);
0085       const auto& singleStepper = cmp.singleStepper(stepper);
0086 
0087       if (!ForcedSurfaceReached::checkAbort(singleState, singleStepper,
0088                                             navigator, logger)) {
0089         reached = false;
0090       } else {
0091         cmp.status() = Acts::IntersectionStatus::onSurface;
0092       }
0093     }
0094 
0095     if (reached) {
0096       ACTS_VERBOSE(
0097           "MultiStepperSurfaceReached aborter | "
0098           "Reached target in single component mode");
0099     }
0100 
0101     return reached;
0102   }
0103 };
0104 
0105 }  // namespace Acts