Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-20 09:25:11

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/Algebra.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Utilities/Intersection.hpp"
0016 
0017 namespace Acts::detail {
0018 
0019 /// Estimate the propagation direction to the closest straight-line surface
0020 /// intersection, ignoring bounds. Zero path length selects forward propagation.
0021 /// @param gctx Geometry context
0022 /// @param surface Surface to approach
0023 /// @param position Current global position
0024 /// @param direction Current unit momentum direction
0025 /// @return Forward or backward according to the signed intersection path length
0026 inline Direction directionToSurface(const GeometryContext& gctx,
0027                                     const Surface& surface,
0028                                     const Vector3& position,
0029                                     const Vector3& direction) {
0030   const Intersection3D intersection =
0031       surface
0032           .intersect(gctx, position, direction, BoundaryTolerance::Infinite())
0033           .closest();
0034   return Direction::fromScalarZeroAsPositive(intersection.pathLength());
0035 }
0036 
0037 }  // namespace Acts::detail