File indexing completed on 2025-01-18 09:11:17
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/InternalNavigation.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::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::AxisBoundaryType::Closed) {
0047 rBins.reserve(bmax - bmin + 1u + 2 * expand);
0048
0049 if (type == Acts::AxisBoundaryType::Bound) {
0050 bmin = bmin > expand ? bmin - expand : 1u;
0051 bmax = (bmax + expand <= nBins) ? bmax + expand : nBins;
0052 } else if (type == Acts::AxisBoundaryType::Open) {
0053 bmin = bmin >= expand ? 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) && (bmin > expand)) {
0062 return binSequence({bmin, bmax}, expand, nBins,
0063 Acts::AxisBoundaryType::Bound);
0064 } else if (2 * span < nBins) {
0065 bmin = bmin > expand ? bmin - expand : 1u;
0066 bmax = bmax + expand <= nBins ? bmax + expand : nBins;
0067 fill_linear(bmin, bmax);
0068
0069 if (bmax + expand > nBins) {
0070 std::size_t overstep = (bmax + expand - nBins);
0071 fill_linear(1u, overstep);
0072 }
0073 if (bmin <= expand) {
0074 std::size_t understep = expand - bmin;
0075 fill_linear(nBins - understep, nBins);
0076 }
0077 std::ranges::sort(rBins);
0078 } else {
0079
0080 fill_linear(bmax - expand, nBins);
0081 fill_linear(1, bmin + expand);
0082 std::ranges::sort(rBins);
0083 }
0084 }
0085 return rBins;
0086 }