File indexing completed on 2026-11-16 09:43:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Utilities/Helpers.hpp"
0013 #include "Acts/Utilities/IMultiAxis.hpp"
0014
0015 #include <algorithm>
0016
0017 namespace Acts {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 template <AxisConcept... Axes>
0033 class MultiAxis : public IMultiAxisXD<sizeof...(Axes)> {
0034 public:
0035
0036 using Base = IMultiAxisXD<sizeof...(Axes)>;
0037
0038
0039 static constexpr std::size_t DIM = Base::DIM;
0040
0041 using GlobalBin = typename Base::GlobalBin;
0042
0043 using LocalBins = typename Base::LocalBins;
0044
0045 using Point = typename Base::Point;
0046
0047 using VectorPoint = Vector<DIM>;
0048
0049
0050 using AxesTuple = std::tuple<Axes...>;
0051
0052
0053
0054 explicit MultiAxis(const std::tuple<Axes...>& axes) : m_axes(axes) {}
0055
0056
0057
0058 explicit MultiAxis(std::tuple<Axes...>&& axes) : m_axes(std::move(axes)) {}
0059
0060
0061
0062 explicit MultiAxis(Axes&&... axes) : m_axes(std::forward_as_tuple(axes...)) {}
0063
0064
0065
0066 explicit MultiAxis(const Axes&... axes) : m_axes(std::tuple(axes...)) {}
0067
0068
0069 const IAxis& getAxis(std::size_t i) const final {
0070 return template_switch_lambda<0, DIM - 1>(
0071 i, [this]<typename T>(T) -> const IAxis& {
0072 constexpr std::size_t iValue = T::value;
0073 return std::get<iValue>(m_axes);
0074 });
0075 }
0076
0077
0078
0079 const AxesTuple& getAxesTuple() const { return m_axes; }
0080
0081
0082 LocalBins getNBins() const final {
0083 return detail::MultiAxisHelper::getNBins(m_axes);
0084 }
0085
0086
0087 Point getMinPoint() const final {
0088 return detail::MultiAxisHelper::getMin(m_axes);
0089 }
0090
0091
0092 Point getMaxPoint() const final {
0093 return detail::MultiAxisHelper::getMax(m_axes);
0094 }
0095
0096
0097 bool isInside(const Point& point) const final {
0098 return detail::MultiAxisHelper::isInside(point, m_axes);
0099 }
0100
0101
0102
0103
0104
0105 template <typename Derived>
0106 bool isInside(const Eigen::MatrixBase<Derived>& point) const {
0107 return detail::MultiAxisHelper::isInside(point.derived(), m_axes);
0108 }
0109
0110
0111 Point getLowerLeftBinEdge(const LocalBins& localBins) const final {
0112 return detail::MultiAxisHelper::getLowerLeftBinEdge(localBins, m_axes);
0113 }
0114
0115
0116 Point getUpperRightBinEdge(const LocalBins& localBins) const final {
0117 return detail::MultiAxisHelper::getUpperRightBinEdge(localBins, m_axes);
0118 }
0119
0120
0121 Point getBinCenter(const LocalBins& localBins) const final {
0122 return detail::MultiAxisHelper::getBinCenter(localBins, m_axes);
0123 }
0124
0125
0126 Point getBinWidth(const LocalBins& localBins) const final {
0127 return detail::MultiAxisHelper::getBinWidth(localBins, m_axes);
0128 }
0129
0130
0131 GlobalBin getGlobalBinFromPoint(const Point& point) const final {
0132 return getGlobalBinFromLocalBins(getLocalBinsFromPoint(point));
0133 }
0134
0135
0136
0137
0138
0139 template <typename Derived>
0140 GlobalBin getGlobalBinFromPoint(
0141 const Eigen::MatrixBase<Derived>& point) const {
0142 return getGlobalBinFromLocalBins(getLocalBinsFromPoint(point));
0143 }
0144
0145
0146
0147
0148
0149 GlobalBin getGlobalBinFromLowerLeftEdge(const Point& point) const {
0150 return getGlobalBinFromLocalBins(getLocalBinsFromLowerLeftEdge(point));
0151 }
0152
0153
0154
0155 template <typename Derived>
0156 GlobalBin getGlobalBinFromLowerLeftEdge(
0157 const Eigen::MatrixBase<Derived>& point) const {
0158 return getGlobalBinFromLocalBins(getLocalBinsFromLowerLeftEdge(point));
0159 }
0160
0161
0162 GlobalBin getGlobalBinFromLocalBins(const LocalBins& localBins) const final {
0163 return detail::MultiAxisHelper::getGlobalBinFromLocalBins(localBins,
0164 m_axes);
0165 }
0166
0167
0168 LocalBins getLocalBinsFromPoint(const Point& point) const final {
0169 return detail::MultiAxisHelper::getLocalBinsFromPoint(point, m_axes);
0170 }
0171
0172
0173
0174
0175
0176 template <typename Derived>
0177 LocalBins getLocalBinsFromPoint(
0178 const Eigen::MatrixBase<Derived>& point) const {
0179 return detail::MultiAxisHelper::getLocalBinsFromPoint(point.derived(),
0180 m_axes);
0181 }
0182
0183
0184
0185
0186
0187
0188 LocalBins getLocalBinsFromLowerLeftEdge(const Point& point) const {
0189 return detail::MultiAxisHelper::getLocalBinsFromLowerLeftEdge(point,
0190 m_axes);
0191 }
0192
0193
0194
0195 template <typename Derived>
0196 LocalBins getLocalBinsFromLowerLeftEdge(
0197 const Eigen::MatrixBase<Derived>& point) const {
0198 return detail::MultiAxisHelper::getLocalBinsFromLowerLeftEdge(
0199 point.derived(), m_axes);
0200 }
0201
0202
0203 LocalBins getLocalBinsFromGlobalBin(GlobalBin globalBin) const final {
0204 return detail::MultiAxisHelper::getLocalBinsFromGlobalBin(globalBin,
0205 m_axes);
0206 }
0207
0208
0209 detail::FlatNeighborHoodIndices<DIM> getNeighborHoodIndices(
0210 const LocalBins& localBins, std::size_t size = 1u) const final {
0211 return detail::MultiAxisHelper::neighborHoodIndices(localBins, size,
0212 m_axes);
0213 }
0214
0215
0216 detail::FlatNeighborHoodIndices<DIM> getNeighborHoodIndices(
0217 const LocalBins& localBins, const std::pair<int, int>& size) const final {
0218 return detail::MultiAxisHelper::neighborHoodIndices(localBins, size,
0219 m_axes);
0220 }
0221
0222
0223 detail::FlatNeighborHoodIndices<DIM> getNeighborHoodIndices(
0224 const LocalBins& localBins,
0225 const std::array<std::pair<int, int>, DIM>& sizePerAxis) const final {
0226 return detail::MultiAxisHelper::neighborHoodIndices(localBins, sizePerAxis,
0227 m_axes);
0228 }
0229
0230
0231 detail::FlatNeighborHoodIndices<DIM> getClosestPointsIndices(
0232 const LocalBins& localBins) const override {
0233 return getNeighborHoodIndices(localBins, {0, 1});
0234 }
0235
0236
0237 detail::FlatNeighborHoodIndices<DIM> getClosestPointsIndices(
0238 const Point& point) const override {
0239 return getNeighborHoodIndices(getLocalBinsFromPoint(point), {0, 1});
0240 }
0241
0242
0243
0244
0245
0246 template <typename Derived>
0247 detail::FlatNeighborHoodIndices<DIM> getClosestPointsIndices(
0248 const Eigen::MatrixBase<Derived>& point) const {
0249 return getNeighborHoodIndices(getLocalBinsFromPoint(point), {0, 1});
0250 }
0251
0252 private:
0253
0254 std::tuple<Axes...> m_axes;
0255 };
0256
0257 }