Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/include/Acts/Material/InterpolatedMaterialMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct MaterialMapLookup {
MaterialCell getMaterialCell(const Vector3& position) const {
const auto& gridPosition = m_transformPos(position);
std::size_t bin = m_grid.globalBinFromPosition(gridPosition);
const auto& indices = m_grid.localBinsFromPosition(bin);
const auto& indices = m_grid.localBinsFromGlobalBin(bin);
Comment thread
AJPfleger marked this conversation as resolved.
const auto& lowerLeft = m_grid.lowerLeftBinEdge(indices);
const auto& upperRight = m_grid.upperRightBinEdge(indices);

Expand Down
33 changes: 5 additions & 28 deletions Core/include/Acts/Seeding/BinnedGroupIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#pragma once

#include "Acts/Utilities/Holders.hpp"
#include "Acts/Utilities/detail/grid_helper.hpp"
#include "Acts/Utilities/MathHelpers.hpp"

#include <array>
#include <tuple>
#include <vector>

#include <boost/container/small_vector.hpp>

Expand Down Expand Up @@ -57,29 +58,6 @@ class BinnedGroupIterator {
std::array<std::size_t, DIM> index,
std::array<std::vector<std::size_t>, DIM> navigation);

/// Do not allow Copy operations
Comment thread
AJPfleger marked this conversation as resolved.

/// @brief Copy Constructor
/// @param [in] other The BinnedGroupIterator to copy
BinnedGroupIterator(const BinnedGroupIterator<grid_t>& other) = delete;
/// @brief Copy assignment
/// @param [in] other The BinnedGroupIterator to copy
/// @return The copied BinnedGroupIterator
BinnedGroupIterator<grid_t>& operator=(
const BinnedGroupIterator<grid_t>& other) = delete;

/// @brief Move Constructor
/// @param [in] other The BinnedGroupIterator to move
BinnedGroupIterator(BinnedGroupIterator<grid_t>&& other) noexcept = default;
/// @brief Move assignment
/// @param [in] other The BinnedGroupIterator to move
/// @return The moved BinnedGroupIterator
BinnedGroupIterator<grid_t>& operator=(BinnedGroupIterator&& other) noexcept =
default;

/// @brief Default Destructor
~BinnedGroupIterator() = default;

/// @brief Equality operator
/// @param [in] other The BinnedGroupIterator we are comparing against this one
/// @return The result of the comparison
Expand All @@ -93,10 +71,9 @@ class BinnedGroupIterator {
/// bins with the possible bottom and top candidates
///
/// @return The collection of all the bins in the grid
std::tuple<
boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>,
std::size_t,
boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>>
std::tuple<boost::container::small_vector<std::size_t, ipow(3, grid_t::DIM)>,
std::size_t,
boost::container::small_vector<std::size_t, ipow(3, grid_t::DIM)>>
operator*() const;

private:
Expand Down
11 changes: 5 additions & 6 deletions Core/include/Acts/Seeding/BinnedGroupIterator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ BinnedGroupIterator<grid_t>& BinnedGroupIterator<grid_t>::operator++() {
}

template <typename grid_t>
std::tuple<
boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>,
std::size_t,
boost::container::small_vector<std::size_t, detail::ipow(3, grid_t::DIM)>>
std::tuple<boost::container::small_vector<std::size_t, ipow(3, grid_t::DIM)>,
std::size_t,
boost::container::small_vector<std::size_t, ipow(3, grid_t::DIM)>>
BinnedGroupIterator<grid_t>::operator*() const {
/// Get the global and local position from current iterator. This is the bin
/// with the middle candidate And we know this is not an empty bin
Expand All @@ -54,9 +53,9 @@ BinnedGroupIterator<grid_t>::operator*() const {
m_group->grid().globalBinFromLocalBins(localPosition);

/// Get the neighbouring bins
boost::container::small_vector<std::size_t, detail::ipow(3, DIM)> bottoms =
boost::container::small_vector<std::size_t, ipow(3, DIM)> bottoms =
m_group->m_bottomBinFinder->findBins(localPosition, m_group->grid());
boost::container::small_vector<std::size_t, detail::ipow(3, DIM)> tops =
boost::container::small_vector<std::size_t, ipow(3, DIM)> tops =
m_group->m_topBinFinder->findBins(localPosition, m_group->grid());

// GCC12+ in Release throws an overread warning here due to the move.
Expand Down
11 changes: 5 additions & 6 deletions Core/include/Acts/Seeding/SeedFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Acts/Seeding/SeedFinderUtils.hpp"
#include "Acts/Seeding/detail/UtilityFunctions.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/MathHelpers.hpp"
#include "Acts/Utilities/RangeXD.hpp"

#include <memory>
Expand Down Expand Up @@ -75,12 +76,10 @@ SeedFinder {
/// Managing seed candidates for SpM
CandidatesForMiddleSp<const external_space_point_t> candidatesCollector{};
/// Managing bottom doublet candidates
boost::container::small_vector<Neighbour<grid_t>,
detail::ipow(3, grid_t::DIM)>
boost::container::small_vector<Neighbour<grid_t>, ipow(3, grid_t::DIM)>
bottomNeighbours{};
/// Managing top doublet candidates
boost::container::small_vector<Neighbour<grid_t>,
detail::ipow(3, grid_t::DIM)>
boost::container::small_vector<Neighbour<grid_t>, ipow(3, grid_t::DIM)>
topNeighbours{};

/// Mutable variables for Space points used in the seeding
Expand Down Expand Up @@ -148,8 +147,8 @@ SeedFinder {
void getCompatibleDoublets(
const SeedFinderOptions& options, const grid_t& grid,
SpacePointMutableData& mutableData,
boost::container::small_vector<
Neighbour<grid_t>, detail::ipow(3, grid_t::DIM)>& otherSPsNeighbours,
boost::container::small_vector<Neighbour<grid_t>, ipow(3, grid_t::DIM)>&
otherSPsNeighbours,
const external_space_point_t& mediumSP,
std::vector<LinCircle>& linCircleVec, out_range_t& outVec,
const float deltaRMinSP, const float deltaRMaxSP, const float uIP,
Expand Down
6 changes: 4 additions & 2 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "Acts/Seeding/SeedFinder.hpp"

#include "Acts/Utilities/MathHelpers.hpp"

#include <algorithm>
#include <cmath>

Expand Down Expand Up @@ -205,8 +207,8 @@ inline void
SeedFinder<external_space_point_t, grid_t, platform_t>::getCompatibleDoublets(
const SeedFinderOptions& options, const grid_t& grid,
SpacePointMutableData& mutableData,
boost::container::small_vector<
Neighbour<grid_t>, detail::ipow(3, grid_t::DIM)>& otherSPsNeighbours,
boost::container::small_vector<Neighbour<grid_t>, ipow(3, grid_t::DIM)>&
otherSPsNeighbours,
const external_space_point_t& mediumSP,
std::vector<LinCircle>& linCircleVec, out_range_t& outVec,
const float deltaRMinSP, const float deltaRMaxSP, const float uIP,
Expand Down
58 changes: 34 additions & 24 deletions Core/include/Acts/Utilities/Grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "Acts/Utilities/IAxis.hpp"
#include "Acts/Utilities/Interpolation.hpp"
#include "Acts/Utilities/TypeTag.hpp"
#include "Acts/Utilities/detail/grid_helper.hpp"
#include "Acts/Utilities/detail/MultiAxisHelper.hpp"
#include "Acts/Utilities/detail/interpolation_impl.hpp"

#include <algorithm>
Expand Down Expand Up @@ -300,7 +300,7 @@ class Grid final : public IGrid {
/// dimensions where d is dimensionality of the grid. It must lie
/// within the grid range (i.e. not within a under-/overflow bin).
template <class Point>
detail::GlobalNeighborHoodIndices<DIM> closestPointsIndices(
detail::FlatNeighborHoodIndices<DIM> closestPointsIndices(
const Point& position) const {
return rawClosestPointsIndices(localBinsFromPosition(position));
}
Expand All @@ -321,7 +321,7 @@ class Grid final : public IGrid {
/// @pre All local bin indices must be a valid index for the corresponding
/// axis (excluding the under-/overflow bins for each axis).
point_t binCenter(const index_t& localBins) const {
return detail::grid_helper::getBinCenter(localBins, m_axes);
return detail::MultiAxisHelper::getBinCenter(localBins, m_axes);
}

AnyPointType binCenterAny(AnyIndexType indices) const override {
Expand Down Expand Up @@ -352,7 +352,8 @@ class Grid final : public IGrid {
/// @pre All local bin indices must be a valid index for the corresponding
/// axis (including the under-/overflow bin for this axis).
std::size_t globalBinFromLocalBins(const index_t& localBins) const {
return detail::grid_helper::getGlobalBin(localBins, m_axes);
return detail::MultiAxisHelper::getFlatIndexFromMultiIndex(localBins,
m_axes);
}

/// @brief determine global bin index of the bin with the lower left edge
Expand Down Expand Up @@ -386,7 +387,7 @@ class Grid final : public IGrid {
/// @note This could be a under-/overflow bin along one or more axes.
template <class Point>
index_t localBinsFromPosition(const Point& point) const {
return detail::grid_helper::getLocalBinIndices(point, m_axes);
return detail::MultiAxisHelper::getMultiIndexFromPoint(point, m_axes);
}

/// @brief determine local bin index for each axis from global bin index
Expand All @@ -398,7 +399,7 @@ class Grid final : public IGrid {
/// @note Local bin indices can contain under-/overflow bins along the
/// corresponding axis.
index_t localBinsFromGlobalBin(std::size_t bin) const {
return detail::grid_helper::getLocalBinIndices(bin, m_axes);
return detail::MultiAxisHelper::getMultiIndexFromFlatIndex(bin, m_axes);
}

/// @brief determine local bin index of the bin with the lower left edge
Expand All @@ -417,11 +418,12 @@ class Grid final : public IGrid {
template <class Point>
index_t localBinsFromLowerLeftEdge(const Point& point) const {
Point shiftedPoint;
point_t width = detail::grid_helper::getWidth(m_axes);
point_t width = detail::MultiAxisHelper::getWidth(m_axes);
for (std::size_t i = 0; i < DIM; i++) {
shiftedPoint[i] = point[i] + width[i] / 2;
}
return detail::grid_helper::getLocalBinIndices(shiftedPoint, m_axes);
return detail::MultiAxisHelper::getMultiIndexFromPoint(shiftedPoint,
m_axes);
}

/// @brief retrieve lower-left bin edge from set of local bin indices
Expand All @@ -432,7 +434,7 @@ class Grid final : public IGrid {
/// @pre @c localBins must only contain valid bin indices (excluding
/// underflow bins).
point_t lowerLeftBinEdge(const index_t& localBins) const {
return detail::grid_helper::getLowerLeftBinEdge(localBins, m_axes);
return detail::MultiAxisHelper::getLowerLeftBinCorner(localBins, m_axes);
}

/// @copydoc Acts::IGrid::lowerLeftBinEdgeAny
Expand All @@ -448,7 +450,7 @@ class Grid final : public IGrid {
/// @pre @c localBins must only contain valid bin indices (excluding
/// overflow bins).
point_t upperRightBinEdge(const index_t& localBins) const {
return detail::grid_helper::getUpperRightBinEdge(localBins, m_axes);
return detail::MultiAxisHelper::getUpperRightBinCorner(localBins, m_axes);
}

/// @copydoc Acts::IGrid::upperRightBinEdgeAny
Expand All @@ -459,14 +461,16 @@ class Grid final : public IGrid {
/// @brief get bin width along each specific axis
///
/// @return array giving the bin width alonf all axes
point_t binWidth() const { return detail::grid_helper::getWidth(m_axes); }
point_t binWidth() const { return detail::MultiAxisHelper::getWidth(m_axes); }

/// @brief get number of bins along each specific axis
///
/// @return array giving the number of bins along all axes
///
/// @note Not including under- and overflow bins
index_t numLocalBins() const { return detail::grid_helper::getNBins(m_axes); }
index_t numLocalBins() const {
return detail::MultiAxisHelper::getNBins(m_axes);
}

/// @copydoc Acts::IGrid::numLocalBinsAny
AnyIndexType numLocalBinsAny() const override {
Expand All @@ -476,20 +480,25 @@ class Grid final : public IGrid {
/// @brief get the minimum value of all axes of one grid
///
/// @return array returning the minima of all given axes
point_t minPosition() const { return detail::grid_helper::getMin(m_axes); }
point_t minPosition() const {
return detail::MultiAxisHelper::getMin(m_axes);
}

/// @brief get the maximum value of all axes of one grid
///
/// @return array returning the maxima of all given axes
point_t maxPosition() const { return detail::grid_helper::getMax(m_axes); }
point_t maxPosition() const {
return detail::MultiAxisHelper::getMax(m_axes);
}

/// @brief set all overflow and underflow bins to a certain value
///
/// @param [in] value value to be inserted in every overflow and underflow
/// bin of the grid.
///
void setExteriorBins(const value_type& value) {
for (std::size_t index : detail::grid_helper::exteriorBinIndices(m_axes)) {
for (std::size_t index :
detail::MultiAxisHelper::exteriorBinIndices(m_axes)) {
at(index) = value;
}
}
Expand Down Expand Up @@ -562,7 +571,7 @@ class Grid final : public IGrid {
/// along any axis.
template <class Point>
bool isInside(const Point& position) const {
return detail::grid_helper::isInside(position, m_axes);
return detail::MultiAxisHelper::isInside(position, m_axes);
}

/// @brief get global bin indices for neighborhood
Expand All @@ -580,9 +589,10 @@ class Grid final : public IGrid {
/// Ignoring the truncation of the neighborhood size reaching beyond
/// over-/underflow bins, the neighborhood is of size \f$2 \times
/// \text{size}+1\f$ along each dimension.
detail::GlobalNeighborHoodIndices<DIM> neighborHoodIndices(
detail::FlatNeighborHoodIndices<DIM> neighborHoodIndices(
const index_t& localBins, std::size_t size = 1u) const {
return detail::grid_helper::neighborHoodIndices(localBins, size, m_axes);
return detail::MultiAxisHelper::neighborHoodIndices(localBins, size,
m_axes);
}

/// @brief get global bin indices for neighborhood
Expand All @@ -601,11 +611,11 @@ class Grid final : public IGrid {
/// Ignoring the truncation of the neighborhood size reaching beyond
/// over-/underflow bins, the neighborhood is of size \f$2 \times
/// \text{size}+1\f$ along each dimension.
detail::GlobalNeighborHoodIndices<DIM> neighborHoodIndices(
detail::FlatNeighborHoodIndices<DIM> neighborHoodIndices(
const index_t& localBins,
std::array<std::pair<int, int>, DIM>& sizePerAxis) const {
return detail::grid_helper::neighborHoodIndices(localBins, sizePerAxis,
m_axes);
return detail::MultiAxisHelper::neighborHoodIndices(localBins, sizePerAxis,
m_axes);
}

/// @brief total number of bins
Expand Down Expand Up @@ -675,7 +685,7 @@ class Grid final : public IGrid {
/// @return Vector containing pointers to all grid axes
boost::container::small_vector<const IAxis*, 3> axes() const override {
boost::container::small_vector<const IAxis*, 3> result;
auto axes = detail::grid_helper::getAxes(m_axes);
auto axes = detail::MultiAxisHelper::getAxes(m_axes);
std::ranges::copy(axes, std::back_inserter(result));
return result;
}
Expand Down Expand Up @@ -725,9 +735,9 @@ class Grid final : public IGrid {
// Part of closestPointsIndices that goes after local bins resolution.
// Used as an interpolation performance optimization, but not exposed as it
// doesn't make that much sense from an API design standpoint.
detail::GlobalNeighborHoodIndices<DIM> rawClosestPointsIndices(
detail::FlatNeighborHoodIndices<DIM> rawClosestPointsIndices(
const index_t& localBins) const {
return detail::grid_helper::closestPointsIndices(localBins, m_axes);
return detail::MultiAxisHelper::closestPointsIndices(localBins, m_axes);
}

template <std::size_t... Is>
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Utilities/GridBinFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "Acts/Utilities/Concepts.hpp"
#include "Acts/Utilities/Grid.hpp"
#include "Acts/Utilities/detail/grid_helper.hpp"
#include "Acts/Utilities/MathHelpers.hpp"

#include <variant>
#include <vector>
Expand All @@ -29,7 +29,7 @@ template <std::size_t DIM>
class GridBinFinder {
public:
/// Number of neighbor bins in 3^DIM grid configuration
static constexpr std::size_t dimCubed = detail::ipow(3, DIM);
static constexpr std::size_t dimCubed = ipow(3, DIM);

/// Type alias for variant storing different bin finding configurations
using stored_values_t =
Expand Down
10 changes: 10 additions & 0 deletions Core/include/Acts/Utilities/MathHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,14 @@ inline double sinc(double x) {
return std::sin(x) / x;
}

/// Calculate the integer power of a number at compile time using recursion.
Comment thread
andiwand marked this conversation as resolved.
/// @tparam T The type of the base number, which should support multiplication by itself
/// @param num The base number to be raised to a power
/// @param pow The exponent to which the base number is raised
/// @return The result of num raised to the power of pow
template <typename T>
constexpr T ipow(T num, unsigned int pow) {
Comment thread
andiwand marked this conversation as resolved.
Outdated
return (pow == 0) ? 1 : num * ipow(num, pow - 1);
}
Comment thread
andiwand marked this conversation as resolved.

} // namespace Acts
Loading
Loading