Skip to content

Commit

Permalink
Merge branch 'main' into chore-ci-clean-lcg-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jul 18, 2024
2 parents 7813c90 + 05e7f82 commit 935d00a
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 259 deletions.
90 changes: 38 additions & 52 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ class MultiTrajectory {
/// @note Only available if the MultiTrajectory is not read-only
/// @param istate The index to access
/// @return Read-write proxy to the stored track state
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
TrackStateProxy getTrackState(IndexType istate) {
TrackStateProxy getTrackState(IndexType istate) requires(!ReadOnly) {
return {*this, istate};
}

Expand All @@ -238,20 +237,18 @@ class MultiTrajectory {
/// which to leave invalid
/// @param iprevious index of the previous state, kInvalid if first
/// @return Index of the newly added track state
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
IndexType addTrackState(TrackStatePropMask mask = TrackStatePropMask::All,
IndexType iprevious = kInvalid) {
IndexType iprevious = kInvalid) requires(!ReadOnly) {
return self().addTrackState_impl(mask, iprevious);
}

/// Add a track state to the container and return a track state proxy to it
/// This effectively calls @c addTrackState and @c getTrackState
/// @note Only available if the track state container is not read-only
/// @return a track state proxy to the newly added track state
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
TrackStateProxy makeTrackState(
TrackStatePropMask mask = TrackStatePropMask::All,
IndexType iprevious = kInvalid) {
IndexType iprevious = kInvalid) requires(!ReadOnly) {
return getTrackState(addTrackState(mask, iprevious));
}

Expand All @@ -276,8 +273,8 @@ class MultiTrajectory {
/// @warning If the trajectory contains multiple components with common
/// points, this can have an impact on the other components.
/// @note Only available if the MultiTrajectory is not read-only
template <typename F, bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void applyBackwards(IndexType iendpoint, F&& callable) {
template <typename F>
void applyBackwards(IndexType iendpoint, F&& callable) requires(!ReadOnly) {
static_assert(detail_lt::VisitorConcept<F, TrackStateProxy>,
"Callable needs to satisfy VisitorConcept");

Expand Down Expand Up @@ -327,8 +324,7 @@ class MultiTrajectory {
/// @param iendpoint Trajectory entry point to start from
/// @return Iterator pair to iterate over
/// @note Mutable version
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto reverseTrackStateRange(IndexType iendpoint) {
auto reverseTrackStateRange(IndexType iendpoint) requires(!ReadOnly) {
using range_t =
detail_lt::TrackStateRange<true, Derived, MeasurementSizeMax, false>;
if (iendpoint == kInvalid) {
Expand Down Expand Up @@ -360,8 +356,7 @@ class MultiTrajectory {
/// @param istartpoint Trajectory state index for the innermost track
/// state to start from
/// @return Iterator pair to iterate over
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto forwardTrackStateRange(IndexType istartpoint) {
auto forwardTrackStateRange(IndexType istartpoint) requires(!ReadOnly) {
using range_t =
detail_lt::TrackStateRange<false, Derived, MeasurementSizeMax, false>;
if (istartpoint == kInvalid) {
Expand All @@ -386,8 +381,8 @@ class MultiTrajectory {
/// @note This takes a string argument rather than a hashed string to maintain
/// compatibility with backends.
/// @note Only available if the MultiTrajectory is not read-only
template <typename T, bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void addColumn(std::string_view key) {
template <typename T>
void addColumn(std::string_view key) requires(!ReadOnly) {
self().template addColumn_impl<T>(key);
}

Expand All @@ -400,10 +395,7 @@ class MultiTrajectory {

/// Clear the @c MultiTrajectory. Leaves the underlying storage untouched
/// @note Only available if the MultiTrajectory is not read-only
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void clear() {
self().clear_impl();
}
void clear() requires(!ReadOnly) { self().clear_impl(); }

/// Returns the number of track states contained
/// @return The number of track states
Expand Down Expand Up @@ -432,8 +424,8 @@ class MultiTrajectory {
/// Retrieve a parameter proxy instance for parameters at a given index
/// @param parIdx Index into the parameter column
/// @return Mutable proxy
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::Parameters parameters(IndexType parIdx) {
typename TrackStateProxy::Parameters parameters(IndexType parIdx) requires(
!ReadOnly) {
return self().parameters_impl(parIdx);
}

Expand All @@ -447,8 +439,8 @@ class MultiTrajectory {
/// Retrieve a covariance proxy instance for a covariance at a given index
/// @param covIdx Index into the covariance column
/// @return Mutable proxy
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::Covariance covariance(IndexType covIdx) {
typename TrackStateProxy::Covariance covariance(IndexType covIdx) requires(
!ReadOnly) {
return self().covariance_impl(covIdx);
}

Expand All @@ -462,8 +454,8 @@ class MultiTrajectory {
/// Retrieve a jacobian proxy instance for a jacobian at a given index
/// @param istate The track state
/// @return Mutable proxy
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::Covariance jacobian(IndexType istate) {
typename TrackStateProxy::Covariance jacobian(IndexType istate) requires(
!ReadOnly) {
return self().jacobian_impl(istate);
}

Expand All @@ -479,10 +471,9 @@ class MultiTrajectory {
/// @tparam measdim the measurement dimension
/// @param istate The track state
/// @return Mutable proxy
template <std::size_t measdim, bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
template <std::size_t measdim>
typename TrackStateProxy::template Calibrated<measdim> calibrated(
IndexType istate) {
IndexType istate) requires(!ReadOnly) {
return self().template calibrated_impl<measdim>(istate);
}

Expand All @@ -502,16 +493,14 @@ class MultiTrajectory {
/// @tparam measdim the measurement dimension
/// @param istate The track state
/// @return Mutable proxy
template <std::size_t measdim, bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
template <std::size_t measdim>
typename TrackStateProxy::template CalibratedCovariance<measdim>
calibratedCovariance(IndexType istate) {
calibratedCovariance(IndexType istate) requires(!ReadOnly) {
return self().template calibratedCovariance_impl<measdim>(istate);
}

template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::EffectiveCalibrated effectiveCalibrated(
IndexType istate) {
IndexType istate) requires(!ReadOnly) {
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
Expand All @@ -528,9 +517,8 @@ class MultiTrajectory {
calibrated<eBoundSize>(istate).data(), calibratedSize(istate)};
}

template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::EffectiveCalibratedCovariance
effectiveCalibratedCovariance(IndexType istate) {
effectiveCalibratedCovariance(IndexType istate) requires(!ReadOnly) {
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
Expand Down Expand Up @@ -576,27 +564,25 @@ class MultiTrajectory {
/// or projector. See @c TrackStatePropMask.
/// @note The track states both need to be stored in the
/// same @c MultiTrajectory instance
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void shareFrom(IndexType iself, IndexType iother,
TrackStatePropMask shareSource,
TrackStatePropMask shareTarget) {
TrackStatePropMask shareTarget) requires(!ReadOnly) {
self().shareFrom_impl(iself, iother, shareSource, shareTarget);
}

/// Unset an optional track state component
/// @param target The component to unset
/// @param istate The track state index to operate on
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void unset(TrackStatePropMask target, IndexType istate) {
void unset(TrackStatePropMask target, IndexType istate) requires(!ReadOnly) {
self().unset_impl(target, istate);
}

/// Add additional components to an existing track state
/// @note Only available if the track state container is not read-only
/// @param istate The track state index to alter
/// @param mask The bitmask that instructs which components to allocate
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void addTrackStateComponents(IndexType istate, TrackStatePropMask mask) {
void addTrackStateComponents(IndexType istate,
TrackStatePropMask mask) requires(!ReadOnly) {
self().addTrackStateComponents_impl(istate, mask);
}

Expand All @@ -605,9 +591,8 @@ class MultiTrajectory {
/// @tparam key String key for the component to access
/// @param istate The track state index to operate on
/// @return Mutable reference to the component given by @p key
template <typename T, HashedString key, bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
T& component(IndexType istate) {
template <typename T, HashedString key>
T& component(IndexType istate) requires(!ReadOnly) {
assert(checkOptional(key, istate));
return *std::any_cast<T*>(self().component_impl(key, istate));
}
Expand All @@ -617,8 +602,8 @@ class MultiTrajectory {
/// @param key String key for the component to access
/// @param istate The track state index to operate on
/// @return Mutable reference to the component given by @p key
template <typename T, bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
T& component(HashedString key, IndexType istate) {
template <typename T>
T& component(HashedString key, IndexType istate) requires(!ReadOnly) {
assert(checkOptional(key, istate));
return *std::any_cast<T*>(self().component_impl(key, istate));
}
Expand Down Expand Up @@ -657,8 +642,8 @@ class MultiTrajectory {
self().allocateCalibrated_impl(istate, measdim);
}

template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void setUncalibratedSourceLink(IndexType istate, SourceLink sourceLink) {
void setUncalibratedSourceLink(IndexType istate,
SourceLink sourceLink) requires(!ReadOnly) {
self().setUncalibratedSourceLink_impl(istate, std::move(sourceLink));
}

Expand All @@ -670,15 +655,16 @@ class MultiTrajectory {
return self().referenceSurface_impl(istate);
}

template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void setReferenceSurface(IndexType istate,
std::shared_ptr<const Surface> surface) {
void setReferenceSurface(
IndexType istate,
std::shared_ptr<const Surface> surface) requires(!ReadOnly) {
self().setReferenceSurface_impl(istate, std::move(surface));
}

private:
template <typename T, bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void copyDynamicFrom(IndexType dstIdx, const T& src, IndexType srcIdx) {
template <typename T>
void copyDynamicFrom(IndexType dstIdx, const T& src,
IndexType srcIdx) requires(!ReadOnly) {
const auto& dynamicKeys = src.self().dynamicKeys_impl();
for (const auto key : dynamicKeys) {
std::any srcPtr = src.self().component_impl(key, srcIdx);
Expand Down
Loading

0 comments on commit 935d00a

Please sign in to comment.