File indexing completed on 2025-12-13 09:21:18
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Geometry/IndexGrid.hpp"
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Utilities/IAxis.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015
0016 #include <algorithm>
0017 #include <array>
0018 #include <set>
0019 #include <string>
0020 #include <vector>
0021
0022 std::vector<std::size_t> Acts::binSequence(
0023 std::array<std::size_t, 2u> minMaxBins, std::size_t expand,
0024 std::size_t nBins, Acts::AxisBoundaryType type) {
0025
0026 std::vector<std::size_t> rBins;
0027
0028
0029
0030
0031 auto fill_linear = [&](std::size_t lmin, std::size_t lmax) -> void {
0032 for (std::size_t b = lmin; b <= lmax; ++b) {
0033 rBins.push_back(b);
0034 }
0035 };
0036 std::size_t bmin = minMaxBins[0u];
0037 std::size_t bmax = minMaxBins[1u];
0038
0039
0040 if (type != Acts::AxisBoundaryType::Closed) {
0041 rBins.reserve(bmax - bmin + 1u + 2 * expand);
0042
0043 if (type == Acts::AxisBoundaryType::Bound) {
0044 bmin = bmin > expand ? bmin - expand : 1u;
0045 bmax = (bmax + expand <= nBins) ? bmax + expand : nBins;
0046 } else if (type == Acts::AxisBoundaryType::Open) {
0047 bmin = bmin >= expand ? bmin - expand : 0u;
0048 bmax = (bmax + expand <= nBins + 1u) ? bmax + expand : nBins + 1u;
0049 }
0050 fill_linear(bmin, bmax);
0051 } else {
0052
0053 std::size_t span = bmax - bmin + 1u + 2 * expand;
0054
0055 if (2 * span < nBins && (bmax + expand <= nBins) && (bmin > expand)) {
0056 return binSequence({bmin, bmax}, expand, nBins,
0057 Acts::AxisBoundaryType::Bound);
0058 } else if (2 * span < nBins) {
0059 bmin = bmin > expand ? bmin - expand : 1u;
0060 bmax = bmax + expand <= nBins ? bmax + expand : nBins;
0061 fill_linear(bmin, bmax);
0062
0063 if (bmax + expand > nBins) {
0064 std::size_t overstep = (bmax + expand - nBins);
0065 fill_linear(1u, overstep);
0066 }
0067 if (bmin <= expand) {
0068 std::size_t understep = expand - bmin;
0069 fill_linear(nBins - understep, nBins);
0070 }
0071 std::ranges::sort(rBins);
0072 } else {
0073
0074 fill_linear(bmax - expand, nBins);
0075 fill_linear(1, bmin + expand);
0076 std::ranges::sort(rBins);
0077 }
0078 }
0079 return rBins;
0080 }