File indexing completed on 2026-07-27 08:32:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Utilities/Helpers.hpp"
0012 #include "Acts/Utilities/IMultiAxis.hpp"
0013
0014 #include <algorithm>
0015
0016 namespace Acts {
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 template <AxisConcept... Axes>
0032 class MultiAxis : public IMultiAxisXD<sizeof...(Axes)> {
0033 public:
0034
0035 using Base = IMultiAxisXD<sizeof...(Axes)>;
0036
0037
0038 static constexpr std::size_t DIM = Base::DIM;
0039
0040 using GlobalBin = typename Base::GlobalBin;
0041
0042 using LocalBins = typename Base::LocalBins;
0043
0044 using Point = typename Base::Point;
0045
0046
0047 using AxesTuple = std::tuple<Axes...>;
0048
0049
0050
0051 explicit MultiAxis(const std::tuple<Axes...>& axes) : m_axes(axes) {}
0052
0053
0054
0055 explicit MultiAxis(std::tuple<Axes...>&& axes) : m_axes(std::move(axes)) {}
0056
0057
0058
0059 explicit MultiAxis(Axes&&... axes) : m_axes(std::forward_as_tuple(axes...)) {}
0060
0061
0062
0063 explicit MultiAxis(const Axes&... axes) : m_axes(std::tuple(axes...)) {}
0064
0065
0066 const IAxis& getAxis(std::size_t i) const final {
0067 return template_switch_lambda<0, DIM - 1>(
0068 i, [this]<typename T>(T) -> const IAxis& {
0069 constexpr std::size_t iValue = T::value;
0070 return std::get<iValue>(m_axes);
0071 });
0072 }
0073
0074
0075
0076 const AxesTuple& getAxesTuple() const { return m_axes; }
0077
0078
0079 LocalBins getNBins() const final {
0080 return detail::MultiAxisHelper::getNBins(m_axes);
0081 }
0082
0083
0084 Point getMinPoint() const final {
0085 return detail::MultiAxisHelper::getMin(m_axes);
0086 }
0087
0088
0089 Point getMaxPoint() const final {
0090 return detail::MultiAxisHelper::getMax(m_axes);
0091 }
0092
0093
0094 bool isInside(const Point& point) const final {
0095 return detail::MultiAxisHelper::isInside(point, m_axes);
0096 }
0097
0098
0099 Point getLowerLeftBinEdge(const LocalBins& localBins) const final {
0100 return detail::MultiAxisHelper::getLowerLeftBinEdge(localBins, m_axes);
0101 }
0102
0103
0104 Point getUpperRightBinEdge(const LocalBins& localBins) const final {
0105 return detail::MultiAxisHelper::getUpperRightBinEdge(localBins, m_axes);
0106 }
0107
0108
0109 Point getBinCenter(const LocalBins& localBins) const final {
0110 return detail::MultiAxisHelper::getBinCenter(localBins, m_axes);
0111 }
0112
0113
0114 Point getBinWidth(const LocalBins& localBins) const final {
0115 return detail::MultiAxisHelper::getBinWidth(localBins, m_axes);
0116 }
0117
0118
0119 GlobalBin getGlobalBinFromPoint(const Point& point) const final {
0120 return getGlobalBinFromLocalBins(getLocalBinsFromPoint(point));
0121 }
0122
0123
0124 GlobalBin getGlobalBinFromLocalBins(const LocalBins& localBins) const final {
0125 return detail::MultiAxisHelper::getGlobalBinFromLocalBins(localBins,
0126 m_axes);
0127 }
0128
0129
0130 LocalBins getLocalBinsFromPoint(const Point& point) const final {
0131 return detail::MultiAxisHelper::getLocalBinsFromPoint(point, m_axes);
0132 }
0133
0134
0135
0136
0137
0138
0139 LocalBins getLocalBinsFromLowerLeftEdge(const Point& point) const {
0140 return detail::MultiAxisHelper::getLocalBinsFromLowerLeftEdge(
0141 point, m_axes.getAxesTuple());
0142 }
0143
0144
0145 LocalBins getLocalBinsFromGlobalBin(GlobalBin globalBin) const final {
0146 return detail::MultiAxisHelper::getLocalBinsFromGlobalBin(globalBin,
0147 m_axes);
0148 }
0149
0150
0151 detail::FlatNeighborHoodIndices<DIM> getNeighborHoodIndices(
0152 const LocalBins& localBins, std::size_t size = 1u) const final {
0153 return detail::MultiAxisHelper::neighborHoodIndices(localBins, size,
0154 m_axes);
0155 }
0156
0157
0158 detail::FlatNeighborHoodIndices<DIM> getNeighborHoodIndices(
0159 const LocalBins& localBins, const std::pair<int, int>& size) const final {
0160 return detail::MultiAxisHelper::neighborHoodIndices(localBins, size,
0161 m_axes);
0162 }
0163
0164
0165 detail::FlatNeighborHoodIndices<DIM> getNeighborHoodIndices(
0166 const LocalBins& localBins,
0167 const std::array<std::pair<int, int>, DIM>& sizePerAxis) const final {
0168 return detail::MultiAxisHelper::neighborHoodIndices(localBins, sizePerAxis,
0169 m_axes);
0170 }
0171
0172
0173 detail::FlatNeighborHoodIndices<DIM> getClosestPointsIndices(
0174 const LocalBins& localBins) const override {
0175 return getNeighborHoodIndices(localBins, {0, 1});
0176 }
0177
0178
0179 detail::FlatNeighborHoodIndices<DIM> getClosestPointsIndices(
0180 const Point& point) const override {
0181 return getNeighborHoodIndices(getLocalBinsFromPoint(point), {0, 1});
0182 }
0183
0184 private:
0185
0186 std::tuple<Axes...> m_axes;
0187 };
0188
0189 }