File indexing completed on 2025-12-04 09:16:13
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 struct IndexSourceLinkSurfaceAccessor;
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 class IndexSourceLink final {
0033 public:
0034 using SurfaceAccessor = IndexSourceLinkSurfaceAccessor;
0035
0036
0037 constexpr IndexSourceLink(Acts::GeometryIdentifier gid, Index idx)
0038 : m_geometryId(gid), m_index(idx) {}
0039
0040
0041
0042 IndexSourceLink() = default;
0043 IndexSourceLink(const IndexSourceLink&) = default;
0044 IndexSourceLink(IndexSourceLink&&) = default;
0045 IndexSourceLink& operator=(const IndexSourceLink&) = default;
0046 IndexSourceLink& operator=(IndexSourceLink&&) = default;
0047
0048
0049 constexpr Index index() const { return m_index; }
0050
0051 Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
0052
0053 private:
0054 Acts::GeometryIdentifier m_geometryId;
0055 Index m_index = 0;
0056
0057 friend bool operator==(const IndexSourceLink& lhs,
0058 const IndexSourceLink& rhs) {
0059 return (lhs.geometryId() == rhs.geometryId()) &&
0060 (lhs.m_index == rhs.m_index);
0061 }
0062 };
0063
0064 struct IndexSourceLinkSurfaceAccessor {
0065 const Acts::TrackingGeometry& geometry;
0066
0067 const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
0068 const auto& indexSourceLink = sourceLink.get<IndexSourceLink>();
0069 return geometry.findSurface(indexSourceLink.geometryId());
0070 }
0071 };
0072
0073
0074
0075
0076
0077 struct IndexSourceLinkAccessor : GeometryIdMultisetAccessor<IndexSourceLink> {
0078 using BaseIterator = GeometryIdMultisetAccessor<IndexSourceLink>::Iterator;
0079
0080 using Iterator = Acts::SourceLinkAdapterIterator<BaseIterator>;
0081
0082
0083 std::pair<Iterator, Iterator> range(const Acts::Surface& surface) const {
0084 assert(container != nullptr);
0085 auto [begin, end] = container->equal_range(surface.geometryId());
0086 return {Iterator{begin}, Iterator{end}};
0087 }
0088 };
0089
0090 }