Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Core/include/Acts/Propagator/detail/NavigationHelpers.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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/Geometry/Layer.hpp"
0012 #include "Acts/Geometry/TrackingVolume.hpp"
0013 #include "Acts/Propagator/NavigationTarget.hpp"
0014 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 #include "Acts/Surfaces/SurfaceArray.hpp"
0017 #include "Acts/Utilities/Helpers.hpp"
0018 #include "Acts/Utilities/Intersection.hpp"
0019 
0020 #include <variant>
0021 
0022 namespace Acts::detail {
0023 
0024 using AnyIntersectionObject =
0025     std::variant<const Surface*, const Layer*, const BoundarySurface*>;
0026 
0027 /// @brief A candidate object for navigation
0028 struct NavigationObjectCandidate {
0029   AnyIntersectionObject object;
0030   const Surface* representation = nullptr;
0031   BoundaryTolerance boundaryTolerance;
0032 
0033   NavigationObjectCandidate(const Surface& _surface,
0034                             BoundaryTolerance _boundaryTolerance)
0035       : object(&_surface),
0036         representation(&_surface),
0037         boundaryTolerance(_boundaryTolerance) {}
0038   NavigationObjectCandidate(const Layer& _layer, const Surface& _representation,
0039                             BoundaryTolerance _boundaryTolerance)
0040       : object(&_layer),
0041         representation(&_representation),
0042         boundaryTolerance(_boundaryTolerance) {}
0043   NavigationObjectCandidate(const BoundarySurface& _boundary,
0044                             BoundaryTolerance _boundaryTolerance)
0045       : object(&_boundary),
0046         representation(&_boundary.surfaceRepresentation()),
0047         boundaryTolerance(_boundaryTolerance) {}
0048 
0049   MultiIntersection3D intersect(const GeometryContext& gctx,
0050                                 const Vector3& position,
0051                                 const Vector3& direction,
0052                                 double tolerance) const {
0053     return representation->intersect(gctx, position, direction,
0054                                      boundaryTolerance, tolerance);
0055   }
0056 
0057   NavigationTarget target(const Intersection3D& intersection,
0058                           IntersectionIndex intersectionIndex) const {
0059     return std::visit(
0060         overloaded{[&](const Surface* surface) -> NavigationTarget {
0061                      return {intersection, intersectionIndex, *surface,
0062                              boundaryTolerance};
0063                    },
0064                    [&](const Layer* layer) -> NavigationTarget {
0065                      return {intersection, intersectionIndex, *layer,
0066                              *representation, boundaryTolerance};
0067                    },
0068                    [&](const BoundarySurface* boundary) -> NavigationTarget {
0069                      return {intersection, intersectionIndex, *boundary,
0070                              boundaryTolerance};
0071                    }},
0072         object);
0073   }
0074 };
0075 
0076 /// @brief Emplace all navigation candidates for a given volume
0077 inline void emplaceAllVolumeCandidates(
0078     std::vector<NavigationObjectCandidate>& candidates,
0079     const TrackingVolume& volume, bool resolveSensitive, bool resolveMaterial,
0080     bool resolvePassive,
0081     const BoundaryTolerance& boundaryToleranceSurfaceApproach,
0082     const Logger& logger) {
0083   // Get all boundary candidates
0084   {
0085     ACTS_VERBOSE("Searching for boundaries.");
0086 
0087     const auto& boundaries = volume.boundarySurfaces();
0088 
0089     ACTS_VERBOSE("Found " << boundaries.size() << " boundaries.");
0090 
0091     for (const auto& boundary : boundaries) {
0092       candidates.emplace_back(*boundary, BoundaryTolerance::None());
0093     }
0094   }
0095 
0096   // Get all layer candidates
0097   {
0098     ACTS_VERBOSE("Searching for layers.");
0099 
0100     const auto& layers = volume.confinedLayers()->arrayObjects();
0101 
0102     ACTS_VERBOSE("Found " << layers.size() << " layers.");
0103 
0104     for (const auto& layer : layers) {
0105       if (!layer->resolve(resolveSensitive, resolveMaterial, resolvePassive)) {
0106         continue;
0107       }
0108 
0109       if (!resolveSensitive ||
0110           layer->surfaceRepresentation().surfaceMaterial() != nullptr) {
0111         candidates.emplace_back(*layer, layer->surfaceRepresentation(),
0112                                 boundaryToleranceSurfaceApproach);
0113       }
0114 
0115       if (layer->approachDescriptor() != nullptr) {
0116         const auto& approaches =
0117             layer->approachDescriptor()->containedSurfaces();
0118 
0119         for (const Surface* approach : approaches) {
0120           candidates.emplace_back(*layer, *approach,
0121                                   boundaryToleranceSurfaceApproach);
0122         }
0123       }
0124 
0125       // Get all surface candidates from layers
0126       {
0127         ACTS_VERBOSE("Searching for surfaces.");
0128 
0129         if (layer->surfaceArray() != nullptr) {
0130           const auto& surfaces = layer->surfaceArray()->surfaces();
0131 
0132           ACTS_VERBOSE("Found " << surfaces.size() << " surfaces.");
0133 
0134           for (const Surface* surface : surfaces) {
0135             candidates.emplace_back(*surface, boundaryToleranceSurfaceApproach);
0136           }
0137         }
0138       }
0139     }
0140   }
0141 }
0142 
0143 }  // namespace Acts::detail