|
|
|||
File indexing completed on 2025-12-11 09:39:49
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/SourceLink.hpp" 0012 #include "Acts/EventData/Types.hpp" 0013 #include "Acts/Utilities/TypeTraits.hpp" 0014 0015 #include <cassert> 0016 #include <span> 0017 0018 namespace Acts { 0019 0020 class SpacePointContainer2; 0021 template <typename T, bool read_only> 0022 class SpacePointColumnProxy; 0023 template <typename T> 0024 using MutableSpacePointColumnProxy = SpacePointColumnProxy<T, false>; 0025 template <typename T> 0026 using ConstSpacePointColumnProxy = SpacePointColumnProxy<T, true>; 0027 0028 /// A proxy class for accessing individual space points. 0029 template <bool read_only> 0030 class SpacePointProxy2 { 0031 public: 0032 /// Indicates whether this space point proxy is read-only or data can be 0033 /// modified 0034 static constexpr bool ReadOnly = read_only; 0035 0036 /// Type alias for space point index type 0037 using Index = SpacePointIndex2; 0038 0039 /// Type alias for container type (const if read-only) 0040 using Container = const_if_t<ReadOnly, SpacePointContainer2>; 0041 0042 /// Constructs a space point proxy for the given container and index. 0043 /// @param container The container holding the space point. 0044 /// @param index The index of the space point in the container. 0045 SpacePointProxy2(Container &container, Index index) noexcept 0046 : m_container(&container), m_index(index) {} 0047 0048 /// Copy construct a space point proxy. 0049 /// @param other The space point proxy to copy. 0050 SpacePointProxy2(const SpacePointProxy2 &other) noexcept = default; 0051 0052 /// Copy construct a mutable space point proxy. 0053 /// @param other The mutable space point proxy to copy. 0054 explicit SpacePointProxy2(const SpacePointProxy2<false> &other) noexcept 0055 requires ReadOnly 0056 : m_container(&other.container()), m_index(other.index()) {} 0057 0058 /// Returns a const proxy of the space point. 0059 /// @return A const proxy of the space point. 0060 SpacePointProxy2<true> asConst() const noexcept 0061 requires(!ReadOnly) 0062 { 0063 return {*m_container, m_index}; 0064 } 0065 0066 /// Gets the container holding the space point. 0067 /// @return A reference to the container holding the space point. 0068 SpacePointContainer2 &container() const noexcept 0069 requires(!ReadOnly) 0070 { 0071 return *m_container; 0072 } 0073 /// Gets the container holding the space point. 0074 /// @return A const reference to the container holding the space point. 0075 const SpacePointContainer2 &container() const noexcept { 0076 return *m_container; 0077 } 0078 /// Gets the index of the space point in the container. 0079 /// @return The index of the space point in the container. 0080 Index index() const noexcept { return m_index; } 0081 0082 /// Assigns source links to the space point. 0083 /// @param sourceLinks A span of source links to assign to the space point. 0084 /// @throws std::out_of_range if the index is out of range. 0085 /// @throws std::logic_error if no source links column is available. 0086 /// @throws std::logic_error if source links are already assigned to the space point. 0087 void assignSourceLinks(std::span<const SourceLink> sourceLinks) const 0088 requires(!ReadOnly) 0089 { 0090 m_container->assignSourceLinks(m_index, sourceLinks); 0091 } 0092 0093 /// Mutable access to the source links of the space point. 0094 /// @return A mutable span of source links associated with the space point. 0095 std::span<SourceLink> sourceLinks() const noexcept 0096 requires(!ReadOnly) 0097 { 0098 return m_container->sourceLinks(m_index); 0099 } 0100 /// Mutable access to the x coordinate of the space point. 0101 /// @return A mutable reference to the x coordinate of the space point. 0102 float &x() const noexcept 0103 requires(!ReadOnly) 0104 { 0105 return m_container->x(m_index); 0106 } 0107 /// Mutable access to the y coordinate of the space point. 0108 /// @return A mutable reference to the y coordinate of the space point. 0109 float &y() const noexcept 0110 requires(!ReadOnly) 0111 { 0112 return m_container->y(m_index); 0113 } 0114 /// Mutable access to the z coordinate of the space point. 0115 /// @return A mutable reference to the z coordinate of the space point. 0116 float &z() const noexcept 0117 requires(!ReadOnly) 0118 { 0119 return m_container->z(m_index); 0120 } 0121 /// Mutable access to the r coordinate of the space point. 0122 /// @return A mutable reference to the r coordinate of the space point. 0123 float &r() const noexcept 0124 requires(!ReadOnly) 0125 { 0126 return m_container->r(m_index); 0127 } 0128 /// Mutable access to the phi coordinate of the space point. 0129 /// @return A mutable reference to the phi coordinate of the space point. 0130 float &phi() const noexcept 0131 requires(!ReadOnly) 0132 { 0133 return m_container->phi(m_index); 0134 } 0135 /// Mutable access to the time information of the space point. 0136 /// @return A mutable reference to the time information of the space point. 0137 float &time() const noexcept 0138 requires(!ReadOnly) 0139 { 0140 return m_container->time(m_index); 0141 } 0142 /// Mutable access to the variance in Z direction of the space point. 0143 /// @return A mutable reference to the variance in Z direction of the space point. 0144 float &varianceZ() const noexcept 0145 requires(!ReadOnly) 0146 { 0147 return m_container->varianceZ(m_index); 0148 } 0149 /// Mutable access to the variance in R direction of the space point. 0150 /// @return A mutable reference to the variance in R direction of the space point. 0151 float &varianceR() const noexcept 0152 requires(!ReadOnly) 0153 { 0154 return m_container->varianceR(m_index); 0155 } 0156 /// Mutable access to the top strip vector of the space point. 0157 /// @return A mutable reference to the top strip vector of the space point. 0158 std::array<float, 3> &topStripVector() const noexcept 0159 requires(!ReadOnly) 0160 { 0161 return m_container->topStripVector(m_index); 0162 } 0163 /// Mutable access to the bottom strip vector of the space point. 0164 /// @return A mutable reference to the bottom strip vector of the space point. 0165 std::array<float, 3> &bottomStripVector() const noexcept 0166 requires(!ReadOnly) 0167 { 0168 return m_container->bottomStripVector(m_index); 0169 } 0170 /// Mutable access to the strip center distance of the space point. 0171 /// @return A mutable reference to the strip center distance of the space point. 0172 std::array<float, 3> &stripCenterDistance() const noexcept 0173 requires(!ReadOnly) 0174 { 0175 return m_container->stripCenterDistance(m_index); 0176 } 0177 /// Mutable access to the top strip center of the space point. 0178 /// @return A mutable reference to the top strip center of the space point. 0179 std::array<float, 3> &topStripCenter() const noexcept 0180 requires(!ReadOnly) 0181 { 0182 return m_container->topStripCenter(m_index); 0183 } 0184 /// Mutable access to the copy from index of the space point. 0185 /// @return A mutable reference to the copy from index of the space point. 0186 SpacePointIndex2 ©FromIndex() const noexcept 0187 requires(!ReadOnly) 0188 { 0189 return m_container->copyFromIndex(m_index); 0190 } 0191 /// @brief Get mutable reference to XY coordinates of the space point 0192 /// @return Mutable reference to array containing [x, y] coordinates 0193 std::array<float, 2> &xy() const noexcept 0194 requires(!ReadOnly) 0195 { 0196 return m_container->xy(m_index); 0197 } 0198 /// @brief Get mutable reference to ZR coordinates of the space point 0199 /// @return Mutable reference to array containing [z, r] coordinates 0200 std::array<float, 2> &zr() const noexcept 0201 requires(!ReadOnly) 0202 { 0203 return m_container->zr(m_index); 0204 } 0205 /// @brief Get mutable reference to XYZR coordinates of the space point 0206 /// @return Mutable reference to array containing [x, y, z, r] coordinates 0207 std::array<float, 4> &xyzr() const noexcept 0208 requires(!ReadOnly) 0209 { 0210 return m_container->xyzr(m_index); 0211 } 0212 /// @brief Get mutable reference to ZR coordinate variances 0213 /// @return Mutable reference to array containing [var_z, var_r] variances 0214 std::array<float, 2> &varianceZR() const noexcept 0215 requires(!ReadOnly) 0216 { 0217 return m_container->varianceZR(m_index); 0218 } 0219 0220 /// Mutable access to an extra column of data for the space point. 0221 /// @param column The extra column proxy to access. 0222 /// @return A mutable reference to the value in the extra column for the space point. 0223 template <typename T> 0224 T &extra(MutableSpacePointColumnProxy<T> &column) const noexcept { 0225 return column[m_index]; 0226 } 0227 0228 /// Const access to the source links of the space point. 0229 /// @return A const span of source links associated with the space point. 0230 std::span<const SourceLink> sourceLinks() const noexcept { 0231 return m_container->sourceLinks(m_index); 0232 } 0233 /// Const access to the x coordinate of the space point. 0234 /// @return The x coordinate of the space point. 0235 float x() const noexcept { return m_container->x(m_index); } 0236 /// Const access to the y coordinate of the space point. 0237 /// @return The y coordinate of the space point. 0238 float y() const noexcept { return m_container->y(m_index); } 0239 /// Const access to the z coordinate of the space point. 0240 /// @return The z coordinate of the space point. 0241 float z() const noexcept { return m_container->z(m_index); } 0242 /// Const access to the r coordinate of the space point. 0243 /// @return The r coordinate of the space point. 0244 float r() const noexcept { return m_container->r(m_index); } 0245 /// Const access to the phi coordinate of the space point. 0246 /// @return The phi coordinate of the space point. 0247 float phi() const noexcept { return m_container->phi(m_index); } 0248 /// Const access to the time information of the space point. 0249 /// @return An optional containing the time information of the space point, or 0250 float time() const noexcept { return m_container->time(m_index); } 0251 /// Const access to the variance in Z direction of the space point. 0252 /// @return The variance in Z direction of the space point. 0253 float varianceZ() const noexcept { return m_container->varianceZ(m_index); } 0254 /// Const access to the variance in R direction of the space point. 0255 /// @return The variance in R direction of the space point. 0256 float varianceR() const noexcept { return m_container->varianceR(m_index); } 0257 /// Const access to the top strip vector of the space point. 0258 /// @return A const reference to the top strip vector of the space point. 0259 const std::array<float, 3> &topStripVector() const noexcept { 0260 return m_container->topStripVector(m_index); 0261 } 0262 /// Const access to the bottom strip vector of the space point. 0263 /// @return A const reference to the bottom strip vector of the space point. 0264 const std::array<float, 3> &bottomStripVector() const noexcept { 0265 return m_container->bottomStripVector(m_index); 0266 } 0267 /// Const access to the strip center distance of the space point. 0268 /// @return A const reference to the strip center distance of the space point. 0269 const std::array<float, 3> &stripCenterDistance() const noexcept { 0270 return m_container->stripCenterDistance(m_index); 0271 } 0272 /// Const access to the top strip center of the space point. 0273 /// @return A const reference to the top strip center of the space point. 0274 const std::array<float, 3> &topStripCenter() const noexcept { 0275 return m_container->topStripCenter(m_index); 0276 } 0277 /// Const access to the copy from index of the space point. 0278 /// @return A const reference to the copy from index of the space point. 0279 SpacePointIndex2 copyFromIndex() const noexcept { 0280 return m_container->copyFromIndex(m_index); 0281 } 0282 /// @brief Get const reference to XY coordinates of the space point 0283 /// @return Const reference to array containing [x, y] coordinates 0284 const std::array<float, 2> &xy() const noexcept { 0285 return m_container->xy(m_index); 0286 } 0287 /// @brief Get const reference to ZR coordinates of the space point 0288 /// @return Const reference to array containing [z, r] coordinates 0289 const std::array<float, 2> &zr() const noexcept { 0290 return m_container->zr(m_index); 0291 } 0292 /// @brief Get const reference to XYZR coordinates of the space point 0293 /// @return Const reference to array containing [x, y, z, r] coordinates 0294 const std::array<float, 4> &xyzr() const noexcept { 0295 return m_container->xyzr(m_index); 0296 } 0297 /// @brief Get const reference to ZR coordinate variances 0298 /// @return Const reference to array containing [var_z, var_r] variances 0299 const std::array<float, 2> &varianceZR() const noexcept { 0300 return m_container->varianceZR(m_index); 0301 } 0302 0303 /// Const access to an extra column of data for the space point. 0304 /// @param column The extra column proxy to access. 0305 /// @return A const reference to the value in the extra column for the space point. 0306 template <typename T> 0307 const T &extra(const ConstSpacePointColumnProxy<T> &column) const noexcept { 0308 return column[m_index]; 0309 } 0310 0311 /// Returns the resolved index of the space point. 0312 /// This resolves the index if the space point was copied from another index. 0313 /// @return The resolved index of the space point. 0314 SpacePointIndex2 resolvedIndex() const noexcept { 0315 return m_container->resolvedIndex(m_index); 0316 } 0317 0318 private: 0319 Container *m_container{}; 0320 Index m_index{}; 0321 }; 0322 0323 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|