|
||||
File indexing completed on 2025-01-18 09: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/Concepts.hpp" 0012 #include "Acts/Utilities/Grid.hpp" 0013 #include "Acts/Utilities/Holders.hpp" 0014 #include "Acts/Utilities/detail/grid_helper.hpp" 0015 0016 #include <variant> 0017 #include <vector> 0018 0019 #include <boost/container/small_vector.hpp> 0020 0021 namespace Acts { 0022 0023 /// @class BinFinder 0024 /// @tparam DIM Dimension of the Grid on which the GridBinFinder will be used 0025 /// 0026 /// The BinFinder is used by the ISPGroupSelector. It can be 0027 /// used to find both bins that could be bottom bins as well as bins that could 0028 /// be top bins, which are assumed to be the same bins. Does not take 0029 /// interaction region into account to limit z-bins. 0030 template <std::size_t DIM> 0031 class GridBinFinder { 0032 public: 0033 static constexpr std::size_t dimCubed = Acts::detail::ipow(3, DIM); 0034 /// @brief Constructor 0035 /// @tparam args ... Input parameters provided by the user 0036 /// 0037 /// @param [in] vals The input parameters that define how many neighbours we need to find 0038 /// 0039 /// @pre The provided paramers must be of type 'int', 'std::pair<int, int>' or 'std::vector<std::pair<int, int>>' 0040 /// no other type is allowed. The order of these parameters must correspond to 0041 /// the same ordering of the axes in the grid 0042 template <typename... args> 0043 explicit GridBinFinder(args&&... vals) 0044 requires( 0045 sizeof...(args) == DIM && 0046 (Concepts::same_as_any_of<std::decay_t<args>, int, std::pair<int, int>, 0047 std::vector<std::pair<int, int>>> && 0048 ...)) 0049 { 0050 storeValue(std::forward<args>(vals)...); 0051 } 0052 0053 /// @brief Retrieve the neighbouring bins given a local position in the grid 0054 /// 0055 /// Return all bins that could contain space points that can be used with the 0056 /// space points in the bin with the provided indices to create seeds. 0057 /// 0058 /// @tparam stored_t The type of elements stored in the Grid 0059 /// @tparam Axes ... The type of the axes of the grid 0060 /// 0061 /// @param [in] locPosition The N-dimentional local position in the grid 0062 /// @param [in] grid The grid 0063 /// @return The list of neighbouring bins 0064 /// 0065 /// @pre The provided local position must be a valid local bins configuration in the grid 0066 template <typename stored_t, class... Axes> 0067 boost::container::small_vector<std::size_t, dimCubed> findBins( 0068 const std::array<std::size_t, DIM>& locPosition, 0069 const Acts::Grid<stored_t, Axes...>& grid) const; 0070 0071 private: 0072 /// @brief Store the values provided by the user for each axis in the grid 0073 /// @tparam first_value_t Type of the first value 0074 /// @tparam vals ... values of the remaining values 0075 /// 0076 /// @param [in] fv The first value in the list 0077 /// @param [in] others The remaining values in the list 0078 /// 0079 /// @pre both first_value_t and vals ... can be only int or std::vector<std::pair<int, int>> 0080 /// In the second case, the number of entries of the vector of pairs MUST be 0081 /// equal to the number of bins in that specific axis. Empty vectors are also 0082 /// allowed but in this case the value will be replaced with a 1 (integer), 0083 /// thus instructing the code to look for neighbours in the range {-1 ,1} 0084 template <typename first_value_t, typename... vals> 0085 void storeValue(first_value_t&& fv, vals&&... others); 0086 0087 /// @brief Get the instructions for retrieving the neighbouring bins given a local position 0088 /// 0089 /// @param [in] locPosition The requested local position 0090 /// @return the instructions for retrieving the neighbouring bins for this local position 0091 /// 0092 /// @pre The local position must be a valid local bins configuration for the grid 0093 std::array<std::pair<int, int>, DIM> getSizePerAxis( 0094 const std::array<std::size_t, DIM>& locPosition) const; 0095 0096 /// @brief Check the GridBinFinder configuration is compatible with the grid 0097 /// by checking the values of m_values against the axes of the grid 0098 /// This function is called only in debug mode 0099 /// 0100 /// @tparam stored_t The type of elements stored in the Grid 0101 /// @tparam Axes ... The type of the axes of the grid 0102 /// 0103 /// @param [in] grid The Grid 0104 /// @return If the GridBinFinder is compatible with the grid 0105 template <typename stored_t, class... Axes> 0106 bool isGridCompatible(const Acts::Grid<stored_t, Axes...>& grid) const; 0107 0108 private: 0109 using stored_values_t = 0110 std::variant<int, std::pair<int, int>, std::vector<std::pair<int, int>>>; 0111 /// @brief the instructions for retrieving the nieghbouring bins for each given axis in the grid 0112 /// These values are provided by the user and can be ints, a pair of ints or a 0113 /// vector of pair of ints. In the first case, the neighbours will be +/- bins 0114 /// from the given local bin In the second case, the user defines how many 0115 /// bins in both directions should be provided 0116 /// 0117 /// @pre The list of entries of the vector of pairs MUST be equal to the number of bins in that specific 0118 /// axis. Empty vectors are also allowed but in this case the value will be 0119 /// replaced with a 1 (integer), thus instructing the code to look for 0120 /// neighbours in the range {-1 ,1} 0121 std::array<stored_values_t, DIM> m_values{}; 0122 }; 0123 0124 } // namespace Acts 0125 #include "Acts/Utilities/GridBinFinder.ipp"
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |