Skip to content

Commit

Permalink
refactor: Range1D becomes special case of RangeXD (#3023)
Browse files Browse the repository at this point in the history
This PR reimplements the `Range1D` as a special case of the more general `RangeXD`. Most importantly, I'm switching the `operator[]` of `RangeXD` to return a 1-dim `RangeXD` with the vector type set to a simple "simple element" container that has reference semantics.

Finally, `Range1D` is typedef'ed to `RangeXD` of dimension 1.

One remaining question is that the naming `XD` is not super well aligned with the rest of our naming (e.g. `Vector2`, `Vector3`), but I'm not sure if `Range`/`Range1` is any better.
  • Loading branch information
paulgessinger authored Mar 13, 2024
1 parent 248a2ab commit 572c49a
Show file tree
Hide file tree
Showing 19 changed files with 436 additions and 383 deletions.
16 changes: 5 additions & 11 deletions Core/include/Acts/Geometry/Extent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/Enumerate.hpp"
#include "Acts/Utilities/Range1D.hpp"
#include "Acts/Utilities/RangeXD.hpp"

#include <array>
Expand Down Expand Up @@ -122,17 +121,17 @@ class Extent {
/// @param bValue is the binning value to be returned
///
/// @return a one dimensional arrange
Range1D<ActsScalar>& range(BinningValue bValue);
auto range(BinningValue bValue) { return m_range[bValue]; }

/// Return the individual 1-dimensional range
///
/// @param bValue is the binning value to be returned
///
/// @return a one dimensional arrange
const Range1D<ActsScalar>& range(BinningValue bValue) const;
Range1D<ActsScalar> range(BinningValue bValue) const;

/// Return the N-dimension range
const RangeXD<binValues, ActsScalar> range() const;
const RangeXD<binValues, ActsScalar>& range() const;

/// Return an D-dimensional sub range according to the
/// the given @param binValues
Expand Down Expand Up @@ -227,16 +226,11 @@ class Extent {
std::array<std::vector<ActsScalar>, binValues> m_valueHistograms;
};

inline Range1D<ActsScalar>& Acts::Extent::range(BinningValue bValue) {
inline Range1D<ActsScalar> Acts::Extent::range(BinningValue bValue) const {
return m_range[bValue];
}

inline const Range1D<ActsScalar>& Acts::Extent::range(
BinningValue bValue) const {
return m_range[bValue];
}

inline const RangeXD<binValues, ActsScalar> Extent::range() const {
inline const RangeXD<binValues, ActsScalar>& Extent::range() const {
return m_range;
}

Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Utilities/DBScan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class DBScan {
// hypercube with a length of 2 epsilon).
typename Tree::range_t range;
for (std::size_t dim = 0; dim < kDims; dim++) {
range[dim] = std::make_pair(currentPoint[dim] - m_eps,
currentPoint[dim] + m_eps);
range[dim] = Range1D<scalar_t>(currentPoint[dim] - m_eps,
currentPoint[dim] + m_eps);
}
// We use the KDTree to find the neighbours.
// An extra cut needs to be applied to only keep the neighbours that
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Utilities/KDTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class KDTree {
using value_t = Type;

/// @brief The type describing a multi-dimensional orthogonal range.
using range_t = RangeXD<Dims, Scalar, Vector>;
using range_t = RangeXD<Dims, Scalar>;

/// @brief The type of coordinates for points.
using coordinate_t = Vector<Scalar, Dims>;
Expand Down Expand Up @@ -303,7 +303,7 @@ class KDTree {
range_t r;

for (std::size_t j = 0; j < Dims; ++j) {
r[j] = {min_v[j], nextRepresentable(max_v[j])};
r[j] = Range1D<Scalar>{min_v[j], nextRepresentable(max_v[j])};
}

return r;
Expand Down
Loading

0 comments on commit 572c49a

Please sign in to comment.