Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Acts/Seeding/BinnedGroupIterator.ipp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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