Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:22

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