Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:36

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