|
|
|||
File indexing completed on 2025-12-13 09:38:48
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/EventData/Types.hpp" 0012 #include "Acts/Utilities/detail/ContainerIterator.hpp" 0013 0014 #include <cassert> 0015 #include <span> 0016 #include <vector> 0017 0018 namespace Acts { 0019 0020 template <bool read_only> 0021 class SeedProxy2; 0022 0023 using MutableSeedProxy2 = SeedProxy2<false>; 0024 using ConstSeedProxy2 = SeedProxy2<true>; 0025 0026 /// A container of seeds. Individual seeds are modeled as a sequence of N space 0027 /// points which are addressed via an index into the space point container. 0028 /// Individual seeds are addressed via index. A proxy object simplifies the 0029 /// handling. 0030 class SeedContainer2 { 0031 public: 0032 /// Type alias for seed index type 0033 using Index = SeedIndex2; 0034 /// Type alias for mutable seed proxy 0035 using MutableProxy = MutableSeedProxy2; 0036 /// Type alias for const seed proxy 0037 using ConstProxy = ConstSeedProxy2; 0038 0039 /// Constructs and empty seed container. 0040 SeedContainer2() noexcept; 0041 0042 /// Constructs a copy of the given seed container. 0043 /// @param other The seed container to copy. 0044 SeedContainer2(const SeedContainer2 &other) noexcept; 0045 0046 /// Move constructs a seed container. 0047 /// @param other The seed container to move. 0048 SeedContainer2(SeedContainer2 &&other) noexcept; 0049 0050 /// Detructs the seed container. 0051 ~SeedContainer2() noexcept = default; 0052 0053 /// Assignment operator for copying a seed container. 0054 /// @param other The seed container to copy. 0055 /// @return A reference to this seed container. 0056 SeedContainer2 &operator=(const SeedContainer2 &other) noexcept; 0057 0058 /// Move assignment operator for a seed container. 0059 /// @param other The seed container to move. 0060 /// @return A reference to this seed container. 0061 SeedContainer2 &operator=(SeedContainer2 &&other) noexcept; 0062 0063 /// Returns the size of the seed container, i.e., the number of seeds 0064 /// contained in it. 0065 /// @return The number of seeds in the container. 0066 std::size_t size() const noexcept { return m_size; } 0067 /// Checks if the seed container is empty. 0068 /// @return True if the container is empty, false otherwise. 0069 bool empty() const noexcept { return size() == 0; } 0070 0071 /// Reserves space for the given number of seeds. 0072 /// @param size The number of seeds to reserve space for. 0073 /// @param averageSpacePoints The average number of space points per seed. 0074 void reserve(std::size_t size, float averageSpacePoints = 3) noexcept; 0075 0076 /// Clears the seed container, removing all seeds and space points. 0077 void clear() noexcept; 0078 0079 /// Creates a new seed. 0080 /// @return A mutable proxy to the newly created seed. 0081 MutableProxy createSeed() noexcept; 0082 0083 /// Returns a mutable proxy to the seed at the given index. 0084 /// If the index is out of range, an exception is thrown. 0085 /// @param index The index of the seed to access. 0086 /// @return A mutable proxy to the seed at the given index. 0087 /// @throws std::out_of_range if the index is out of range. 0088 MutableProxy at(Index index); 0089 /// Returns a const proxy to the seed at the given index. 0090 /// If the index is out of range, an exception is thrown. 0091 /// @param index The index of the seed to access. 0092 /// @return A const proxy to the seed at the given index. 0093 /// @throws std::out_of_range if the index is out of range. 0094 ConstProxy at(Index index) const; 0095 0096 /// Returns a mutable proxy to the seed at the given index. 0097 /// @param index The index of the seed to access. 0098 /// @return A mutable proxy to the seed at the given index. 0099 MutableProxy operator[](Index index) noexcept; 0100 /// Returns a const proxy to the seed at the given index. 0101 /// @param index The index of the seed to access. 0102 /// @return A const proxy to the seed at the given index. 0103 ConstProxy operator[](Index index) const noexcept; 0104 0105 /// Assigns space point indices to the seed at the given index. 0106 /// @param index The index of the seed to assign space point indices to. 0107 /// @param spacePointIndices A span of space point indices to assign to the seed. 0108 /// @throws std::out_of_range if the index is out of range. 0109 /// @throws std::logic_error if space point indices are already assigned to the seed. 0110 void assignSpacePointIndices( 0111 Index index, std::span<const SpacePointIndex2> spacePointIndices); 0112 0113 /// Mutable access to the space point indices of the seed at the given index. 0114 /// @param index The index of the seed. 0115 /// @return A span of space point indices associated with the seed at the given 0116 /// index. 0117 std::span<SpacePointIndex2> spacePointIndices(Index index) noexcept { 0118 assert(index < m_spacePointCounts.size() && "Index out of bounds"); 0119 assert(index < m_spacePointOffsets.size() && "Index out of bounds"); 0120 return std::span<SpacePointIndex2>( 0121 m_spacePoints.data() + m_spacePointOffsets[index], 0122 m_spacePoints.data() + m_spacePointOffsets[index] + 0123 m_spacePointCounts[index]); 0124 } 0125 0126 /// Mutable access to the quality of the seed at the given index. 0127 /// @param index The index of the seed. 0128 /// @return A mutable reference to the quality of the seed at the given index. 0129 float &quality(Index index) noexcept { 0130 assert(index < m_qualities.size() && "Index out of bounds"); 0131 return m_qualities[index]; 0132 } 0133 /// Mutable access to the vertex Z coordinate of the seed at the given index. 0134 /// @param index The index of the seed. 0135 /// @return A mutable reference to the vertex Z coordinate of the seed at the 0136 float &vertexZ(Index index) noexcept { 0137 assert(index < m_vertexZs.size() && "Index out of bounds"); 0138 return m_vertexZs[index]; 0139 } 0140 0141 /// Const access to the space point indices of the seed at the given index. 0142 /// @param index The index of the seed. 0143 /// @return A span of space point indices associated with the seed at the given 0144 /// index. 0145 std::span<const SpacePointIndex2> spacePointIndices( 0146 Index index) const noexcept { 0147 assert(index < m_spacePointCounts.size() && "Index out of bounds"); 0148 assert(index < m_spacePointOffsets.size() && "Index out of bounds"); 0149 return std::span<const SpacePointIndex2>( 0150 m_spacePoints.data() + m_spacePointOffsets[index], 0151 m_spacePoints.data() + m_spacePointOffsets[index] + 0152 m_spacePointCounts[index]); 0153 } 0154 0155 /// Const access to the quality of the seed at the given index. 0156 /// @param index The index of the seed. 0157 /// @return A const reference to the quality of the seed at the given index. 0158 float quality(Index index) const noexcept { 0159 assert(index < m_qualities.size() && "Index out of bounds"); 0160 return m_qualities[index]; 0161 } 0162 /// Const access to the vertex Z coordinate of the seed at the given index. 0163 /// @param index The index of the seed. 0164 /// @return A const reference to the vertex Z coordinate of the seed at the 0165 /// given index. 0166 float vertexZ(Index index) const noexcept { 0167 assert(index < m_vertexZs.size() && "Index out of bounds"); 0168 return m_vertexZs[index]; 0169 } 0170 0171 /// Type alias for iterator template over seed container 0172 template <bool read_only> 0173 using Iterator = detail::ContainerIterator< 0174 SeedContainer2, 0175 std::conditional_t<read_only, ConstSeedProxy2, MutableSeedProxy2>, Index, 0176 read_only>; 0177 0178 /// Type alias for mutable iterator over seeds 0179 using iterator = Iterator<false>; 0180 /// Type alias for const iterator over seeds 0181 using const_iterator = Iterator<true>; 0182 0183 /// Get mutable iterator to the beginning of seeds 0184 /// @return Mutable iterator to the first seed 0185 iterator begin() noexcept { return iterator(*this, 0); } 0186 /// Get mutable iterator to the end of seeds 0187 /// @return Mutable iterator past the last seed 0188 iterator end() noexcept { return iterator(*this, size()); } 0189 0190 /// Get const iterator to the beginning of seeds 0191 /// @return Const iterator to the first seed 0192 const_iterator begin() const noexcept { return const_iterator(*this, 0); } 0193 /// Get const iterator to the end of seeds 0194 /// @return Const iterator past the last seed 0195 const_iterator end() const noexcept { return const_iterator(*this, size()); } 0196 0197 private: 0198 std::uint32_t m_size{0}; 0199 std::vector<std::size_t> m_spacePointOffsets; 0200 std::vector<std::uint8_t> m_spacePointCounts; 0201 std::vector<float> m_qualities; 0202 std::vector<float> m_vertexZs; 0203 std::vector<SpacePointIndex2> m_spacePoints; 0204 0205 auto knownColumns() & noexcept { 0206 return std::tie(m_spacePointOffsets, m_spacePointCounts, m_qualities, 0207 m_vertexZs, m_spacePoints); 0208 } 0209 auto knownColumns() const & noexcept { 0210 return std::tie(m_spacePointOffsets, m_spacePointCounts, m_qualities, 0211 m_vertexZs, m_spacePoints); 0212 } 0213 auto knownColumns() && noexcept { 0214 return std::tuple(std::move(m_spacePointOffsets), 0215 std::move(m_spacePointCounts), std::move(m_qualities), 0216 std::move(m_vertexZs), std::move(m_spacePoints)); 0217 } 0218 }; 0219 0220 } // namespace Acts 0221 0222 #include "Acts/EventData/SeedContainer2.ipp"
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|