Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:14:04

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 #include "Acts/Geometry/GenericApproachDescriptor.hpp"
0010 
0011 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0012 #include "Acts/Surfaces/Surface.hpp"
0013 #include "Acts/Utilities/Intersection.hpp"
0014 
0015 #include <algorithm>
0016 
0017 #include <boost/container/small_vector.hpp>
0018 
0019 namespace Acts {
0020 
0021 void GenericApproachDescriptor::registerLayer(const Layer& lay) {
0022   // go through the surfaces
0023   for (auto& sf : m_surfaceCache) {
0024     auto mutableSf = const_cast<Surface*>(sf);
0025     mutableSf->associateLayer(lay);
0026   }
0027 }
0028 
0029 SurfaceIntersection GenericApproachDescriptor::approachSurface(
0030     const GeometryContext& gctx, const Vector3& position,
0031     const Vector3& direction, const BoundaryTolerance& boundaryTolerance,
0032     double nearLimit, double farLimit) const {
0033   // almost always 2
0034   boost::container::small_vector<SurfaceIntersection, 4> sIntersections;
0035   sIntersections.reserve(m_surfaceCache.size());
0036   for (const auto& sf : m_surfaceCache) {
0037     auto sfIntersection =
0038         sf->intersect(gctx, position, direction, boundaryTolerance);
0039     for (const auto& intersection : sfIntersection.split()) {
0040       if (intersection.isValid() &&
0041           detail::checkPathLength(intersection.pathLength(), nearLimit,
0042                                   farLimit)) {
0043         sIntersections.push_back(intersection);
0044       }
0045     }
0046   }
0047   if (sIntersections.empty()) {
0048     return SurfaceIntersection::invalid();
0049   }
0050   return *std::min_element(sIntersections.begin(), sIntersections.end(),
0051                            SurfaceIntersection::pathLengthOrder);
0052 }
0053 
0054 const std::vector<const Surface*>&
0055 GenericApproachDescriptor::containedSurfaces() const {
0056   return m_surfaceCache;
0057 }
0058 
0059 std::vector<const Surface*>& GenericApproachDescriptor::containedSurfaces() {
0060   return m_surfaceCache;
0061 }
0062 
0063 }  // namespace Acts