Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:51:51

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/BinnedGroupIterator.hpp"
0012 
0013 namespace Acts {
0014 
0015 template <typename grid_t>
0016 BinnedGroupIterator<grid_t>::BinnedGroupIterator(
0017     const BinnedGroup<grid_t>& group,
0018     std::array<std::size_t, BinnedGroupIterator<grid_t>::DIM> index,
0019     std::array<std::vector<std::size_t>, BinnedGroupIterator<grid_t>::DIM>
0020         navigation)
0021     : m_group(group), m_gridItr(group.grid(), index, navigation) {
0022   std::array<std::size_t, DIM> endline{};
0023   for (std::size_t i(0ul); i < DIM; ++i) {
0024     endline[i] = navigation[i].size();
0025   }
0026   m_gridItrEnd = typename grid_t::local_iterator_t(m_group->grid(), endline,
0027                                                    std::move(navigation));
0028   findNotEmptyBin();
0029 }
0030 
0031 template <typename grid_t>
0032 bool BinnedGroupIterator<grid_t>::operator==(
0033     const BinnedGroupIterator<grid_t>& other) const {
0034   return m_group.ptr == other.m_group.ptr && m_gridItr == other.m_gridItr;
0035 }
0036 
0037 template <typename grid_t>
0038 BinnedGroupIterator<grid_t>& BinnedGroupIterator<grid_t>::operator++() {
0039   ++m_gridItr;
0040   findNotEmptyBin();
0041   return *this;
0042 }
0043 
0044 template <typename grid_t>
0045 std::tuple<
0046     boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>,
0047     std::size_t,
0048     boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>>
0049 BinnedGroupIterator<grid_t>::operator*() const {
0050   /// Get the global and local position from current iterator. This is the bin
0051   /// with the middle candidate And we know this is not an empty bin
0052   std::array<std::size_t, DIM> localPosition = m_gridItr.localBinsIndices();
0053   std::size_t global_index =
0054       m_group->grid().globalBinFromLocalBins(localPosition);
0055 
0056   /// Get the neighbouring bins
0057   boost::container::small_vector<std::size_t, detail::ipow(3, DIM)> bottoms =
0058       m_group->m_bottomBinFinder->findBins(localPosition, m_group->grid());
0059   boost::container::small_vector<std::size_t, detail::ipow(3, DIM)> tops =
0060       m_group->m_topBinFinder->findBins(localPosition, m_group->grid());
0061 
0062   // GCC12+ in Release throws an overread warning here due to the move.
0063   // This is from inside boost code, so best we can do is to suppress it.
0064 #if defined(__GNUC__) && __GNUC__ >= 12 && !defined(__clang__)
0065 #pragma GCC diagnostic push
0066 #pragma GCC diagnostic ignored "-Wstringop-overread"
0067 #endif
0068   return {std::move(bottoms), global_index, std::move(tops)};
0069 #if defined(__GNUC__) && __GNUC__ >= 12 && !defined(__clang__)
0070 #pragma GCC diagnostic pop
0071 #endif
0072 }
0073 
0074 template <typename grid_t>
0075 void BinnedGroupIterator<grid_t>::findNotEmptyBin() {
0076   if (m_gridItr == m_gridItrEnd) {
0077     return;
0078   }
0079   /// Iterate on the grid till we find a not-empty bin
0080   /// We start from the current bin configuration and move forward
0081   std::size_t dimCollection = (*m_gridItr).size();
0082   // Check if the current global bin is masked. This only makes sense if
0083   // we have not reached the end of the mask
0084   bool passesMask = false;
0085   if (m_gridItr != m_gridItrEnd) {
0086     passesMask = m_group->mask().at(m_gridItr.globalBinIndex());
0087   }
0088   // loop and only stop when we find a non-empty bin which is not masked
0089   while ((dimCollection == 0ul || !passesMask) &&
0090          (++m_gridItr != m_gridItrEnd)) {
0091     dimCollection = (*m_gridItr).size();
0092     if (dimCollection == 0ul) {
0093       continue;
0094     }
0095     passesMask = m_group->mask().at(m_gridItr.globalBinIndex());
0096   }
0097 }
0098 
0099 }  // namespace Acts