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