Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Nov 28, 2024
1 parent 820142d commit 902c6d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 57 deletions.
8 changes: 5 additions & 3 deletions Core/include/Acts/EventData/SubspaceHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "Acts/Utilities/AlgebraHelpers.hpp"
#include "Acts/Utilities/Enumerate.hpp"

#include <ranges>

#include <boost/container/static_vector.hpp>

namespace Acts {
Expand All @@ -29,7 +31,7 @@ namespace Acts {
/// @param subspaceSize the size of the subspace
///
/// @return true if the indices are consistent
template <std::ranges::range index_range_t>
template <std::ranges::sized_range index_range_t>
inline static bool checkSubspaceIndices(const index_range_t& indexRange,
std::size_t fullSize,
std::size_t subspaceSize) {
Expand Down Expand Up @@ -185,7 +187,7 @@ class VariableSubspaceHelper
using IndexType = index_t;
using Container = boost::container::static_vector<IndexType, FullSize>;

template <std::ranges::range other_index_range_t>
template <std::ranges::sized_range other_index_range_t>
explicit VariableSubspaceHelper(const other_index_range_t& indices) {
assert(checkSubspaceIndices(indices, kFullSize, indices.size()) &&
"Invalid indices");
Expand Down Expand Up @@ -234,7 +236,7 @@ class FixedSubspaceHelper
using IndexType = index_t;
using Container = std::array<IndexType, kSubspaceSize>;

template <std::ranges::range other_index_range_t>
template <std::ranges::sized_range other_index_range_t>
explicit FixedSubspaceHelper(const other_index_range_t& indices) {
assert(checkSubspaceIndices(indices, kFullSize, kSubspaceSize) &&
"Invalid indices");
Expand Down
57 changes: 9 additions & 48 deletions Core/include/Acts/EventData/TrackStateProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Acts/Utilities/Helpers.hpp"

#include <cstddef>
#include <ranges>
#include <span>

#include <Eigen/Core>
Expand Down Expand Up @@ -597,62 +598,22 @@ class TrackStateProxy {
///
/// @{

/// Set the projector subspace indices
/// @param boundSubspace The projector subspace indices to set
void setProjectorSubspaceIndices(BoundSubspaceIndices boundSubspace)
requires(!ReadOnly)
{
assert(has<hashString("projector")>());
component<SerializedSubspaceIndices, hashString("projector")>() =
serializeSubspaceIndices(boundSubspace);
}

/// Set the projector subspace indices
/// @param subspace The projector subspace indices to set
template <std::size_t measdim>
void setProjectorSubspaceIndices(SubspaceIndices<measdim> subspace)
requires(!ReadOnly && measdim <= eBoundSize)
{
assert(has<hashString("projector")>());
BoundSubspaceIndices boundSubspace{};
std::copy(subspace.begin(), subspace.end(), boundSubspace.begin());
setProjectorSubspaceIndices(boundSubspace);
}

/// Set the projector subspace indices
/// @param subspaceIndices The projector subspace indices to set
template <std::size_t measdim, typename index_t>
void setProjectorSubspaceIndices(std::span<index_t, measdim> subspaceIndices)
requires(!ReadOnly && measdim <= eBoundSize)
template <std::ranges::sized_range index_range_t>
void setProjectorSubspaceIndices(const index_range_t& subspaceIndices)
requires(!ReadOnly &&
std::convertible_to<std::ranges::range_value_t<index_range_t>,
std::uint8_t>)
{
assert(has<hashString("projector")>());
BoundSubspaceIndices boundSubspace{};
std::transform(subspaceIndices.begin(), subspaceIndices.end(),
boundSubspace.begin(),
[](index_t i) { return static_cast<std::uint8_t>(i); });
setProjectorSubspaceIndices(boundSubspace);
}

/// Set the projector subspace indices
/// @param subspaceIndices The projector subspace indices to set
template <typename index_t>
void setProjectorSubspaceIndices(std::span<index_t> subspaceIndices) {
assert(has<hashString("projector")>());
assert(subspaceIndices.size() <= eBoundSize);
BoundSubspaceIndices boundSubspace{};
std::transform(subspaceIndices.begin(), subspaceIndices.end(),
boundSubspace.begin(),
[](index_t i) { return static_cast<std::uint8_t>(i); });
setProjectorSubspaceIndices(boundSubspace);
}

/// Set the projector subspace indices
/// @param subspaceIndices The projector subspace indices to set
template <std::size_t measdim, typename index_t>
void setProjectorSubspaceIndices(std::array<index_t, measdim> subspaceIndices)
requires(!ReadOnly && measdim <= eBoundSize)
{
setProjectorSubspaceIndices(std::span(subspaceIndices));
[](auto i) { return static_cast<std::uint8_t>(i); });
component<SerializedSubspaceIndices, hashString("projector")>() =
serializeSubspaceIndices(boundSubspace);
}

/// Returns whether a projector is set
Expand Down
9 changes: 3 additions & 6 deletions Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

#include <boost/test/unit_test.hpp>

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/MultiTrajectory.hpp"
#include "Acts/EventData/TrackStatePropMask.hpp"
#include "Acts/EventData/TrackStateType.hpp"
#include "Acts/EventData/VectorMultiTrajectory.hpp"
Expand All @@ -19,7 +17,6 @@
#include "Acts/TrackFitting/MbfSmoother.hpp"
#include "Acts/Utilities/Result.hpp"

#include <cmath>
#include <cstddef>
#include <numbers>

Expand Down Expand Up @@ -59,7 +56,7 @@ BOOST_AUTO_TEST_CASE(Smooth) {
ts.allocateCalibrated(2);
ts.calibrated<2>() << 0.351, 0.473;
ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8;
ts.setProjectorSubspaceIndices<2>(projector);
ts.setProjectorSubspaceIndices(projector);

ts.filtered() << 0.301, 0.503, std::numbers::pi / 2., 0., 1 / 100., 0.;
ts.filteredCovariance() = covTrk;
Expand All @@ -76,7 +73,7 @@ BOOST_AUTO_TEST_CASE(Smooth) {
ts.allocateCalibrated(2);
ts.calibrated<2>() << 0.351, 0.473;
ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8;
ts.setProjectorSubspaceIndices<2>(projector);
ts.setProjectorSubspaceIndices(projector);

ts.filtered() << 0.27, 0.53, std::numbers::pi / 2., 0., 1 / 100., 0.;
ts.filteredCovariance() = covTrk;
Expand All @@ -93,7 +90,7 @@ BOOST_AUTO_TEST_CASE(Smooth) {
ts.allocateCalibrated(2);
ts.calibrated<2>() << 0.351, 0.473;
ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8;
ts.setProjectorSubspaceIndices<2>(projector);
ts.setProjectorSubspaceIndices(projector);

ts.filtered() << 0.33, 0.43, std::numbers::pi / 2., 0., 1 / 100., 0.;
ts.filteredCovariance() = covTrk;
Expand Down

0 comments on commit 902c6d0

Please sign in to comment.