Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:04:13

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013 #include "Acts/Definitions/Tolerance.hpp"
0014 #include "Acts/Propagator/ConstrainedStep.hpp"
0015 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Utilities/Intersection.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 
0020 #include <limits>
0021 
0022 namespace Acts::detail {
0023 
0024 /// Update surface status - Single component
0025 ///
0026 /// This method intersect the provided surface and update the navigation
0027 /// step estimation accordingly (hence it changes the state). It also
0028 /// returns the status of the intersection to trigger onSurface in case
0029 /// the surface is reached.
0030 ///
0031 /// @param state [in,out] The stepping state (thread-local cache)
0032 /// @param surface [in] The surface provided
0033 /// @param boundaryTolerance [in] The boundary check for this status update
0034 template <typename stepper_t>
0035 Acts::Intersection3D::Status updateSingleSurfaceStatus(
0036     const stepper_t& stepper, typename stepper_t::State& state,
0037     const Surface& surface, std::uint8_t index, Direction navDir,
0038     const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance,
0039     const Logger& logger) {
0040   ACTS_VERBOSE("Update single surface status for surface: "
0041                << surface.geometryId() << " index " << static_cast<int>(index));
0042 
0043   auto sIntersection =
0044       surface.intersect(state.geoContext, stepper.position(state),
0045                         navDir * stepper.direction(state), boundaryTolerance,
0046                         surfaceTolerance)[index];
0047 
0048   // The intersection is on surface already
0049   if (sIntersection.status() == Intersection3D::Status::onSurface) {
0050     // Release navigation step size
0051     state.stepSize.release(ConstrainedStep::actor);
0052     ACTS_VERBOSE("Intersection: state is ON SURFACE");
0053     return Intersection3D::Status::onSurface;
0054   }
0055 
0056   const double nearLimit = std::numeric_limits<double>::lowest();
0057   const double farLimit = state.stepSize.value(ConstrainedStep::aborter);
0058 
0059   if (sIntersection.isValid() &&
0060       detail::checkPathLength(sIntersection.pathLength(), nearLimit, farLimit,
0061                               logger)) {
0062     ACTS_VERBOSE("Surface is reachable");
0063     stepper.updateStepSize(state, sIntersection.pathLength(),
0064                            ConstrainedStep::actor);
0065     return Intersection3D::Status::reachable;
0066   }
0067 
0068   ACTS_VERBOSE("Surface is NOT reachable");
0069   return Intersection3D::Status::unreachable;
0070 }
0071 
0072 /// Update the Step size - single component
0073 ///
0074 /// It takes a (valid) object intersection from the compatibleX(...)
0075 /// calls in the geometry and updates the step size
0076 ///
0077 /// @param state [in,out] The stepping state (thread-local cache)
0078 /// @param oIntersection [in] The object that yielded this step size
0079 /// @param release [in] A release flag
0080 template <typename stepper_t, typename object_intersection_t>
0081 void updateSingleStepSize(typename stepper_t::State& state,
0082                           const object_intersection_t& oIntersection,
0083                           bool release = true) {
0084   double stepSize = oIntersection.pathLength();
0085   state.stepSize.update(stepSize, ConstrainedStep::actor, release);
0086 }
0087 
0088 }  // namespace Acts::detail