Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:18:42

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 #include "Acts/EventData/SeedContainer.hpp"
0010 
0011 #include "Acts/EventData/SpacePointContainer.hpp"
0012 #include "Acts/Utilities/Helpers.hpp"
0013 
0014 #include <limits>
0015 
0016 namespace Acts {
0017 
0018 static_assert(std::ranges::random_access_range<SeedContainer>);
0019 
0020 SeedContainer::SeedContainer() noexcept = default;
0021 
0022 SeedContainer::SeedContainer(const SeedContainer &other) noexcept = default;
0023 
0024 SeedContainer::SeedContainer(SeedContainer &&other) noexcept = default;
0025 
0026 SeedContainer &SeedContainer::operator=(const SeedContainer &other) noexcept =
0027     default;
0028 
0029 SeedContainer &SeedContainer::operator=(SeedContainer &&other) noexcept =
0030     default;
0031 
0032 void SeedContainer::reserve(Index size, float averageSpacePoints) noexcept {
0033   m_spacePointOffsets.reserve(size);
0034   m_spacePointCounts.reserve(size);
0035   m_qualities.reserve(size);
0036   m_vertexZs.reserve(size);
0037   m_spacePoints.reserve(static_cast<std::size_t>(size * averageSpacePoints));
0038 }
0039 
0040 void SeedContainer::clear() noexcept {
0041   m_size = 0;
0042 
0043   m_spacePointOffsets.clear();
0044   m_spacePointCounts.clear();
0045   m_qualities.clear();
0046   m_vertexZs.clear();
0047   m_spacePoints.clear();
0048 }
0049 
0050 void SeedContainer::assignSpacePointContainer(
0051     SpacePointContainer &&spacePointContainer) noexcept {
0052   auto movedContainer =
0053       std::make_shared<SpacePointContainer>(std::move(spacePointContainer));
0054 
0055   m_sharedConstSpacePointContainer = movedContainer;
0056   m_constSpacePointContainer = movedContainer.get();
0057   m_mutableSpacePointContainer = movedContainer.get();
0058 }
0059 
0060 void SeedContainer::assignSpacePointContainer(
0061     SpacePointContainer &spacePointContainer) noexcept {
0062   m_sharedConstSpacePointContainer = nullptr;
0063   m_mutableSpacePointContainer = &spacePointContainer;
0064   m_constSpacePointContainer = &spacePointContainer;
0065 }
0066 
0067 void SeedContainer::assignSpacePointContainer(
0068     const SpacePointContainer &spacePointContainer) noexcept {
0069   m_sharedConstSpacePointContainer = nullptr;
0070   m_constSpacePointContainer = &spacePointContainer;
0071   m_mutableSpacePointContainer = nullptr;
0072 }
0073 
0074 void SeedContainer::assignSpacePointContainer(
0075     const std::shared_ptr<SpacePointContainer> &spacePointContainer) noexcept {
0076   m_sharedConstSpacePointContainer = spacePointContainer;
0077   m_constSpacePointContainer = spacePointContainer.get();
0078   m_mutableSpacePointContainer = spacePointContainer.get();
0079 }
0080 
0081 void SeedContainer::assignSpacePointContainer(
0082     const std::shared_ptr<const SpacePointContainer>
0083         &spacePointContainer) noexcept {
0084   m_sharedConstSpacePointContainer = spacePointContainer;
0085   m_constSpacePointContainer = spacePointContainer.get();
0086   m_mutableSpacePointContainer = nullptr;
0087 }
0088 
0089 bool SeedContainer::hasSpacePointContainer() const noexcept {
0090   return m_constSpacePointContainer != nullptr;
0091 }
0092 
0093 bool SeedContainer::hasMutableSpacePointContainer() const noexcept {
0094   return m_mutableSpacePointContainer != nullptr;
0095 }
0096 
0097 SpacePointContainer &SeedContainer::mutableSpacePointContainer() {
0098   if (!hasMutableSpacePointContainer()) {
0099     throw std::logic_error(
0100         "No mutable SpacePointContainer assigned to SeedContainer");
0101   }
0102   return *m_mutableSpacePointContainer;
0103 }
0104 
0105 const SpacePointContainer &SeedContainer::spacePointContainer() const {
0106   if (!hasSpacePointContainer()) {
0107     throw std::logic_error("No SpacePointContainer assigned to SeedContainer");
0108   }
0109   return *m_constSpacePointContainer;
0110 }
0111 
0112 MutableSeedProxy SeedContainer::createSeed() noexcept {
0113   ++m_size;
0114 
0115   m_spacePointOffsets.push_back(
0116       static_cast<std::uint32_t>(m_spacePoints.size()));
0117   m_spacePointCounts.push_back(static_cast<std::uint8_t>(0));
0118   m_qualities.push_back(-std::numeric_limits<float>::infinity());
0119   m_vertexZs.push_back(0.f);
0120 
0121   return MutableProxy(*this, size() - 1);
0122 }
0123 
0124 void SeedContainer::copyFrom(Index index, const SeedContainer &otherContainer,
0125                              Index otherIndex, SeedColumns columnsToCopy) {
0126   if (index >= size()) {
0127     throw std::out_of_range("Index out of range in SeedContainer");
0128   }
0129   if (otherIndex >= otherContainer.size()) {
0130     throw std::out_of_range("Other index out of range in SeedContainer");
0131   }
0132 
0133   if (ACTS_CHECK_BIT(columnsToCopy, SeedColumns::SpacePointIndices)) {
0134     at(index).assignSpacePointIndices(
0135         otherContainer.at(otherIndex).spacePointIndices());
0136   }
0137   if (ACTS_CHECK_BIT(columnsToCopy, SeedColumns::Quality)) {
0138     at(index).quality() = otherContainer.at(otherIndex).quality();
0139   }
0140   if (ACTS_CHECK_BIT(columnsToCopy, SeedColumns::VertexZ)) {
0141     at(index).vertexZ() = otherContainer.at(otherIndex).vertexZ();
0142   }
0143 }
0144 
0145 }  // namespace Acts