Commit 790ba9ad authored by Tadej Novak's avatar Tadej Novak
Browse files

Merge branch 'Bump_Acts_21.1.0' into 'master'

Bump Acts Tag to v21.1.0

See merge request atlas/athena!58832
parents e7ba648e c08ee00a
......@@ -12,27 +12,10 @@ namespace xAOD {
meas,
setMeas)
static const SG::AuxElement::Accessor<std::vector<double>> measAcc("meas");
TrackMeasurement_v1::VectorMap TrackMeasurement_v1::measEigen() {
return VectorMap{measAcc(*this).data()};
}
TrackMeasurement_v1::ConstVectorMap TrackMeasurement_v1::measEigen() const {
return ConstVectorMap{measAcc(*this).data()};
}
AUXSTORE_OBJECT_SETTER_AND_GETTER(TrackMeasurement_v1,
std::vector<double>,
covMatrix,
setCovMatrix)
static const SG::AuxElement::Accessor<std::vector<double>> covMatrixAcc("covMatrix");
TrackMeasurement_v1::MatrixMap TrackMeasurement_v1::covMatrixEigen() {
return MatrixMap{covMatrixAcc(*this).data()};
}
TrackMeasurement_v1::ConstMatrixMap TrackMeasurement_v1::covMatrixEigen() const {
return ConstMatrixMap{covMatrixAcc(*this).data()};
}
AUXSTORE_OBJECT_SETTER_AND_GETTER(TrackMeasurement_v1,
ElementLink<xAOD::UncalibratedMeasurementContainer>,
......@@ -58,4 +41,4 @@ namespace xAOD {
measAcc(*this).resize(sz);
covMatrixAcc(*this).resize(sz * sz);
}
}
\ No newline at end of file
}
......@@ -11,6 +11,9 @@
#include "EventPrimitives/EventPrimitives.h"
static const SG::AuxElement::Accessor<std::vector<double>> measAcc("meas");
static const SG::AuxElement::Accessor<std::vector<double>> covMatrixAcc("covMatrix");
namespace xAOD {
/**
* @brief Track Measurements for Acts MultiTrajectory
......@@ -18,20 +21,21 @@ namespace xAOD {
class TrackMeasurement_v1 : public SG::AuxElement {
public:
using ConstVectorMap = Eigen::Map<const Eigen::Matrix<double, 6, 1>>;
using VectorMap = Eigen::Map<Eigen::Matrix<double, 6, 1>>;
using ConstMatrixMap = Eigen::Map<const Eigen::Matrix<double, 6, 6>>;
using MatrixMap = Eigen::Map<Eigen::Matrix<double, 6, 6>>;
TrackMeasurement_v1() = default;
/**
* access track Measurements vector of const element
**/
ConstVectorMap measEigen() const;
template<std::size_t measdim = 6>
Eigen::Map<const Eigen::Matrix<double, measdim, 1>> measEigen() const {
return Eigen::Map<const Eigen::Matrix<double, measdim, 1>>{measAcc(*this).data()};
}
/**
* access Measurements of non const element
**/
VectorMap measEigen();
template<std::size_t measdim = 6>
Eigen::Map<Eigen::Matrix<double, measdim, 1>> measEigen() {
return Eigen::Map<Eigen::Matrix<double, measdim, 1>>{measAcc(*this).data()};
}
/**
* access track Measurements as plain vector
......@@ -46,12 +50,18 @@ namespace xAOD {
/**
* access track covariance matrix (flattened, rows layout) of const element
**/
ConstMatrixMap covMatrixEigen() const;
template<std::size_t measdim = 6>
Eigen::Map<const Eigen::Matrix<double, measdim, measdim>> covMatrixEigen() const {
return Eigen::Map<const Eigen::Matrix<double, measdim, measdim>>{covMatrixAcc(*this).data()};
}
/**
* access track covariance matrix (flattened, rows layout)
**/
MatrixMap covMatrixEigen();
template<std::size_t measdim = 6>
Eigen::Map<Eigen::Matrix<double, measdim, measdim>> covMatrixEigen() {
return Eigen::Map<Eigen::Matrix<double, measdim, measdim>> {covMatrixAcc(*this).data()};
}
/**
* access track covariance as plain vector
......@@ -92,4 +102,4 @@ namespace xAOD {
void resize(size_t sz = 6);
};
}
#endif
\ No newline at end of file
#endif
......@@ -12,7 +12,7 @@ ATLAS_BUILDTYPE="RelWithDebInfo"
ATLAS_EXTRA_CMAKE_ARGS=(-DLCG_VERSION_NUMBER=102
-DLCG_VERSION_POSTFIX="b_ATLAS_6"
-DATLAS_GAUDI_SOURCE="URL;https://gitlab.cern.ch/atlas/Gaudi/-/archive/v36r6.003/Gaudi-v36r6.003.tar.gz;URL_MD5;e7b279804438a7c68b190084fe2592a7"
-DATLAS_ACTS_SOURCE="URL;https://github.com/acts-project/acts/archive/refs/tags/v20.3.0.tar.gz;URL_MD5;2f4d7c2b04495ec5f4ea2ed30c419770"
-DATLAS_ACTS_SOURCE="URL;https://github.com/acts-project/acts/archive/refs/tags/v21.1.0.tar.gz;URL_MD5;6c852dabc9c750326377761a1d298139"
-DATLAS_GEOMODEL_SOURCE="URL;https://gitlab.cern.ch/GeoModelDev/GeoModel/-/archive/4.4.3/GeoModel-4.4.3.tar.bz2;URL_MD5;593a9eda9974e73d30b60d4d670b6940")
ATLAS_EXTRA_MAKE_ARGS=()
......
......@@ -39,7 +39,7 @@ ActsGeantFollowerHelper::ActsGeantFollowerHelper(const std::string& t, const std
m_extrapolateDirectly(true),
m_extrapolateIncrementally(true),
m_parameterCache(nullptr),
m_actsParameterCache(nullptr),
m_actsParameterCache(std::nullopt),
m_tX0Cache(0.),
m_tX0NonSensitiveCache(0.),
m_tNonSensitiveCache(0.),
......@@ -209,7 +209,7 @@ void ActsGeantFollowerHelper::trackParticle(const G4ThreeVector& pos,
Acts::Vector4 actsStart(pos.x(),pos.y(),pos.z(),0);
Acts::Vector3 dir = nmom.normalized();
m_actsParameterCache = std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters::create(surface, gctx.context(), actsStart, dir, mom.mag()/1000, charge).value());
m_actsParameterCache = std::make_optional<Acts::BoundTrackParameters>(Acts::BoundTrackParameters::create(surface, gctx.context(), actsStart, dir, mom.mag()/1000, charge).value());
}
// Store material in cache
......@@ -256,12 +256,12 @@ void ActsGeantFollowerHelper::trackParticle(const G4ThreeVector& pos,
// create a Acts::Surface that correspond to the Trk::Surface
auto destinationSurfaceActs = Acts::Surface::makeShared<Acts::PlaneSurface>(destinationSurface.center(), destinationSurface.normal());
std::unique_ptr<const Acts::BoundTrackParameters> actsParameters = m_actsExtrapolator->propagate(ctx,
*m_actsParameterCache,
*destinationSurfaceActs,
Acts::NavigationDirection::Forward,
std::numeric_limits<double>::max(),
particleHypo);
std::optional<Acts::BoundTrackParameters> actsParameters = m_actsExtrapolator->propagate(ctx,
*m_actsParameterCache,
*destinationSurfaceActs,
Acts::NavigationDirection::Forward,
std::numeric_limits<double>::max(),
particleHypo);
float X0Acts = m_actsExtrapolator->propagationSteps(ctx,
*m_actsParameterCache,
......@@ -270,7 +270,7 @@ void ActsGeantFollowerHelper::trackParticle(const G4ThreeVector& pos,
std::numeric_limits<double>::max(),
particleHypo).second.materialInX0;
if(actsParameters == nullptr){
if(not actsParameters.has_value()){
ATH_MSG_ERROR("Error in the Acts extrapolation, skip the current step");
return;
}
......@@ -357,7 +357,7 @@ void ActsGeantFollowerHelper::trackParticle(const G4ThreeVector& pos,
delete m_parameterCache;
m_actsParameterCache.reset();
m_parameterCache = trkParameters;
m_actsParameterCache = std::move(actsParameters);
m_actsParameterCache = actsParameters;
}
// delete cache and increment
delete g4Parameters;
......
......@@ -61,7 +61,7 @@ class ActsGeantFollowerHelper : public extends<AthAlgTool, IActsGeantFollowerHel
bool m_extrapolateIncrementally;
Trk::TrackParameters* m_parameterCache;
std::unique_ptr<const Acts::BoundTrackParameters> m_actsParameterCache;
std::optional<Acts::BoundTrackParameters> m_actsParameterCache;
std::unique_ptr<std::vector<Acts::SurfaceHit>> m_actsSurfaceCache;
std::vector<Acts::SurfaceHit>::iterator m_actsSurfaceIterator;
// Hypothesis to pdg converter
......
......@@ -82,8 +82,8 @@ void ATLASSourceLinkCalibrator::calibrate(const Acts::GeometryContext& /*gctx*/,
throw std::runtime_error("Cannot create dim 0 measurement");
} else if (sourceLink.dim() == 1) {
// return Acts::makeMeasurement(sourceLink, sourceLink.values().head<1>(), sourceLink.cov().topLeftCorner<1, 1>(), Acts::eBoundLoc0);
trackState.calibrated().template head<1>() = sourceLink.values().head<1>();
trackState.calibratedCovariance().template topLeftCorner<1, 1>() = sourceLink.cov().topLeftCorner<1, 1>();
trackState.template calibrated<1>() = sourceLink.values().head<1>();
trackState.template calibratedCovariance<1>() = sourceLink.cov().topLeftCorner<1, 1>();
trackState.calibratedSize() = sourceLink.dim();
// Create a 1D projection matrix
Acts::ActsMatrix<Acts::MultiTrajectory<trajectory_t>::MeasurementSizeMax, 1> proj;
......@@ -94,8 +94,8 @@ void ATLASSourceLinkCalibrator::calibrate(const Acts::GeometryContext& /*gctx*/,
else if (sourceLink.dim() == 2)
{
// return Acts::makeMeasurement(sourceLink, sourceLink.values().head<2>(), sourceLink.cov().topLeftCorner<2, 2>(), Acts::eBoundLoc0, Acts::eBoundLoc1);
trackState.calibrated().template head<2>() = sourceLink.values().head<2>();
trackState.calibratedCovariance().template topLeftCorner<2, 2>() = sourceLink.cov().topLeftCorner<2, 2>();
trackState.template calibrated<2>() = sourceLink.values().head<2>();
trackState.template calibratedCovariance<2>() = sourceLink.cov().topLeftCorner<2, 2>();
trackState.calibratedSize() = sourceLink.dim();
// Create a 2D projection matrix
Acts::ActsMatrix<Acts::MultiTrajectory<trajectory_t>::MeasurementSizeMax, 2> proj;
......
......@@ -77,7 +77,7 @@ public:
Trk::ParticleHypothesis particleHypo = Trk::pion) const override;
virtual
std::unique_ptr<const Acts::CurvilinearTrackParameters>
std::optional<const Acts::CurvilinearTrackParameters>
propagate(const EventContext& ctx,
const Acts::BoundTrackParameters& startParameters,
Acts::NavigationDirection navDir = Acts::NavigationDirection::Forward,
......@@ -94,7 +94,7 @@ public:
Trk::ParticleHypothesis particleHypo = Trk::pion) const override;
virtual
std::unique_ptr<const Acts::BoundTrackParameters>
std::optional<const Acts::BoundTrackParameters>
propagate(const EventContext& ctx,
const Acts::BoundTrackParameters& startParameters,
const Acts::Surface& target,
......
......@@ -213,7 +213,7 @@ ActsExtrapolationTool::propagationSteps(const EventContext& ctx,
std::unique_ptr<const Acts::CurvilinearTrackParameters>
std::optional<const Acts::CurvilinearTrackParameters>
ActsExtrapolationTool::propagate(const EventContext& ctx,
const Acts::BoundTrackParameters& startParameters,
Acts::NavigationDirection navDir /*= Acts::NavigationDirection::Forward*/,
......@@ -254,14 +254,14 @@ ActsExtrapolationTool::propagate(const EventContext& ctx,
mInteractor.energyLoss = m_interactionEloss;
mInteractor.recordInteractions = m_interactionRecord;
auto parameters = boost::apply_visitor([&](const auto& propagator) -> std::unique_ptr<const Acts::CurvilinearTrackParameters> {
auto parameters = boost::apply_visitor([&](const auto& propagator) -> std::optional<const Acts::CurvilinearTrackParameters> {
auto result = propagator.propagate(startParameters, options);
if (!result.ok()) {
ATH_MSG_ERROR("Got error during propagation:" << result.error()
<< ". Returning empty parameters.");
return nullptr;
return std::nullopt;
}
return std::move(result.value().endParameters);
return result.value().endParameters;
}, *m_varProp);
return parameters;
......@@ -338,7 +338,7 @@ ActsExtrapolationTool::propagationSteps(const EventContext& ctx,
return output;
}
std::unique_ptr<const Acts::BoundTrackParameters>
std::optional<const Acts::BoundTrackParameters>
ActsExtrapolationTool::propagate(const EventContext& ctx,
const Acts::BoundTrackParameters& startParameters,
const Acts::Surface& target,
......@@ -380,14 +380,14 @@ ActsExtrapolationTool::propagate(const EventContext& ctx,
mInteractor.energyLoss = m_interactionEloss;
mInteractor.recordInteractions = m_interactionRecord;
auto parameters = boost::apply_visitor([&](const auto& propagator) -> std::unique_ptr<const Acts::BoundTrackParameters> {
auto parameters = boost::apply_visitor([&](const auto& propagator) -> std::optional<const Acts::BoundTrackParameters> {
auto result = propagator.propagate(startParameters, target, options);
if (!result.ok()) {
ATH_MSG_ERROR("Got error during propagation: " << result.error()
<< ". Returning empty parameters.");
return nullptr;
return std::nullopt;
}
return std::move(result.value().endParameters);
return result.value().endParameters;
}, *m_varProp);
return parameters;
......
......@@ -42,7 +42,7 @@ class IActsExtrapolationTool : virtual public IAlgTool {
Trk::ParticleHypothesis particleHypo = Trk::pion) const = 0;
virtual
std::unique_ptr<const Acts::CurvilinearTrackParameters>
std::optional<const Acts::CurvilinearTrackParameters>
propagate(const EventContext& ctx,
const Acts::BoundTrackParameters& startParameters,
Acts::NavigationDirection navDir = Acts::NavigationDirection::Forward,
......@@ -59,7 +59,7 @@ class IActsExtrapolationTool : virtual public IAlgTool {
Trk::ParticleHypothesis particleHypo = Trk::pion) const = 0;
virtual
std::unique_ptr<const Acts::BoundTrackParameters>
std::optional<const Acts::BoundTrackParameters>
propagate(const EventContext& ctx,
const Acts::BoundTrackParameters& startParameters,
const Acts::Surface& target,
......
......@@ -11,7 +11,7 @@
#include "Acts/Seeding/BinFinder.hpp"
#include "Acts/Seeding/BinnedSPGroup.hpp"
#include "Acts/Seeding/SeedFilter.hpp"
#include "Acts/Seeding/Seedfinder.hpp"
#include "Acts/Seeding/SeedFinder.hpp"
#include "TrkSpacePoint/SpacePointCollection.h"
#include "AthenaMonitoringKernel/Monitored.h"
......
......@@ -11,7 +11,7 @@
#include "Acts/Seeding/BinFinder.hpp"
#include "Acts/Seeding/BinnedSPGroup.hpp"
#include "Acts/Seeding/SeedFilter.hpp"
#include "Acts/Seeding/Seedfinder.hpp"
#include "Acts/Seeding/SeedFinder.hpp"
#include "InDetReadoutGeometry/SiDetectorElementCollection.h"
#include "TrkSpacePoint/SpacePointCollection.h"
......
......@@ -5,6 +5,7 @@
#define ActsTrkEvent_MultiTrajectory_h
#include <type_traits>
#include "CxxUtils/concepts.h"
#include "Acts/EventData/VectorMultiTrajectory.hpp"
#include "Acts/EventData/MultiTrajectory.hpp"
#include "Acts/EventData/TrackStatePropMask.hpp"
#include "Acts/Utilities/HashedString.hpp"
......@@ -18,13 +19,23 @@
#include "ActsTrkEvent/SourceLink.h"
namespace ActsTrk {
template<bool RWState>
class MultiTrajectory;
namespace detail { struct Decoration; }
constexpr static bool IsReadOnly = true;
constexpr static bool IsReadWrite = false;
}
namespace Acts {
template <>
struct isReadOnlyMultiTrajectory<ActsTrk::MultiTrajectory<ActsTrk::IsReadOnly>> : std::true_type {};
template <>
struct isReadOnlyMultiTrajectory<ActsTrk::MultiTrajectory<ActsTrk::IsReadWrite>> : std::false_type {};
}
namespace detail { struct Decoration; }
constexpr static bool IsReadOnly = true;
constexpr static bool IsReadWrite = false;
namespace ActsTrk {
/**
* @brief Athena implementation of ACTS::MultiTrajectory
*
......@@ -32,7 +43,7 @@ namespace ActsTrk {
*/
template<bool RWState>
class MultiTrajectory final
: public Acts::MultiTrajectory<ActsTrk::MultiTrajectory<RWState>>{ // TODO select other variant of the interface for UNMODIFIABLE (needs next ACTS version)
: public Acts::MultiTrajectory<ActsTrk::MultiTrajectory<RWState>>{
public:
using TrackStateContainerBackendPtr = typename std::conditional<RWState, const xAOD::TrackStateContainer*, xAOD::TrackStateContainer*>::type;
......@@ -107,7 +118,7 @@ namespace ActsTrk {
typename ConstTrackStateProxy::Parameters parameters_impl(IndexType index) const {
return trackParameters().at(index)-> paramsEigen();
};
}
ATH_MEMBER_REQUIRES(RWState==IsReadWrite, typename TrackStateProxy::Parameters) parameters_impl(IndexType index){
return trackParameters().at(index)-> paramsEigen();
}
......@@ -120,7 +131,7 @@ namespace ActsTrk {
*/
typename ConstTrackStateProxy::Covariance covariance_impl(IndexType index) const {
return trackParameters().at(index)-> covMatrixEigen();
};
}
ATH_MEMBER_REQUIRES(RWState==IsReadWrite, typename TrackStateProxy::Covariance) covariance_impl(IndexType index) {
return trackParameters().at(index)-> covMatrixEigen();
}
......@@ -133,7 +144,7 @@ namespace ActsTrk {
*/
typename ConstTrackStateProxy::Covariance trackMeasurementsCov(IndexType index) const {
return trackMeasurements().at(index)-> covMatrixEigen();
};
}
ATH_MEMBER_REQUIRES(RWState==IsReadWrite, typename TrackStateProxy::Covariance) trackMeasurementsCov(IndexType index) {
return trackMeasurements().at(index)-> covMatrixEigen();
}
......@@ -147,7 +158,7 @@ namespace ActsTrk {
inline typename ConstTrackStateProxy::Covariance jacobian_impl(IndexType index) const {
return trackJacobians().at(index)-> jacEigen();
};
}
ATH_MEMBER_REQUIRES(RWState==IsReadWrite, typename TrackStateProxy::Covariance) jacobian_impl(IndexType index) {
return trackJacobians().at(index)-> jacEigen();
}
......@@ -159,11 +170,14 @@ namespace ActsTrk {
* @return TrackStateProxy::Measurement
*/
inline typename ConstTrackStateProxy::Measurement measurement_impl(IndexType index) const {
return trackMeasurements().at(index)-> measEigen();
};
ATH_MEMBER_REQUIRES(RWState==IsReadWrite, typename TrackStateProxy::Measurement) measurement_impl(IndexType index) {
return trackMeasurements().at(index)-> measEigen();
template<std::size_t measdim>
inline typename ConstTrackStateProxy::Measurement<measdim> measurement_impl(IndexType index) const {
return trackMeasurements().at(index)->template measEigen<measdim>();
}
template<std::size_t measdim, bool Enable = true>
std::enable_if_t<Enable && (RWState==IsReadWrite), typename TrackStateProxy::Measurement<measdim>>
measurement_impl(IndexType index) {
return trackMeasurements().at(index)->template measEigen<measdim>();
}
/**
* @brief obtain measurements covariance for a state at given index
......@@ -172,11 +186,14 @@ namespace ActsTrk {
* @return TrackStateProxy::Covariance
*/
inline typename ConstTrackStateProxy::Covariance measurementCovariance_impl(IndexType index) const {
return trackMeasurements().at(index)-> covMatrixEigen();
};
ATH_MEMBER_REQUIRES(RWState==IsReadWrite, typename TrackStateProxy::Covariance) measurementCovariance_impl(IndexType index) {
return trackMeasurements().at(index)-> covMatrixEigen();
template<std::size_t measdim>
inline typename ConstTrackStateProxy::MeasurementCovariance<measdim> measurementCovariance_impl(IndexType index) const {
return trackMeasurements().at(index)->template covMatrixEigen<measdim>();
}
template<std::size_t measdim, bool Enable = true>
std::enable_if_t<Enable && (RWState==IsReadWrite), typename TrackStateProxy::MeasurementCovariance<measdim>>
measurementCovariance_impl(IndexType index) {
return trackMeasurements().at(index)->template covMatrixEigen<measdim>();
}
/**
......@@ -187,7 +204,7 @@ namespace ActsTrk {
inline size_t size_impl() const {
return m_trackStates->size();
};
}
/**
* @brief clears backends
......@@ -198,7 +215,7 @@ namespace ActsTrk {
m_trackParameters->clear();
m_trackJacobians->clear();
m_trackMeasurements->clear();
};
}
/**
* @brief checks if the backends are connected (i.e. is safe to use, else any other call will cause segfaults)
......@@ -252,16 +269,15 @@ namespace ActsTrk {
std::vector<SourceLinkType*> m_sourceLinks;
};
typedef ActsTrk::MultiTrajectory<ActsTrk::IsReadOnly> ConstMultiTrajectory;
typedef ActsTrk::MultiTrajectory<ActsTrk::IsReadWrite> MutableMultiTrajectory;
namespace detail {
struct Decoration {
using SetterType = std::function<std::any(MultiTrajectory<true>::IndexType, const std::string&)>;
using GetterType = std::function<const std::any(MultiTrajectory<true>::IndexType, const std::string&)>;
using SetterType = std::function<std::any(ActsTrk::MultiTrajectory<true>::IndexType, const std::string&)>;
using GetterType = std::function<const std::any(ActsTrk::MultiTrajectory<true>::IndexType, const std::string&)>;
Decoration(const std::string& n, SetterType s, GetterType g)
: name(n), hash(Acts::hashString(name)), setter(s), getter(g) {}
std::string name; // xAOD API needs this
......@@ -271,10 +287,7 @@ namespace ActsTrk {
};
}
} // EOF namespace ActsTrk
#include "MultiTrajectory.icc"
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
// File based on Acts:
// https://github.com/acts-project/acts/blob/v21.0.0/Tests/CommonHelpers/Acts/Tests/CommonHelpers/MeasurementHelpers.hpp
// TODO: centralize the helper files
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include <cstddef>
namespace Acts {
namespace detail {
/// Helper functor for @c visit_measurement. This is the actual functor given
/// to @c template_switch.
/// @tparam I Compile time int value
template <size_t I>
struct visit_measurement_callable {
/// The invoked function. It will perform the head/top-left corner
/// extraction, and pass thee results to the given lambda.
/// @tparam L The lambda type
/// @tparam A The parameter vector type
/// @tparam B The covariance matrix type
/// @note No requirements on @c A and @c B are made, to enable a single
/// overload for both const and non-const matrices/vectors.
/// @param param The parameter vector
/// @param cov The covariance matrix
/// @param lambda The lambda to call with the statically sized subsets
template <typename L, typename A, typename B>
auto static constexpr invoke(A&& param, B&& cov, L&& lambda) {
return lambda(param.template head<I>(), cov.template topLeftCorner<I, I>());
}
};
} // namespace detail
/// Dispatch a lambda call on an overallocated parameter vector and covariance
/// matrix, based on a runtime dimension value. Inside the lambda call, the
/// vector and matrix will have fixed dimensions, but will still point back to
/// the originally given overallocated values.
/// @tparam L The lambda type
/// @tparam A The parameter vector type
/// @tparam B The covariance matrix type
/// @note No requirements on @c A and @c B are made, to enable a single
/// overload for both const and non-const matrices/vectors.
/// @param param The parameter vector
/// @param cov The covariance matrix
/// @param dim The actual dimension as a runtime value
/// @param lambda The lambda to call with the statically sized subsets
template <typename L, typename A, typename B>
auto visit_measurement(A&& param, B&& cov, size_t dim, L&& lambda) {
return template_switch<detail::visit_measurement_callable, 1, eBoundSize>(
dim, param, cov, lambda);
}
//MWMW
/// Alternative version of @c template_switch which accepts a generic
/// lambda and communicates the dimension via an integral constant type
/// @tparam N Value from which to start the dispatch chain, i.e. 0 in most cases
/// @tparam NMAX Maximum value up to which to attempt a dispatch
/// @param v The runtime value to dispatch on
/// @param func The lambda to invoke
/// @param args Additional arguments passed to @p func
template <size_t N, size_t NMAX, typename Lambda, typename... Args>
auto template_switch_lambda(size_t v, Lambda&& func, Args&&... args) {
if (v == N) {
return func(std::integral_constant<size_t, N>{},
std::forward<Args>(args)...);
}
if constexpr (N < NMAX) {
return template_switch_lambda<N + 1, NMAX>(v, func,
std::forward<Args>(args)...);
}
std::cerr << "template_switch<Fn, " << N << ", " << NMAX << ">(v=" << v
<< ") is not valid (v > NMAX)" << std::endl;
std::abort();
}
// MWMW end
/// Dispatch a generic lambda on a measurement dimension. This overload doesn't
/// assume anything about what is needed inside the lambda, it communicates the
/// dimension via an integral constant type
/// @tparam L The generic lambda type to call
/// @param dim The runtime dimension of the measurement
/// @param lambda The generic lambda instance to call
/// @return Returns the lambda return value
template <typename L>
auto visit_measurement(size_t dim, L&& lambda) {
return template_switch_lambda<1, eBoundSize>(dim, lambda);
}
} // namespace Acts
\ No newline at end of file
......@@ -8,6 +8,8 @@
#include "Acts/EventData/Measurement.hpp"
#include "Acts/EventData/MultiTrajectory.hpp"
#include "Acts/EventData/TrackParameters.hpp"