File indexing completed on 2025-01-18 09:11:46
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Detector/Detector.hpp"
0012 #include "Acts/EventData/SourceLink.hpp"
0013 #include "Acts/Geometry/TrackingGeometry.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "ActsExamples/EventData/GeometryContainers.hpp"
0016 #include "ActsExamples/EventData/Index.hpp"
0017
0018 #include <cassert>
0019
0020 namespace ActsExamples {
0021
0022 struct IndexSourceLinkSurfaceAccessor;
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class IndexSourceLink final {
0034 public:
0035 using SurfaceAccessor = IndexSourceLinkSurfaceAccessor;
0036
0037
0038 constexpr IndexSourceLink(Acts::GeometryIdentifier gid, Index idx)
0039 : m_geometryId(gid), m_index(idx) {}
0040
0041
0042
0043 IndexSourceLink() = default;
0044 IndexSourceLink(const IndexSourceLink&) = default;
0045 IndexSourceLink(IndexSourceLink&&) = default;
0046 IndexSourceLink& operator=(const IndexSourceLink&) = default;
0047 IndexSourceLink& operator=(IndexSourceLink&&) = default;
0048
0049
0050 constexpr Index index() const { return m_index; }
0051
0052 Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
0053
0054 private:
0055 Acts::GeometryIdentifier m_geometryId;
0056 Index m_index = 0;
0057
0058 friend bool operator==(const IndexSourceLink& lhs,
0059 const IndexSourceLink& rhs) {
0060 return (lhs.geometryId() == rhs.geometryId()) &&
0061 (lhs.m_index == rhs.m_index);
0062 }
0063 };
0064
0065 struct IndexSourceLinkSurfaceAccessor {
0066 const Acts::TrackingGeometry& geometry;
0067
0068 const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
0069 const auto& indexSourceLink = sourceLink.get<IndexSourceLink>();
0070 return geometry.findSurface(indexSourceLink.geometryId());
0071 }
0072 };
0073
0074 namespace Experimental {
0075
0076 struct IndexSourceLinkSurfaceAccessor {
0077 const Acts::Experimental::Detector& geometry;
0078
0079 const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
0080 const auto& indexSourceLink = sourceLink.get<IndexSourceLink>();
0081 return geometry.findSurface(indexSourceLink.geometryId());
0082 }
0083 };
0084
0085 }
0086
0087
0088
0089
0090
0091 struct IndexSourceLinkAccessor : GeometryIdMultisetAccessor<IndexSourceLink> {
0092 using BaseIterator = GeometryIdMultisetAccessor<IndexSourceLink>::Iterator;
0093
0094 using Iterator = Acts::SourceLinkAdapterIterator<BaseIterator>;
0095
0096
0097 std::pair<Iterator, Iterator> range(const Acts::Surface& surface) const {
0098 assert(container != nullptr);
0099 auto [begin, end] = container->equal_range(surface.geometryId());
0100 return {Iterator{begin}, Iterator{end}};
0101 }
0102 };
0103
0104 }