Skip to content

Commit

Permalink
refactor!: Track EDM brush over (acts-project#3192)
Browse files Browse the repository at this point in the history
- use `calibrated` instead of `measurement`
- expose typedefs
- correct index params
  • Loading branch information
andiwand authored Jul 10, 2024
1 parent 6643b83 commit fa78ed3
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 192 deletions.
103 changes: 72 additions & 31 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2019-2020 CERN for the benefit of the Acts project
// Copyright (C) 2019-2024 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -148,6 +148,7 @@ struct IsReadOnlyMultiTrajectory;
/// iterating over specific sub-components.
template <typename derived_t>
class MultiTrajectory {
public:
using Derived = derived_t;

static constexpr bool ReadOnly = IsReadOnlyMultiTrajectory<Derived>::value;
Expand All @@ -161,7 +162,6 @@ class MultiTrajectory {
template <typename T>
friend class MultiTrajectory;

public:
/// Alias for the const version of a track state proxy, with the same
/// backends as this container
using ConstTrackStateProxy =
Expand Down Expand Up @@ -461,62 +461,103 @@ class MultiTrajectory {
}

/// Retrieve a jacobian proxy instance for a jacobian at a given index
/// @param jacIdx Index into the jacobian column
/// @param istate The track state
/// @return Mutable proxy
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::Covariance jacobian(IndexType jacIdx) {
return self().jacobian_impl(jacIdx);
typename TrackStateProxy::Covariance jacobian(IndexType istate) {
return self().jacobian_impl(istate);
}

/// Retrieve a jacobian proxy instance for a jacobian at a given index
/// @param jacIdx Index into the jacobian column
/// @param istate The track state
/// @return Const proxy
typename ConstTrackStateProxy::Covariance jacobian(IndexType jacIdx) const {
return self().jacobian_impl(jacIdx);
typename ConstTrackStateProxy::Covariance jacobian(IndexType istate) const {
return self().jacobian_impl(istate);
}

/// Retrieve a measurement proxy instance for a measurement at a given index
/// Retrieve a calibrated measurement proxy instance for a measurement at a
/// given index
/// @tparam measdim the measurement dimension
/// @param measIdx Index into the measurement column
/// @param istate The track state
/// @return Mutable proxy
template <std::size_t measdim, bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
typename TrackStateProxy::template Measurement<measdim> measurement(
IndexType measIdx) {
return self().template measurement_impl<measdim>(measIdx);
typename TrackStateProxy::template Calibrated<measdim> calibrated(
IndexType istate) {
return self().template calibrated_impl<measdim>(istate);
}

/// Retrieve a measurement proxy instance for a measurement at a given index
/// Retrieve a calibrated measurement proxy instance for a measurement at a
/// given index
/// @tparam measdim the measurement dimension
/// @param measIdx Index into the measurement column
/// @param istate The track state
/// @return Const proxy
template <std::size_t measdim>
typename ConstTrackStateProxy::template Measurement<measdim> measurement(
IndexType measIdx) const {
return self().template measurement_impl<measdim>(measIdx);
typename ConstTrackStateProxy::template Calibrated<measdim> calibrated(
IndexType istate) const {
return self().template calibrated_impl<measdim>(istate);
}

/// Retrieve a measurement covariance proxy instance for a measurement at a
/// given index
/// Retrieve a calibrated measurement covariance proxy instance for a
/// measurement at a given index
/// @tparam measdim the measurement dimension
/// @param covIdx Index into the measurement covariance column
/// @param istate The track state
/// @return Mutable proxy
template <std::size_t measdim, bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
typename TrackStateProxy::template MeasurementCovariance<measdim>
measurementCovariance(IndexType covIdx) {
return self().template measurementCovariance_impl<measdim>(covIdx);
typename TrackStateProxy::template CalibratedCovariance<measdim>
calibratedCovariance(IndexType istate) {
return self().template calibratedCovariance_impl<measdim>(istate);
}

/// Retrieve a measurement covariance proxy instance for a measurement at a
/// given index
/// @param covIdx Index into the measurement covariance column
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::EffectiveCalibrated effectiveCalibrated(
IndexType istate) {
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
return typename TrackStateProxy::EffectiveCalibrated{
calibrated<eBoundSize>(istate).data(), calibratedSize(istate)};
}

typename ConstTrackStateProxy::EffectiveCalibrated effectiveCalibrated(
IndexType istate) const {
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
return typename ConstTrackStateProxy::EffectiveCalibrated{
calibrated<eBoundSize>(istate).data(), calibratedSize(istate)};
}

template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
typename TrackStateProxy::EffectiveCalibratedCovariance
effectiveCalibratedCovariance(IndexType istate) {
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
return typename TrackStateProxy::EffectiveCalibratedCovariance{
calibratedCovariance<eBoundSize>(istate).data(), calibratedSize(istate),
calibratedSize(istate)};
}

typename ConstTrackStateProxy::EffectiveCalibratedCovariance
effectiveCalibratedCovariance(IndexType istate) const {
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
return typename ConstTrackStateProxy::EffectiveCalibratedCovariance{
calibratedCovariance<eBoundSize>(istate).data(), calibratedSize(istate),
calibratedSize(istate)};
}

/// Retrieve a calibrated measurement covariance proxy instance for a
/// measurement at a given index
/// @param istate The track state
/// @return Const proxy
template <std::size_t measdim>
constexpr
typename ConstTrackStateProxy::template MeasurementCovariance<measdim>
measurementCovariance(IndexType covIdx) const {
return self().template measurementCovariance_impl<measdim>(covIdx);
typename ConstTrackStateProxy::template CalibratedCovariance<measdim>
calibratedCovariance(IndexType istate) const {
return self().template calibratedCovariance_impl<measdim>(istate);
}

/// Get the calibrated measurement size for a track state
Expand Down
15 changes: 9 additions & 6 deletions Core/include/Acts/EventData/MultiTrajectoryBackendConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
#include <type_traits>

#if defined(__cpp_concepts)

#include <concepts>

namespace Acts {

namespace detail {

using Parameters = Eigen::Map<BoundVector>;
using Covariance = Eigen::Map<BoundMatrix>;

Expand Down Expand Up @@ -59,11 +61,11 @@ concept CommonMultiTrajectoryBackend = requires(const T& cv, HashedString key,
{ cv.jacobian_impl(istate) } -> std::same_as<detail::ConstCovariance>;

{
cv.template measurement_impl<2>(istate)
cv.template calibrated_impl<2>(istate)
} -> std::same_as<Eigen::Map<const ActsVector<2>>>;

{
cv.template measurementCovariance_impl<2>(istate)
cv.template calibratedCovariance_impl<2>(istate)
} -> std::same_as<Eigen::Map<const ActsSquareMatrix<2>>>;

{ cv.has_impl(key, istate) } -> std::same_as<bool>;
Expand All @@ -88,11 +90,11 @@ concept ConstMultiTrajectoryBackend = CommonMultiTrajectoryBackend<T> &&
{ v.jacobian_impl(istate) } -> std::same_as<detail::ConstCovariance>;

{
v.template measurement_impl<2>(istate)
v.template calibrated_impl<2>(istate)
} -> std::same_as<Eigen::Map<const ActsVector<2>>>;

{
v.template measurementCovariance_impl<2>(istate)
v.template calibratedCovariance_impl<2>(istate)
} -> std::same_as<Eigen::Map<const ActsSquareMatrix<2>>>;
};

Expand All @@ -108,11 +110,11 @@ concept MutableMultiTrajectoryBackend = CommonMultiTrajectoryBackend<T> &&
{ v.jacobian_impl(istate) } -> std::same_as<detail::Covariance>;

{
v.template measurement_impl<2>(istate)
v.template calibrated_impl<2>(istate)
} -> std::same_as<Eigen::Map<ActsVector<2>>>;

{
v.template measurementCovariance_impl<2>(istate)
v.template calibratedCovariance_impl<2>(istate)
} -> std::same_as<Eigen::Map<ActsSquareMatrix<2>>>;

{ v.addTrackState_impl() } -> std::same_as<TrackIndexType>;
Expand Down Expand Up @@ -142,4 +144,5 @@ concept MutableMultiTrajectoryBackend = CommonMultiTrajectoryBackend<T> &&
};

} // namespace Acts

#endif
8 changes: 4 additions & 4 deletions Core/include/Acts/EventData/TrackProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,20 @@ class TrackProxy {
/// Map-type for a bound parameter vector. This has reference semantics, i.e.
/// points at a matrix by an internal pointer.
using Parameters =
typename detail_lt::Types<eBoundSize, false>::CoefficientsMap;
typename detail_lt::FixedSizeTypes<eBoundSize, false>::CoefficientsMap;

/// Same as @ref Parameters, but with const semantics
using ConstParameters =
typename detail_lt::Types<eBoundSize, true>::CoefficientsMap;
typename detail_lt::FixedSizeTypes<eBoundSize, true>::CoefficientsMap;

/// Map-type for a bound covariance. This has reference semantics, i.e.
/// points at a matrix by an internal pointer.
using Covariance =
typename detail_lt::Types<eBoundSize, false>::CovarianceMap;
typename detail_lt::FixedSizeTypes<eBoundSize, false>::CovarianceMap;

/// Same as @ref Covariance, but with const semantics
using ConstCovariance =
typename detail_lt::Types<eBoundSize, true>::CovarianceMap;
typename detail_lt::FixedSizeTypes<eBoundSize, true>::CovarianceMap;

#ifndef DOXYGEN
friend TrackContainer<Container, Trajectory, holder_t>;
Expand Down
Loading

0 comments on commit fa78ed3

Please sign in to comment.