Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:11:10

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/Utilities/Holders.hpp"
0012 #include "Acts/Utilities/detail/grid_helper.hpp"
0013 
0014 #include <array>
0015 #include <tuple>
0016 
0017 #include <boost/container/small_vector.hpp>
0018 
0019 namespace Acts {
0020 
0021 template <typename grid_t>
0022 class BinnedGroup;
0023 
0024 template <typename grid_t>
0025 class BinnedGroupIterator {
0026  public:
0027   static constexpr std::size_t DIM = grid_t::DIM;
0028 
0029   /// @brief Constructor
0030   /// Never take the ownership of the group
0031   ///
0032   /// @param [in] group The group we are iterating on
0033   /// @param [in] index Current local position in the grid
0034   /// @param [in] navigation The navigation pattern in the grid
0035   BinnedGroupIterator(
0036       BinnedGroup<grid_t>&& group, std::array<std::size_t, DIM> index,
0037       std::array<std::vector<std::size_t>, DIM> navigation) = delete;
0038 
0039   /// @brief Constructor
0040   /// Never take the ownership of the group
0041   ///
0042   /// @param [in] group The group we are iterating on
0043   /// @param [in] index Current local position in the grid
0044   /// @param [in] navigation The navigation pattern in the grid
0045   BinnedGroupIterator(
0046       const BinnedGroup<grid_t>&& group, std::array<std::size_t, DIM> index,
0047       std::array<std::vector<std::size_t>, DIM> navigation) = delete;
0048 
0049   /// @brief Constructor
0050   /// @param [in] group The group we are iterating on
0051   /// @param [in] index Current local position in the grid
0052   /// @param [in] navigation The navigation pattern in the grid
0053   BinnedGroupIterator(const BinnedGroup<grid_t>& group,
0054                       std::array<std::size_t, DIM> index,
0055                       std::array<std::vector<std::size_t>, DIM> navigation);
0056 
0057   /// Do not allow Copy operations
0058 
0059   /// @brief Copy Constructor
0060   /// @param [in] other The BinnedGroupIterator to copy
0061   BinnedGroupIterator(const BinnedGroupIterator<grid_t>& other) = delete;
0062   /// @brief Copy assignment
0063   /// @param [in] other The BinnedGroupIterator to copy
0064   /// @return The copied BinnedGroupIterator
0065   BinnedGroupIterator<grid_t>& operator=(
0066       const BinnedGroupIterator<grid_t>& other) = delete;
0067 
0068   /// @brief Move Constructor
0069   /// @param [in] other The BinnedGroupIterator to move
0070   BinnedGroupIterator(BinnedGroupIterator<grid_t>&& other) noexcept = default;
0071   /// @brief Move assignment
0072   /// @param [in] other The BinnedGroupIterator to move
0073   /// @return The moved BinnedGroupIterator
0074   BinnedGroupIterator<grid_t>& operator=(BinnedGroupIterator&& other) noexcept =
0075       default;
0076 
0077   /// @brief Default Destructor
0078   ~BinnedGroupIterator() = default;
0079 
0080   /// @brief Equality operator
0081   /// @param [in] other The BinnedGroupIterator we are comparing against this one
0082   /// @return The result of the comparison
0083   bool operator==(const BinnedGroupIterator<grid_t>& other) const;
0084 
0085   /// @brief Increment the iterator by one (pre)
0086   /// @return The incremented iterator
0087   BinnedGroupIterator<grid_t>& operator++();
0088 
0089   /// @brief Return the current bin with the middle candidate, as well as all the
0090   /// bins with the possible bottom and top candidates
0091   ///
0092   /// @return The collection of all the bins in the grid
0093   std::tuple<
0094       boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>,
0095       std::size_t,
0096       boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>>
0097   operator*() const;
0098 
0099  private:
0100   /// @brief Move to the next not-empty bin in the grid
0101   void findNotEmptyBin();
0102 
0103  private:
0104   /// @brief The group that contains the grid and the bin finders
0105   detail::RefHolder<const BinnedGroup<grid_t>> m_group{nullptr};
0106   /// @brief Current N-dimentional grid iterator
0107   typename grid_t::local_iterator_t m_gridItr;
0108   /// @brief End iterator;
0109   typename grid_t::local_iterator_t m_gridItrEnd;
0110 };
0111 
0112 }  // namespace Acts
0113 
0114 #include "Acts/Seeding/BinnedGroupIterator.ipp"