File indexing completed on 2025-09-18 08:11:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Geometry/Layer.hpp"
0012 #include "Acts/Geometry/TrackingVolume.hpp"
0013 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Surfaces/SurfaceArray.hpp"
0016 #include "Acts/Utilities/Intersection.hpp"
0017
0018 #include <variant>
0019
0020 namespace Acts::detail {
0021
0022 using AnyIntersectionObject =
0023 std::variant<const Surface*, const Layer*, const BoundarySurface*>;
0024
0025
0026 struct NavigationObjectCandidate {
0027 AnyIntersectionObject object;
0028 const Surface* representation = nullptr;
0029 BoundaryTolerance boundaryTolerance;
0030
0031 NavigationObjectCandidate(AnyIntersectionObject _object,
0032 const Surface* _representation,
0033 BoundaryTolerance _boundaryTolerance)
0034 : object(_object),
0035 representation(_representation),
0036 boundaryTolerance(_boundaryTolerance) {}
0037
0038 std::pair<SurfaceMultiIntersection, AnyIntersectionObject> intersect(
0039 const GeometryContext& gctx, const Vector3& position,
0040 const Vector3& direction, double tolerance) const {
0041 auto intersection = representation->intersect(gctx, position, direction,
0042 boundaryTolerance, tolerance);
0043
0044 if (std::holds_alternative<const Surface*>(object)) {
0045 const auto& surface = std::get<const Surface*>(object);
0046 return {intersection, surface};
0047 }
0048 if (std::holds_alternative<const Layer*>(object)) {
0049 const auto& layer = std::get<const Layer*>(object);
0050 return {intersection, layer};
0051 }
0052 if (std::holds_alternative<const BoundarySurface*>(object)) {
0053 const auto& boundary = std::get<const BoundarySurface*>(object);
0054 return {intersection, boundary};
0055 }
0056 throw std::runtime_error("unknown type");
0057 }
0058 };
0059
0060
0061
0062 struct IntersectedNavigationObject {
0063 SurfaceIntersection intersection;
0064 AnyIntersectionObject anyObject;
0065 BoundaryTolerance boundaryTolerance;
0066
0067 IntersectedNavigationObject(SurfaceIntersection _intersection,
0068 AnyIntersectionObject _anyObject,
0069 BoundaryTolerance _boundaryTolerance)
0070 : intersection(_intersection),
0071 anyObject(_anyObject),
0072 boundaryTolerance(_boundaryTolerance) {}
0073
0074 template <typename object_t>
0075 bool checkType() const {
0076 return std::holds_alternative<const object_t*>(anyObject);
0077 }
0078
0079 template <typename object_t>
0080 const object_t* object() const {
0081 return std::get<const object_t*>(anyObject);
0082 }
0083
0084 static bool forwardOrder(const IntersectedNavigationObject& aCandidate,
0085 const IntersectedNavigationObject& bCandidate) {
0086 return Intersection3D::pathLengthOrder(
0087 aCandidate.intersection.intersection(),
0088 bCandidate.intersection.intersection());
0089 }
0090 };
0091
0092
0093 inline void emplaceAllVolumeCandidates(
0094 std::vector<NavigationObjectCandidate>& candidates,
0095 const TrackingVolume& volume, bool resolveSensitive, bool resolveMaterial,
0096 bool resolvePassive,
0097 const BoundaryTolerance& boundaryToleranceSurfaceApproach,
0098 const Logger& logger) {
0099 auto addCandidate = [&](AnyIntersectionObject object,
0100 const Surface* representation,
0101 const BoundaryTolerance& boundaryTolerance) {
0102 candidates.emplace_back(object, representation, boundaryTolerance);
0103 };
0104
0105
0106 {
0107 ACTS_VERBOSE("Searching for boundaries.");
0108
0109 const auto& boundaries = volume.boundarySurfaces();
0110
0111 ACTS_VERBOSE("Found " << boundaries.size() << " boundaries.");
0112
0113 for (const auto& boundary : boundaries) {
0114 addCandidate(boundary.get(), &boundary->surfaceRepresentation(),
0115 BoundaryTolerance::None());
0116 }
0117 }
0118
0119
0120 {
0121 ACTS_VERBOSE("Searching for layers.");
0122
0123 const auto& layers = volume.confinedLayers()->arrayObjects();
0124
0125 ACTS_VERBOSE("Found " << layers.size() << " layers.");
0126
0127 for (const auto& layer : layers) {
0128 if (!layer->resolve(resolveSensitive, resolveMaterial, resolvePassive)) {
0129 continue;
0130 }
0131
0132 if (!resolveSensitive ||
0133 layer->surfaceRepresentation().surfaceMaterial() != nullptr) {
0134 addCandidate(layer.get(), &layer->surfaceRepresentation(),
0135 BoundaryTolerance::None());
0136 }
0137
0138 if (layer->approachDescriptor() != nullptr) {
0139 const auto& approaches =
0140 layer->approachDescriptor()->containedSurfaces();
0141
0142 for (const auto& approach : approaches) {
0143 addCandidate(layer.get(), approach, BoundaryTolerance::None());
0144 }
0145 }
0146
0147
0148 {
0149 ACTS_VERBOSE("Searching for surfaces.");
0150
0151 if (layer->surfaceArray() != nullptr) {
0152 const auto& surfaces = layer->surfaceArray()->surfaces();
0153
0154 ACTS_VERBOSE("Found " << surfaces.size() << " surfaces.");
0155
0156 for (const auto& surface : surfaces) {
0157 addCandidate(surface, surface, boundaryToleranceSurfaceApproach);
0158 }
0159 }
0160 }
0161 }
0162 }
0163 }
0164
0165 }