Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:41:29

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/Seeding/BinnedGroup.hpp"
0012 
0013 #include <numeric>
0014 
0015 namespace Acts {
0016 
0017 template <typename grid_t>
0018 BinnedGroup<grid_t>::BinnedGroup(
0019     grid_t&& grid, const GridBinFinder<BinnedGroup<grid_t>::DIM>& bottomFinder,
0020     const GridBinFinder<BinnedGroup<grid_t>::DIM>& topFinder,
0021     std::array<std::vector<std::size_t>, BinnedGroup<grid_t>::DIM> navigation)
0022     : m_grid(std::move(grid)),
0023       m_mask(m_grid.size(true), true),
0024       m_bottomBinFinder(&bottomFinder),
0025       m_topBinFinder(&topFinder),
0026       m_bins(std::move(navigation)) {
0027   /// If navigation is not defined for all axes, then we default that to a
0028   /// std::iota from 1ul
0029   std::array<std::size_t, DIM> numLocBins = m_grid.numLocalBins();
0030   for (std::size_t i(0ul); i < DIM; ++i) {
0031     if (!m_bins[i].empty()) {
0032       continue;
0033     }
0034     m_bins[i].resize(numLocBins[i]);
0035     std::iota(m_bins[i].begin(), m_bins[i].end(), 1ul);
0036   }
0037 }
0038 
0039 template <typename grid_t>
0040 BinnedGroup<grid_t>::BinnedGroup(
0041     grid_t&& grid, std::vector<bool> mask,
0042     const GridBinFinder<BinnedGroup<grid_t>::DIM>& bottomFinder,
0043     const GridBinFinder<BinnedGroup<grid_t>::DIM>& topFinder,
0044     std::array<std::vector<std::size_t>, BinnedGroup<grid_t>::DIM> navigation)
0045     : m_grid(std::move(grid)),
0046       m_mask(std::move(mask)),
0047       m_bottomBinFinder(&bottomFinder),
0048       m_topBinFinder(&topFinder),
0049       m_bins(std::move(navigation)) {
0050   // Check the elements in the mask corresponds to all the global bins in the
0051   // grid so that we can check if a global bin is masked
0052   if (m_mask.size() != m_grid.size(true)) {
0053     throw std::invalid_argument(
0054         "Provided mask does not match the grid. The number of entries must "
0055         "correspond to the number of global bins in the grid.");
0056   }
0057 
0058   /// If navigation is not defined for all axes, then we default that to a
0059   /// std::iota from 1ul
0060   std::array<std::size_t, DIM> numLocBins = m_grid.numLocalBins();
0061   for (std::size_t i(0ul); i < DIM; ++i) {
0062     if (!m_bins[i].empty()) {
0063       continue;
0064     }
0065     m_bins[i].resize(numLocBins[i]);
0066     std::iota(m_bins[i].begin(), m_bins[i].end(), 1ul);
0067   }
0068 }
0069 
0070 template <typename grid_t>
0071 const grid_t& BinnedGroup<grid_t>::grid() const {
0072   return m_grid;
0073 }
0074 
0075 template <typename grid_t>
0076 grid_t& BinnedGroup<grid_t>::grid() {
0077   return m_grid;
0078 }
0079 
0080 template <typename grid_t>
0081 const std::vector<bool>& BinnedGroup<grid_t>::mask() const {
0082   return m_mask;
0083 }
0084 
0085 template <typename grid_t>
0086 BinnedGroupIterator<grid_t> BinnedGroup<grid_t>::begin() const {
0087   return BinnedGroupIterator<grid_t>(
0088       *this, std::array<std::size_t, BinnedGroup<grid_t>::DIM>(), m_bins);
0089 }
0090 
0091 template <typename grid_t>
0092 BinnedGroupIterator<grid_t> BinnedGroup<grid_t>::end() const {
0093   std::array<std::size_t, BinnedGroup<grid_t>::DIM> endline{};
0094   for (std::size_t i(0ul); i < BinnedGroup<grid_t>::DIM; ++i) {
0095     endline[i] = m_bins[i].size();
0096   }
0097   return BinnedGroupIterator<grid_t>(*this, endline, m_bins);
0098 }
0099 
0100 }  // namespace Acts