File indexing completed on 2025-07-12 07:51:25
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/Types.hpp"
0012 #include "Acts/Utilities/TypeTraits.hpp"
0013
0014 #include <cassert>
0015 #include <span>
0016 #include <vector>
0017
0018 namespace Acts::Experimental {
0019
0020 template <bool read_only>
0021 class SeedProxy2;
0022
0023 using MutableSeedProxy2 = SeedProxy2<false>;
0024 using ConstSeedProxy2 = SeedProxy2<true>;
0025
0026
0027
0028
0029
0030 class SeedContainer2 {
0031 public:
0032 using IndexType = SeedIndex2;
0033 using MutableProxyType = MutableSeedProxy2;
0034 using ConstProxyType = ConstSeedProxy2;
0035
0036
0037
0038
0039 std::size_t size() const noexcept { return m_sizes.size(); }
0040
0041
0042 bool empty() const noexcept { return size() == 0; }
0043
0044
0045
0046
0047 void reserve(std::size_t size, float averageSpacePoints = 3) noexcept;
0048
0049
0050 void clear() noexcept;
0051
0052
0053
0054
0055 MutableProxyType createSeed(
0056 std::span<const SpacePointIndex2> spacePoints) noexcept;
0057
0058
0059
0060
0061
0062
0063 MutableProxyType at(IndexType index);
0064
0065
0066
0067
0068
0069 ConstProxyType at(IndexType index) const;
0070
0071
0072
0073
0074
0075 std::span<SpacePointIndex2> spacePointIndices(IndexType index) noexcept {
0076 assert(index < m_sizes.size() && "Index out of bounds");
0077 assert(index < m_spacePointOffsets.size() && "Index out of bounds");
0078 return std::span<SpacePointIndex2>(
0079 m_spacePoints.data() + m_spacePointOffsets[index],
0080 m_spacePoints.data() + m_spacePointOffsets[index] + m_sizes[index]);
0081 }
0082
0083
0084
0085
0086 float &quality(IndexType index) noexcept {
0087 assert(index < m_qualities.size() && "Index out of bounds");
0088 return m_qualities[index];
0089 }
0090
0091
0092
0093 float &vertexZ(IndexType index) noexcept {
0094 assert(index < m_vertexZs.size() && "Index out of bounds");
0095 return m_vertexZs[index];
0096 }
0097
0098
0099
0100
0101
0102 std::span<const SpacePointIndex2> spacePointIndices(
0103 IndexType index) const noexcept {
0104 assert(index < m_sizes.size() && "Index out of bounds");
0105 assert(index < m_spacePointOffsets.size() && "Index out of bounds");
0106 return std::span<const SpacePointIndex2>(
0107 m_spacePoints.data() + m_spacePointOffsets[index],
0108 m_spacePoints.data() + m_spacePointOffsets[index] + m_sizes[index]);
0109 }
0110
0111
0112
0113
0114 float quality(IndexType index) const noexcept {
0115 assert(index < m_qualities.size() && "Index out of bounds");
0116 return m_qualities[index];
0117 }
0118
0119
0120
0121
0122 float vertexZ(IndexType index) const noexcept {
0123 assert(index < m_vertexZs.size() && "Index out of bounds");
0124 return m_vertexZs[index];
0125 }
0126
0127 template <bool read_only>
0128 class SeedIterator {
0129 public:
0130 static constexpr bool ReadOnly = read_only;
0131
0132 using ContainerType = const_if_t<ReadOnly, SeedContainer2>;
0133
0134 using iterator_category = std::forward_iterator_tag;
0135 using value_type = SeedProxy2<ReadOnly>;
0136 using difference_type = std::ptrdiff_t;
0137
0138 SeedIterator() = default;
0139 SeedIterator(ContainerType &container, IndexType index)
0140 : m_container(&container), m_index(index) {}
0141
0142 SeedIterator &operator++() {
0143 ++m_index;
0144 return *this;
0145 }
0146 SeedIterator operator++(int) {
0147 SeedIterator tmp(*this);
0148 ++(*this);
0149 return tmp;
0150 }
0151
0152 value_type operator*() const { return value_type(*m_container, m_index); }
0153
0154 private:
0155 ContainerType *m_container{};
0156 IndexType m_index{};
0157
0158 friend bool operator==(const SeedIterator &a, const SeedIterator &b) {
0159 return a.m_index == b.m_index && a.m_container == b.m_container;
0160 }
0161 };
0162 using iterator = SeedIterator<false>;
0163 using const_iterator = SeedIterator<true>;
0164
0165 iterator begin() noexcept { return iterator(*this, 0); }
0166 iterator end() noexcept { return iterator(*this, size()); }
0167
0168 const_iterator begin() const noexcept { return const_iterator(*this, 0); }
0169 const_iterator end() const noexcept { return const_iterator(*this, size()); }
0170
0171 private:
0172 std::vector<std::uint8_t> m_sizes;
0173 std::vector<std::size_t> m_spacePointOffsets;
0174 std::vector<float> m_qualities;
0175 std::vector<float> m_vertexZs;
0176 std::vector<SpacePointIndex2> m_spacePoints;
0177 };
0178
0179 }
0180
0181 #include "Acts/EventData/SeedContainer2.ipp"