|
|
|||
File indexing completed on 2026-07-26 08:18:06
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/SeedColumns.hpp" 0012 #include "Acts/EventData/SpacePointContainer.hpp" 0013 #include "Acts/EventData/Types.hpp" 0014 #include "Acts/Utilities/detail/ContainerIterator.hpp" 0015 0016 #include <cassert> 0017 #include <vector> 0018 0019 namespace Acts { 0020 0021 template <bool read_only> 0022 class SeedProxy; 0023 0024 /// Mutable proxy to a seed allowing modification 0025 using MutableSeedProxy = SeedProxy<false>; 0026 /// Const proxy to a seed for read-only access 0027 using ConstSeedProxy = SeedProxy<true>; 0028 0029 /// A container of seeds. Individual seeds are modeled as a sequence of N space 0030 /// points which are addressed via an index into the space point container. 0031 /// Individual seeds are addressed via index. A proxy object simplifies the 0032 /// handling. 0033 class SeedContainer { 0034 public: 0035 /// Type alias for seed index type 0036 using Index = SeedIndex; 0037 /// Type alias for mutable seed proxy 0038 using MutableProxy = MutableSeedProxy; 0039 /// Type alias for const seed proxy 0040 using ConstProxy = ConstSeedProxy; 0041 0042 /// Constructs and empty seed container. 0043 SeedContainer() noexcept; 0044 0045 /// Constructs a copy of the given seed container. 0046 /// @param other The seed container to copy. 0047 SeedContainer(const SeedContainer &other) noexcept; 0048 0049 /// Move constructs a seed container. 0050 /// @param other The seed container to move. 0051 SeedContainer(SeedContainer &&other) noexcept; 0052 0053 /// Detructs the seed container. 0054 ~SeedContainer() noexcept = default; 0055 0056 /// Assignment operator for copying a seed container. 0057 /// @param other The seed container to copy. 0058 /// @return A reference to this seed container. 0059 SeedContainer &operator=(const SeedContainer &other) noexcept; 0060 0061 /// Move assignment operator for a seed container. 0062 /// @param other The seed container to move. 0063 /// @return A reference to this seed container. 0064 SeedContainer &operator=(SeedContainer &&other) noexcept; 0065 0066 /// Returns the size of the seed container, i.e., the number of seeds 0067 /// contained in it. 0068 /// @return The number of seeds in the container. 0069 Index size() const noexcept { return m_size; } 0070 0071 /// Checks if the seed container is empty. 0072 /// @return True if the container is empty, false otherwise. 0073 bool empty() const noexcept { return size() == 0; } 0074 0075 /// Reserves space for the given number of seeds. 0076 /// @param size The number of seeds to reserve space for. 0077 /// @param averageSpacePoints The average number of space points per seed. 0078 void reserve(Index size, float averageSpacePoints = 3) noexcept; 0079 0080 /// Clears the seed container, removing all seeds and space points. 0081 void clear() noexcept; 0082 0083 /// Assigns the mutable space point container to be used by this seed 0084 /// container by value. This can be used to either copy or move-assign a 0085 /// container. The ownership of the space point container is transferred to 0086 /// this seed container. 0087 /// @param spacePointContainer The space point container to assign. 0088 void assignSpacePointContainer( 0089 SpacePointContainer &&spacePointContainer) noexcept; 0090 0091 /// Assigns the mutable space point container to be used by this seed 0092 /// container by reference. Note that the ownership of the space point 0093 /// container is not transferred and the user must ensure that the space point 0094 /// container remains valid for the lifetime of this seed container. 0095 /// @param spacePointContainer The space point container to assign. 0096 void assignSpacePointContainer( 0097 SpacePointContainer &spacePointContainer) noexcept; 0098 0099 /// Assigns the const space point container to be used by this seed container 0100 /// by const reference. Note that the ownership of the space point container 0101 /// is not transferred and the user must ensure that the space point container 0102 /// remains valid for the lifetime of this seed container. 0103 /// @param spacePointContainer The space point container to assign. 0104 void assignSpacePointContainer( 0105 const SpacePointContainer &spacePointContainer) noexcept; 0106 0107 /// Assigns the mutable space point container to be used by this seed 0108 /// container by shared pointer. The ownership of the space point container is 0109 /// shared between this seed container and the user. 0110 /// @param spacePointContainer The space point container to assign. 0111 void assignSpacePointContainer( 0112 const std::shared_ptr<SpacePointContainer> &spacePointContainer) noexcept; 0113 0114 /// Assigns the const space point container to be used by this seed container 0115 /// by shared pointer. The ownership of the space point container is shared 0116 /// between this seed container and the user. 0117 /// @param spacePointContainer The space point container to assign. 0118 void assignSpacePointContainer( 0119 const std::shared_ptr<const SpacePointContainer> 0120 &spacePointContainer) noexcept; 0121 0122 /// Checks if a space point container has been assigned to this seed 0123 /// container. 0124 /// @return True if a space point container has been assigned. 0125 bool hasSpacePointContainer() const noexcept; 0126 0127 /// Checks if a mutable space point container has been assigned to this seed 0128 /// container. 0129 /// @return True if a mutable space point container has been assigned. 0130 bool hasMutableSpacePointContainer() const noexcept; 0131 0132 /// Returns a const reference to the assigned space point container. 0133 /// @return A const reference to the assigned space point container. 0134 /// @throws std::logic_error if no space point container has been assigned. 0135 const SpacePointContainer &spacePointContainer() const; 0136 0137 /// Returns a mutable reference to the assigned space point container. 0138 /// @return A mutable reference to the assigned space point container. 0139 /// @throws std::logic_error if no mutable space point container has been assigned. 0140 SpacePointContainer &mutableSpacePointContainer(); 0141 0142 /// Creates a new seed. 0143 /// @return A mutable proxy to the newly created seed. 0144 MutableProxy createSeed() noexcept; 0145 0146 /// Copies the specified columns from another seed to this seed 0147 /// @param index The index of the seed to copy to in this container. 0148 /// @param otherContainer The seed container to copy from. 0149 /// @param otherIndex The index of the seed to copy from in the other container. 0150 /// @param columnsToCopy The columns to copy from the other seed. 0151 void copyFrom(Index index, const SeedContainer &otherContainer, 0152 Index otherIndex, SeedColumns columnsToCopy); 0153 0154 /// Returns a mutable proxy to the seed at the given index. 0155 /// If the index is out of range, an exception is thrown. 0156 /// @param index The index of the seed to access. 0157 /// @return A mutable proxy to the seed at the given index. 0158 /// @throws std::out_of_range if the index is out of range. 0159 MutableProxy at(Index index); 0160 0161 /// Returns a const proxy to the seed at the given index. 0162 /// If the index is out of range, an exception is thrown. 0163 /// @param index The index of the seed to access. 0164 /// @return A const proxy to the seed at the given index. 0165 /// @throws std::out_of_range if the index is out of range. 0166 ConstProxy at(Index index) const; 0167 0168 /// Returns a mutable proxy to the seed at the given index. 0169 /// @param index The index of the seed to access. 0170 /// @return A mutable proxy to the seed at the given index. 0171 MutableProxy operator[](Index index) noexcept; 0172 0173 /// Returns a const proxy to the seed at the given index. 0174 /// @param index The index of the seed to access. 0175 /// @return A const proxy to the seed at the given index. 0176 ConstProxy operator[](Index index) const noexcept; 0177 0178 /// Type alias for iterator template over seed container 0179 template <bool read_only> 0180 using Iterator = detail::ContainerIterator< 0181 SeedContainer, 0182 std::conditional_t<read_only, ConstSeedProxy, MutableSeedProxy>, Index, 0183 read_only>; 0184 0185 /// Type alias for mutable iterator over seeds 0186 using iterator = Iterator<false>; 0187 /// Type alias for const iterator over seeds 0188 using const_iterator = Iterator<true>; 0189 0190 /// Get mutable iterator to the beginning of seeds 0191 /// @return Mutable iterator to the first seed 0192 iterator begin() noexcept { return {*this, 0}; } 0193 /// Get mutable iterator to the end of seeds 0194 /// @return Mutable iterator past the last seed 0195 iterator end() noexcept { return {*this, size()}; } 0196 0197 /// Get const iterator to the beginning of seeds 0198 /// @return Const iterator to the first seed 0199 const_iterator begin() const noexcept { return {*this, 0}; } 0200 /// Get const iterator to the end of seeds 0201 /// @return Const iterator past the last seed 0202 const_iterator end() const noexcept { return {*this, size()}; } 0203 0204 private: 0205 template <bool> 0206 friend class SeedProxy; 0207 0208 std::uint32_t m_size{0}; 0209 std::vector<std::uint32_t> m_spacePointOffsets; 0210 std::vector<std::uint8_t> m_spacePointCounts; 0211 std::vector<float> m_qualities; 0212 std::vector<float> m_vertexZs; 0213 std::vector<SpacePointIndex> m_spacePoints; 0214 0215 std::shared_ptr<const SpacePointContainer> m_sharedConstSpacePointContainer; 0216 SpacePointContainer *m_mutableSpacePointContainer{nullptr}; 0217 const SpacePointContainer *m_constSpacePointContainer{nullptr}; 0218 }; 0219 0220 } // namespace Acts 0221 0222 #include "Acts/EventData/SeedContainer.ipp"
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|