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