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