From 47c80773ccd8f76b2d06fd94157aee665767c6a9 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 29 Jul 2024 18:36:44 +0200 Subject: [PATCH 01/23] refactor: Rework projector --- Core/include/Acts/Definitions/Alignment.hpp | 2 +- Core/include/Acts/Definitions/Common.hpp | 3 +- .../Acts/Definitions/TrackParametrization.hpp | 5 +- .../Acts/EventData/TrackStateProxy.hpp | 55 ++- .../Acts/EventData/TrackStateProxy.ipp | 9 +- Core/include/Acts/EventData/Types.hpp | 6 +- .../Acts/EventData/VectorMultiTrajectory.hpp | 5 +- .../Acts/Geometry/ConeVolumeBounds.hpp | 3 +- .../Acts/Geometry/CuboidVolumeBounds.hpp | 3 +- .../Acts/Geometry/CylinderVolumeBounds.hpp | 3 +- .../Acts/Geometry/TrapezoidVolumeBounds.hpp | 3 +- .../Acts/TrackFinding/MeasurementSelector.hpp | 5 +- .../Acts/TrackFinding/MeasurementSelector.ipp | 10 +- .../Acts/Utilities/detail/Subspace.hpp | 343 ------------------ .../Vertexing/LinearizerTrackParameters.hpp | 2 +- Core/src/TrackFinding/MeasurementSelector.cpp | 20 +- .../Digitization/MeasurementCreation.hpp | 4 +- .../ActsExamples/EventData/Measurement.hpp | 51 +-- .../src/EventData/MeasurementCalibration.cpp | 4 +- .../src/EventData/ScalingCalibrator.cpp | 4 +- Tests/UnitTests/Core/Utilities/CMakeLists.txt | 1 - 21 files changed, 114 insertions(+), 427 deletions(-) delete mode 100644 Core/include/Acts/Utilities/detail/Subspace.hpp diff --git a/Core/include/Acts/Definitions/Alignment.hpp b/Core/include/Acts/Definitions/Alignment.hpp index d906f4fabbf..252619d4443 100644 --- a/Core/include/Acts/Definitions/Alignment.hpp +++ b/Core/include/Acts/Definitions/Alignment.hpp @@ -19,7 +19,7 @@ namespace Acts { /// This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum AlignmentIndices : unsigned int { +enum AlignmentIndices : std::uint8_t { // Center of geometry object in global 3D cartesian coordinates eAlignmentCenter0 = 0u, eAlignmentCenter1 = eAlignmentCenter0 + 1u, diff --git a/Core/include/Acts/Definitions/Common.hpp b/Core/include/Acts/Definitions/Common.hpp index 538de54a945..33ae4cb4266 100644 --- a/Core/include/Acts/Definitions/Common.hpp +++ b/Core/include/Acts/Definitions/Common.hpp @@ -8,6 +8,7 @@ #pragma once +#include #include namespace Acts { @@ -40,7 +41,7 @@ enum NoiseUpdateMode : int { removeNoise = -1, addNoise = 1 }; /// This index enum is not user-configurable (in contrast e.g. to the track /// parameter index enums) since it must be compatible with varying /// dimensionality (2d-4d) and other access methods (`.{x,y,z}()` accessors). -enum CoordinateIndices : unsigned int { +enum CoordinateIndices : std::uint8_t { // generic position-like access ePos0 = 0, ePos1 = 1, diff --git a/Core/include/Acts/Definitions/TrackParametrization.hpp b/Core/include/Acts/Definitions/TrackParametrization.hpp index 952fe24c512..1307addf120 100644 --- a/Core/include/Acts/Definitions/TrackParametrization.hpp +++ b/Core/include/Acts/Definitions/TrackParametrization.hpp @@ -10,6 +10,7 @@ #include "Acts/Definitions/Algebra.hpp" +#include #include // The user can override the track parameters ordering. If the preprocessor @@ -34,7 +35,7 @@ namespace Acts { /// This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum BoundIndices : unsigned int { +enum BoundIndices : std::uint8_t { // Local position on the reference surface. // This is intentionally named different from the position components in // the other data vectors, to clarify that this is defined on a surface @@ -61,7 +62,7 @@ enum BoundIndices : unsigned int { /// This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum FreeIndices : unsigned int { +enum FreeIndices : std::uint8_t { // Spatial position // The spatial position components must be stored as one continuous block. eFreePos0 = 0u, diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index f0ebe42cdd9..64c4f4a8003 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-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 @@ -11,6 +11,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/SourceLink.hpp" +#include "Acts/EventData/SubspaceHelpers.hpp" #include "Acts/EventData/TrackStatePropMask.hpp" #include "Acts/EventData/TrackStateProxyConcept.hpp" #include "Acts/EventData/TrackStateType.hpp" @@ -21,6 +22,7 @@ #include "Acts/Utilities/Helpers.hpp" #include +#include #include @@ -601,7 +603,11 @@ class TrackStateProxy { /// dimensions. The NxM submatrix, where N is the actual dimension of the /// measurement, is located in the top left corner, everything else is zero. /// @return The overallocated projector - Projector projector() const; + /// @deprecated This will be swapped out in favor of `projectorMapping` in the future + [[deprecated( + "This will be swapped out in favor of projectorMapping in the " + "future")]] Projector + projector() const; /// Returns whether a projector is set /// @return Whether it is set @@ -613,7 +619,9 @@ class TrackStateProxy { /// is of dimension \f$N\times M\f$, where \f$N\f$ is the actual dimension of the /// measurement. /// @return The effective projector - EffectiveProjector effectiveProjector() const { + /// @deprecated This will be dropped in the future + [[deprecated("This will be dropped in the future")]] EffectiveProjector + effectiveProjector() const { return projector().topLeftCorner(calibratedSize(), M); } @@ -622,9 +630,10 @@ class TrackStateProxy { /// and store it. /// @param projector The projector in the form of a dense matrix /// @note @p projector is assumed to only have 0s or 1s as components. + /// @deprecated Use setProjector(span) instead template - void setProjector(const Eigen::MatrixBase& projector) requires( - !ReadOnly) { + [[deprecated("use setProjector(span) instead")]] void setProjector( + const Eigen::MatrixBase& projector) requires(!ReadOnly) { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; constexpr int cols = Eigen::MatrixBase::ColsAtCompileTime; @@ -646,8 +655,7 @@ class TrackStateProxy { // convert to bitset before storing auto projectorBitset = matrixToBitset(fullProjector); - component() = - projectorBitset.to_ullong(); + setProjectorBitset(projectorBitset); } /// Directly get the projector bitset, a compressed form of a projection @@ -656,9 +664,26 @@ class TrackStateProxy { /// to another. Use the `projector` or `effectiveProjector` method if /// you want to access the matrix. /// @return The projector bitset - ProjectorBitset projectorBitset() const { + /// @deprecated Use projector() instead + [[deprecated("use projector() instead")]] ProjectorBitset projectorBitset() + const { + assert(has()); + ProjectorMapping mapping = projectorMapping(); + SubspaceHelper subspaceHelper(mapping, calibratedSize()); + return subspaceHelper.projectorBitset(); + } + + ProjectorMapping projectorMapping() const { + assert(has()); + return component(); + } + + void setProjector(std::span proj) requires(!ReadOnly) { assert(has()); - return component(); + ProjectorMapping mapping{}; + std::copy(proj.begin(), proj.end(), mapping.begin()); + std::fill(mapping.begin() + proj.size(), mapping.end(), eBoundSize); + component() = mapping; } /// Set the projector bitset, a compressed form of a projection matrix @@ -667,9 +692,13 @@ class TrackStateProxy { /// @note This is mainly to copy explicitly a projector from one state /// to another. If you have a projection matrix, set it with /// `setProjector`. - void setProjectorBitset(ProjectorBitset proj) requires(!ReadOnly) { + /// @deprecated Use setProjector(span) instead + [[deprecated("use setProjector(span) instead")]] void setProjectorBitset( + ProjectorBitset proj) requires(!ReadOnly) { assert(has()); - component() = proj; + BoundMatrix projMatrix = bitsetToMatrix(proj); + ProjectorMapping mapping = projectorToIndices(projMatrix); + component() = mapping; } /// Uncalibrated measurement in the form of a source link. Const version @@ -907,7 +936,7 @@ class TrackStateProxy { other.template calibratedCovariance(); }); - setProjectorBitset(other.projectorBitset()); + setProjector(other.projectorMapping()); } } else { if (ACTS_CHECK_BIT(mask, PM::Predicted) && @@ -954,7 +983,7 @@ class TrackStateProxy { other.template calibratedCovariance(); }); - setProjectorBitset(other.projectorBitset()); + setProjector(other.projectorMapping()); } } diff --git a/Core/include/Acts/EventData/TrackStateProxy.ipp b/Core/include/Acts/EventData/TrackStateProxy.ipp index cfce0d9648c..dce15f15dd9 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.ipp +++ b/Core/include/Acts/EventData/TrackStateProxy.ipp @@ -1,11 +1,12 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-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 // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include "Acts/EventData/SubspaceHelpers.hpp" namespace Acts { template inline TrackStateProxy::TrackStateProxy( @@ -63,8 +64,10 @@ inline auto TrackStateProxy::covariance() const template inline auto TrackStateProxy::projector() const -> Projector { assert(has()); - return bitsetToMatrix( - component()); + ProjectorMapping mapping = + component(); + SubspaceHelper subspaceHelper(mapping, calibratedSize()); + return subspaceHelper.fullProjector(); } template diff --git a/Core/include/Acts/EventData/Types.hpp b/Core/include/Acts/EventData/Types.hpp index c212e0bf5d0..bb4e694a42f 100644 --- a/Core/include/Acts/EventData/Types.hpp +++ b/Core/include/Acts/EventData/Types.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-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 @@ -8,14 +8,18 @@ #pragma once +#include "Acts/Definitions/TrackParametrization.hpp" + #include #include namespace Acts { + using TrackIndexType = std::uint32_t; static constexpr TrackIndexType kTrackIndexInvalid = std::numeric_limits::max(); using ProjectorBitset = std::uint64_t; +using ProjectorMapping = std::array; } // namespace Acts diff --git a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp index 97511817cca..4a3a682b19c 100644 --- a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp +++ b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp @@ -13,6 +13,7 @@ #include "Acts/EventData/MultiTrajectoryBackendConcept.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/EventData/TrackStatePropMask.hpp" +#include "Acts/EventData/Types.hpp" #include "Acts/EventData/detail/DynamicColumn.hpp" #include "Acts/EventData/detail/DynamicKeyIterator.hpp" #include "Acts/Utilities/HashedString.hpp" @@ -132,7 +133,7 @@ class VectorMultiTrajectoryBase { h("meas", isMeas, weight(meas_size)); h("measCov", isMeas, weight(meas_cov_size)); h("sourceLinks", isMeas, weight(sizeof(const SourceLink))); - h("projectors", isMeas, weight(sizeof(ProjectorBitset))); + h("projectors", isMeas, weight(sizeof(ProjectorMapping))); } if (ts.hasJacobian() && @@ -326,7 +327,7 @@ class VectorMultiTrajectoryBase { std::vector::Covariance> m_jac; std::vector> m_sourceLinks; - std::vector m_projectors; + std::vector m_projectors; // owning vector of shared pointers to surfaces // diff --git a/Core/include/Acts/Geometry/ConeVolumeBounds.hpp b/Core/include/Acts/Geometry/ConeVolumeBounds.hpp index f946705f6ce..1d24bd78e19 100644 --- a/Core/include/Acts/Geometry/ConeVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/ConeVolumeBounds.hpp @@ -14,6 +14,7 @@ #include "Acts/Utilities/BoundingBox.hpp" #include +#include #include #include #include @@ -34,7 +35,7 @@ class PlanarBounds; class ConeVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for readability - enum BoundValues : unsigned int { + enum BoundValues : std::uint8_t { eInnerAlpha = 0, eInnerOffsetZ = 1, eOuterAlpha = 2, diff --git a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp index d0c7a1b604d..94be1962333 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -49,7 +50,7 @@ class RectangleBounds; class CuboidVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for streaming and access - enum BoundValues : unsigned int { + enum BoundValues : std::uint8_t { eHalfLengthX = 0, eHalfLengthY = 1, eHalfLengthZ = 2, diff --git a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp index c5a28a4edb7..1ba47d379e1 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp @@ -14,6 +14,7 @@ #include "Acts/Utilities/BinningType.hpp" #include +#include #include #include #include @@ -69,7 +70,7 @@ class PlanarBounds; class CylinderVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for streaming and access - enum BoundValues : unsigned int { + enum BoundValues : std::uint8_t { eMinR = 0, eMaxR = 1, eHalfLengthZ = 2, diff --git a/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp b/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp index edfcd8da1c7..3d1fae5545e 100644 --- a/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp @@ -13,6 +13,7 @@ #include "Acts/Geometry/VolumeBounds.hpp" #include +#include #include #include #include @@ -50,7 +51,7 @@ class TrapezoidBounds; class TrapezoidVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for access / streaming - enum BoundValues : unsigned int { + enum BoundValues : std::uint8_t { eHalfLengthXnegY = 0, //!< halflength in x at negative y eHalfLengthXposY = 1, //!< halflength in x at positive y eHalfLengthY = 2, //!< halflength in y diff --git a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp index a05f67d7cc0..03dafbe2ef6 100644 --- a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp +++ b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp @@ -12,6 +12,7 @@ #include "Acts/EventData/MeasurementHelpers.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/EventData/Types.hpp" #include "Acts/Geometry/GeometryHierarchyMap.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/TrackFinding/CombinatorialKalmanFilterError.hpp" @@ -105,9 +106,7 @@ class MeasurementSelector { false>::Parameters predicted, TrackStateTraits::Covariance predictedCovariance, - TrackStateTraits::Projector projector, - unsigned int calibratedSize) const; + ProjectorMapping projector, unsigned int calibratedSize) const; Config m_config; }; diff --git a/Core/include/Acts/TrackFinding/MeasurementSelector.ipp b/Core/include/Acts/TrackFinding/MeasurementSelector.ipp index 49b03e4730e..0ca65a8cfee 100644 --- a/Core/include/Acts/TrackFinding/MeasurementSelector.ipp +++ b/Core/include/Acts/TrackFinding/MeasurementSelector.ipp @@ -67,11 +67,11 @@ MeasurementSelector::select( // with compile time size. That way the Eigen math operations are // still done with compile time size and no dynamic memory allocation // is needed. - double chi2 = - calculateChi2(trackState.effectiveCalibrated().data(), - trackState.effectiveCalibratedCovariance().data(), - trackState.predicted(), trackState.predictedCovariance(), - trackState.projector(), trackState.calibratedSize()); + double chi2 = calculateChi2( + trackState.effectiveCalibrated().data(), + trackState.effectiveCalibratedCovariance().data(), + trackState.predicted(), trackState.predictedCovariance(), + trackState.projectorMapping(), trackState.calibratedSize()); trackState.chi2() = chi2; if (chi2 < minChi2) { diff --git a/Core/include/Acts/Utilities/detail/Subspace.hpp b/Core/include/Acts/Utilities/detail/Subspace.hpp deleted file mode 100644 index 556a4bc4b2f..00000000000 --- a/Core/include/Acts/Utilities/detail/Subspace.hpp +++ /dev/null @@ -1,343 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include "Acts/Definitions/Algebra.hpp" - -#include -#include -#include -#include - -namespace Acts::detail { - -/// @defgroup subspace Linear subspace definitions -/// -/// All types in this group define a linear subspace of a larger vector space -/// with the following properties: the subspace is defined by a set of axis -/// indices in the full space, i.e. there is no need for a non-trivial -/// projection matrix, all subspace axis indices are unique and there are no -/// duplicated ones, and the set of axis indices must be ordered, i.e. the axis -/// order in the subspace is the same as in the full space. The last requirement -/// is not strictly required by the implementation, but is still added to -/// simplify reasoning. -/// -/// Only the size of the subspace are defined by the types at compile time. -/// Which axes comprise the subspace is defined at runtime. This allows to use -/// fixed-size computations (selected at compile time) but avoids the -/// combinatorial explosion of also having to handle all possible combination of -/// axes at compile time. This was tried previously and resulted in sizable -/// resource consumption at compile time without runtime benefits. -/// -/// All types are intentionally using `std::size_t` as their template values, -/// instead of the more specific index enums, to reduce the number of templates. -/// This is fully compatible as the index enums are required to be convertible -/// to `std::size_t`. -/// -/// All types intentionally only define the subspace but not how vectors -/// and matrices are stored to avoid unnecessary coupling between components, -/// i.e here between the pure definition and the storage. -/// -/// All types provide `.projectVector(...)` and `.exandVector(...)` methods to -/// convert to/from the subspace. They also provide `.projector()` and -/// `.expander()` methods to create projection and expansion matrices if they -/// are required explicitly. For the specific subspace requirements listed -/// above, the projection and expansion matrices are transpose to each other. In -/// the general case, this does not have to be the case and users are encouraged -/// to use `.projector()` and `.expander()` instead of e.g. -/// `.projector().transpose()`. -/// -/// @{ - -/// Fixed-size subspace representation. -/// -/// @tparam kFullSize Size of the full vector space -/// @tparam kSize Size of the subspace -template -class FixedSizeSubspace { - static_assert(kFullSize <= static_cast( - std::numeric_limits::max()), - "Full vector space size is larger than the supported range"); - static_assert(1u <= kSize, "Subspace size must be at least 1"); - static_assert(kSize <= kFullSize, - "Subspace can only be as large as the full space"); - - template - using SubspaceVectorFor = Eigen::Matrix; - template - using FullspaceVectorFor = - Eigen::Matrix; - template - using ProjectionMatrix = Eigen::Matrix; - template - using ExpansionMatrix = Eigen::Matrix; - - // the functionality could also be implemented using a std::bitset where each - // bit corresponds to an axis in the fullspace and set bits indicate which - // bits make up the subspace. this would be a more compact representation but - // complicates the implementation since we can not easily iterate over the - // indices of the subspace. storing the subspace indices directly requires a - // bit more memory but is easier to work with. for our typical use cases with - // n<=8, this still takes only 64bit of memory. - std::array m_axes; - - public: - /// Construct from a container of axis indices. - /// - /// @tparam index_t Input index type, must be convertible to std::uint8_t - /// @param indices Unique, ordered indices - template - constexpr explicit FixedSizeSubspace( - const std::array& indices) { - for (std::size_t i = 0u; i < kSize; ++i) { - assert((indices[i] < kFullSize) && - "Axis indices must be within the full space"); - if (0u < i) { - assert((indices[i - 1u] < indices[i]) && - "Axis indices must be unique and ordered"); - } - } - for (std::size_t i = 0; i < kSize; ++i) { - m_axes[i] = static_cast(indices[i]); - } - } - - /// Size of the subspace. - static constexpr std::size_t size() { return kSize; } - /// Size of the full vector space. - static constexpr std::size_t fullSize() { return kFullSize; } - - /// Access axis index by position. - /// - /// @param i Position in the subspace - /// @return Axis index in the full space - constexpr std::size_t operator[](std::size_t i) const { return m_axes[i]; } - - /// Axis indices that comprise the subspace. - /// - /// The specific container and index type should be considered an - /// implementation detail. Users should treat the return type as a generic - /// container whose elements are convertible to `std::size_t`. - constexpr const std::array& indices() const { - return m_axes; - } - - /// Check if the given axis index in the full space is part of the subspace. - constexpr bool contains(std::size_t index) const { - bool isContained = false; - // always iterate over all elements to avoid branching and hope the compiler - // can optimise this for us. - for (std::uint8_t a : m_axes) { - isContained = isContained || (a == index); - } - return isContained; - } - - /// Project a full vector into the subspace. - /// - /// @tparam fullspace_vector_t Vector type in the full space - /// @param full Vector in the full space - /// @return Subspace vector w/ just the configured axis components - /// - /// @note Always returns a column vector regardless of the input - template - SubspaceVectorFor projectVector( - const Eigen::MatrixBase& full) const { - EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(fullspace_vector_t, kFullSize); - - SubspaceVectorFor sub; - for (std::size_t i = 0u; i < kSize; ++i) { - sub[i] = full[m_axes[i]]; - } - return sub; - } - - /// Expand a subspace vector into the full space. - /// - /// @tparam subspace_vector_t Subspace vector type - /// @param sub Subspace vector - /// @return Vector in the full space w/ zeros for non-subspace components - /// - /// @note Always returns a column vector regardless of the input - template - FullspaceVectorFor expandVector( - const Eigen::MatrixBase& sub) const { - EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(subspace_vector_t, kSize); - - FullspaceVectorFor full; - full.setZero(); - for (std::size_t i = 0u; i < kSize; ++i) { - full[m_axes[i]] = sub[i]; - } - return full; - } - - /// Projection matrix that maps from the full space into the subspace. - /// - /// @tparam scalar_t Scalar type for the projection matrix - template - ProjectionMatrix projector() const { - ProjectionMatrix proj; - proj.setZero(); - for (std::size_t i = 0u; i < kSize; ++i) { - proj(i, m_axes[i]) = 1; - } - return proj; - } - - /// Expansion matrix that maps from the subspace into the full space. - /// - /// @tparam scalar_t Scalar type of the generated expansion matrix - template - ExpansionMatrix expander() const { - ExpansionMatrix expn; - expn.setZero(); - for (std::size_t i = 0u; i < kSize; ++i) { - expn(m_axes[i], i) = 1; - } - return expn; - } -}; - -/// Variable-size subspace representation. -/// -/// @tparam kFullSize Size of the full vector space -/// @tparam kSize Size of the subspace -template -class VariableSizeSubspace { - static_assert(kFullSize <= static_cast(UINT8_MAX), - "Full vector space size is larger than the supported range"); - - template - using FullProjectionMatrix = Eigen::Matrix; - template - using FullExpansionMatrix = Eigen::Matrix; - - std::size_t m_size{}; - - // the functionality could also be implemented using a std::bitset where each - // bit corresponds to an axis in the fullspace and set bits indicate which - // bits make up the subspace. this would be a more compact representation but - // complicates the implementation since we can not easily iterate over the - // indices of the subspace. storing the subspace indices directly requires a - // bit more memory but is easier to work with. for our typical use cases with - // n<=8, this still takes only 64bit of memory. - std::array m_axes{}; - - public: - /// Construct from a container of axis indices. - /// - /// @tparam index_t Input index type, must be convertible to std::uint8_t - /// @param indices Unique, ordered indices - template - constexpr explicit VariableSizeSubspace( - const std::array& indices) { - m_size = kSize; - for (std::size_t i = 0u; i < kSize; ++i) { - assert((indices[i] < kFullSize) && - "Axis indices must be within the full space"); - if (0u < i) { - assert((indices[i - 1u] < indices[i]) && - "Axis indices must be unique and ordered"); - } - } - for (std::size_t i = 0; i < kSize; ++i) { - m_axes[i] = static_cast(indices[i]); - } - } - - /// Size of the subspace. - constexpr std::size_t size() const { return m_size; } - /// Size of the full vector space. - static constexpr std::size_t fullSize() { return kFullSize; } - - /// Access axis index by position. - /// - /// @param i Position in the subspace - /// @return Axis index in the full space - constexpr std::size_t operator[](std::size_t i) const { - assert(i < m_size); - return m_axes[i]; - } - - /// Check if the given axis index in the full space is part of the subspace. - constexpr bool contains(std::size_t index) const { - bool isContained = false; - // always iterate over all elements to avoid branching and hope the compiler - // can optimise this for us. - for (std::size_t i = 0; i < kFullSize; ++i) { - isContained = isContained || ((i < m_size) && (m_axes[i] == index)); - } - return isContained; - } - - /// Projection matrix that maps from the full space into the subspace. - /// - /// @tparam scalar_t Scalar type for the projection matrix - template - FullProjectionMatrix fullProjector() const { - FullProjectionMatrix proj; - proj.setZero(); - for (std::size_t i = 0u; i < m_size; ++i) { - proj(i, m_axes[i]) = 1; - } - return proj; - } - - /// Expansion matrix that maps from the subspace into the full space. - /// - /// @tparam scalar_t Scalar type of the generated expansion matrix - template - FullExpansionMatrix fullExpander() const { - FullExpansionMatrix expn; - expn.setZero(); - for (std::size_t i = 0u; i < m_size; ++i) { - expn(m_axes[i], i) = 1; - } - return expn; - } - - std::uint64_t projectorBits() const { - std::uint64_t result = 0; - - for (std::size_t i = 0; i < m_size; ++i) { - for (std::size_t j = 0; j < kFullSize; ++j) { - // the bit order is defined in `Acts/Utilities/AlgebraHelpers.hpp` - // in `matrixToBitset` - std::size_t index = m_size * kFullSize - 1 - (i + j * m_size); - if (m_axes[i] == j) { - result |= (1ull << index); - } - } - } - - return result; - } - - std::uint64_t fullProjectorBits() const { - std::uint64_t result = 0; - - for (std::size_t i = 0; i < kFullSize; ++i) { - for (std::size_t j = 0; j < kFullSize; ++j) { - // the bit order is defined in `Acts/Utilities/AlgebraHelpers.hpp` - // in `matrixToBitset` - std::size_t index = kFullSize * kFullSize - 1 - (i + j * kFullSize); - if (i < m_size && m_axes[i] == j) { - result |= (1ull << index); - } - } - } - - return result; - } -}; - -/// @} - -} // namespace Acts::detail diff --git a/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp b/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp index b4b665152fa..db808d6b15b 100644 --- a/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp +++ b/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp @@ -19,7 +19,7 @@ namespace Acts { /// @note This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum LinIndices : unsigned int { +enum LinIndices : std::uint8_t { // Global spatial position of a point on the track, must be stored as one // continuous block. eLinPos0 = 0u, diff --git a/Core/src/TrackFinding/MeasurementSelector.cpp b/Core/src/TrackFinding/MeasurementSelector.cpp index 946ca981949..dcc3c4fcf09 100644 --- a/Core/src/TrackFinding/MeasurementSelector.cpp +++ b/Core/src/TrackFinding/MeasurementSelector.cpp @@ -9,7 +9,10 @@ #include "Acts/TrackFinding/MeasurementSelector.hpp" #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" +#include "Acts/EventData/SubspaceHelpers.hpp" +#include "Acts/EventData/Types.hpp" #include @@ -30,9 +33,7 @@ double MeasurementSelector::calculateChi2( false>::Parameters predicted, TrackStateTraits::Covariance predictedCovariance, - TrackStateTraits::Projector projector, - unsigned int calibratedSize) const { + ProjectorMapping projector, unsigned int calibratedSize) const { return visit_measurement( calibratedSize, [&fullCalibrated, &fullCalibratedCovariance, &predicted, @@ -47,17 +48,18 @@ double MeasurementSelector::calculateChi2( using ParametersVector = ActsVector; - // Take the projector (measurement mapping function) - const auto H = - projector.template topLeftCorner() - .eval(); + SubspaceHelper subspaceHelper(projector, kMeasurementSize); // Get the residuals - ParametersVector res = calibrated - H * predicted; + ParametersVector res = + calibrated - + subspaceHelper.projectVector(predicted); // Get the chi2 return (res.transpose() * - (calibratedCovariance + H * predictedCovariance * H.transpose()) + (calibratedCovariance + + subspaceHelper.projectMatrix( + predictedCovariance)) .inverse() * res) .eval()(0, 0); diff --git a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp index 3d9476815c9..ad2ab7e87f8 100644 --- a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp +++ b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp @@ -52,10 +52,10 @@ Measurement createMeasurement(const DigitizedParameters& dParams, /// /// @return a tuple of constituents for a measurement template -std::tuple, Acts::ActsVector, +std::tuple, Acts::ActsVector, Acts::ActsSquareMatrix> measurementConstituents(const DigitizedParameters& dParams) { - std::array indices{}; + std::array indices{}; Acts::ActsVector par; Acts::ActsSquareMatrix cov = Acts::ActsSquareMatrix::Identity(); diff --git a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp index 297508140f5..2c576dfd001 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp @@ -13,7 +13,6 @@ #include "Acts/EventData/detail/CalculateResiduals.hpp" #include "Acts/EventData/detail/ParameterTraits.hpp" #include "Acts/EventData/detail/PrintParameters.hpp" -#include "Acts/Utilities/detail/Subspace.hpp" #include #include @@ -49,8 +48,6 @@ class FixedSizeMeasurement { static constexpr std::size_t kFullSize = Acts::detail::kParametersSize; - using Subspace = Acts::detail::FixedSizeSubspace; - public: using Scalar = Acts::ActsScalar; /// Vector type containing for measured parameter values. @@ -75,11 +72,11 @@ class FixedSizeMeasurement { /// of parameters and covariance. template FixedSizeMeasurement(Acts::SourceLink source, - const std::array& indices, + const std::array& indices, const Eigen::MatrixBase& params, const Eigen::MatrixBase& cov) : m_source(std::move(source)), - m_subspace(indices), + m_indices(indices), m_params(params), m_cov(cov) { // TODO we should be able to support arbitrary ordering, by sorting the @@ -104,16 +101,13 @@ class FixedSizeMeasurement { static constexpr std::size_t size() { return kSize; } /// Check if a specific parameter is part of this measurement. - bool contains(indices_t i) const { return m_subspace.contains(i); } + bool contains(indices_t i) const { + return std::find(m_indices.begin(), m_indices.end(), i) != m_indices.end(); + } /// The measurement indices - constexpr std::array indices() const { - std::array subInds = m_subspace.indices(); - std::array inds{}; - for (std::size_t i = 0; i < kSize; i++) { - inds[i] = static_cast(subInds[i]); - } - return inds; + constexpr const std::array& indices() const { + return m_indices; } /// Measured parameters values. @@ -124,7 +118,11 @@ class FixedSizeMeasurement { /// Projection matrix from the full space into the measured subspace. ProjectionMatrix projector() const { - return m_subspace.template projector(); + ProjectionMatrix proj = ProjectionMatrix::Zero(); + for (std::size_t i = 0u; i < kSize; ++i) { + proj(i, m_indices[i]) = 1; + } + return proj; } /// Expansion matrix from the measured subspace into the full space. @@ -134,34 +132,23 @@ class FixedSizeMeasurement { /// still recommended to use the expansion matrix directly in cases where it /// is explicitly used. ExpansionMatrix expander() const { - return m_subspace.template expander(); - } - - /// Compute residuals in the measured subspace. - /// - /// @param reference Reference parameters in the full space. - /// - /// This computes the difference `measured - reference` taking into account - /// the allowed parameter ranges. Only the reference values in the measured - /// subspace are used for the computation. - ParametersVector residuals(const FullParametersVector& reference) const { - ParametersVector res = ParametersVector::Zero(); - Acts::detail::calculateResiduals(static_cast(kSize), - m_subspace.indices(), reference, m_params, - res); - return res; + ExpansionMatrix expn = ExpansionMatrix::Zero(); + for (std::size_t i = 0u; i < kSize; ++i) { + expn(m_indices[i], i) = 1; + } + return expn; } std::ostream& operator<<(std::ostream& os) const { Acts::detail::printMeasurement(os, static_cast(kSize), - m_subspace.indices().data(), m_params.data(), + m_indices.data(), m_params.data(), m_cov.data()); return os; } private: Acts::SourceLink m_source; - Subspace m_subspace; + std::array m_indices; ParametersVector m_params; CovarianceMatrix m_cov; }; diff --git a/Examples/Framework/src/EventData/MeasurementCalibration.cpp b/Examples/Framework/src/EventData/MeasurementCalibration.cpp index c76d7195033..edd1b6dcf41 100644 --- a/Examples/Framework/src/EventData/MeasurementCalibration.cpp +++ b/Examples/Framework/src/EventData/MeasurementCalibration.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-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 @@ -40,7 +40,7 @@ void ActsExamples::PassThroughCalibrator::calibrate( trackState.calibrated() = meas.parameters(); trackState.calibratedCovariance() = meas.covariance(); - trackState.setProjector(meas.projector()); + trackState.setProjector(meas.indices()); }, measurements[idxSourceLink.index()]); } diff --git a/Examples/Framework/src/EventData/ScalingCalibrator.cpp b/Examples/Framework/src/EventData/ScalingCalibrator.cpp index 59a9bcef2dc..e5d908aa976 100644 --- a/Examples/Framework/src/EventData/ScalingCalibrator.cpp +++ b/Examples/Framework/src/EventData/ScalingCalibrator.cpp @@ -168,7 +168,7 @@ void ActsExamples::ScalingCalibrator::calibrate( constexpr std::size_t kSize = std::remove_reference_t::size(); - std::array indices = meas.indices(); + std::array indices = meas.indices(); Acts::ActsVector cpar = P * fpar; Acts::ActsSquareMatrix ccov = P * fcov * P.transpose(); @@ -178,7 +178,7 @@ void ActsExamples::ScalingCalibrator::calibrate( trackState.allocateCalibrated(cmeas.size()); trackState.calibrated() = meas.parameters(); trackState.calibratedCovariance() = meas.covariance(); - trackState.setProjector(meas.projector()); + trackState.setProjector(meas.indices()); }, (measurements)[idxSourceLink.index()]); } diff --git a/Tests/UnitTests/Core/Utilities/CMakeLists.txt b/Tests/UnitTests/Core/Utilities/CMakeLists.txt index af362d6d564..33629511826 100644 --- a/Tests/UnitTests/Core/Utilities/CMakeLists.txt +++ b/Tests/UnitTests/Core/Utilities/CMakeLists.txt @@ -33,7 +33,6 @@ add_unittest(RangeXD RangeXDTests.cpp) add_unittest(Ray RayTest.cpp) add_unittest(RealQuadraticEquation RealQuadraticEquationTests.cpp) add_unittest(Result ResultTests.cpp) -add_unittest(Subspace SubspaceTests.cpp) add_unittest(TypeList TypeListTests.cpp) add_unittest(TypeTraits TypeTraitsTest.cpp) add_unittest(UnitVectors UnitVectorsTests.cpp) From 264bb7a5d3015b18d15d152b58c3ef6acf89b71e Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 29 Jul 2024 18:45:54 +0200 Subject: [PATCH 02/23] add missing file --- .../Acts/EventData/SubspaceHelpers.hpp | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 Core/include/Acts/EventData/SubspaceHelpers.hpp diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp new file mode 100644 index 00000000000..596b372a477 --- /dev/null +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -0,0 +1,165 @@ +// This file is part of the Acts project. +// +// Copyright (C) 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 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Definitions/Algebra.hpp" +#include "Acts/Definitions/TrackParametrization.hpp" +#include "Acts/EventData/Types.hpp" +#include "Acts/Utilities/AlgebraHelpers.hpp" +#include "Acts/Utilities/Enumerate.hpp" + +#include +#include + +namespace Acts { + +template +class SubspaceHelper { + public: + explicit SubspaceHelper(std::span indices) + : SubspaceHelper(indices, indices.size()) {} + + SubspaceHelper(std::span indices, std::size_t size) + : m_indices(indices.begin(), indices.begin() + size) { + assert(check() && "Invalid subspace"); + } + + std::size_t size() const { return m_indices.size(); } + + BoundMatrix fullProjector() const { + BoundMatrix result = BoundMatrix::Zero(); + for (auto [i, index] : enumerate(m_indices)) { + result(i, index) = 1; + } + return result; + } + + BoundMatrix fullExpander() const { + BoundMatrix result = BoundMatrix::Zero(); + for (auto [i, index] : enumerate(m_indices)) { + result(index, i) = 1; + } + return result; + } + + template + ActsMatrix projector() const { + assert(size() == M && "Invalid subspace size"); + ActsMatrix result = ActsMatrix::Zero(); + for (auto [i, index] : enumerate(m_indices)) { + result(i, index) = 1; + } + return result; + } + + template + ActsMatrix expander() const { + assert(size() == M && "Invalid subspace size"); + ActsMatrix result = ActsMatrix::Zero(); + for (auto [i, index] : enumerate(m_indices)) { + result(index, i) = 1; + } + return result; + } + + ProjectorBitset projectorBitset() const { + return matrixToBitset(fullProjector()).to_ullong(); + } + + template + ActsMatrix applyLeft(const Eigen::DenseBase& matrix) const { + assert(size() == M && "Invalid subspace size"); + assert(matrix.rows() == M && "Invalid matrix size"); + ActsMatrix result = ActsMatrix::Zero(); + for (auto [i, indexI] : enumerate(m_indices)) { + for (std::size_t j = 0; j < K; ++j) { + result(i, j) = matrix(indexI, j); + } + } + return result; + } + + template + ActsMatrix applyRight(const Eigen::DenseBase& matrix) const { + assert(size() == M && "Invalid subspace size"); + assert(matrix.rows() == M && "Invalid matrix size"); + ActsMatrix result = ActsMatrix::Zero(); + for (auto [i, indexI] : enumerate(m_indices)) { + for (std::size_t j = 0; j < K; ++j) { + result(i, j) = matrix(j, indexI); + } + } + return result; + } + + template + ActsVector projectVector( + const Eigen::DenseBase& fullVector) const { + assert(size() == N && "Invalid subspace size"); + assert(fullVector.size() == kFullSize && "Invalid full vector size"); + ActsVector result = ActsVector::Zero(); + for (auto [i, index] : enumerate(m_indices)) { + result(i) = fullVector(index); + } + return result; + } + + template + ActsSquareMatrix projectMatrix( + const Eigen::DenseBase& fullMatrix) const { + assert(size() == N && "Invalid subspace size"); + assert(fullMatrix.rows() == kFullSize && fullMatrix.cols() == kFullSize && + "Invalid full matrix size"); + ActsSquareMatrix result = ActsSquareMatrix::Zero(); + for (auto [i, indexI] : enumerate(m_indices)) { + for (auto [j, indexJ] : enumerate(m_indices)) { + result(i, j) = fullMatrix(indexI, indexJ); + } + } + return result; + } + + private: + std::span m_indices; + + bool check() const { + for (std::size_t i = 0; i < m_indices.size(); ++i) { + auto index = m_indices[i]; + if (index < 0 || index >= kFullSize) { + return false; + } + if (std::find(m_indices.begin() + i + 1, m_indices.end(), index) != + m_indices.end()) { + return false; + } + } + return true; + } +}; + +template +std::array projectorToIndices( + const Eigen::DenseBase& projector) { + assert(projector.cols() == kFullSize && projector.rows() <= kFullSize && + "Invalid projector size"); + std::array indices{}; + for (std::size_t i = 0; i < projector.rows(); ++i) { + for (std::size_t j = 0; j < projector.cols(); ++j) { + assert(projector(i, j) == 0 || + projector(i, j) == 1 && "Invalid projector value"); + if (projector(i, j) == 1) { + indices[i] = j; + } + } + assert(projector.row(i).sum() != 1 && "Invalid projector row"); + } + return indices; +} + +} // namespace Acts From 6d29495de0e336c0b796a5082feb761d34978f60 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 29 Jul 2024 19:23:41 +0200 Subject: [PATCH 03/23] make tests compile --- .../Acts/EventData/TrackStateProxy.hpp | 129 +++++++++--- .../Acts/EventData/detail/TestSourceLink.hpp | 12 +- .../Digitization/MeasurementCreation.hpp | 4 +- .../ActsExamples/EventData/Measurement.hpp | 40 ++-- .../src/EventData/ScalingCalibrator.cpp | 2 +- .../Core/TrackFitting/MbfSmootherTests.cpp | 5 +- .../Core/Utilities/SubspaceTests.cpp | 188 ------------------ 7 files changed, 131 insertions(+), 249 deletions(-) delete mode 100644 Tests/UnitTests/Core/Utilities/SubspaceTests.cpp diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 64c4f4a8003..4e7204ad59e 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -314,7 +314,9 @@ class TrackStateProxy { /// the track sequence /// @note Only available if the track state proxy is not read-only /// @return The index of the previous track state. - IndexType& previous() requires(!ReadOnly) { + IndexType& previous() + requires(!ReadOnly) + { return component(); } @@ -332,14 +334,18 @@ class TrackStateProxy { /// Unset an optional track state component /// @note Only available if the track state proxy is not read-only /// @param target The component to unset - void unset(TrackStatePropMask target) requires(!ReadOnly) { + void unset(TrackStatePropMask target) + requires(!ReadOnly) + { m_traj->self().unset(target, m_istate); } /// Add additional components to the track state /// @note Only available if the track state proxy is not read-only /// @param mask The bitmask that instructs which components to allocate - void addComponents(TrackStatePropMask mask) requires(!ReadOnly) { + void addComponents(TrackStatePropMask mask) + requires(!ReadOnly) + { m_traj->self().addTrackStateComponents_impl(m_istate, mask); } @@ -363,8 +369,9 @@ class TrackStateProxy { /// Set the reference surface to a given value /// @param srf Shared pointer to the surface to set /// @note This overload is only present in case @c ReadOnly is false. - void setReferenceSurface(std::shared_ptr srf) requires( - !ReadOnly) { + void setReferenceSurface(std::shared_ptr srf) + requires(!ReadOnly) + { m_traj->setReferenceSurface(m_istate, std::move(srf)); } // NOLINTEND(performance-unnecessary-value-param) @@ -374,7 +381,9 @@ class TrackStateProxy { /// value directly into the backing store. /// @note this overload is only enabled in case the proxy is not read-only /// @return Mutable reference to the chi2 value - float& chi2() requires(!ReadOnly) { + float& chi2() + requires(!ReadOnly) + { return component(); } @@ -403,7 +412,9 @@ class TrackStateProxy { /// This overloaded is only enabled if not read-only, and returns a mutable /// reference. /// @return reference to the type flags. - TrackStateType typeFlags() requires(!ReadOnly) { + TrackStateType typeFlags() + requires(!ReadOnly) + { return TrackStateType{ component()}; } @@ -457,7 +468,9 @@ class TrackStateProxy { component()); } - Covariance predictedCovariance() requires(!ReadOnly) { + Covariance predictedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -479,7 +492,9 @@ class TrackStateProxy { /// Filtered track parameters vector /// @return The filtered parameters /// @note Mutable version - Parameters filtered() requires(!ReadOnly) { + Parameters filtered() + requires(!ReadOnly) + { assert(has()); return m_traj->self().parameters( component()); @@ -497,7 +512,9 @@ class TrackStateProxy { /// Filtered track parameters covariance matrix /// @return The filtered parameters covariance /// @note Mutable version - Covariance filteredCovariance() requires(!ReadOnly) { + Covariance filteredCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -519,7 +536,9 @@ class TrackStateProxy { /// Smoothed track parameters vector /// @return The smoothed parameters /// @note Mutable version - Parameters smoothed() requires(!ReadOnly) { + Parameters smoothed() + requires(!ReadOnly) + { assert(has()); return m_traj->self().parameters( component()); @@ -537,7 +556,9 @@ class TrackStateProxy { /// Smoothed track parameters covariance matrix /// @return the parameter covariance matrix /// @note Mutable version - Covariance smoothedCovariance() requires(!ReadOnly) { + Covariance smoothedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -558,7 +579,9 @@ class TrackStateProxy { /// Returns the jacobian from the previous trackstate to this one /// @return The jacobian matrix /// @note Mutable version - Covariance jacobian() requires(!ReadOnly) { + Covariance jacobian() + requires(!ReadOnly) + { assert(has()); return m_traj->self().jacobian(m_istate); } @@ -633,7 +656,9 @@ class TrackStateProxy { /// @deprecated Use setProjector(span) instead template [[deprecated("use setProjector(span) instead")]] void setProjector( - const Eigen::MatrixBase& projector) requires(!ReadOnly) { + const Eigen::MatrixBase& projector) + requires(!ReadOnly) + { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; constexpr int cols = Eigen::MatrixBase::ColsAtCompileTime; @@ -678,10 +703,20 @@ class TrackStateProxy { return component(); } - void setProjector(std::span proj) requires(!ReadOnly) { + void setProjector(const ProjectorMapping& proj) + requires(!ReadOnly) + { + component() = proj; + } + + void setProjector(std::span proj) + requires(!ReadOnly) + { assert(has()); - ProjectorMapping mapping{}; - std::copy(proj.begin(), proj.end(), mapping.begin()); + ProjectorMapping mapping; + for (std::size_t i = 0; i < proj.size(); ++i) { + mapping[i] = static_cast(proj[i]); + } std::fill(mapping.begin() + proj.size(), mapping.end(), eBoundSize); component() = mapping; } @@ -694,7 +729,9 @@ class TrackStateProxy { /// `setProjector`. /// @deprecated Use setProjector(span) instead [[deprecated("use setProjector(span) instead")]] void setProjectorBitset( - ProjectorBitset proj) requires(!ReadOnly) { + ProjectorBitset proj) + requires(!ReadOnly) + { assert(has()); BoundMatrix projMatrix = bitsetToMatrix(proj); ProjectorMapping mapping = projectorToIndices(projMatrix); @@ -707,7 +744,9 @@ class TrackStateProxy { /// Set an uncalibrated source link /// @param sourceLink The uncalibrated source link to set - void setUncalibratedSourceLink(SourceLink sourceLink) requires(!ReadOnly) { + void setUncalibratedSourceLink(SourceLink sourceLink) + requires(!ReadOnly) + { m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink)); } @@ -736,7 +775,9 @@ class TrackStateProxy { /// @return The measurement vector /// @note Mutable version template - Calibrated calibrated() requires(!ReadOnly) { + Calibrated calibrated() + requires(!ReadOnly) + { assert(has()); return m_traj->self().template calibrated(m_istate); } @@ -754,7 +795,9 @@ class TrackStateProxy { /// covariance is located in the top left corner, everything else is zeroed. /// @return The measurement covariance matrix template - CalibratedCovariance calibratedCovariance() requires(!ReadOnly) { + CalibratedCovariance calibratedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().template calibratedCovariance(m_istate); } @@ -762,7 +805,9 @@ class TrackStateProxy { /// Mutable dynamic measurement vector with only the valid dimensions. /// @warning The dynamic vector has a runtime overhead! /// @return The effective calibrated measurement vector - EffectiveCalibrated effectiveCalibrated() requires(!ReadOnly) { + EffectiveCalibrated effectiveCalibrated() + requires(!ReadOnly) + { assert(has()); return m_traj->self().effectiveCalibrated(m_istate); } @@ -827,8 +872,9 @@ class TrackStateProxy { /// @param shareSource Which component to share from /// @param shareTarget Which component to share as. This should be different from /// as @p shareSource, e.g. predicted can be shared as filtered. - void shareFrom(TrackStatePropMask shareSource, - TrackStatePropMask shareTarget) requires(!ReadOnly) { + void shareFrom(TrackStatePropMask shareSource, TrackStatePropMask shareTarget) + requires(!ReadOnly) + { shareFrom(*this, shareSource, shareTarget); } @@ -839,7 +885,9 @@ class TrackStateProxy { /// same @c MultiTrajectory instance template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask component) requires(!ReadOnly) { + TrackStatePropMask component) + requires(!ReadOnly) + { shareFrom(other, component, component); } @@ -852,8 +900,9 @@ class TrackStateProxy { /// or projector. See @c TrackStatePropMask. template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask shareSource, - TrackStatePropMask shareTarget) requires(!ReadOnly) { + TrackStatePropMask shareSource, TrackStatePropMask shareTarget) + requires(!ReadOnly) + { assert(m_traj == other.m_traj && "Cannot share components across MultiTrajectories"); @@ -876,7 +925,9 @@ class TrackStateProxy { template void copyFrom(const track_state_proxy_t& other, TrackStatePropMask mask = TrackStatePropMask::All, - bool onlyAllocated = true) requires(!ReadOnly) { + bool onlyAllocated = true) + requires(!ReadOnly) + { using PM = TrackStatePropMask; if (onlyAllocated) { @@ -1032,7 +1083,9 @@ class TrackStateProxy { /// @tparam key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component() requires(!ReadOnly) { + constexpr T& component() + requires(!ReadOnly) + { return m_traj->template component(m_istate); } @@ -1041,7 +1094,9 @@ class TrackStateProxy { /// @param key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component(HashedString key) requires(!ReadOnly) { + constexpr T& component(HashedString key) + requires(!ReadOnly) + { return m_traj->template component(key, m_istate); } @@ -1051,7 +1106,9 @@ class TrackStateProxy { /// @note This might hash the @p key at runtime instead of compile-time /// @return Mutable reference to the component given by @p key template - constexpr T& component(std::string_view key) requires(!ReadOnly) { + constexpr T& component(std::string_view key) + requires(!ReadOnly) + { return m_traj->template component(hashString(key), m_istate); } @@ -1087,7 +1144,9 @@ class TrackStateProxy { /// Return a mutable reference to the underlying backend container /// @return A reference to the backend container - MultiTrajectory& trajectory() requires(!ReadOnly) { + MultiTrajectory& trajectory() + requires(!ReadOnly) + { return *m_traj; } @@ -1097,7 +1156,11 @@ class TrackStateProxy { /// Get a mutable reference to the track state container backend /// @return a mutable reference to the backend - auto& container() requires(!ReadOnly) { return *m_traj; } + auto& container() + requires(!ReadOnly) + { + return *m_traj; + } /// Get a const reference to the track state container backend /// @return a const reference to the backend diff --git a/Core/include/Acts/EventData/detail/TestSourceLink.hpp b/Core/include/Acts/EventData/detail/TestSourceLink.hpp index 421180eb279..60ef67238f4 100644 --- a/Core/include/Acts/EventData/detail/TestSourceLink.hpp +++ b/Core/include/Acts/EventData/detail/TestSourceLink.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2020-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 @@ -16,7 +16,6 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Utilities/CalibrationContext.hpp" -#include "Acts/Utilities/detail/Subspace.hpp" #include #include @@ -121,22 +120,19 @@ void testSourceLinkCalibratorReturn( trackState.allocateCalibrated(2); trackState.template calibrated<2>() = sl.parameters; trackState.template calibratedCovariance<2>() = sl.covariance; - trackState.setProjector(FixedSizeSubspace( - std::array{sl.indices[0], sl.indices[1]}) - .projector()); + trackState.setProjector(std::array{sl.indices[0], sl.indices[1]}); } else if (sl.indices[0] != Acts::eBoundSize) { trackState.allocateCalibrated(1); trackState.template calibrated<1>() = sl.parameters.head<1>(); trackState.template calibratedCovariance<1>() = sl.covariance.topLeftCorner<1, 1>(); - trackState.setProjector(FixedSizeSubspace( - std::array{sl.indices[0]}) - .projector()); + trackState.setProjector(std::array{sl.indices[0]}); } else { throw std::runtime_error( "Tried to extract measurement from invalid TestSourceLink"); } } + /// Extract the measurement from a TestSourceLink. /// /// @param gctx Unused diff --git a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp index ad2ab7e87f8..3d9476815c9 100644 --- a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp +++ b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/MeasurementCreation.hpp @@ -52,10 +52,10 @@ Measurement createMeasurement(const DigitizedParameters& dParams, /// /// @return a tuple of constituents for a measurement template -std::tuple, Acts::ActsVector, +std::tuple, Acts::ActsVector, Acts::ActsSquareMatrix> measurementConstituents(const DigitizedParameters& dParams) { - std::array indices{}; + std::array indices{}; Acts::ActsVector par; Acts::ActsSquareMatrix cov = Acts::ActsSquareMatrix::Identity(); diff --git a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp index 2c576dfd001..15429002396 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp @@ -72,19 +72,15 @@ class FixedSizeMeasurement { /// of parameters and covariance. template FixedSizeMeasurement(Acts::SourceLink source, - const std::array& indices, + const std::array& indices, const Eigen::MatrixBase& params, const Eigen::MatrixBase& cov) - : m_source(std::move(source)), - m_indices(indices), - m_params(params), - m_cov(cov) { - // TODO we should be able to support arbitrary ordering, by sorting the - // indices and reordering parameters/covariance. since the parameter order - // can be modified by the user, the user can not always know what the - // right order is. another option is too remove the requirement for index - // ordering from the subspace types, but that will make it harder to - // refactor their implementation later on. + : m_source(std::move(source)), m_params(params), m_cov(cov) { + for (std::size_t i = 0u; i < kSize; ++i) { + assert(indices[i] >= 0 && indices[i] < kFullSize && + "Index out of bounds"); + m_indices[i] = static_cast(indices[i]); + } } /// A measurement can only be constructed with valid parameters. FixedSizeMeasurement() = delete; @@ -106,8 +102,12 @@ class FixedSizeMeasurement { } /// The measurement indices - constexpr const std::array& indices() const { - return m_indices; + constexpr std::array indices() const { + std::array result; + for (std::size_t i = 0u; i < kSize; ++i) { + result[i] = static_cast(m_indices[i]); + } + return result; } /// Measured parameters values. @@ -139,6 +139,20 @@ class FixedSizeMeasurement { return expn; } + /// Compute residuals in the measured subspace. + /// + /// @param reference Reference parameters in the full space. + /// + /// This computes the difference `measured - reference` taking into account + /// the allowed parameter ranges. Only the reference values in the measured + /// subspace are used for the computation. + ParametersVector residuals(const FullParametersVector& reference) const { + ParametersVector res = ParametersVector::Zero(); + Acts::detail::calculateResiduals(static_cast(kSize), m_indices, + reference, m_params, res); + return res; + } + std::ostream& operator<<(std::ostream& os) const { Acts::detail::printMeasurement(os, static_cast(kSize), m_indices.data(), m_params.data(), diff --git a/Examples/Framework/src/EventData/ScalingCalibrator.cpp b/Examples/Framework/src/EventData/ScalingCalibrator.cpp index e5d908aa976..0433eb766e2 100644 --- a/Examples/Framework/src/EventData/ScalingCalibrator.cpp +++ b/Examples/Framework/src/EventData/ScalingCalibrator.cpp @@ -168,7 +168,7 @@ void ActsExamples::ScalingCalibrator::calibrate( constexpr std::size_t kSize = std::remove_reference_t::size(); - std::array indices = meas.indices(); + std::array indices = meas.indices(); Acts::ActsVector cpar = P * fpar; Acts::ActsSquareMatrix ccov = P * fcov * P.transpose(); diff --git a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp index bdd6d3acab2..e51dfbbb0d7 100644 --- a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp @@ -18,7 +18,6 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/TrackFitting/MbfSmoother.hpp" #include "Acts/Utilities/Result.hpp" -#include "Acts/Utilities/detail/Subspace.hpp" #include #include @@ -41,9 +40,7 @@ BOOST_AUTO_TEST_SUITE(TrackFittingMbfSmoother) BOOST_AUTO_TEST_CASE(Smooth) { VectorMultiTrajectory traj; - auto projector = detail::FixedSizeSubspace( - std::array{eBoundLoc0, eBoundLoc1}) - .projector(); + std::array projector{eBoundLoc0, eBoundLoc1}; // Make dummy track parameter CovarianceMatrix covTrk; diff --git a/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp b/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp deleted file mode 100644 index 0d91065089e..00000000000 --- a/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" -#include "Acts/Utilities/AlgebraHelpers.hpp" -#include "Acts/Utilities/detail/Subspace.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - -using namespace Acts; - -// meta-programming type list of scalar type + subspace type combinations -// clang-format off -using ScalarsAndFixedSizeSubspaces = std::tuple< - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple>, - std::tuple> ->; -// clang-format on - -/// Construct a random vector of the specified size. -template -Eigen::Matrix makeRandomVector() { - Eigen::Matrix vec; - vec.setRandom(); - return vec; -} - -/// Construct a vector w/ monotonically inceasing values starting at 0. -std::vector makeMonotonicIndices(std::size_t n) { - std::vector indices(n); - std::iota(indices.begin(), indices.end(), 0u); - return indices; -} - -/// Build a sorted array from the first kSize indices. -template -std::array selectFixedIndices( - const std::vector& fullIndices) { - std::array indices{}; - for (auto i = 0u; i < kSize; ++i) { - indices[i] = fullIndices[i]; - } - std::sort(indices.begin(), indices.end()); - return indices; -} - -} // namespace - -BOOST_AUTO_TEST_SUITE(UtilitiesSubspace) - -// all these cases should lead to compile-time errors -// BOOST_AUTO_TEST_CASE(ConstructFixedInvalid) { -// { -// using Subspace = detail::FixedSizeSubspace<6u, 7u>; -// Subspace subspace(0u, 1u, 2u, 3u, 4u, 5u, 6u); -// } -// { -// using Subspace = detail::FixedSizeSubspace<8u, 9u>; -// Subspace subspace(0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u); -// } -// } - -BOOST_AUTO_TEST_CASE_TEMPLATE(FixedSizeSubspace, ScalarAndSubspace, - ScalarsAndFixedSizeSubspaces) { - // extract the test types - using Scalar = std::tuple_element_t<0, ScalarAndSubspace>; - using Subspace = std::tuple_element_t<1, ScalarAndSubspace>; - - auto x = makeRandomVector(); - auto fullIndices = makeMonotonicIndices(Subspace::fullSize()); - - // in principle, we would like to iterate over all possible ordered subsets - // from the full space indices with a size identical to the subspace. since i - // do not know how to do that in a simple manner, we are iterating over all - // permutations of the full indices and pick the first n elements. this should - // give a reasonable set of different subspace configurations. - do { - auto indices = selectFixedIndices(fullIndices); - Subspace subspace(indices); - - // verify projector/expander consistency - BOOST_CHECK_EQUAL(subspace.template projector().transpose(), - subspace.template expander()); - BOOST_CHECK_EQUAL(subspace.template expander().transpose(), - subspace.template projector()); - // project into the subspace - auto s0 = subspace.projectVector(x); - auto s1 = (subspace.template projector() * x).eval(); - for (auto i = 0u; i < subspace.size(); ++i) { - BOOST_TEST_INFO("Checking projected subspace component " << i); - BOOST_CHECK_EQUAL(s0[i], x[indices[i]]); - BOOST_CHECK_EQUAL(s1[i], x[indices[i]]); - } - // expand from the subspace back into the full space - auto y0 = subspace.expandVector(s1); - auto y1 = (subspace.template expander() * s0).eval(); - for (auto i = 0u; i < subspace.fullSize(); ++i) { - BOOST_TEST_INFO("Checking expanded fullspace component " << i); - BOOST_CHECK_EQUAL(y0[i], subspace.contains(i) ? x[i] : 0); - BOOST_CHECK_EQUAL(y1[i], subspace.contains(i) ? x[i] : 0); - } - } while (std::next_permutation(fullIndices.begin(), fullIndices.end())); -} - -BOOST_AUTO_TEST_CASE_TEMPLATE(VariableSizeSubspace, ScalarAndSubspace, - ScalarsAndFixedSizeSubspaces) { - // extract the test types - using Scalar = std::tuple_element_t<0, ScalarAndSubspace>; - using FixedSubspace = std::tuple_element_t<1, ScalarAndSubspace>; - using VariableSubspace = - detail::VariableSizeSubspace; - - auto fullIndices = makeMonotonicIndices(FixedSubspace::fullSize()); - - // in principle, we would like to iterate over all possible ordered subsets - // from the full space indices with a size identical to the subspace. since i - // do not know how to do that in a simple manner, we are iterating over all - // permutations of the full indices and pick the first n elements. this should - // give a reasonable set of different subspace configurations. - do { - auto indices = selectFixedIndices(fullIndices); - FixedSubspace fixedSubspace(indices); - VariableSubspace variableSubspace(indices); - - BOOST_CHECK_EQUAL(variableSubspace.size(), fixedSubspace.size()); - BOOST_CHECK_EQUAL(variableSubspace.fullSize(), fixedSubspace.fullSize()); - - auto fixedProjector = fixedSubspace.template projector(); - std::uint64_t fixedProjectorBits = - matrixToBitset(fixedProjector).to_ullong(); - - Eigen::Matrix - fixedFullProjector; - fixedFullProjector.setZero(); - fixedFullProjector.template topLeftCorner() = - fixedProjector; - std::uint64_t fixedFullProjectorBits = - matrixToBitset(fixedFullProjector).to_ullong(); - - std::uint64_t variableProjectorBits = variableSubspace.projectorBits(); - std::uint64_t variableFullProjectorBits = - variableSubspace.fullProjectorBits(); - - BOOST_CHECK_EQUAL(variableProjectorBits, fixedProjectorBits); - BOOST_CHECK_EQUAL(variableFullProjectorBits, fixedFullProjectorBits); - } while (std::next_permutation(fullIndices.begin(), fullIndices.end())); -} - -BOOST_AUTO_TEST_SUITE_END() From 85ee6b2f0e4e3b73f3ef8f39f215bbc48f39a667 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 29 Jul 2024 20:15:42 +0200 Subject: [PATCH 04/23] pr feedback --- Core/include/Acts/Definitions/Alignment.hpp | 2 +- Core/include/Acts/Definitions/Common.hpp | 3 +- .../Acts/Definitions/TrackParametrization.hpp | 5 +- .../Acts/EventData/SubspaceHelpers.hpp | 19 +-- .../Acts/EventData/TrackStateProxy.hpp | 134 ++++++------------ .../Acts/EventData/TrackStateProxy.ipp | 3 +- .../Acts/Geometry/ConeVolumeBounds.hpp | 3 +- .../Acts/Geometry/CuboidVolumeBounds.hpp | 3 +- .../Acts/Geometry/CylinderVolumeBounds.hpp | 3 +- .../Acts/Geometry/TrapezoidVolumeBounds.hpp | 3 +- .../Vertexing/LinearizerTrackParameters.hpp | 2 +- Core/src/TrackFinding/MeasurementSelector.cpp | 3 +- .../TrackFitting/src/RefittingCalibrator.cpp | 2 +- 13 files changed, 65 insertions(+), 120 deletions(-) diff --git a/Core/include/Acts/Definitions/Alignment.hpp b/Core/include/Acts/Definitions/Alignment.hpp index 252619d4443..d906f4fabbf 100644 --- a/Core/include/Acts/Definitions/Alignment.hpp +++ b/Core/include/Acts/Definitions/Alignment.hpp @@ -19,7 +19,7 @@ namespace Acts { /// This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum AlignmentIndices : std::uint8_t { +enum AlignmentIndices : unsigned int { // Center of geometry object in global 3D cartesian coordinates eAlignmentCenter0 = 0u, eAlignmentCenter1 = eAlignmentCenter0 + 1u, diff --git a/Core/include/Acts/Definitions/Common.hpp b/Core/include/Acts/Definitions/Common.hpp index 33ae4cb4266..538de54a945 100644 --- a/Core/include/Acts/Definitions/Common.hpp +++ b/Core/include/Acts/Definitions/Common.hpp @@ -8,7 +8,6 @@ #pragma once -#include #include namespace Acts { @@ -41,7 +40,7 @@ enum NoiseUpdateMode : int { removeNoise = -1, addNoise = 1 }; /// This index enum is not user-configurable (in contrast e.g. to the track /// parameter index enums) since it must be compatible with varying /// dimensionality (2d-4d) and other access methods (`.{x,y,z}()` accessors). -enum CoordinateIndices : std::uint8_t { +enum CoordinateIndices : unsigned int { // generic position-like access ePos0 = 0, ePos1 = 1, diff --git a/Core/include/Acts/Definitions/TrackParametrization.hpp b/Core/include/Acts/Definitions/TrackParametrization.hpp index 1307addf120..952fe24c512 100644 --- a/Core/include/Acts/Definitions/TrackParametrization.hpp +++ b/Core/include/Acts/Definitions/TrackParametrization.hpp @@ -10,7 +10,6 @@ #include "Acts/Definitions/Algebra.hpp" -#include #include // The user can override the track parameters ordering. If the preprocessor @@ -35,7 +34,7 @@ namespace Acts { /// This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum BoundIndices : std::uint8_t { +enum BoundIndices : unsigned int { // Local position on the reference surface. // This is intentionally named different from the position components in // the other data vectors, to clarify that this is defined on a surface @@ -62,7 +61,7 @@ enum BoundIndices : std::uint8_t { /// This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum FreeIndices : std::uint8_t { +enum FreeIndices : unsigned int { // Spatial position // The spatial position components must be stored as one continuous block. eFreePos0 = 0u, diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index 596b372a477..b270dbef7ea 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -23,11 +23,8 @@ template class SubspaceHelper { public: explicit SubspaceHelper(std::span indices) - : SubspaceHelper(indices, indices.size()) {} - - SubspaceHelper(std::span indices, std::size_t size) - : m_indices(indices.begin(), indices.begin() + size) { - assert(check() && "Invalid subspace"); + : m_indices(indices) { + assert(check() && "Invalid subspace indices"); } std::size_t size() const { return m_indices.size(); } @@ -129,6 +126,9 @@ class SubspaceHelper { std::span m_indices; bool check() const { + if (m_indices.size() == 0 || m_indices.size() > kFullSize) { + return false; + } for (std::size_t i = 0; i < m_indices.size(); ++i) { auto index = m_indices[i]; if (index < 0 || index >= kFullSize) { @@ -146,11 +146,12 @@ class SubspaceHelper { template std::array projectorToIndices( const Eigen::DenseBase& projector) { - assert(projector.cols() == kFullSize && projector.rows() <= kFullSize && - "Invalid projector size"); + auto rows = static_cast(projector.rows()); + auto cols = static_cast(projector.cols()); + assert(cols == kFullSize && rows <= kFullSize && "Invalid projector size"); std::array indices{}; - for (std::size_t i = 0; i < projector.rows(); ++i) { - for (std::size_t j = 0; j < projector.cols(); ++j) { + for (std::size_t i = 0; i < rows; ++i) { + for (std::size_t j = 0; j < cols; ++j) { assert(projector(i, j) == 0 || projector(i, j) == 1 && "Invalid projector value"); if (projector(i, j) == 1) { diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 4e7204ad59e..041e86bde4d 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -314,9 +314,7 @@ class TrackStateProxy { /// the track sequence /// @note Only available if the track state proxy is not read-only /// @return The index of the previous track state. - IndexType& previous() - requires(!ReadOnly) - { + IndexType& previous() requires(!ReadOnly) { return component(); } @@ -334,18 +332,14 @@ class TrackStateProxy { /// Unset an optional track state component /// @note Only available if the track state proxy is not read-only /// @param target The component to unset - void unset(TrackStatePropMask target) - requires(!ReadOnly) - { + void unset(TrackStatePropMask target) requires(!ReadOnly) { m_traj->self().unset(target, m_istate); } /// Add additional components to the track state /// @note Only available if the track state proxy is not read-only /// @param mask The bitmask that instructs which components to allocate - void addComponents(TrackStatePropMask mask) - requires(!ReadOnly) - { + void addComponents(TrackStatePropMask mask) requires(!ReadOnly) { m_traj->self().addTrackStateComponents_impl(m_istate, mask); } @@ -369,9 +363,8 @@ class TrackStateProxy { /// Set the reference surface to a given value /// @param srf Shared pointer to the surface to set /// @note This overload is only present in case @c ReadOnly is false. - void setReferenceSurface(std::shared_ptr srf) - requires(!ReadOnly) - { + void setReferenceSurface(std::shared_ptr srf) requires( + !ReadOnly) { m_traj->setReferenceSurface(m_istate, std::move(srf)); } // NOLINTEND(performance-unnecessary-value-param) @@ -381,9 +374,7 @@ class TrackStateProxy { /// value directly into the backing store. /// @note this overload is only enabled in case the proxy is not read-only /// @return Mutable reference to the chi2 value - float& chi2() - requires(!ReadOnly) - { + float& chi2() requires(!ReadOnly) { return component(); } @@ -412,9 +403,7 @@ class TrackStateProxy { /// This overloaded is only enabled if not read-only, and returns a mutable /// reference. /// @return reference to the type flags. - TrackStateType typeFlags() - requires(!ReadOnly) - { + TrackStateType typeFlags() requires(!ReadOnly) { return TrackStateType{ component()}; } @@ -468,9 +457,7 @@ class TrackStateProxy { component()); } - Covariance predictedCovariance() - requires(!ReadOnly) - { + Covariance predictedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -492,9 +479,7 @@ class TrackStateProxy { /// Filtered track parameters vector /// @return The filtered parameters /// @note Mutable version - Parameters filtered() - requires(!ReadOnly) - { + Parameters filtered() requires(!ReadOnly) { assert(has()); return m_traj->self().parameters( component()); @@ -512,9 +497,7 @@ class TrackStateProxy { /// Filtered track parameters covariance matrix /// @return The filtered parameters covariance /// @note Mutable version - Covariance filteredCovariance() - requires(!ReadOnly) - { + Covariance filteredCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -536,9 +519,7 @@ class TrackStateProxy { /// Smoothed track parameters vector /// @return The smoothed parameters /// @note Mutable version - Parameters smoothed() - requires(!ReadOnly) - { + Parameters smoothed() requires(!ReadOnly) { assert(has()); return m_traj->self().parameters( component()); @@ -556,9 +537,7 @@ class TrackStateProxy { /// Smoothed track parameters covariance matrix /// @return the parameter covariance matrix /// @note Mutable version - Covariance smoothedCovariance() - requires(!ReadOnly) - { + Covariance smoothedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -579,9 +558,7 @@ class TrackStateProxy { /// Returns the jacobian from the previous trackstate to this one /// @return The jacobian matrix /// @note Mutable version - Covariance jacobian() - requires(!ReadOnly) - { + Covariance jacobian() requires(!ReadOnly) { assert(has()); return m_traj->self().jacobian(m_istate); } @@ -656,9 +633,7 @@ class TrackStateProxy { /// @deprecated Use setProjector(span) instead template [[deprecated("use setProjector(span) instead")]] void setProjector( - const Eigen::MatrixBase& projector) - requires(!ReadOnly) - { + const Eigen::MatrixBase& projector) requires(!ReadOnly) { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; constexpr int cols = Eigen::MatrixBase::ColsAtCompileTime; @@ -692,10 +667,7 @@ class TrackStateProxy { /// @deprecated Use projector() instead [[deprecated("use projector() instead")]] ProjectorBitset projectorBitset() const { - assert(has()); - ProjectorMapping mapping = projectorMapping(); - SubspaceHelper subspaceHelper(mapping, calibratedSize()); - return subspaceHelper.projectorBitset(); + return projectorSubspace().projectorBitset(); } ProjectorMapping projectorMapping() const { @@ -703,16 +675,20 @@ class TrackStateProxy { return component(); } - void setProjector(const ProjectorMapping& proj) - requires(!ReadOnly) - { + SubspaceHelper projectorSubspace() const { + assert(has()); + ProjectorMapping mapping = projectorMapping(); + return SubspaceHelper( + {mapping.begin(), mapping.begin() + calibratedSize()}); + } + + void setProjector(const ProjectorMapping& proj) requires(!ReadOnly) { component() = proj; } - void setProjector(std::span proj) - requires(!ReadOnly) - { + void setProjector(std::span proj) requires(!ReadOnly) { assert(has()); + assert(proj.size() == calibratedSize() && "Invalid projector size"); ProjectorMapping mapping; for (std::size_t i = 0; i < proj.size(); ++i) { mapping[i] = static_cast(proj[i]); @@ -729,9 +705,7 @@ class TrackStateProxy { /// `setProjector`. /// @deprecated Use setProjector(span) instead [[deprecated("use setProjector(span) instead")]] void setProjectorBitset( - ProjectorBitset proj) - requires(!ReadOnly) - { + ProjectorBitset proj) requires(!ReadOnly) { assert(has()); BoundMatrix projMatrix = bitsetToMatrix(proj); ProjectorMapping mapping = projectorToIndices(projMatrix); @@ -744,9 +718,7 @@ class TrackStateProxy { /// Set an uncalibrated source link /// @param sourceLink The uncalibrated source link to set - void setUncalibratedSourceLink(SourceLink sourceLink) - requires(!ReadOnly) - { + void setUncalibratedSourceLink(SourceLink sourceLink) requires(!ReadOnly) { m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink)); } @@ -775,9 +747,7 @@ class TrackStateProxy { /// @return The measurement vector /// @note Mutable version template - Calibrated calibrated() - requires(!ReadOnly) - { + Calibrated calibrated() requires(!ReadOnly) { assert(has()); return m_traj->self().template calibrated(m_istate); } @@ -795,9 +765,7 @@ class TrackStateProxy { /// covariance is located in the top left corner, everything else is zeroed. /// @return The measurement covariance matrix template - CalibratedCovariance calibratedCovariance() - requires(!ReadOnly) - { + CalibratedCovariance calibratedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().template calibratedCovariance(m_istate); } @@ -805,9 +773,7 @@ class TrackStateProxy { /// Mutable dynamic measurement vector with only the valid dimensions. /// @warning The dynamic vector has a runtime overhead! /// @return The effective calibrated measurement vector - EffectiveCalibrated effectiveCalibrated() - requires(!ReadOnly) - { + EffectiveCalibrated effectiveCalibrated() requires(!ReadOnly) { assert(has()); return m_traj->self().effectiveCalibrated(m_istate); } @@ -872,9 +838,8 @@ class TrackStateProxy { /// @param shareSource Which component to share from /// @param shareTarget Which component to share as. This should be different from /// as @p shareSource, e.g. predicted can be shared as filtered. - void shareFrom(TrackStatePropMask shareSource, TrackStatePropMask shareTarget) - requires(!ReadOnly) - { + void shareFrom(TrackStatePropMask shareSource, + TrackStatePropMask shareTarget) requires(!ReadOnly) { shareFrom(*this, shareSource, shareTarget); } @@ -885,9 +850,7 @@ class TrackStateProxy { /// same @c MultiTrajectory instance template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask component) - requires(!ReadOnly) - { + TrackStatePropMask component) requires(!ReadOnly) { shareFrom(other, component, component); } @@ -900,9 +863,8 @@ class TrackStateProxy { /// or projector. See @c TrackStatePropMask. template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask shareSource, TrackStatePropMask shareTarget) - requires(!ReadOnly) - { + TrackStatePropMask shareSource, + TrackStatePropMask shareTarget) requires(!ReadOnly) { assert(m_traj == other.m_traj && "Cannot share components across MultiTrajectories"); @@ -925,9 +887,7 @@ class TrackStateProxy { template void copyFrom(const track_state_proxy_t& other, TrackStatePropMask mask = TrackStatePropMask::All, - bool onlyAllocated = true) - requires(!ReadOnly) - { + bool onlyAllocated = true) requires(!ReadOnly) { using PM = TrackStatePropMask; if (onlyAllocated) { @@ -1083,9 +1043,7 @@ class TrackStateProxy { /// @tparam key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component() - requires(!ReadOnly) - { + constexpr T& component() requires(!ReadOnly) { return m_traj->template component(m_istate); } @@ -1094,9 +1052,7 @@ class TrackStateProxy { /// @param key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component(HashedString key) - requires(!ReadOnly) - { + constexpr T& component(HashedString key) requires(!ReadOnly) { return m_traj->template component(key, m_istate); } @@ -1106,9 +1062,7 @@ class TrackStateProxy { /// @note This might hash the @p key at runtime instead of compile-time /// @return Mutable reference to the component given by @p key template - constexpr T& component(std::string_view key) - requires(!ReadOnly) - { + constexpr T& component(std::string_view key) requires(!ReadOnly) { return m_traj->template component(hashString(key), m_istate); } @@ -1144,9 +1098,7 @@ class TrackStateProxy { /// Return a mutable reference to the underlying backend container /// @return A reference to the backend container - MultiTrajectory& trajectory() - requires(!ReadOnly) - { + MultiTrajectory& trajectory() requires(!ReadOnly) { return *m_traj; } @@ -1156,11 +1108,7 @@ class TrackStateProxy { /// Get a mutable reference to the track state container backend /// @return a mutable reference to the backend - auto& container() - requires(!ReadOnly) - { - return *m_traj; - } + auto& container() requires(!ReadOnly) { return *m_traj; } /// Get a const reference to the track state container backend /// @return a const reference to the backend diff --git a/Core/include/Acts/EventData/TrackStateProxy.ipp b/Core/include/Acts/EventData/TrackStateProxy.ipp index dce15f15dd9..c509720bc11 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.ipp +++ b/Core/include/Acts/EventData/TrackStateProxy.ipp @@ -66,7 +66,8 @@ inline auto TrackStateProxy::projector() const -> Projector { assert(has()); ProjectorMapping mapping = component(); - SubspaceHelper subspaceHelper(mapping, calibratedSize()); + SubspaceHelper subspaceHelper( + {mapping.begin(), mapping.begin() + calibratedSize()}); return subspaceHelper.fullProjector(); } diff --git a/Core/include/Acts/Geometry/ConeVolumeBounds.hpp b/Core/include/Acts/Geometry/ConeVolumeBounds.hpp index 1d24bd78e19..f946705f6ce 100644 --- a/Core/include/Acts/Geometry/ConeVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/ConeVolumeBounds.hpp @@ -14,7 +14,6 @@ #include "Acts/Utilities/BoundingBox.hpp" #include -#include #include #include #include @@ -35,7 +34,7 @@ class PlanarBounds; class ConeVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for readability - enum BoundValues : std::uint8_t { + enum BoundValues : unsigned int { eInnerAlpha = 0, eInnerOffsetZ = 1, eOuterAlpha = 2, diff --git a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp index 94be1962333..d0c7a1b604d 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -50,7 +49,7 @@ class RectangleBounds; class CuboidVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for streaming and access - enum BoundValues : std::uint8_t { + enum BoundValues : unsigned int { eHalfLengthX = 0, eHalfLengthY = 1, eHalfLengthZ = 2, diff --git a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp index 1ba47d379e1..c5a28a4edb7 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp @@ -14,7 +14,6 @@ #include "Acts/Utilities/BinningType.hpp" #include -#include #include #include #include @@ -70,7 +69,7 @@ class PlanarBounds; class CylinderVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for streaming and access - enum BoundValues : std::uint8_t { + enum BoundValues : unsigned int { eMinR = 0, eMaxR = 1, eHalfLengthZ = 2, diff --git a/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp b/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp index 3d1fae5545e..edfcd8da1c7 100644 --- a/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp @@ -13,7 +13,6 @@ #include "Acts/Geometry/VolumeBounds.hpp" #include -#include #include #include #include @@ -51,7 +50,7 @@ class TrapezoidBounds; class TrapezoidVolumeBounds : public VolumeBounds { public: /// @enum BoundValues for access / streaming - enum BoundValues : std::uint8_t { + enum BoundValues : unsigned int { eHalfLengthXnegY = 0, //!< halflength in x at negative y eHalfLengthXposY = 1, //!< halflength in x at positive y eHalfLengthY = 2, //!< halflength in y diff --git a/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp b/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp index db808d6b15b..b4b665152fa 100644 --- a/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp +++ b/Core/include/Acts/Vertexing/LinearizerTrackParameters.hpp @@ -19,7 +19,7 @@ namespace Acts { /// @note This must be a regular `enum` and not a scoped `enum class` to allow /// implicit conversion to an integer. The enum value are thus visible directly /// in `namespace Acts` and are prefixed to avoid naming collisions. -enum LinIndices : std::uint8_t { +enum LinIndices : unsigned int { // Global spatial position of a point on the track, must be stored as one // continuous block. eLinPos0 = 0u, diff --git a/Core/src/TrackFinding/MeasurementSelector.cpp b/Core/src/TrackFinding/MeasurementSelector.cpp index dcc3c4fcf09..58705c75b29 100644 --- a/Core/src/TrackFinding/MeasurementSelector.cpp +++ b/Core/src/TrackFinding/MeasurementSelector.cpp @@ -48,7 +48,8 @@ double MeasurementSelector::calculateChi2( using ParametersVector = ActsVector; - SubspaceHelper subspaceHelper(projector, kMeasurementSize); + SubspaceHelper subspaceHelper( + {projector.begin(), projector.begin() + kMeasurementSize}); // Get the residuals ParametersVector res = diff --git a/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp b/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp index f63a94df499..0eaf9066173 100644 --- a/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp +++ b/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp @@ -37,7 +37,7 @@ void RefittingCalibrator::calibrate(const Acts::GeometryContext& /*gctx*/, sl.state.template calibratedCovariance(); }); - trackState.setProjectorBitset(sl.state.projectorBitset()); + trackState.setProjector(sl.state.projectorMapping()); } } // namespace ActsExamples From db7248cce0e8185aba3c2b930a0a061898d33a70 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 29 Jul 2024 21:32:32 +0200 Subject: [PATCH 05/23] minor --- Core/include/Acts/EventData/SubspaceHelpers.hpp | 2 +- Core/include/Acts/EventData/Types.hpp | 2 ++ Core/src/EventData/VectorMultiTrajectory.cpp | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index b270dbef7ea..134db98e681 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -131,7 +131,7 @@ class SubspaceHelper { } for (std::size_t i = 0; i < m_indices.size(); ++i) { auto index = m_indices[i]; - if (index < 0 || index >= kFullSize) { + if (index >= kFullSize) { return false; } if (std::find(m_indices.begin() + i + 1, m_indices.end(), index) != diff --git a/Core/include/Acts/EventData/Types.hpp b/Core/include/Acts/EventData/Types.hpp index bb4e694a42f..4986a53e0da 100644 --- a/Core/include/Acts/EventData/Types.hpp +++ b/Core/include/Acts/EventData/Types.hpp @@ -21,5 +21,7 @@ static constexpr TrackIndexType kTrackIndexInvalid = using ProjectorBitset = std::uint64_t; using ProjectorMapping = std::array; +static constexpr ProjectorMapping kProjectorMappingInvalid = { + eBoundSize, eBoundSize, eBoundSize, eBoundSize, eBoundSize, eBoundSize}; } // namespace Acts diff --git a/Core/src/EventData/VectorMultiTrajectory.cpp b/Core/src/EventData/VectorMultiTrajectory.cpp index b778e5787a0..ab4ea70352a 100644 --- a/Core/src/EventData/VectorMultiTrajectory.cpp +++ b/Core/src/EventData/VectorMultiTrajectory.cpp @@ -8,6 +8,7 @@ #include "Acts/EventData/VectorMultiTrajectory.hpp" +#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/TrackStatePropMask.hpp" #include "Acts/Utilities/Helpers.hpp" @@ -75,7 +76,7 @@ auto VectorMultiTrajectory::addTrackState_impl(TrackStatePropMask mask, m_sourceLinks.emplace_back(std::nullopt); p.icalibratedsourcelink = m_sourceLinks.size() - 1; - m_projectors.emplace_back(); + m_projectors.push_back(kProjectorMappingInvalid); p.iprojector = m_projectors.size() - 1; } @@ -130,7 +131,7 @@ void VectorMultiTrajectory::addTrackStateComponents_impl( m_sourceLinks.emplace_back(std::nullopt); p.icalibratedsourcelink = m_sourceLinks.size() - 1; - m_projectors.emplace_back(); + m_projectors.push_back(kProjectorMappingInvalid); p.iprojector = m_projectors.size() - 1; } From 9a01d17ceaf742f33849e2c04ac2fc0691d50bb1 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 29 Jul 2024 22:58:12 +0200 Subject: [PATCH 06/23] relax on warnings --- .../Acts/EventData/TrackStateProxy.hpp | 131 +++++++++++++----- .../Acts/TrackFitting/GainMatrixUpdater.hpp | 6 +- .../TrackFitting/GlobalChiSquareFitter.hpp | 8 +- .../Acts/TrackFitting/detail/GsfUtils.hpp | 10 +- Core/src/TrackFitting/GainMatrixUpdater.cpp | 9 +- Core/src/TrackFitting/GsfUtils.cpp | 11 +- 6 files changed, 121 insertions(+), 54 deletions(-) diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 041e86bde4d..1e1b1f65fb7 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -314,7 +314,9 @@ class TrackStateProxy { /// the track sequence /// @note Only available if the track state proxy is not read-only /// @return The index of the previous track state. - IndexType& previous() requires(!ReadOnly) { + IndexType& previous() + requires(!ReadOnly) + { return component(); } @@ -332,14 +334,18 @@ class TrackStateProxy { /// Unset an optional track state component /// @note Only available if the track state proxy is not read-only /// @param target The component to unset - void unset(TrackStatePropMask target) requires(!ReadOnly) { + void unset(TrackStatePropMask target) + requires(!ReadOnly) + { m_traj->self().unset(target, m_istate); } /// Add additional components to the track state /// @note Only available if the track state proxy is not read-only /// @param mask The bitmask that instructs which components to allocate - void addComponents(TrackStatePropMask mask) requires(!ReadOnly) { + void addComponents(TrackStatePropMask mask) + requires(!ReadOnly) + { m_traj->self().addTrackStateComponents_impl(m_istate, mask); } @@ -363,8 +369,9 @@ class TrackStateProxy { /// Set the reference surface to a given value /// @param srf Shared pointer to the surface to set /// @note This overload is only present in case @c ReadOnly is false. - void setReferenceSurface(std::shared_ptr srf) requires( - !ReadOnly) { + void setReferenceSurface(std::shared_ptr srf) + requires(!ReadOnly) + { m_traj->setReferenceSurface(m_istate, std::move(srf)); } // NOLINTEND(performance-unnecessary-value-param) @@ -374,7 +381,9 @@ class TrackStateProxy { /// value directly into the backing store. /// @note this overload is only enabled in case the proxy is not read-only /// @return Mutable reference to the chi2 value - float& chi2() requires(!ReadOnly) { + float& chi2() + requires(!ReadOnly) + { return component(); } @@ -403,7 +412,9 @@ class TrackStateProxy { /// This overloaded is only enabled if not read-only, and returns a mutable /// reference. /// @return reference to the type flags. - TrackStateType typeFlags() requires(!ReadOnly) { + TrackStateType typeFlags() + requires(!ReadOnly) + { return TrackStateType{ component()}; } @@ -457,7 +468,9 @@ class TrackStateProxy { component()); } - Covariance predictedCovariance() requires(!ReadOnly) { + Covariance predictedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -479,7 +492,9 @@ class TrackStateProxy { /// Filtered track parameters vector /// @return The filtered parameters /// @note Mutable version - Parameters filtered() requires(!ReadOnly) { + Parameters filtered() + requires(!ReadOnly) + { assert(has()); return m_traj->self().parameters( component()); @@ -497,7 +512,9 @@ class TrackStateProxy { /// Filtered track parameters covariance matrix /// @return The filtered parameters covariance /// @note Mutable version - Covariance filteredCovariance() requires(!ReadOnly) { + Covariance filteredCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -519,7 +536,9 @@ class TrackStateProxy { /// Smoothed track parameters vector /// @return The smoothed parameters /// @note Mutable version - Parameters smoothed() requires(!ReadOnly) { + Parameters smoothed() + requires(!ReadOnly) + { assert(has()); return m_traj->self().parameters( component()); @@ -537,7 +556,9 @@ class TrackStateProxy { /// Smoothed track parameters covariance matrix /// @return the parameter covariance matrix /// @note Mutable version - Covariance smoothedCovariance() requires(!ReadOnly) { + Covariance smoothedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -558,7 +579,9 @@ class TrackStateProxy { /// Returns the jacobian from the previous trackstate to this one /// @return The jacobian matrix /// @note Mutable version - Covariance jacobian() requires(!ReadOnly) { + Covariance jacobian() + requires(!ReadOnly) + { assert(has()); return m_traj->self().jacobian(m_istate); } @@ -604,10 +627,8 @@ class TrackStateProxy { /// measurement, is located in the top left corner, everything else is zero. /// @return The overallocated projector /// @deprecated This will be swapped out in favor of `projectorMapping` in the future - [[deprecated( - "This will be swapped out in favor of projectorMapping in the " - "future")]] Projector - projector() const; + //[[deprecated("This will be swapped out in favor of projectorMapping in the future")]] + Projector projector() const; /// Returns whether a projector is set /// @return Whether it is set @@ -620,8 +641,8 @@ class TrackStateProxy { /// measurement. /// @return The effective projector /// @deprecated This will be dropped in the future - [[deprecated("This will be dropped in the future")]] EffectiveProjector - effectiveProjector() const { + //[[deprecated("This will be dropped in the future")]] + EffectiveProjector effectiveProjector() const { return projector().topLeftCorner(calibratedSize(), M); } @@ -633,7 +654,9 @@ class TrackStateProxy { /// @deprecated Use setProjector(span) instead template [[deprecated("use setProjector(span) instead")]] void setProjector( - const Eigen::MatrixBase& projector) requires(!ReadOnly) { + const Eigen::MatrixBase& projector) + requires(!ReadOnly) + { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; constexpr int cols = Eigen::MatrixBase::ColsAtCompileTime; @@ -682,11 +705,15 @@ class TrackStateProxy { {mapping.begin(), mapping.begin() + calibratedSize()}); } - void setProjector(const ProjectorMapping& proj) requires(!ReadOnly) { + void setProjector(const ProjectorMapping& proj) + requires(!ReadOnly) + { component() = proj; } - void setProjector(std::span proj) requires(!ReadOnly) { + void setProjector(std::span proj) + requires(!ReadOnly) + { assert(has()); assert(proj.size() == calibratedSize() && "Invalid projector size"); ProjectorMapping mapping; @@ -705,7 +732,9 @@ class TrackStateProxy { /// `setProjector`. /// @deprecated Use setProjector(span) instead [[deprecated("use setProjector(span) instead")]] void setProjectorBitset( - ProjectorBitset proj) requires(!ReadOnly) { + ProjectorBitset proj) + requires(!ReadOnly) + { assert(has()); BoundMatrix projMatrix = bitsetToMatrix(proj); ProjectorMapping mapping = projectorToIndices(projMatrix); @@ -718,7 +747,9 @@ class TrackStateProxy { /// Set an uncalibrated source link /// @param sourceLink The uncalibrated source link to set - void setUncalibratedSourceLink(SourceLink sourceLink) requires(!ReadOnly) { + void setUncalibratedSourceLink(SourceLink sourceLink) + requires(!ReadOnly) + { m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink)); } @@ -747,7 +778,9 @@ class TrackStateProxy { /// @return The measurement vector /// @note Mutable version template - Calibrated calibrated() requires(!ReadOnly) { + Calibrated calibrated() + requires(!ReadOnly) + { assert(has()); return m_traj->self().template calibrated(m_istate); } @@ -765,7 +798,9 @@ class TrackStateProxy { /// covariance is located in the top left corner, everything else is zeroed. /// @return The measurement covariance matrix template - CalibratedCovariance calibratedCovariance() requires(!ReadOnly) { + CalibratedCovariance calibratedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().template calibratedCovariance(m_istate); } @@ -773,7 +808,9 @@ class TrackStateProxy { /// Mutable dynamic measurement vector with only the valid dimensions. /// @warning The dynamic vector has a runtime overhead! /// @return The effective calibrated measurement vector - EffectiveCalibrated effectiveCalibrated() requires(!ReadOnly) { + EffectiveCalibrated effectiveCalibrated() + requires(!ReadOnly) + { assert(has()); return m_traj->self().effectiveCalibrated(m_istate); } @@ -838,8 +875,9 @@ class TrackStateProxy { /// @param shareSource Which component to share from /// @param shareTarget Which component to share as. This should be different from /// as @p shareSource, e.g. predicted can be shared as filtered. - void shareFrom(TrackStatePropMask shareSource, - TrackStatePropMask shareTarget) requires(!ReadOnly) { + void shareFrom(TrackStatePropMask shareSource, TrackStatePropMask shareTarget) + requires(!ReadOnly) + { shareFrom(*this, shareSource, shareTarget); } @@ -850,7 +888,9 @@ class TrackStateProxy { /// same @c MultiTrajectory instance template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask component) requires(!ReadOnly) { + TrackStatePropMask component) + requires(!ReadOnly) + { shareFrom(other, component, component); } @@ -863,8 +903,9 @@ class TrackStateProxy { /// or projector. See @c TrackStatePropMask. template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask shareSource, - TrackStatePropMask shareTarget) requires(!ReadOnly) { + TrackStatePropMask shareSource, TrackStatePropMask shareTarget) + requires(!ReadOnly) + { assert(m_traj == other.m_traj && "Cannot share components across MultiTrajectories"); @@ -887,7 +928,9 @@ class TrackStateProxy { template void copyFrom(const track_state_proxy_t& other, TrackStatePropMask mask = TrackStatePropMask::All, - bool onlyAllocated = true) requires(!ReadOnly) { + bool onlyAllocated = true) + requires(!ReadOnly) + { using PM = TrackStatePropMask; if (onlyAllocated) { @@ -1043,7 +1086,9 @@ class TrackStateProxy { /// @tparam key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component() requires(!ReadOnly) { + constexpr T& component() + requires(!ReadOnly) + { return m_traj->template component(m_istate); } @@ -1052,7 +1097,9 @@ class TrackStateProxy { /// @param key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component(HashedString key) requires(!ReadOnly) { + constexpr T& component(HashedString key) + requires(!ReadOnly) + { return m_traj->template component(key, m_istate); } @@ -1062,7 +1109,9 @@ class TrackStateProxy { /// @note This might hash the @p key at runtime instead of compile-time /// @return Mutable reference to the component given by @p key template - constexpr T& component(std::string_view key) requires(!ReadOnly) { + constexpr T& component(std::string_view key) + requires(!ReadOnly) + { return m_traj->template component(hashString(key), m_istate); } @@ -1098,7 +1147,9 @@ class TrackStateProxy { /// Return a mutable reference to the underlying backend container /// @return A reference to the backend container - MultiTrajectory& trajectory() requires(!ReadOnly) { + MultiTrajectory& trajectory() + requires(!ReadOnly) + { return *m_traj; } @@ -1108,7 +1159,11 @@ class TrackStateProxy { /// Get a mutable reference to the track state container backend /// @return a mutable reference to the backend - auto& container() requires(!ReadOnly) { return *m_traj; } + auto& container() + requires(!ReadOnly) + { + return *m_traj; + } /// Get a const reference to the track state container backend /// @return a const reference to the backend diff --git a/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp b/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp index 86b6035bad8..1509ca4b37c 100644 --- a/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp +++ b/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp @@ -10,6 +10,7 @@ #include "Acts/EventData/MeasurementHelpers.hpp" #include "Acts/EventData/MultiTrajectory.hpp" +#include "Acts/EventData/Types.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/TrackFitting/KalmanFitterError.hpp" #include "Acts/Utilities/Logger.hpp" @@ -28,8 +29,7 @@ class GainMatrixUpdater { // This is used to build a covariance matrix view in the .cpp file const double* calibrated; const double* calibratedCovariance; - TrackStateTraits::Projector projector; + ProjectorMapping projector; TrackStateTraits::Parameters predicted; @@ -80,7 +80,7 @@ class GainMatrixUpdater { // shape later trackState.effectiveCalibrated().data(), trackState.effectiveCalibratedCovariance().data(), - trackState.projector(), + trackState.projectorMapping(), trackState.predicted(), trackState.predictedCovariance(), trackState.filtered(), diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index e575a4f1bdc..285c4a579a1 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -12,10 +12,12 @@ #include "Acts/Utilities/detail/ReferenceWrapperAnyCompat.hpp" #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/MultiTrajectoryHelpers.hpp" #include "Acts/EventData/SourceLink.hpp" +#include "Acts/EventData/SubspaceHelpers.hpp" #include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/EventData/VectorTrackContainer.hpp" @@ -248,8 +250,12 @@ void addToGx2fSums(BoundMatrix& aMatrix, BoundVector& bVector, double& chi2sum, ActsSquareMatrix covarianceMeasurement = trackState.template calibratedCovariance(); + SubspaceHelper subspaceHelper( + {trackState.projectorMapping().begin(), + trackState.projectorMapping().begin() + kMeasDim}); + ActsMatrix projector = - trackState.projector().template topLeftCorner(); + subspaceHelper.template projector(); ActsMatrix projJacobian = projector * jacobianFromStart; diff --git a/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp b/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp index 49f61eed3f3..adb83ec2b55 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-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 @@ -13,6 +13,7 @@ #include "Acts/EventData/MultiComponentTrackParameters.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/EventData/Types.hpp" #include "Acts/Utilities/Logger.hpp" #include @@ -154,9 +155,7 @@ ActsScalar calculateDeterminant( const double *fullCalibratedCovariance, TrackStateTraits::Covariance predictedCovariance, - TrackStateTraits::Projector - projector, - unsigned int calibratedSize); + ProjectorMapping projector, unsigned int calibratedSize); /// Reweight the components according to `R. Frühwirth, "Track fitting /// with non-Gaussian noise"`. See also the implementation in Athena at @@ -190,7 +189,8 @@ void computePosteriorWeights( .template calibratedCovariance< MultiTrajectoryTraits::MeasurementSizeMax>() .data(), - state.predictedCovariance(), state.projector(), state.calibratedSize()); + state.predictedCovariance(), state.projectorMapping(), + state.calibratedSize()); const auto factor = std::sqrt(1. / detR) * safeExp(-0.5 * chi2); diff --git a/Core/src/TrackFitting/GainMatrixUpdater.cpp b/Core/src/TrackFitting/GainMatrixUpdater.cpp index 8fbd2b1d841..a0260b3992f 100644 --- a/Core/src/TrackFitting/GainMatrixUpdater.cpp +++ b/Core/src/TrackFitting/GainMatrixUpdater.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" +#include "Acts/EventData/SubspaceHelpers.hpp" #include "Acts/TrackFitting/KalmanFitterError.hpp" #include @@ -42,9 +43,11 @@ std::tuple GainMatrixUpdater::visitMeasurement( ACTS_VERBOSE("Calibrated measurement covariance:\n" << calibratedCovariance); - const auto H = trackState.projector - .template topLeftCorner() - .eval(); + SubspaceHelper subspaceHelper( + {trackState.projector.begin(), + trackState.projector.begin() + kMeasurementSize}); + + const auto H = subspaceHelper.template projector(); ACTS_VERBOSE("Measurement projector H:\n" << H); diff --git a/Core/src/TrackFitting/GsfUtils.cpp b/Core/src/TrackFitting/GsfUtils.cpp index 56ed204fcd4..54435f7cbeb 100644 --- a/Core/src/TrackFitting/GsfUtils.cpp +++ b/Core/src/TrackFitting/GsfUtils.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-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 @@ -9,6 +9,7 @@ #include "Acts/TrackFitting/detail/GsfUtils.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" +#include "Acts/EventData/SubspaceHelpers.hpp" #include @@ -20,7 +21,7 @@ using TrackStateTraits = ActsScalar calculateDeterminant( const double* fullCalibratedCovariance, TrackStateTraits::Covariance predictedCovariance, - TrackStateTraits::Projector projector, unsigned int calibratedSize) { + ProjectorMapping projector, unsigned int calibratedSize) { return visit_measurement(calibratedSize, [&](auto N) { constexpr std::size_t kMeasurementSize = decltype(N)::value; @@ -28,8 +29,10 @@ ActsScalar calculateDeterminant( kMeasurementSize, true>::CalibratedCovariance calibratedCovariance{ fullCalibratedCovariance}; - const auto H = - projector.template topLeftCorner().eval(); + SubspaceHelper subspaceHelper( + {projector.begin(), projector.begin() + kMeasurementSize}); + + const auto H = subspaceHelper.template projector(); return (H * predictedCovariance * H.transpose() + calibratedCovariance) .determinant(); From d7f4681ec76189e3f8a0ffdd4b580b4b094b1a7b Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 08:26:26 +0200 Subject: [PATCH 07/23] revert gsf and gx2f changes --- Core/include/Acts/EventData/TrackStateProxy.ipp | 2 +- .../Acts/TrackFitting/GlobalChiSquareFitter.hpp | 8 +------- Core/include/Acts/TrackFitting/detail/GsfUtils.hpp | 10 +++++----- Core/src/TrackFitting/GsfUtils.cpp | 11 ++++------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Core/include/Acts/EventData/TrackStateProxy.ipp b/Core/include/Acts/EventData/TrackStateProxy.ipp index c509720bc11..853ae33d54f 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.ipp +++ b/Core/include/Acts/EventData/TrackStateProxy.ipp @@ -6,8 +6,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include "Acts/EventData/SubspaceHelpers.hpp" namespace Acts { + template inline TrackStateProxy::TrackStateProxy( detail_lt::ConstIf, ReadOnly>& trajectory, diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index 285c4a579a1..e575a4f1bdc 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -12,12 +12,10 @@ #include "Acts/Utilities/detail/ReferenceWrapperAnyCompat.hpp" #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/MultiTrajectoryHelpers.hpp" #include "Acts/EventData/SourceLink.hpp" -#include "Acts/EventData/SubspaceHelpers.hpp" #include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/EventData/VectorTrackContainer.hpp" @@ -250,12 +248,8 @@ void addToGx2fSums(BoundMatrix& aMatrix, BoundVector& bVector, double& chi2sum, ActsSquareMatrix covarianceMeasurement = trackState.template calibratedCovariance(); - SubspaceHelper subspaceHelper( - {trackState.projectorMapping().begin(), - trackState.projectorMapping().begin() + kMeasDim}); - ActsMatrix projector = - subspaceHelper.template projector(); + trackState.projector().template topLeftCorner(); ActsMatrix projJacobian = projector * jacobianFromStart; diff --git a/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp b/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp index adb83ec2b55..49f61eed3f3 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfUtils.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021-2024 CERN for the benefit of the Acts project +// Copyright (C) 2021 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 @@ -13,7 +13,6 @@ #include "Acts/EventData/MultiComponentTrackParameters.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/TrackParameters.hpp" -#include "Acts/EventData/Types.hpp" #include "Acts/Utilities/Logger.hpp" #include @@ -155,7 +154,9 @@ ActsScalar calculateDeterminant( const double *fullCalibratedCovariance, TrackStateTraits::Covariance predictedCovariance, - ProjectorMapping projector, unsigned int calibratedSize); + TrackStateTraits::Projector + projector, + unsigned int calibratedSize); /// Reweight the components according to `R. Frühwirth, "Track fitting /// with non-Gaussian noise"`. See also the implementation in Athena at @@ -189,8 +190,7 @@ void computePosteriorWeights( .template calibratedCovariance< MultiTrajectoryTraits::MeasurementSizeMax>() .data(), - state.predictedCovariance(), state.projectorMapping(), - state.calibratedSize()); + state.predictedCovariance(), state.projector(), state.calibratedSize()); const auto factor = std::sqrt(1. / detR) * safeExp(-0.5 * chi2); diff --git a/Core/src/TrackFitting/GsfUtils.cpp b/Core/src/TrackFitting/GsfUtils.cpp index 54435f7cbeb..56ed204fcd4 100644 --- a/Core/src/TrackFitting/GsfUtils.cpp +++ b/Core/src/TrackFitting/GsfUtils.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021-2024 CERN for the benefit of the Acts project +// Copyright (C) 2021 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 @@ -9,7 +9,6 @@ #include "Acts/TrackFitting/detail/GsfUtils.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" -#include "Acts/EventData/SubspaceHelpers.hpp" #include @@ -21,7 +20,7 @@ using TrackStateTraits = ActsScalar calculateDeterminant( const double* fullCalibratedCovariance, TrackStateTraits::Covariance predictedCovariance, - ProjectorMapping projector, unsigned int calibratedSize) { + TrackStateTraits::Projector projector, unsigned int calibratedSize) { return visit_measurement(calibratedSize, [&](auto N) { constexpr std::size_t kMeasurementSize = decltype(N)::value; @@ -29,10 +28,8 @@ ActsScalar calculateDeterminant( kMeasurementSize, true>::CalibratedCovariance calibratedCovariance{ fullCalibratedCovariance}; - SubspaceHelper subspaceHelper( - {projector.begin(), projector.begin() + kMeasurementSize}); - - const auto H = subspaceHelper.template projector(); + const auto H = + projector.template topLeftCorner().eval(); return (H * predictedCovariance * H.transpose() + calibratedCovariance) .determinant(); From b46013d64ef302e5a2cb8d8a00c495fada2352d8 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 08:39:39 +0200 Subject: [PATCH 08/23] drop deprecation for now --- Core/include/Acts/EventData/SubspaceHelpers.hpp | 4 ++-- Core/include/Acts/EventData/TrackStateProxy.hpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index 134db98e681..5ea850841c5 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -152,8 +152,8 @@ std::array projectorToIndices( std::array indices{}; for (std::size_t i = 0; i < rows; ++i) { for (std::size_t j = 0; j < cols; ++j) { - assert(projector(i, j) == 0 || - projector(i, j) == 1 && "Invalid projector value"); + assert((projector(i, j) == 0 || projector(i, j) == 1) && + "Invalid projector value"); if (projector(i, j) == 1) { indices[i] = j; } diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 1e1b1f65fb7..699d1597e02 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -627,7 +627,8 @@ class TrackStateProxy { /// measurement, is located in the top left corner, everything else is zero. /// @return The overallocated projector /// @deprecated This will be swapped out in favor of `projectorMapping` in the future - //[[deprecated("This will be swapped out in favor of projectorMapping in the future")]] + //[[deprecated("This will be swapped out in favor of projectorMapping in the + // future")]] Projector projector() const; /// Returns whether a projector is set @@ -653,8 +654,8 @@ class TrackStateProxy { /// @note @p projector is assumed to only have 0s or 1s as components. /// @deprecated Use setProjector(span) instead template - [[deprecated("use setProjector(span) instead")]] void setProjector( - const Eigen::MatrixBase& projector) + //[[deprecated("use setProjector(span) instead")]] + void setProjector(const Eigen::MatrixBase& projector) requires(!ReadOnly) { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; @@ -688,8 +689,8 @@ class TrackStateProxy { /// you want to access the matrix. /// @return The projector bitset /// @deprecated Use projector() instead - [[deprecated("use projector() instead")]] ProjectorBitset projectorBitset() - const { + //[[deprecated("use projector() instead")]] + ProjectorBitset projectorBitset() const { return projectorSubspace().projectorBitset(); } @@ -731,8 +732,8 @@ class TrackStateProxy { /// to another. If you have a projection matrix, set it with /// `setProjector`. /// @deprecated Use setProjector(span) instead - [[deprecated("use setProjector(span) instead")]] void setProjectorBitset( - ProjectorBitset proj) + //[[deprecated("use setProjector(span) instead")]] + void setProjectorBitset(ProjectorBitset proj) requires(!ReadOnly) { assert(has()); From de2b09e8fbe2d788aad8bc82a6e9272d2fb61997 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 15:59:57 +0200 Subject: [PATCH 09/23] refactor subspace; rework track state interface --- .../Acts/EventData/SubspaceHelpers.hpp | 213 ++++++++++++------ .../Acts/EventData/TrackStateProxy.hpp | 205 +++++++---------- .../Acts/EventData/TrackStateProxy.ipp | 9 +- Core/include/Acts/EventData/Types.hpp | 7 +- .../Acts/EventData/VectorMultiTrajectory.hpp | 4 +- .../Acts/EventData/detail/TestSourceLink.hpp | 5 +- .../Acts/TrackFinding/MeasurementSelector.hpp | 2 +- .../Acts/TrackFinding/MeasurementSelector.ipp | 2 +- .../Acts/TrackFitting/GainMatrixUpdater.hpp | 4 +- Core/src/EventData/VectorMultiTrajectory.cpp | 5 +- Core/src/TrackFinding/MeasurementSelector.cpp | 13 +- Core/src/TrackFitting/GainMatrixUpdater.cpp | 9 +- .../TrackFitting/src/RefittingCalibrator.cpp | 2 +- .../ActsExamples/EventData/Measurement.hpp | 23 +- .../src/EventData/MeasurementCalibration.cpp | 2 +- .../src/EventData/ScalingCalibrator.cpp | 2 +- .../Core/TrackFitting/MbfSmootherTests.cpp | 6 +- 17 files changed, 275 insertions(+), 238 deletions(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index 5ea850841c5..9a6d65d28ec 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -17,64 +17,151 @@ #include #include +#include + namespace Acts { -template -class SubspaceHelper { +template +class SubspaceHelperBase { public: - explicit SubspaceHelper(std::span indices) - : m_indices(indices) { - assert(check() && "Invalid subspace indices"); - } + static constexpr std::size_t kFullSize = FullSize; - std::size_t size() const { return m_indices.size(); } + using FullSquareMatrix = ActsSquareMatrix; + + SubspaceHelperBase() { assert(check() && "Invalid subspace indices"); } + + std::size_t size() const { return self().size(); } - BoundMatrix fullProjector() const { - BoundMatrix result = BoundMatrix::Zero(); - for (auto [i, index] : enumerate(m_indices)) { + auto operator[](std::size_t i) const { return self()[i]; } + + auto begin() const { return self().begin(); } + auto end() const { return self().end(); } + + FullSquareMatrix fullProjector() const { + FullSquareMatrix result = FullSquareMatrix::Zero(); + for (auto [i, index] : enumerate(*this)) { result(i, index) = 1; } return result; } - BoundMatrix fullExpander() const { - BoundMatrix result = BoundMatrix::Zero(); - for (auto [i, index] : enumerate(m_indices)) { + FullSquareMatrix fullExpander() const { + FullSquareMatrix result = FullSquareMatrix::Zero(); + for (auto [i, index] : enumerate(*this)) { result(index, i) = 1; } return result; } - template - ActsMatrix projector() const { - assert(size() == M && "Invalid subspace size"); - ActsMatrix result = ActsMatrix::Zero(); - for (auto [i, index] : enumerate(m_indices)) { + ProjectorBitset projectorBitset() const { + return matrixToBitset(fullProjector()).to_ullong(); + } + + private: + const Derived& self() const { return static_cast(*this); } + + bool check() const { + if (size() == 0 || size() > kFullSize) { + return false; + } + for (std::size_t i = 0; i < size(); ++i) { + auto index = operator[](i); + if (index >= kFullSize) { + return false; + } + if (std::find(begin() + i + 1, end(), index) != end()) { + return false; + } + } + return true; + } +}; + +template +class VariableSubspaceHelper + : public SubspaceHelperBase, + FullSize> { + public: + static constexpr std::size_t kFullSize = FullSize; + + using IndexType = index_t; + using Container = boost::container::static_vector; + + template + explicit VariableSubspaceHelper(const OtherContainer& indices) { + for (std::size_t i = 0; i < indices.size(); ++i) { + m_indices[i] = static_cast(indices[i]); + } + } + + std::size_t size() const { return m_indices.size(); } + + IndexType operator[](std::size_t i) const { return m_indices[i]; } + + auto begin() const { return m_indices.begin(); } + auto end() const { return m_indices.end(); } + + private: + Container m_indices; +}; + +template +class FixedSubspaceHelper + : public SubspaceHelperBase< + FixedSubspaceHelper, FullSize> { + public: + static constexpr std::size_t kFullSize = FullSize; + static constexpr std::size_t kSubspaceSize = SubspaceSize; + + using Projector = ActsMatrix; + using Expander = ActsMatrix; + using Vector = ActsVector; + using SquareMatrix = ActsSquareMatrix; + template + using ApplyLeftResult = ActsMatrix; + template + using ApplyRightResult = ActsMatrix; + + using IndexType = index_t; + using Container = std::array; + + template + explicit FixedSubspaceHelper(const OtherContainer& indices) { + for (std::size_t i = 0; i < kSubspaceSize; ++i) { + m_indices[i] = static_cast(indices[i]); + } + } + + std::size_t size() const { return m_indices.size(); } + + IndexType operator[](std::uint32_t i) const { return m_indices[i]; } + + auto begin() const { return m_indices.begin(); } + auto end() const { return m_indices.end(); } + + Projector projector() const { + Projector result = Projector::Zero(); + for (auto [i, index] : enumerate(*this)) { result(i, index) = 1; } return result; } - template - ActsMatrix expander() const { - assert(size() == M && "Invalid subspace size"); - ActsMatrix result = ActsMatrix::Zero(); - for (auto [i, index] : enumerate(m_indices)) { + Expander expander() const { + Expander result = Expander::Zero(); + for (auto [i, index] : enumerate(*this)) { result(index, i) = 1; } return result; } - ProjectorBitset projectorBitset() const { - return matrixToBitset(fullProjector()).to_ullong(); - } - - template - ActsMatrix applyLeft(const Eigen::DenseBase& matrix) const { - assert(size() == M && "Invalid subspace size"); - assert(matrix.rows() == M && "Invalid matrix size"); - ActsMatrix result = ActsMatrix::Zero(); - for (auto [i, indexI] : enumerate(m_indices)) { + template + ApplyLeftResult applyLeftOf( + const Eigen::DenseBase& matrix) const { + assert(matrix.rows() == kFullSize && "Invalid matrix size"); + ApplyLeftResult result = ApplyLeftResult::Zero(); + for (auto [i, indexI] : enumerate(*this)) { for (std::size_t j = 0; j < K; ++j) { result(i, j) = matrix(indexI, j); } @@ -82,40 +169,37 @@ class SubspaceHelper { return result; } - template - ActsMatrix applyRight(const Eigen::DenseBase& matrix) const { - assert(size() == M && "Invalid subspace size"); - assert(matrix.rows() == M && "Invalid matrix size"); - ActsMatrix result = ActsMatrix::Zero(); - for (auto [i, indexI] : enumerate(m_indices)) { - for (std::size_t j = 0; j < K; ++j) { - result(i, j) = matrix(j, indexI); + template + ApplyRightResult applyRightOf( + const Eigen::DenseBase& matrix) const { + assert(matrix.cols() == kSubspaceSize && "Invalid matrix size"); + ApplyRightResult result = ApplyRightResult::Zero(); + for (std::size_t i = 0; i < N; ++i) { + for (auto [j, indexJ] : enumerate(*this)) { + result(i, j) = matrix(i, indexJ); } } return result; } - template - ActsVector projectVector( - const Eigen::DenseBase& fullVector) const { - assert(size() == N && "Invalid subspace size"); + template + Vector projectVector(const Eigen::DenseBase& fullVector) const { assert(fullVector.size() == kFullSize && "Invalid full vector size"); - ActsVector result = ActsVector::Zero(); - for (auto [i, index] : enumerate(m_indices)) { + Vector result = Vector::Zero(); + for (auto [i, index] : enumerate(*this)) { result(i) = fullVector(index); } return result; } - template - ActsSquareMatrix projectMatrix( + template + SquareMatrix projectMatrix( const Eigen::DenseBase& fullMatrix) const { - assert(size() == N && "Invalid subspace size"); assert(fullMatrix.rows() == kFullSize && fullMatrix.cols() == kFullSize && "Invalid full matrix size"); - ActsSquareMatrix result = ActsSquareMatrix::Zero(); - for (auto [i, indexI] : enumerate(m_indices)) { - for (auto [j, indexJ] : enumerate(m_indices)) { + SquareMatrix result = SquareMatrix::Zero(); + for (auto [i, indexI] : enumerate(*this)) { + for (auto [j, indexJ] : enumerate(*this)) { result(i, j) = fullMatrix(indexI, indexJ); } } @@ -123,24 +207,7 @@ class SubspaceHelper { } private: - std::span m_indices; - - bool check() const { - if (m_indices.size() == 0 || m_indices.size() > kFullSize) { - return false; - } - for (std::size_t i = 0; i < m_indices.size(); ++i) { - auto index = m_indices[i]; - if (index >= kFullSize) { - return false; - } - if (std::find(m_indices.begin() + i + 1, m_indices.end(), index) != - m_indices.end()) { - return false; - } - } - return true; - } + Container m_indices; }; template @@ -158,7 +225,9 @@ std::array projectorToIndices( indices[i] = j; } } - assert(projector.row(i).sum() != 1 && "Invalid projector row"); + if (projector.row(i).sum() == 0) { + indices[i] = kFullSize; + } } return indices; } diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 699d1597e02..b91e97cbfc7 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -314,9 +314,7 @@ class TrackStateProxy { /// the track sequence /// @note Only available if the track state proxy is not read-only /// @return The index of the previous track state. - IndexType& previous() - requires(!ReadOnly) - { + IndexType& previous() requires(!ReadOnly) { return component(); } @@ -334,18 +332,14 @@ class TrackStateProxy { /// Unset an optional track state component /// @note Only available if the track state proxy is not read-only /// @param target The component to unset - void unset(TrackStatePropMask target) - requires(!ReadOnly) - { + void unset(TrackStatePropMask target) requires(!ReadOnly) { m_traj->self().unset(target, m_istate); } /// Add additional components to the track state /// @note Only available if the track state proxy is not read-only /// @param mask The bitmask that instructs which components to allocate - void addComponents(TrackStatePropMask mask) - requires(!ReadOnly) - { + void addComponents(TrackStatePropMask mask) requires(!ReadOnly) { m_traj->self().addTrackStateComponents_impl(m_istate, mask); } @@ -369,9 +363,8 @@ class TrackStateProxy { /// Set the reference surface to a given value /// @param srf Shared pointer to the surface to set /// @note This overload is only present in case @c ReadOnly is false. - void setReferenceSurface(std::shared_ptr srf) - requires(!ReadOnly) - { + void setReferenceSurface(std::shared_ptr srf) requires( + !ReadOnly) { m_traj->setReferenceSurface(m_istate, std::move(srf)); } // NOLINTEND(performance-unnecessary-value-param) @@ -381,9 +374,7 @@ class TrackStateProxy { /// value directly into the backing store. /// @note this overload is only enabled in case the proxy is not read-only /// @return Mutable reference to the chi2 value - float& chi2() - requires(!ReadOnly) - { + float& chi2() requires(!ReadOnly) { return component(); } @@ -412,9 +403,7 @@ class TrackStateProxy { /// This overloaded is only enabled if not read-only, and returns a mutable /// reference. /// @return reference to the type flags. - TrackStateType typeFlags() - requires(!ReadOnly) - { + TrackStateType typeFlags() requires(!ReadOnly) { return TrackStateType{ component()}; } @@ -468,9 +457,7 @@ class TrackStateProxy { component()); } - Covariance predictedCovariance() - requires(!ReadOnly) - { + Covariance predictedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -492,9 +479,7 @@ class TrackStateProxy { /// Filtered track parameters vector /// @return The filtered parameters /// @note Mutable version - Parameters filtered() - requires(!ReadOnly) - { + Parameters filtered() requires(!ReadOnly) { assert(has()); return m_traj->self().parameters( component()); @@ -512,9 +497,7 @@ class TrackStateProxy { /// Filtered track parameters covariance matrix /// @return The filtered parameters covariance /// @note Mutable version - Covariance filteredCovariance() - requires(!ReadOnly) - { + Covariance filteredCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -536,9 +519,7 @@ class TrackStateProxy { /// Smoothed track parameters vector /// @return The smoothed parameters /// @note Mutable version - Parameters smoothed() - requires(!ReadOnly) - { + Parameters smoothed() requires(!ReadOnly) { assert(has()); return m_traj->self().parameters( component()); @@ -556,9 +537,7 @@ class TrackStateProxy { /// Smoothed track parameters covariance matrix /// @return the parameter covariance matrix /// @note Mutable version - Covariance smoothedCovariance() - requires(!ReadOnly) - { + Covariance smoothedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -579,9 +558,7 @@ class TrackStateProxy { /// Returns the jacobian from the previous trackstate to this one /// @return The jacobian matrix /// @note Mutable version - Covariance jacobian() - requires(!ReadOnly) - { + Covariance jacobian() requires(!ReadOnly) { assert(has()); return m_traj->self().jacobian(m_istate); } @@ -655,9 +632,8 @@ class TrackStateProxy { /// @deprecated Use setProjector(span) instead template //[[deprecated("use setProjector(span) instead")]] - void setProjector(const Eigen::MatrixBase& projector) - requires(!ReadOnly) - { + void setProjector(const Eigen::MatrixBase& projector) requires( + !ReadOnly) { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; constexpr int cols = Eigen::MatrixBase::ColsAtCompileTime; @@ -678,7 +654,7 @@ class TrackStateProxy { fullProjector.template topLeftCorner() = projector; // convert to bitset before storing - auto projectorBitset = matrixToBitset(fullProjector); + ProjectorBitset projectorBitset = matrixToBitset(fullProjector).to_ulong(); setProjectorBitset(projectorBitset); } @@ -691,55 +667,50 @@ class TrackStateProxy { /// @deprecated Use projector() instead //[[deprecated("use projector() instead")]] ProjectorBitset projectorBitset() const { - return projectorSubspace().projectorBitset(); + return calibratedVariableSubspace().projectorBitset(); } - ProjectorMapping projectorMapping() const { - assert(has()); - return component(); + /// Set the projector bitset, a compressed form of a projection matrix + /// @param proj The projector bitset + /// + /// @note This is mainly to copy explicitly a projector from one state + /// to another. If you have a projection matrix, set it with + /// `setProjector`. + /// @deprecated Use setProjector(span) instead + //[[deprecated("use setProjector(span) instead")]] + void setProjectorBitset(ProjectorBitset proj) requires(!ReadOnly) { + BoundMatrix projMatrix = bitsetToMatrix(proj); + FullProjectorMapping fullMapping = + projectorToIndices(projMatrix); + setFullProjectorMapping(fullMapping); } - SubspaceHelper projectorSubspace() const { + FullProjectorMapping fullProjectorMapping() const { assert(has()); - ProjectorMapping mapping = projectorMapping(); - return SubspaceHelper( - {mapping.begin(), mapping.begin() + calibratedSize()}); + return component(); } - void setProjector(const ProjectorMapping& proj) - requires(!ReadOnly) - { - component() = proj; + template + ProjectorMapping projectorMapping() const { + FullProjectorMapping fullMapping = fullProjectorMapping(); + ProjectorMapping mapping; + std::copy(fullMapping.begin(), fullMapping.begin() + measdim, + mapping.begin()); + return mapping; } - void setProjector(std::span proj) - requires(!ReadOnly) - { + void setFullProjectorMapping(FullProjectorMapping fullMapping) requires( + !ReadOnly) { assert(has()); - assert(proj.size() == calibratedSize() && "Invalid projector size"); - ProjectorMapping mapping; - for (std::size_t i = 0; i < proj.size(); ++i) { - mapping[i] = static_cast(proj[i]); - } - std::fill(mapping.begin() + proj.size(), mapping.end(), eBoundSize); - component() = mapping; + component() = fullMapping; } - /// Set the projector bitset, a compressed form of a projection matrix - /// @param proj The projector bitset - /// - /// @note This is mainly to copy explicitly a projector from one state - /// to another. If you have a projection matrix, set it with - /// `setProjector`. - /// @deprecated Use setProjector(span) instead - //[[deprecated("use setProjector(span) instead")]] - void setProjectorBitset(ProjectorBitset proj) - requires(!ReadOnly) - { + template + void setProjectorMapping(ProjectorMapping proj) requires(!ReadOnly) { assert(has()); - BoundMatrix projMatrix = bitsetToMatrix(proj); - ProjectorMapping mapping = projectorToIndices(projMatrix); - component() = mapping; + FullProjectorMapping& fullMapping = + component(); + std::copy(proj.begin(), proj.end(), fullMapping.begin()); } /// Uncalibrated measurement in the form of a source link. Const version @@ -748,9 +719,7 @@ class TrackStateProxy { /// Set an uncalibrated source link /// @param sourceLink The uncalibrated source link to set - void setUncalibratedSourceLink(SourceLink sourceLink) - requires(!ReadOnly) - { + void setUncalibratedSourceLink(SourceLink sourceLink) requires(!ReadOnly) { m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink)); } @@ -779,9 +748,7 @@ class TrackStateProxy { /// @return The measurement vector /// @note Mutable version template - Calibrated calibrated() - requires(!ReadOnly) - { + Calibrated calibrated() requires(!ReadOnly) { assert(has()); return m_traj->self().template calibrated(m_istate); } @@ -799,9 +766,7 @@ class TrackStateProxy { /// covariance is located in the top left corner, everything else is zeroed. /// @return The measurement covariance matrix template - CalibratedCovariance calibratedCovariance() - requires(!ReadOnly) - { + CalibratedCovariance calibratedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().template calibratedCovariance(m_istate); } @@ -809,9 +774,7 @@ class TrackStateProxy { /// Mutable dynamic measurement vector with only the valid dimensions. /// @warning The dynamic vector has a runtime overhead! /// @return The effective calibrated measurement vector - EffectiveCalibrated effectiveCalibrated() - requires(!ReadOnly) - { + EffectiveCalibrated effectiveCalibrated() requires(!ReadOnly) { assert(has()); return m_traj->self().effectiveCalibrated(m_istate); } @@ -854,6 +817,28 @@ class TrackStateProxy { m_traj->allocateCalibrated(m_istate, measdim); } + VariableSubspaceHelper calibratedVariableSubspace() const { + FullProjectorMapping fullMapping = fullProjectorMapping(); + return VariableSubspaceHelper(fullMapping); + } + + template + FixedSubspaceHelper calibratedFixedSubspace() const { + ProjectorMapping mapping = projectorMapping(); + return FixedSubspaceHelper(mapping); + } + + template + void setCalibratedSubspace( + std::array subspaceIndices) requires(!ReadOnly) { + assert(has()); + FullProjectorMapping& fullMapping = + component(); + for (std::size_t i = 0; i < eBoundSize; ++i) { + fullMapping[i] = static_cast(subspaceIndices[i]); + } + } + /// @} /// @anchor track_state_share_copy @@ -876,9 +861,8 @@ class TrackStateProxy { /// @param shareSource Which component to share from /// @param shareTarget Which component to share as. This should be different from /// as @p shareSource, e.g. predicted can be shared as filtered. - void shareFrom(TrackStatePropMask shareSource, TrackStatePropMask shareTarget) - requires(!ReadOnly) - { + void shareFrom(TrackStatePropMask shareSource, + TrackStatePropMask shareTarget) requires(!ReadOnly) { shareFrom(*this, shareSource, shareTarget); } @@ -889,9 +873,7 @@ class TrackStateProxy { /// same @c MultiTrajectory instance template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask component) - requires(!ReadOnly) - { + TrackStatePropMask component) requires(!ReadOnly) { shareFrom(other, component, component); } @@ -904,9 +886,8 @@ class TrackStateProxy { /// or projector. See @c TrackStatePropMask. template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask shareSource, TrackStatePropMask shareTarget) - requires(!ReadOnly) - { + TrackStatePropMask shareSource, + TrackStatePropMask shareTarget) requires(!ReadOnly) { assert(m_traj == other.m_traj && "Cannot share components across MultiTrajectories"); @@ -929,9 +910,7 @@ class TrackStateProxy { template void copyFrom(const track_state_proxy_t& other, TrackStatePropMask mask = TrackStatePropMask::All, - bool onlyAllocated = true) - requires(!ReadOnly) - { + bool onlyAllocated = true) requires(!ReadOnly) { using PM = TrackStatePropMask; if (onlyAllocated) { @@ -991,7 +970,7 @@ class TrackStateProxy { other.template calibratedCovariance(); }); - setProjector(other.projectorMapping()); + setFullProjectorMapping(other.fullProjectorMapping()); } } else { if (ACTS_CHECK_BIT(mask, PM::Predicted) && @@ -1038,7 +1017,7 @@ class TrackStateProxy { other.template calibratedCovariance(); }); - setProjector(other.projectorMapping()); + setFullProjectorMapping(other.fullProjectorMapping()); } } @@ -1087,9 +1066,7 @@ class TrackStateProxy { /// @tparam key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component() - requires(!ReadOnly) - { + constexpr T& component() requires(!ReadOnly) { return m_traj->template component(m_istate); } @@ -1098,9 +1075,7 @@ class TrackStateProxy { /// @param key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component(HashedString key) - requires(!ReadOnly) - { + constexpr T& component(HashedString key) requires(!ReadOnly) { return m_traj->template component(key, m_istate); } @@ -1110,9 +1085,7 @@ class TrackStateProxy { /// @note This might hash the @p key at runtime instead of compile-time /// @return Mutable reference to the component given by @p key template - constexpr T& component(std::string_view key) - requires(!ReadOnly) - { + constexpr T& component(std::string_view key) requires(!ReadOnly) { return m_traj->template component(hashString(key), m_istate); } @@ -1148,9 +1121,7 @@ class TrackStateProxy { /// Return a mutable reference to the underlying backend container /// @return A reference to the backend container - MultiTrajectory& trajectory() - requires(!ReadOnly) - { + MultiTrajectory& trajectory() requires(!ReadOnly) { return *m_traj; } @@ -1160,11 +1131,7 @@ class TrackStateProxy { /// Get a mutable reference to the track state container backend /// @return a mutable reference to the backend - auto& container() - requires(!ReadOnly) - { - return *m_traj; - } + auto& container() requires(!ReadOnly) { return *m_traj; } /// Get a const reference to the track state container backend /// @return a const reference to the backend diff --git a/Core/include/Acts/EventData/TrackStateProxy.ipp b/Core/include/Acts/EventData/TrackStateProxy.ipp index 853ae33d54f..3dfaa2bacbb 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.ipp +++ b/Core/include/Acts/EventData/TrackStateProxy.ipp @@ -7,7 +7,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. namespace Acts { - + template inline TrackStateProxy::TrackStateProxy( detail_lt::ConstIf, ReadOnly>& trajectory, @@ -63,12 +63,7 @@ inline auto TrackStateProxy::covariance() const template inline auto TrackStateProxy::projector() const -> Projector { - assert(has()); - ProjectorMapping mapping = - component(); - SubspaceHelper subspaceHelper( - {mapping.begin(), mapping.begin() + calibratedSize()}); - return subspaceHelper.fullProjector(); + return calibratedVariableSubspace().fullProjector(); } template diff --git a/Core/include/Acts/EventData/Types.hpp b/Core/include/Acts/EventData/Types.hpp index 4986a53e0da..2fe5c18e35e 100644 --- a/Core/include/Acts/EventData/Types.hpp +++ b/Core/include/Acts/EventData/Types.hpp @@ -20,8 +20,11 @@ static constexpr TrackIndexType kTrackIndexInvalid = std::numeric_limits::max(); using ProjectorBitset = std::uint64_t; -using ProjectorMapping = std::array; -static constexpr ProjectorMapping kProjectorMappingInvalid = { + +template +using ProjectorMapping = std::array; +using FullProjectorMapping = ProjectorMapping; +static constexpr FullProjectorMapping kFullProjectorMappingEmpty = { eBoundSize, eBoundSize, eBoundSize, eBoundSize, eBoundSize, eBoundSize}; } // namespace Acts diff --git a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp index 4a3a682b19c..bbe271a279f 100644 --- a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp +++ b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp @@ -133,7 +133,7 @@ class VectorMultiTrajectoryBase { h("meas", isMeas, weight(meas_size)); h("measCov", isMeas, weight(meas_cov_size)); h("sourceLinks", isMeas, weight(sizeof(const SourceLink))); - h("projectors", isMeas, weight(sizeof(ProjectorMapping))); + h("projectors", isMeas, weight(sizeof(FullProjectorMapping))); } if (ts.hasJacobian() && @@ -327,7 +327,7 @@ class VectorMultiTrajectoryBase { std::vector::Covariance> m_jac; std::vector> m_sourceLinks; - std::vector m_projectors; + std::vector m_projectors; // owning vector of shared pointers to surfaces // diff --git a/Core/include/Acts/EventData/detail/TestSourceLink.hpp b/Core/include/Acts/EventData/detail/TestSourceLink.hpp index 60ef67238f4..f2ead6974aa 100644 --- a/Core/include/Acts/EventData/detail/TestSourceLink.hpp +++ b/Core/include/Acts/EventData/detail/TestSourceLink.hpp @@ -120,13 +120,14 @@ void testSourceLinkCalibratorReturn( trackState.allocateCalibrated(2); trackState.template calibrated<2>() = sl.parameters; trackState.template calibratedCovariance<2>() = sl.covariance; - trackState.setProjector(std::array{sl.indices[0], sl.indices[1]}); + trackState.template setCalibratedSubspace( + std::array{sl.indices[0], sl.indices[1]}); } else if (sl.indices[0] != Acts::eBoundSize) { trackState.allocateCalibrated(1); trackState.template calibrated<1>() = sl.parameters.head<1>(); trackState.template calibratedCovariance<1>() = sl.covariance.topLeftCorner<1, 1>(); - trackState.setProjector(std::array{sl.indices[0]}); + trackState.template setCalibratedSubspace(std::array{sl.indices[0]}); } else { throw std::runtime_error( "Tried to extract measurement from invalid TestSourceLink"); diff --git a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp index 03dafbe2ef6..40a5388fbf9 100644 --- a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp +++ b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp @@ -106,7 +106,7 @@ class MeasurementSelector { false>::Parameters predicted, TrackStateTraits::Covariance predictedCovariance, - ProjectorMapping projector, unsigned int calibratedSize) const; + FullProjectorMapping projector, unsigned int calibratedSize) const; Config m_config; }; diff --git a/Core/include/Acts/TrackFinding/MeasurementSelector.ipp b/Core/include/Acts/TrackFinding/MeasurementSelector.ipp index 0ca65a8cfee..e950de4179c 100644 --- a/Core/include/Acts/TrackFinding/MeasurementSelector.ipp +++ b/Core/include/Acts/TrackFinding/MeasurementSelector.ipp @@ -71,7 +71,7 @@ MeasurementSelector::select( trackState.effectiveCalibrated().data(), trackState.effectiveCalibratedCovariance().data(), trackState.predicted(), trackState.predictedCovariance(), - trackState.projectorMapping(), trackState.calibratedSize()); + trackState.fullProjectorMapping(), trackState.calibratedSize()); trackState.chi2() = chi2; if (chi2 < minChi2) { diff --git a/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp b/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp index 1509ca4b37c..3d6e9125896 100644 --- a/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp +++ b/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp @@ -29,7 +29,7 @@ class GainMatrixUpdater { // This is used to build a covariance matrix view in the .cpp file const double* calibrated; const double* calibratedCovariance; - ProjectorMapping projector; + FullProjectorMapping projector; TrackStateTraits::Parameters predicted; @@ -80,7 +80,7 @@ class GainMatrixUpdater { // shape later trackState.effectiveCalibrated().data(), trackState.effectiveCalibratedCovariance().data(), - trackState.projectorMapping(), + trackState.fullProjectorMapping(), trackState.predicted(), trackState.predictedCovariance(), trackState.filtered(), diff --git a/Core/src/EventData/VectorMultiTrajectory.cpp b/Core/src/EventData/VectorMultiTrajectory.cpp index ab4ea70352a..4ea488b4b23 100644 --- a/Core/src/EventData/VectorMultiTrajectory.cpp +++ b/Core/src/EventData/VectorMultiTrajectory.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/TrackStatePropMask.hpp" +#include "Acts/EventData/Types.hpp" #include "Acts/Utilities/Helpers.hpp" #include @@ -76,7 +77,7 @@ auto VectorMultiTrajectory::addTrackState_impl(TrackStatePropMask mask, m_sourceLinks.emplace_back(std::nullopt); p.icalibratedsourcelink = m_sourceLinks.size() - 1; - m_projectors.push_back(kProjectorMappingInvalid); + m_projectors.push_back(kFullProjectorMappingEmpty); p.iprojector = m_projectors.size() - 1; } @@ -131,7 +132,7 @@ void VectorMultiTrajectory::addTrackStateComponents_impl( m_sourceLinks.emplace_back(std::nullopt); p.icalibratedsourcelink = m_sourceLinks.size() - 1; - m_projectors.push_back(kProjectorMappingInvalid); + m_projectors.push_back(kFullProjectorMappingEmpty); p.iprojector = m_projectors.size() - 1; } diff --git a/Core/src/TrackFinding/MeasurementSelector.cpp b/Core/src/TrackFinding/MeasurementSelector.cpp index 58705c75b29..eb867c5d585 100644 --- a/Core/src/TrackFinding/MeasurementSelector.cpp +++ b/Core/src/TrackFinding/MeasurementSelector.cpp @@ -33,7 +33,7 @@ double MeasurementSelector::calculateChi2( false>::Parameters predicted, TrackStateTraits::Covariance predictedCovariance, - ProjectorMapping projector, unsigned int calibratedSize) const { + FullProjectorMapping projector, unsigned int calibratedSize) const { return visit_measurement( calibratedSize, [&fullCalibrated, &fullCalibratedCovariance, &predicted, @@ -48,19 +48,18 @@ double MeasurementSelector::calculateChi2( using ParametersVector = ActsVector; - SubspaceHelper subspaceHelper( - {projector.begin(), projector.begin() + kMeasurementSize}); + FixedSubspaceHelper subspaceHelper( + std::span( + projector.begin(), projector.begin() + kMeasurementSize)); // Get the residuals ParametersVector res = - calibrated - - subspaceHelper.projectVector(predicted); + calibrated - subspaceHelper.projectVector(predicted); // Get the chi2 return (res.transpose() * (calibratedCovariance + - subspaceHelper.projectMatrix( - predictedCovariance)) + subspaceHelper.projectMatrix(predictedCovariance)) .inverse() * res) .eval()(0, 0); diff --git a/Core/src/TrackFitting/GainMatrixUpdater.cpp b/Core/src/TrackFitting/GainMatrixUpdater.cpp index a0260b3992f..67682a20560 100644 --- a/Core/src/TrackFitting/GainMatrixUpdater.cpp +++ b/Core/src/TrackFitting/GainMatrixUpdater.cpp @@ -43,11 +43,12 @@ std::tuple GainMatrixUpdater::visitMeasurement( ACTS_VERBOSE("Calibrated measurement covariance:\n" << calibratedCovariance); - SubspaceHelper subspaceHelper( - {trackState.projector.begin(), - trackState.projector.begin() + kMeasurementSize}); + FixedSubspaceHelper subspaceHelper( + std::span( + trackState.projector.begin(), + trackState.projector.begin() + kMeasurementSize)); - const auto H = subspaceHelper.template projector(); + const auto H = subspaceHelper.projector(); ACTS_VERBOSE("Measurement projector H:\n" << H); diff --git a/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp b/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp index 0eaf9066173..d25d582ada3 100644 --- a/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp +++ b/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp @@ -37,7 +37,7 @@ void RefittingCalibrator::calibrate(const Acts::GeometryContext& /*gctx*/, sl.state.template calibratedCovariance(); }); - trackState.setProjector(sl.state.projectorMapping()); + trackState.setFullProjectorMapping(sl.state.fullProjectorMapping()); } } // namespace ActsExamples diff --git a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp index 15429002396..c6925882c71 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp @@ -72,14 +72,14 @@ class FixedSizeMeasurement { /// of parameters and covariance. template FixedSizeMeasurement(Acts::SourceLink source, - const std::array& indices, + const std::array& subsetIndices, const Eigen::MatrixBase& params, const Eigen::MatrixBase& cov) : m_source(std::move(source)), m_params(params), m_cov(cov) { for (std::size_t i = 0u; i < kSize; ++i) { - assert(indices[i] >= 0 && indices[i] < kFullSize && + assert(subsetIndices[i] >= 0 && subsetIndices[i] < kFullSize && "Index out of bounds"); - m_indices[i] = static_cast(indices[i]); + m_subsetIndices[i] = static_cast(subsetIndices[i]); } } /// A measurement can only be constructed with valid parameters. @@ -98,14 +98,15 @@ class FixedSizeMeasurement { /// Check if a specific parameter is part of this measurement. bool contains(indices_t i) const { - return std::find(m_indices.begin(), m_indices.end(), i) != m_indices.end(); + return std::find(m_subsetIndices.begin(), m_subsetIndices.end(), i) != + m_subsetIndices.end(); } /// The measurement indices constexpr std::array indices() const { std::array result; for (std::size_t i = 0u; i < kSize; ++i) { - result[i] = static_cast(m_indices[i]); + result[i] = static_cast(m_subsetIndices[i]); } return result; } @@ -120,7 +121,7 @@ class FixedSizeMeasurement { ProjectionMatrix projector() const { ProjectionMatrix proj = ProjectionMatrix::Zero(); for (std::size_t i = 0u; i < kSize; ++i) { - proj(i, m_indices[i]) = 1; + proj(i, m_subsetIndices[i]) = 1; } return proj; } @@ -134,7 +135,7 @@ class FixedSizeMeasurement { ExpansionMatrix expander() const { ExpansionMatrix expn = ExpansionMatrix::Zero(); for (std::size_t i = 0u; i < kSize; ++i) { - expn(m_indices[i], i) = 1; + expn(m_subsetIndices[i], i) = 1; } return expn; } @@ -148,21 +149,21 @@ class FixedSizeMeasurement { /// subspace are used for the computation. ParametersVector residuals(const FullParametersVector& reference) const { ParametersVector res = ParametersVector::Zero(); - Acts::detail::calculateResiduals(static_cast(kSize), m_indices, - reference, m_params, res); + Acts::detail::calculateResiduals(static_cast(kSize), + m_subsetIndices, reference, m_params, res); return res; } std::ostream& operator<<(std::ostream& os) const { Acts::detail::printMeasurement(os, static_cast(kSize), - m_indices.data(), m_params.data(), + m_subsetIndices.data(), m_params.data(), m_cov.data()); return os; } private: Acts::SourceLink m_source; - std::array m_indices; + std::array m_subsetIndices; ParametersVector m_params; CovarianceMatrix m_cov; }; diff --git a/Examples/Framework/src/EventData/MeasurementCalibration.cpp b/Examples/Framework/src/EventData/MeasurementCalibration.cpp index edd1b6dcf41..341a60dad85 100644 --- a/Examples/Framework/src/EventData/MeasurementCalibration.cpp +++ b/Examples/Framework/src/EventData/MeasurementCalibration.cpp @@ -40,7 +40,7 @@ void ActsExamples::PassThroughCalibrator::calibrate( trackState.calibrated() = meas.parameters(); trackState.calibratedCovariance() = meas.covariance(); - trackState.setProjector(meas.indices()); + trackState.setCalibratedSubspace(meas.indices()); }, measurements[idxSourceLink.index()]); } diff --git a/Examples/Framework/src/EventData/ScalingCalibrator.cpp b/Examples/Framework/src/EventData/ScalingCalibrator.cpp index 0433eb766e2..1e14738df8a 100644 --- a/Examples/Framework/src/EventData/ScalingCalibrator.cpp +++ b/Examples/Framework/src/EventData/ScalingCalibrator.cpp @@ -178,7 +178,7 @@ void ActsExamples::ScalingCalibrator::calibrate( trackState.allocateCalibrated(cmeas.size()); trackState.calibrated() = meas.parameters(); trackState.calibratedCovariance() = meas.covariance(); - trackState.setProjector(meas.indices()); + trackState.setCalibratedSubspace(meas.indices()); }, (measurements)[idxSourceLink.index()]); } diff --git a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp index e51dfbbb0d7..d1b484497a4 100644 --- a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp @@ -55,10 +55,10 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts.predicted() << 0.3, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.; ts.predictedCovariance() = covTrk; - ts.setProjector(projector); ts.allocateCalibrated(2); ts.calibrated<2>() << 0.351, 0.473; ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8; + ts.setCalibratedSubspace<2>(projector); ts.filtered() << 0.301, 0.503, 0.5 * M_PI, 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; @@ -72,10 +72,10 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts.predicted() << 0.2, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.; ts.predictedCovariance() = covTrk; - ts.setProjector(projector); ts.allocateCalibrated(2); ts.calibrated<2>() << 0.351, 0.473; ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8; + ts.setCalibratedSubspace<2>(projector); ts.filtered() << 0.27, 0.53, 0.5 * M_PI, 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; @@ -89,10 +89,10 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts.predicted() << 0.35, 0.49, 0.5 * M_PI, 0., 1 / 100., 0.; ts.predictedCovariance() = covTrk; - ts.setProjector(projector); ts.allocateCalibrated(2); ts.calibrated<2>() << 0.351, 0.473; ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8; + ts.setCalibratedSubspace<2>(projector); ts.filtered() << 0.33, 0.43, 0.5 * M_PI, 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; From 8178b6ec93856dbca6111a0883d67d3ba523ff87 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 18:27:14 +0200 Subject: [PATCH 10/23] calm compiler --- Core/include/Acts/EventData/SubspaceHelpers.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index 9a6d65d28ec..5fd3e358897 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -207,7 +207,7 @@ class FixedSubspaceHelper } private: - Container m_indices; + Container m_indices{}; }; template From beb98e27daebe5124b1c464729500166c898ebaa Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 18:40:05 +0200 Subject: [PATCH 11/23] fix silly --- .../Acts/EventData/SubspaceHelpers.hpp | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index 5fd3e358897..ea2c438f4a6 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -21,6 +21,25 @@ namespace Acts { +template +inline static bool checkSubspaceIndices(const Container& container, + std::size_t fullSize) { + if (container.size() == 0 || container.size() > fullSize) { + return false; + } + for (std::size_t i = 0; i < container.size(); ++i) { + auto index = container[i]; + if (index >= fullSize) { + return false; + } + if (std::find(container.begin() + i + 1, container.end(), index) != + container.end()) { + return false; + } + } + return true; +} + template class SubspaceHelperBase { public: @@ -28,8 +47,6 @@ class SubspaceHelperBase { using FullSquareMatrix = ActsSquareMatrix; - SubspaceHelperBase() { assert(check() && "Invalid subspace indices"); } - std::size_t size() const { return self().size(); } auto operator[](std::size_t i) const { return self()[i]; } @@ -59,22 +76,6 @@ class SubspaceHelperBase { private: const Derived& self() const { return static_cast(*this); } - - bool check() const { - if (size() == 0 || size() > kFullSize) { - return false; - } - for (std::size_t i = 0; i < size(); ++i) { - auto index = operator[](i); - if (index >= kFullSize) { - return false; - } - if (std::find(begin() + i + 1, end(), index) != end()) { - return false; - } - } - return true; - } }; template @@ -89,6 +90,7 @@ class VariableSubspaceHelper template explicit VariableSubspaceHelper(const OtherContainer& indices) { + assert(checkSubspaceIndices(indices, kFullSize) && "Invalid indices"); for (std::size_t i = 0; i < indices.size(); ++i) { m_indices[i] = static_cast(indices[i]); } @@ -124,10 +126,11 @@ class FixedSubspaceHelper using ApplyRightResult = ActsMatrix; using IndexType = index_t; - using Container = std::array; + using Container = std::array; template explicit FixedSubspaceHelper(const OtherContainer& indices) { + assert(checkSubspaceIndices(indices, kFullSize) && "Invalid indices"); for (std::size_t i = 0; i < kSubspaceSize; ++i) { m_indices[i] = static_cast(indices[i]); } From f94cf3e3810bf95e56243110fa3d9511cad56ada Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 19:26:52 +0200 Subject: [PATCH 12/23] make gcc happy --- Core/include/Acts/EventData/TrackStateProxy.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index b91e97cbfc7..b7b346ec6b8 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -834,7 +834,7 @@ class TrackStateProxy { assert(has()); FullProjectorMapping& fullMapping = component(); - for (std::size_t i = 0; i < eBoundSize; ++i) { + for (std::size_t i = 0; i < static_cast(eBoundSize); ++i) { fullMapping[i] = static_cast(subspaceIndices[i]); } } From 4667989ad992e28edbcd799915ea4abbce6e2174 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 21:05:19 +0200 Subject: [PATCH 13/23] fix silly --- Core/include/Acts/EventData/TrackStateProxy.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index b7b346ec6b8..4410db6d9a9 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -834,7 +834,7 @@ class TrackStateProxy { assert(has()); FullProjectorMapping& fullMapping = component(); - for (std::size_t i = 0; i < static_cast(eBoundSize); ++i) { + for (std::size_t i = 0; i < measdim; ++i) { fullMapping[i] = static_cast(subspaceIndices[i]); } } From 9b1b150b93b579ab4994d64fc344ddd58ba1b895 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 22:38:38 +0200 Subject: [PATCH 14/23] fix fix fix --- .../Acts/EventData/SubspaceHelpers.hpp | 1 + .../Acts/EventData/TrackStateProxy.hpp | 131 +++++++++++++----- Plugins/Podio/edm.yml | 2 +- .../Podio/PodioTrackStateContainer.hpp | 2 +- 4 files changed, 97 insertions(+), 39 deletions(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index ea2c438f4a6..4eb2c2d5cb5 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -91,6 +91,7 @@ class VariableSubspaceHelper template explicit VariableSubspaceHelper(const OtherContainer& indices) { assert(checkSubspaceIndices(indices, kFullSize) && "Invalid indices"); + m_indices.resize(indices.size()); for (std::size_t i = 0; i < indices.size(); ++i) { m_indices[i] = static_cast(indices[i]); } diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 4410db6d9a9..472b88b2439 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -314,7 +314,9 @@ class TrackStateProxy { /// the track sequence /// @note Only available if the track state proxy is not read-only /// @return The index of the previous track state. - IndexType& previous() requires(!ReadOnly) { + IndexType& previous() + requires(!ReadOnly) + { return component(); } @@ -332,14 +334,18 @@ class TrackStateProxy { /// Unset an optional track state component /// @note Only available if the track state proxy is not read-only /// @param target The component to unset - void unset(TrackStatePropMask target) requires(!ReadOnly) { + void unset(TrackStatePropMask target) + requires(!ReadOnly) + { m_traj->self().unset(target, m_istate); } /// Add additional components to the track state /// @note Only available if the track state proxy is not read-only /// @param mask The bitmask that instructs which components to allocate - void addComponents(TrackStatePropMask mask) requires(!ReadOnly) { + void addComponents(TrackStatePropMask mask) + requires(!ReadOnly) + { m_traj->self().addTrackStateComponents_impl(m_istate, mask); } @@ -363,8 +369,9 @@ class TrackStateProxy { /// Set the reference surface to a given value /// @param srf Shared pointer to the surface to set /// @note This overload is only present in case @c ReadOnly is false. - void setReferenceSurface(std::shared_ptr srf) requires( - !ReadOnly) { + void setReferenceSurface(std::shared_ptr srf) + requires(!ReadOnly) + { m_traj->setReferenceSurface(m_istate, std::move(srf)); } // NOLINTEND(performance-unnecessary-value-param) @@ -374,7 +381,9 @@ class TrackStateProxy { /// value directly into the backing store. /// @note this overload is only enabled in case the proxy is not read-only /// @return Mutable reference to the chi2 value - float& chi2() requires(!ReadOnly) { + float& chi2() + requires(!ReadOnly) + { return component(); } @@ -403,7 +412,9 @@ class TrackStateProxy { /// This overloaded is only enabled if not read-only, and returns a mutable /// reference. /// @return reference to the type flags. - TrackStateType typeFlags() requires(!ReadOnly) { + TrackStateType typeFlags() + requires(!ReadOnly) + { return TrackStateType{ component()}; } @@ -457,7 +468,9 @@ class TrackStateProxy { component()); } - Covariance predictedCovariance() requires(!ReadOnly) { + Covariance predictedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -479,7 +492,9 @@ class TrackStateProxy { /// Filtered track parameters vector /// @return The filtered parameters /// @note Mutable version - Parameters filtered() requires(!ReadOnly) { + Parameters filtered() + requires(!ReadOnly) + { assert(has()); return m_traj->self().parameters( component()); @@ -497,7 +512,9 @@ class TrackStateProxy { /// Filtered track parameters covariance matrix /// @return The filtered parameters covariance /// @note Mutable version - Covariance filteredCovariance() requires(!ReadOnly) { + Covariance filteredCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -519,7 +536,9 @@ class TrackStateProxy { /// Smoothed track parameters vector /// @return The smoothed parameters /// @note Mutable version - Parameters smoothed() requires(!ReadOnly) { + Parameters smoothed() + requires(!ReadOnly) + { assert(has()); return m_traj->self().parameters( component()); @@ -537,7 +556,9 @@ class TrackStateProxy { /// Smoothed track parameters covariance matrix /// @return the parameter covariance matrix /// @note Mutable version - Covariance smoothedCovariance() requires(!ReadOnly) { + Covariance smoothedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().covariance( component()); @@ -558,7 +579,9 @@ class TrackStateProxy { /// Returns the jacobian from the previous trackstate to this one /// @return The jacobian matrix /// @note Mutable version - Covariance jacobian() requires(!ReadOnly) { + Covariance jacobian() + requires(!ReadOnly) + { assert(has()); return m_traj->self().jacobian(m_istate); } @@ -632,8 +655,9 @@ class TrackStateProxy { /// @deprecated Use setProjector(span) instead template //[[deprecated("use setProjector(span) instead")]] - void setProjector(const Eigen::MatrixBase& projector) requires( - !ReadOnly) { + void setProjector(const Eigen::MatrixBase& projector) + requires(!ReadOnly) + { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; constexpr int cols = Eigen::MatrixBase::ColsAtCompileTime; @@ -678,7 +702,9 @@ class TrackStateProxy { /// `setProjector`. /// @deprecated Use setProjector(span) instead //[[deprecated("use setProjector(span) instead")]] - void setProjectorBitset(ProjectorBitset proj) requires(!ReadOnly) { + void setProjectorBitset(ProjectorBitset proj) + requires(!ReadOnly) + { BoundMatrix projMatrix = bitsetToMatrix(proj); FullProjectorMapping fullMapping = projectorToIndices(projMatrix); @@ -699,14 +725,17 @@ class TrackStateProxy { return mapping; } - void setFullProjectorMapping(FullProjectorMapping fullMapping) requires( - !ReadOnly) { + void setFullProjectorMapping(FullProjectorMapping fullMapping) + requires(!ReadOnly) + { assert(has()); component() = fullMapping; } template - void setProjectorMapping(ProjectorMapping proj) requires(!ReadOnly) { + void setProjectorMapping(ProjectorMapping proj) + requires(!ReadOnly) + { assert(has()); FullProjectorMapping& fullMapping = component(); @@ -719,7 +748,9 @@ class TrackStateProxy { /// Set an uncalibrated source link /// @param sourceLink The uncalibrated source link to set - void setUncalibratedSourceLink(SourceLink sourceLink) requires(!ReadOnly) { + void setUncalibratedSourceLink(SourceLink sourceLink) + requires(!ReadOnly) + { m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink)); } @@ -748,7 +779,9 @@ class TrackStateProxy { /// @return The measurement vector /// @note Mutable version template - Calibrated calibrated() requires(!ReadOnly) { + Calibrated calibrated() + requires(!ReadOnly) + { assert(has()); return m_traj->self().template calibrated(m_istate); } @@ -766,7 +799,9 @@ class TrackStateProxy { /// covariance is located in the top left corner, everything else is zeroed. /// @return The measurement covariance matrix template - CalibratedCovariance calibratedCovariance() requires(!ReadOnly) { + CalibratedCovariance calibratedCovariance() + requires(!ReadOnly) + { assert(has()); return m_traj->self().template calibratedCovariance(m_istate); } @@ -774,7 +809,9 @@ class TrackStateProxy { /// Mutable dynamic measurement vector with only the valid dimensions. /// @warning The dynamic vector has a runtime overhead! /// @return The effective calibrated measurement vector - EffectiveCalibrated effectiveCalibrated() requires(!ReadOnly) { + EffectiveCalibrated effectiveCalibrated() + requires(!ReadOnly) + { assert(has()); return m_traj->self().effectiveCalibrated(m_istate); } @@ -819,7 +856,8 @@ class TrackStateProxy { VariableSubspaceHelper calibratedVariableSubspace() const { FullProjectorMapping fullMapping = fullProjectorMapping(); - return VariableSubspaceHelper(fullMapping); + return VariableSubspaceHelper( + std::span(fullMapping.begin(), fullMapping.begin() + calibratedSize())); } template @@ -829,8 +867,9 @@ class TrackStateProxy { } template - void setCalibratedSubspace( - std::array subspaceIndices) requires(!ReadOnly) { + void setCalibratedSubspace(std::array subspaceIndices) + requires(!ReadOnly) + { assert(has()); FullProjectorMapping& fullMapping = component(); @@ -861,8 +900,9 @@ class TrackStateProxy { /// @param shareSource Which component to share from /// @param shareTarget Which component to share as. This should be different from /// as @p shareSource, e.g. predicted can be shared as filtered. - void shareFrom(TrackStatePropMask shareSource, - TrackStatePropMask shareTarget) requires(!ReadOnly) { + void shareFrom(TrackStatePropMask shareSource, TrackStatePropMask shareTarget) + requires(!ReadOnly) + { shareFrom(*this, shareSource, shareTarget); } @@ -873,7 +913,9 @@ class TrackStateProxy { /// same @c MultiTrajectory instance template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask component) requires(!ReadOnly) { + TrackStatePropMask component) + requires(!ReadOnly) + { shareFrom(other, component, component); } @@ -886,8 +928,9 @@ class TrackStateProxy { /// or projector. See @c TrackStatePropMask. template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask shareSource, - TrackStatePropMask shareTarget) requires(!ReadOnly) { + TrackStatePropMask shareSource, TrackStatePropMask shareTarget) + requires(!ReadOnly) + { assert(m_traj == other.m_traj && "Cannot share components across MultiTrajectories"); @@ -910,7 +953,9 @@ class TrackStateProxy { template void copyFrom(const track_state_proxy_t& other, TrackStatePropMask mask = TrackStatePropMask::All, - bool onlyAllocated = true) requires(!ReadOnly) { + bool onlyAllocated = true) + requires(!ReadOnly) + { using PM = TrackStatePropMask; if (onlyAllocated) { @@ -1066,7 +1111,9 @@ class TrackStateProxy { /// @tparam key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component() requires(!ReadOnly) { + constexpr T& component() + requires(!ReadOnly) + { return m_traj->template component(m_istate); } @@ -1075,7 +1122,9 @@ class TrackStateProxy { /// @param key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component(HashedString key) requires(!ReadOnly) { + constexpr T& component(HashedString key) + requires(!ReadOnly) + { return m_traj->template component(key, m_istate); } @@ -1085,7 +1134,9 @@ class TrackStateProxy { /// @note This might hash the @p key at runtime instead of compile-time /// @return Mutable reference to the component given by @p key template - constexpr T& component(std::string_view key) requires(!ReadOnly) { + constexpr T& component(std::string_view key) + requires(!ReadOnly) + { return m_traj->template component(hashString(key), m_istate); } @@ -1121,7 +1172,9 @@ class TrackStateProxy { /// Return a mutable reference to the underlying backend container /// @return A reference to the backend container - MultiTrajectory& trajectory() requires(!ReadOnly) { + MultiTrajectory& trajectory() + requires(!ReadOnly) + { return *m_traj; } @@ -1131,7 +1184,11 @@ class TrackStateProxy { /// Get a mutable reference to the track state container backend /// @return a mutable reference to the backend - auto& container() requires(!ReadOnly) { return *m_traj; } + auto& container() + requires(!ReadOnly) + { + return *m_traj; + } /// Get a const reference to the track state container backend /// @return a const reference to the backend diff --git a/Plugins/Podio/edm.yml b/Plugins/Podio/edm.yml index 4509de3e6fa..dc45e83eba7 100644 --- a/Plugins/Podio/edm.yml +++ b/Plugins/Podio/edm.yml @@ -58,7 +58,7 @@ components: - uint32_t measdim; - uint32_t ijacobian - - uint64_t projector + - std::array projector - bool hasProjector - float chi2 diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp index 5f47f62eaf8..d5d8f060f00 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-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 From 7f65592fd3f735f5e8215140409e1a7bc4baef64 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 23:42:29 +0200 Subject: [PATCH 15/23] try again --- Plugins/Podio/edm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Podio/edm.yml b/Plugins/Podio/edm.yml index dc45e83eba7..4ca37400a6d 100644 --- a/Plugins/Podio/edm.yml +++ b/Plugins/Podio/edm.yml @@ -58,7 +58,7 @@ components: - uint32_t measdim; - uint32_t ijacobian - - std::array projector + - std::array projector - bool hasProjector - float chi2 From c06c0d26f732c1686a6bb1405fab1ce1ee0ef96e Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 30 Jul 2024 23:53:00 +0200 Subject: [PATCH 16/23] format --- .../Acts/EventData/TrackStateProxy.hpp | 128 +++++------------- 1 file changed, 36 insertions(+), 92 deletions(-) diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 472b88b2439..df5a15d9f90 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -314,9 +314,7 @@ class TrackStateProxy { /// the track sequence /// @note Only available if the track state proxy is not read-only /// @return The index of the previous track state. - IndexType& previous() - requires(!ReadOnly) - { + IndexType& previous() requires(!ReadOnly) { return component(); } @@ -334,18 +332,14 @@ class TrackStateProxy { /// Unset an optional track state component /// @note Only available if the track state proxy is not read-only /// @param target The component to unset - void unset(TrackStatePropMask target) - requires(!ReadOnly) - { + void unset(TrackStatePropMask target) requires(!ReadOnly) { m_traj->self().unset(target, m_istate); } /// Add additional components to the track state /// @note Only available if the track state proxy is not read-only /// @param mask The bitmask that instructs which components to allocate - void addComponents(TrackStatePropMask mask) - requires(!ReadOnly) - { + void addComponents(TrackStatePropMask mask) requires(!ReadOnly) { m_traj->self().addTrackStateComponents_impl(m_istate, mask); } @@ -369,9 +363,8 @@ class TrackStateProxy { /// Set the reference surface to a given value /// @param srf Shared pointer to the surface to set /// @note This overload is only present in case @c ReadOnly is false. - void setReferenceSurface(std::shared_ptr srf) - requires(!ReadOnly) - { + void setReferenceSurface(std::shared_ptr srf) requires( + !ReadOnly) { m_traj->setReferenceSurface(m_istate, std::move(srf)); } // NOLINTEND(performance-unnecessary-value-param) @@ -381,9 +374,7 @@ class TrackStateProxy { /// value directly into the backing store. /// @note this overload is only enabled in case the proxy is not read-only /// @return Mutable reference to the chi2 value - float& chi2() - requires(!ReadOnly) - { + float& chi2() requires(!ReadOnly) { return component(); } @@ -412,9 +403,7 @@ class TrackStateProxy { /// This overloaded is only enabled if not read-only, and returns a mutable /// reference. /// @return reference to the type flags. - TrackStateType typeFlags() - requires(!ReadOnly) - { + TrackStateType typeFlags() requires(!ReadOnly) { return TrackStateType{ component()}; } @@ -468,9 +457,7 @@ class TrackStateProxy { component()); } - Covariance predictedCovariance() - requires(!ReadOnly) - { + Covariance predictedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -492,9 +479,7 @@ class TrackStateProxy { /// Filtered track parameters vector /// @return The filtered parameters /// @note Mutable version - Parameters filtered() - requires(!ReadOnly) - { + Parameters filtered() requires(!ReadOnly) { assert(has()); return m_traj->self().parameters( component()); @@ -512,9 +497,7 @@ class TrackStateProxy { /// Filtered track parameters covariance matrix /// @return The filtered parameters covariance /// @note Mutable version - Covariance filteredCovariance() - requires(!ReadOnly) - { + Covariance filteredCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -536,9 +519,7 @@ class TrackStateProxy { /// Smoothed track parameters vector /// @return The smoothed parameters /// @note Mutable version - Parameters smoothed() - requires(!ReadOnly) - { + Parameters smoothed() requires(!ReadOnly) { assert(has()); return m_traj->self().parameters( component()); @@ -556,9 +537,7 @@ class TrackStateProxy { /// Smoothed track parameters covariance matrix /// @return the parameter covariance matrix /// @note Mutable version - Covariance smoothedCovariance() - requires(!ReadOnly) - { + Covariance smoothedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().covariance( component()); @@ -579,9 +558,7 @@ class TrackStateProxy { /// Returns the jacobian from the previous trackstate to this one /// @return The jacobian matrix /// @note Mutable version - Covariance jacobian() - requires(!ReadOnly) - { + Covariance jacobian() requires(!ReadOnly) { assert(has()); return m_traj->self().jacobian(m_istate); } @@ -655,9 +632,8 @@ class TrackStateProxy { /// @deprecated Use setProjector(span) instead template //[[deprecated("use setProjector(span) instead")]] - void setProjector(const Eigen::MatrixBase& projector) - requires(!ReadOnly) - { + void setProjector(const Eigen::MatrixBase& projector) requires( + !ReadOnly) { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; constexpr int cols = Eigen::MatrixBase::ColsAtCompileTime; @@ -702,9 +678,7 @@ class TrackStateProxy { /// `setProjector`. /// @deprecated Use setProjector(span) instead //[[deprecated("use setProjector(span) instead")]] - void setProjectorBitset(ProjectorBitset proj) - requires(!ReadOnly) - { + void setProjectorBitset(ProjectorBitset proj) requires(!ReadOnly) { BoundMatrix projMatrix = bitsetToMatrix(proj); FullProjectorMapping fullMapping = projectorToIndices(projMatrix); @@ -725,17 +699,14 @@ class TrackStateProxy { return mapping; } - void setFullProjectorMapping(FullProjectorMapping fullMapping) - requires(!ReadOnly) - { + void setFullProjectorMapping(FullProjectorMapping fullMapping) requires( + !ReadOnly) { assert(has()); component() = fullMapping; } template - void setProjectorMapping(ProjectorMapping proj) - requires(!ReadOnly) - { + void setProjectorMapping(ProjectorMapping proj) requires(!ReadOnly) { assert(has()); FullProjectorMapping& fullMapping = component(); @@ -748,9 +719,7 @@ class TrackStateProxy { /// Set an uncalibrated source link /// @param sourceLink The uncalibrated source link to set - void setUncalibratedSourceLink(SourceLink sourceLink) - requires(!ReadOnly) - { + void setUncalibratedSourceLink(SourceLink sourceLink) requires(!ReadOnly) { m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink)); } @@ -779,9 +748,7 @@ class TrackStateProxy { /// @return The measurement vector /// @note Mutable version template - Calibrated calibrated() - requires(!ReadOnly) - { + Calibrated calibrated() requires(!ReadOnly) { assert(has()); return m_traj->self().template calibrated(m_istate); } @@ -799,9 +766,7 @@ class TrackStateProxy { /// covariance is located in the top left corner, everything else is zeroed. /// @return The measurement covariance matrix template - CalibratedCovariance calibratedCovariance() - requires(!ReadOnly) - { + CalibratedCovariance calibratedCovariance() requires(!ReadOnly) { assert(has()); return m_traj->self().template calibratedCovariance(m_istate); } @@ -809,9 +774,7 @@ class TrackStateProxy { /// Mutable dynamic measurement vector with only the valid dimensions. /// @warning The dynamic vector has a runtime overhead! /// @return The effective calibrated measurement vector - EffectiveCalibrated effectiveCalibrated() - requires(!ReadOnly) - { + EffectiveCalibrated effectiveCalibrated() requires(!ReadOnly) { assert(has()); return m_traj->self().effectiveCalibrated(m_istate); } @@ -867,9 +830,8 @@ class TrackStateProxy { } template - void setCalibratedSubspace(std::array subspaceIndices) - requires(!ReadOnly) - { + void setCalibratedSubspace( + std::array subspaceIndices) requires(!ReadOnly) { assert(has()); FullProjectorMapping& fullMapping = component(); @@ -900,9 +862,8 @@ class TrackStateProxy { /// @param shareSource Which component to share from /// @param shareTarget Which component to share as. This should be different from /// as @p shareSource, e.g. predicted can be shared as filtered. - void shareFrom(TrackStatePropMask shareSource, TrackStatePropMask shareTarget) - requires(!ReadOnly) - { + void shareFrom(TrackStatePropMask shareSource, + TrackStatePropMask shareTarget) requires(!ReadOnly) { shareFrom(*this, shareSource, shareTarget); } @@ -913,9 +874,7 @@ class TrackStateProxy { /// same @c MultiTrajectory instance template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask component) - requires(!ReadOnly) - { + TrackStatePropMask component) requires(!ReadOnly) { shareFrom(other, component, component); } @@ -928,9 +887,8 @@ class TrackStateProxy { /// or projector. See @c TrackStatePropMask. template void shareFrom(const TrackStateProxy& other, - TrackStatePropMask shareSource, TrackStatePropMask shareTarget) - requires(!ReadOnly) - { + TrackStatePropMask shareSource, + TrackStatePropMask shareTarget) requires(!ReadOnly) { assert(m_traj == other.m_traj && "Cannot share components across MultiTrajectories"); @@ -953,9 +911,7 @@ class TrackStateProxy { template void copyFrom(const track_state_proxy_t& other, TrackStatePropMask mask = TrackStatePropMask::All, - bool onlyAllocated = true) - requires(!ReadOnly) - { + bool onlyAllocated = true) requires(!ReadOnly) { using PM = TrackStatePropMask; if (onlyAllocated) { @@ -1111,9 +1067,7 @@ class TrackStateProxy { /// @tparam key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component() - requires(!ReadOnly) - { + constexpr T& component() requires(!ReadOnly) { return m_traj->template component(m_istate); } @@ -1122,9 +1076,7 @@ class TrackStateProxy { /// @param key String key for the component to access /// @return Mutable reference to the component given by @p key template - constexpr T& component(HashedString key) - requires(!ReadOnly) - { + constexpr T& component(HashedString key) requires(!ReadOnly) { return m_traj->template component(key, m_istate); } @@ -1134,9 +1086,7 @@ class TrackStateProxy { /// @note This might hash the @p key at runtime instead of compile-time /// @return Mutable reference to the component given by @p key template - constexpr T& component(std::string_view key) - requires(!ReadOnly) - { + constexpr T& component(std::string_view key) requires(!ReadOnly) { return m_traj->template component(hashString(key), m_istate); } @@ -1172,9 +1122,7 @@ class TrackStateProxy { /// Return a mutable reference to the underlying backend container /// @return A reference to the backend container - MultiTrajectory& trajectory() - requires(!ReadOnly) - { + MultiTrajectory& trajectory() requires(!ReadOnly) { return *m_traj; } @@ -1184,11 +1132,7 @@ class TrackStateProxy { /// Get a mutable reference to the track state container backend /// @return a mutable reference to the backend - auto& container() - requires(!ReadOnly) - { - return *m_traj; - } + auto& container() requires(!ReadOnly) { return *m_traj; } /// Get a const reference to the track state container backend /// @return a const reference to the backend From ba3394ef2fcc758304050e094c20fa0d7aa977f0 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 31 Jul 2024 09:50:27 +0200 Subject: [PATCH 17/23] workaround podio --- .../include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp index d5d8f060f00..c4735f2f8c2 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp @@ -122,7 +122,10 @@ class PodioTrackStateContainerBase { case "smoothed"_hash: return &data.ismoothed; case "projector"_hash: - return &data.projector; + // workaround podio not allowing `std::uint8_t` as a type + return reinterpret_cast>( + &data.projector); case "measdim"_hash: return &data.measdim; case "chi2"_hash: From 063547ebf9d2601c7f81a768ecff135b516c9ebb Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 1 Aug 2024 10:45:33 +0200 Subject: [PATCH 18/23] pr feedback --- .../Acts/EventData/SubspaceHelpers.hpp | 56 +++++++----- .../Acts/EventData/TrackStateProxy.hpp | 87 ++++++++++--------- .../Acts/EventData/TrackStateProxy.ipp | 2 +- Core/include/Acts/EventData/Types.hpp | 6 +- .../Acts/EventData/VectorMultiTrajectory.hpp | 4 +- .../Acts/EventData/detail/TestSourceLink.hpp | 4 +- .../Acts/TrackFinding/MeasurementSelector.hpp | 2 +- .../Acts/TrackFinding/MeasurementSelector.ipp | 2 +- .../Acts/TrackFitting/GainMatrixUpdater.hpp | 4 +- Core/src/EventData/VectorMultiTrajectory.cpp | 4 +- Core/src/TrackFinding/MeasurementSelector.cpp | 9 +- Core/src/TrackFitting/GainMatrixUpdater.cpp | 10 ++- .../TrackFitting/src/RefittingCalibrator.cpp | 2 +- .../ActsExamples/EventData/Measurement.hpp | 10 +-- .../src/EventData/MeasurementCalibration.cpp | 2 +- .../src/EventData/ScalingCalibrator.cpp | 2 +- .../Podio/PodioTrackStateContainer.hpp | 2 +- .../Core/TrackFitting/MbfSmootherTests.cpp | 6 +- 18 files changed, 115 insertions(+), 99 deletions(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index 4eb2c2d5cb5..85c21df6830 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -23,17 +23,21 @@ namespace Acts { template inline static bool checkSubspaceIndices(const Container& container, - std::size_t fullSize) { - if (container.size() == 0 || container.size() > fullSize) { + std::size_t fullSize, + std::size_t subspaceSize) { + if (subspaceSize > fullSize) { return false; } - for (std::size_t i = 0; i < container.size(); ++i) { - auto index = container[i]; + if (container.size() != subspaceSize) { + return false; + } + for (auto it = container.begin(); it != container.end();) { + auto index = *it; if (index >= fullSize) { return false; } - if (std::find(container.begin() + i + 1, container.end(), index) != - container.end()) { + ++it; + if (std::find(it, container.end(), index) != container.end()) { return false; } } @@ -47,6 +51,7 @@ class SubspaceHelperBase { using FullSquareMatrix = ActsSquareMatrix; + bool empty() const { return self().empty(); } std::size_t size() const { return self().size(); } auto operator[](std::size_t i) const { return self()[i]; } @@ -70,7 +75,7 @@ class SubspaceHelperBase { return result; } - ProjectorBitset projectorBitset() const { + ProjectorBitset projectorBitset() const requires(kFullSize <= 8) { return matrixToBitset(fullProjector()).to_ullong(); } @@ -90,13 +95,14 @@ class VariableSubspaceHelper template explicit VariableSubspaceHelper(const OtherContainer& indices) { - assert(checkSubspaceIndices(indices, kFullSize) && "Invalid indices"); + assert(checkSubspaceIndices(indices, kFullSize, indices.size()) && + "Invalid indices"); m_indices.resize(indices.size()); - for (std::size_t i = 0; i < indices.size(); ++i) { - m_indices[i] = static_cast(indices[i]); - } + std::transform(indices.begin(), indices.end(), m_indices.begin(), + [](auto index) { return static_cast(index); }); } + bool empty() const { return m_indices.empty(); } std::size_t size() const { return m_indices.size(); } IndexType operator[](std::size_t i) const { return m_indices[i]; } @@ -116,6 +122,7 @@ class FixedSubspaceHelper public: static constexpr std::size_t kFullSize = FullSize; static constexpr std::size_t kSubspaceSize = SubspaceSize; + static_assert(kSubspaceSize <= kFullSize, "Invalid subspace size"); using Projector = ActsMatrix; using Expander = ActsMatrix; @@ -131,12 +138,13 @@ class FixedSubspaceHelper template explicit FixedSubspaceHelper(const OtherContainer& indices) { - assert(checkSubspaceIndices(indices, kFullSize) && "Invalid indices"); - for (std::size_t i = 0; i < kSubspaceSize; ++i) { - m_indices[i] = static_cast(indices[i]); - } + assert(checkSubspaceIndices(indices, kFullSize, kSubspaceSize) && + "Invalid indices"); + std::transform(indices.begin(), indices.end(), m_indices.begin(), + [](auto index) { return static_cast(index); }); } + bool empty() const { return m_indices.empty(); } std::size_t size() const { return m_indices.size(); } IndexType operator[](std::uint32_t i) const { return m_indices[i]; } @@ -214,26 +222,30 @@ class FixedSubspaceHelper Container m_indices{}; }; +template +using FixedBoundSubspaceHelper = + FixedSubspaceHelper; +using VariableBoundSubspaceHelper = + VariableSubspaceHelper; + template -std::array projectorToIndices( +SubspaceIndices projectorToSubspaceIndices( const Eigen::DenseBase& projector) { auto rows = static_cast(projector.rows()); auto cols = static_cast(projector.cols()); assert(cols == kFullSize && rows <= kFullSize && "Invalid projector size"); - std::array indices{}; + SubspaceIndices result; + result.fill(kFullSize); for (std::size_t i = 0; i < rows; ++i) { for (std::size_t j = 0; j < cols; ++j) { assert((projector(i, j) == 0 || projector(i, j) == 1) && "Invalid projector value"); if (projector(i, j) == 1) { - indices[i] = j; + result[i] = j; } } - if (projector.row(i).sum() == 0) { - indices[i] = kFullSize; - } } - return indices; + return result; } } // namespace Acts diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index df5a15d9f90..e1710412638 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -667,7 +667,7 @@ class TrackStateProxy { /// @deprecated Use projector() instead //[[deprecated("use projector() instead")]] ProjectorBitset projectorBitset() const { - return calibratedVariableSubspace().projectorBitset(); + return variableBoundSubspaceHelper().projectorBitset(); } /// Set the projector bitset, a compressed form of a projection matrix @@ -680,37 +680,61 @@ class TrackStateProxy { //[[deprecated("use setProjector(span) instead")]] void setProjectorBitset(ProjectorBitset proj) requires(!ReadOnly) { BoundMatrix projMatrix = bitsetToMatrix(proj); - FullProjectorMapping fullMapping = - projectorToIndices(projMatrix); - setFullProjectorMapping(fullMapping); + BoundSubspaceIndices boundSubspace = + projectorToSubspaceIndices(projMatrix); + setBoundSubspaceIndices(boundSubspace); } - FullProjectorMapping fullProjectorMapping() const { + BoundSubspaceIndices boundSubspaceIndices() const { assert(has()); - return component(); + return component(); } template - ProjectorMapping projectorMapping() const { - FullProjectorMapping fullMapping = fullProjectorMapping(); - ProjectorMapping mapping; - std::copy(fullMapping.begin(), fullMapping.begin() + measdim, - mapping.begin()); - return mapping; + SubspaceIndices subspaceIndices() const { + BoundSubspaceIndices boundSubspace = BoundSubspaceIndices(); + SubspaceIndices subspace; + std::copy(boundSubspace.begin(), boundSubspace.begin() + measdim, + subspace.begin()); + return subspace; } - void setFullProjectorMapping(FullProjectorMapping fullMapping) requires( + void setBoundSubspaceIndices(BoundSubspaceIndices boundSubspace) requires( !ReadOnly) { assert(has()); - component() = fullMapping; + component() = boundSubspace; } template - void setProjectorMapping(ProjectorMapping proj) requires(!ReadOnly) { + void setSubspaceIndices(SubspaceIndices proj) requires(!ReadOnly) { assert(has()); - FullProjectorMapping& fullMapping = - component(); - std::copy(proj.begin(), proj.end(), fullMapping.begin()); + BoundSubspaceIndices& boundSubspace = + component(); + std::copy(proj.begin(), proj.end(), boundSubspace.begin()); + } + + template + void setSubspaceIndices( + std::array subspaceIndices) requires(!ReadOnly) { + assert(has()); + BoundSubspaceIndices& boundSubspace = + component(); + std::transform(subspaceIndices.begin(), subspaceIndices.end(), + boundSubspace.begin(), + [](index_t i) { return static_cast(i); }); + } + + VariableBoundSubspaceHelper variableBoundSubspaceHelper() const { + BoundSubspaceIndices boundSubspace = boundSubspaceIndices(); + std::span validSubspaceIndices( + boundSubspace.begin(), boundSubspace.begin() + calibratedSize()); + return VariableBoundSubspaceHelper(validSubspaceIndices); + } + + template + FixedBoundSubspaceHelper fixedBoundSubspaceHelper() const { + SubspaceIndices subspace = subspaceIndices(); + return FixedBoundSubspaceHelper(subspace); } /// Uncalibrated measurement in the form of a source link. Const version @@ -817,29 +841,6 @@ class TrackStateProxy { m_traj->allocateCalibrated(m_istate, measdim); } - VariableSubspaceHelper calibratedVariableSubspace() const { - FullProjectorMapping fullMapping = fullProjectorMapping(); - return VariableSubspaceHelper( - std::span(fullMapping.begin(), fullMapping.begin() + calibratedSize())); - } - - template - FixedSubspaceHelper calibratedFixedSubspace() const { - ProjectorMapping mapping = projectorMapping(); - return FixedSubspaceHelper(mapping); - } - - template - void setCalibratedSubspace( - std::array subspaceIndices) requires(!ReadOnly) { - assert(has()); - FullProjectorMapping& fullMapping = - component(); - for (std::size_t i = 0; i < measdim; ++i) { - fullMapping[i] = static_cast(subspaceIndices[i]); - } - } - /// @} /// @anchor track_state_share_copy @@ -971,7 +972,7 @@ class TrackStateProxy { other.template calibratedCovariance(); }); - setFullProjectorMapping(other.fullProjectorMapping()); + setBoundSubspaceIndices(other.boundSubspaceIndices()); } } else { if (ACTS_CHECK_BIT(mask, PM::Predicted) && @@ -1018,7 +1019,7 @@ class TrackStateProxy { other.template calibratedCovariance(); }); - setFullProjectorMapping(other.fullProjectorMapping()); + setBoundSubspaceIndices(other.boundSubspaceIndices()); } } diff --git a/Core/include/Acts/EventData/TrackStateProxy.ipp b/Core/include/Acts/EventData/TrackStateProxy.ipp index 3dfaa2bacbb..c12c34ac744 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.ipp +++ b/Core/include/Acts/EventData/TrackStateProxy.ipp @@ -63,7 +63,7 @@ inline auto TrackStateProxy::covariance() const template inline auto TrackStateProxy::projector() const -> Projector { - return calibratedVariableSubspace().fullProjector(); + return variableBoundSubspaceHelper().fullProjector(); } template diff --git a/Core/include/Acts/EventData/Types.hpp b/Core/include/Acts/EventData/Types.hpp index 2fe5c18e35e..3aabf64c1e1 100644 --- a/Core/include/Acts/EventData/Types.hpp +++ b/Core/include/Acts/EventData/Types.hpp @@ -22,9 +22,9 @@ static constexpr TrackIndexType kTrackIndexInvalid = using ProjectorBitset = std::uint64_t; template -using ProjectorMapping = std::array; -using FullProjectorMapping = ProjectorMapping; -static constexpr FullProjectorMapping kFullProjectorMappingEmpty = { +using SubspaceIndices = std::array; +using BoundSubspaceIndices = SubspaceIndices; +static constexpr BoundSubspaceIndices kBoundSubspaceIndicesInvalid = { eBoundSize, eBoundSize, eBoundSize, eBoundSize, eBoundSize, eBoundSize}; } // namespace Acts diff --git a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp index bbe271a279f..3195d01d36f 100644 --- a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp +++ b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp @@ -133,7 +133,7 @@ class VectorMultiTrajectoryBase { h("meas", isMeas, weight(meas_size)); h("measCov", isMeas, weight(meas_cov_size)); h("sourceLinks", isMeas, weight(sizeof(const SourceLink))); - h("projectors", isMeas, weight(sizeof(FullProjectorMapping))); + h("projectors", isMeas, weight(sizeof(BoundSubspaceIndices))); } if (ts.hasJacobian() && @@ -327,7 +327,7 @@ class VectorMultiTrajectoryBase { std::vector::Covariance> m_jac; std::vector> m_sourceLinks; - std::vector m_projectors; + std::vector m_projectors; // owning vector of shared pointers to surfaces // diff --git a/Core/include/Acts/EventData/detail/TestSourceLink.hpp b/Core/include/Acts/EventData/detail/TestSourceLink.hpp index f2ead6974aa..fc0ae3cb358 100644 --- a/Core/include/Acts/EventData/detail/TestSourceLink.hpp +++ b/Core/include/Acts/EventData/detail/TestSourceLink.hpp @@ -120,14 +120,14 @@ void testSourceLinkCalibratorReturn( trackState.allocateCalibrated(2); trackState.template calibrated<2>() = sl.parameters; trackState.template calibratedCovariance<2>() = sl.covariance; - trackState.template setCalibratedSubspace( + trackState.template setSubspaceIndices( std::array{sl.indices[0], sl.indices[1]}); } else if (sl.indices[0] != Acts::eBoundSize) { trackState.allocateCalibrated(1); trackState.template calibrated<1>() = sl.parameters.head<1>(); trackState.template calibratedCovariance<1>() = sl.covariance.topLeftCorner<1, 1>(); - trackState.template setCalibratedSubspace(std::array{sl.indices[0]}); + trackState.template setSubspaceIndices(std::array{sl.indices[0]}); } else { throw std::runtime_error( "Tried to extract measurement from invalid TestSourceLink"); diff --git a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp index 40a5388fbf9..32d6bcf12c0 100644 --- a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp +++ b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp @@ -106,7 +106,7 @@ class MeasurementSelector { false>::Parameters predicted, TrackStateTraits::Covariance predictedCovariance, - FullProjectorMapping projector, unsigned int calibratedSize) const; + BoundSubspaceIndices projector, unsigned int calibratedSize) const; Config m_config; }; diff --git a/Core/include/Acts/TrackFinding/MeasurementSelector.ipp b/Core/include/Acts/TrackFinding/MeasurementSelector.ipp index e950de4179c..49fefe3581b 100644 --- a/Core/include/Acts/TrackFinding/MeasurementSelector.ipp +++ b/Core/include/Acts/TrackFinding/MeasurementSelector.ipp @@ -71,7 +71,7 @@ MeasurementSelector::select( trackState.effectiveCalibrated().data(), trackState.effectiveCalibratedCovariance().data(), trackState.predicted(), trackState.predictedCovariance(), - trackState.fullProjectorMapping(), trackState.calibratedSize()); + trackState.boundSubspaceIndices(), trackState.calibratedSize()); trackState.chi2() = chi2; if (chi2 < minChi2) { diff --git a/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp b/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp index 3d6e9125896..61082e747b0 100644 --- a/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp +++ b/Core/include/Acts/TrackFitting/GainMatrixUpdater.hpp @@ -29,7 +29,7 @@ class GainMatrixUpdater { // This is used to build a covariance matrix view in the .cpp file const double* calibrated; const double* calibratedCovariance; - FullProjectorMapping projector; + BoundSubspaceIndices projector; TrackStateTraits::Parameters predicted; @@ -80,7 +80,7 @@ class GainMatrixUpdater { // shape later trackState.effectiveCalibrated().data(), trackState.effectiveCalibratedCovariance().data(), - trackState.fullProjectorMapping(), + trackState.boundSubspaceIndices(), trackState.predicted(), trackState.predictedCovariance(), trackState.filtered(), diff --git a/Core/src/EventData/VectorMultiTrajectory.cpp b/Core/src/EventData/VectorMultiTrajectory.cpp index 4ea488b4b23..689c06ab6ce 100644 --- a/Core/src/EventData/VectorMultiTrajectory.cpp +++ b/Core/src/EventData/VectorMultiTrajectory.cpp @@ -77,7 +77,7 @@ auto VectorMultiTrajectory::addTrackState_impl(TrackStatePropMask mask, m_sourceLinks.emplace_back(std::nullopt); p.icalibratedsourcelink = m_sourceLinks.size() - 1; - m_projectors.push_back(kFullProjectorMappingEmpty); + m_projectors.push_back(kBoundSubspaceIndicesInvalid); p.iprojector = m_projectors.size() - 1; } @@ -132,7 +132,7 @@ void VectorMultiTrajectory::addTrackStateComponents_impl( m_sourceLinks.emplace_back(std::nullopt); p.icalibratedsourcelink = m_sourceLinks.size() - 1; - m_projectors.push_back(kFullProjectorMappingEmpty); + m_projectors.push_back(kBoundSubspaceIndicesInvalid); p.iprojector = m_projectors.size() - 1; } diff --git a/Core/src/TrackFinding/MeasurementSelector.cpp b/Core/src/TrackFinding/MeasurementSelector.cpp index eb867c5d585..278157e7682 100644 --- a/Core/src/TrackFinding/MeasurementSelector.cpp +++ b/Core/src/TrackFinding/MeasurementSelector.cpp @@ -33,7 +33,7 @@ double MeasurementSelector::calculateChi2( false>::Parameters predicted, TrackStateTraits::Covariance predictedCovariance, - FullProjectorMapping projector, unsigned int calibratedSize) const { + BoundSubspaceIndices projector, unsigned int calibratedSize) const { return visit_measurement( calibratedSize, [&fullCalibrated, &fullCalibratedCovariance, &predicted, @@ -48,9 +48,10 @@ double MeasurementSelector::calculateChi2( using ParametersVector = ActsVector; - FixedSubspaceHelper subspaceHelper( - std::span( - projector.begin(), projector.begin() + kMeasurementSize)); + std::span validSubspaceIndices( + projector.begin(), projector.begin() + kMeasurementSize); + FixedBoundSubspaceHelper subspaceHelper( + validSubspaceIndices); // Get the residuals ParametersVector res = diff --git a/Core/src/TrackFitting/GainMatrixUpdater.cpp b/Core/src/TrackFitting/GainMatrixUpdater.cpp index 67682a20560..53b77985357 100644 --- a/Core/src/TrackFitting/GainMatrixUpdater.cpp +++ b/Core/src/TrackFitting/GainMatrixUpdater.cpp @@ -43,11 +43,13 @@ std::tuple GainMatrixUpdater::visitMeasurement( ACTS_VERBOSE("Calibrated measurement covariance:\n" << calibratedCovariance); - FixedSubspaceHelper subspaceHelper( - std::span( - trackState.projector.begin(), - trackState.projector.begin() + kMeasurementSize)); + std::span validSubspaceIndices( + trackState.projector.begin(), + trackState.projector.begin() + kMeasurementSize); + FixedBoundSubspaceHelper subspaceHelper( + validSubspaceIndices); + // TODO use subspace helper for projection instead const auto H = subspaceHelper.projector(); ACTS_VERBOSE("Measurement projector H:\n" << H); diff --git a/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp b/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp index d25d582ada3..680d12fe044 100644 --- a/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp +++ b/Examples/Algorithms/TrackFitting/src/RefittingCalibrator.cpp @@ -37,7 +37,7 @@ void RefittingCalibrator::calibrate(const Acts::GeometryContext& /*gctx*/, sl.state.template calibratedCovariance(); }); - trackState.setFullProjectorMapping(sl.state.fullProjectorMapping()); + trackState.setBoundSubspaceIndices(sl.state.boundSubspaceIndices()); } } // namespace ActsExamples diff --git a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp index c6925882c71..70311dcc531 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp @@ -10,6 +10,7 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/SourceLink.hpp" +#include "Acts/EventData/SubspaceHelpers.hpp" #include "Acts/EventData/detail/CalculateResiduals.hpp" #include "Acts/EventData/detail/ParameterTraits.hpp" #include "Acts/EventData/detail/PrintParameters.hpp" @@ -76,11 +77,10 @@ class FixedSizeMeasurement { const Eigen::MatrixBase& params, const Eigen::MatrixBase& cov) : m_source(std::move(source)), m_params(params), m_cov(cov) { - for (std::size_t i = 0u; i < kSize; ++i) { - assert(subsetIndices[i] >= 0 && subsetIndices[i] < kFullSize && - "Index out of bounds"); - m_subsetIndices[i] = static_cast(subsetIndices[i]); - } + Acts::checkSubspaceIndices(subsetIndices, kFullSize, kSize); + std::transform(subsetIndices.begin(), subsetIndices.end(), + m_subsetIndices.begin(), + [](indices_t i) { return static_cast(i); }); } /// A measurement can only be constructed with valid parameters. FixedSizeMeasurement() = delete; diff --git a/Examples/Framework/src/EventData/MeasurementCalibration.cpp b/Examples/Framework/src/EventData/MeasurementCalibration.cpp index 341a60dad85..ed1f0ebeff3 100644 --- a/Examples/Framework/src/EventData/MeasurementCalibration.cpp +++ b/Examples/Framework/src/EventData/MeasurementCalibration.cpp @@ -40,7 +40,7 @@ void ActsExamples::PassThroughCalibrator::calibrate( trackState.calibrated() = meas.parameters(); trackState.calibratedCovariance() = meas.covariance(); - trackState.setCalibratedSubspace(meas.indices()); + trackState.setSubspaceIndices(meas.indices()); }, measurements[idxSourceLink.index()]); } diff --git a/Examples/Framework/src/EventData/ScalingCalibrator.cpp b/Examples/Framework/src/EventData/ScalingCalibrator.cpp index 1e14738df8a..fd7b672d5e4 100644 --- a/Examples/Framework/src/EventData/ScalingCalibrator.cpp +++ b/Examples/Framework/src/EventData/ScalingCalibrator.cpp @@ -178,7 +178,7 @@ void ActsExamples::ScalingCalibrator::calibrate( trackState.allocateCalibrated(cmeas.size()); trackState.calibrated() = meas.parameters(); trackState.calibratedCovariance() = meas.covariance(); - trackState.setCalibratedSubspace(meas.indices()); + trackState.setSubspaceIndices(meas.indices()); }, (measurements)[idxSourceLink.index()]); } diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp index c4735f2f8c2..d0331176edc 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp @@ -124,7 +124,7 @@ class PodioTrackStateContainerBase { case "projector"_hash: // workaround podio not allowing `std::uint8_t` as a type return reinterpret_cast>( + EnsureConst, const BoundSubspaceIndices*, BoundSubspaceIndices*>>( &data.projector); case "measdim"_hash: return &data.measdim; diff --git a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp index d1b484497a4..0de58b88305 100644 --- a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp @@ -58,7 +58,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.setCalibratedSubspace<2>(projector); + ts.setSubspaceIndices<2>(projector); ts.filtered() << 0.301, 0.503, 0.5 * M_PI, 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; @@ -75,7 +75,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.setCalibratedSubspace<2>(projector); + ts.setSubspaceIndices<2>(projector); ts.filtered() << 0.27, 0.53, 0.5 * M_PI, 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; @@ -92,7 +92,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.setCalibratedSubspace<2>(projector); + ts.setSubspaceIndices<2>(projector); ts.filtered() << 0.33, 0.43, 0.5 * M_PI, 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; From ab987c705f1a61ea4f805c334633e9c75e587713 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 14 Aug 2024 16:51:54 +0200 Subject: [PATCH 19/23] fix `NeuralCalibrator` --- .../Framework/ML/src/NeuralCalibrator.cpp | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Examples/Framework/ML/src/NeuralCalibrator.cpp b/Examples/Framework/ML/src/NeuralCalibrator.cpp index 6dcbe1cc7cf..77af3920a6a 100644 --- a/Examples/Framework/ML/src/NeuralCalibrator.cpp +++ b/Examples/Framework/ML/src/NeuralCalibrator.cpp @@ -113,14 +113,13 @@ void ActsExamples::NeuralCalibrator::calibrate( assert(measurement.contains(Acts::eBoundLoc1) && "Measurement does not contain the required bound loc1"); - auto boundLoc0 = measurement.subspace().indexOf(Acts::eBoundLoc0); - auto boundLoc1 = measurement.subspace().indexOf(Acts::eBoundLoc1); + auto boundLoc0 = measurement.indexOf(Acts::eBoundLoc0); + auto boundLoc1 = measurement.indexOf(Acts::eBoundLoc1); - Acts::Vector2 localPosition{measurement.effectiveParameters()[boundLoc0], - measurement.effectiveParameters()[boundLoc1]}; - Acts::Vector2 localCovariance{ - measurement.effectiveCovariance()(boundLoc0, boundLoc0), - measurement.effectiveCovariance()(boundLoc1, boundLoc1)}; + Acts::Vector2 localPosition{measurement.parameters()[boundLoc0], + measurement.parameters()[boundLoc1]}; + Acts::Vector2 localCovariance{measurement.covariance()(boundLoc0, boundLoc0), + measurement.covariance()(boundLoc1, boundLoc1)}; Acts::Vector3 dir = Acts::makeDirectionFromPhiTheta( trackParameters[Acts::eBoundPhi], trackParameters[Acts::eBoundTheta]); @@ -173,11 +172,10 @@ void ActsExamples::NeuralCalibrator::calibrate( std::size_t iVar0 = 3 * m_nComponents + iMax * 2; Measurement measurementCopy = measurement; - measurementCopy.effectiveParameters()[boundLoc0] = output[iLoc0]; - measurementCopy.effectiveParameters()[boundLoc1] = output[iLoc0 + 1]; - measurementCopy.effectiveCovariance()(boundLoc0, boundLoc0) = output[iVar0]; - measurementCopy.effectiveCovariance()(boundLoc1, boundLoc1) = - output[iVar0 + 1]; + measurementCopy.parameters()[boundLoc0] = output[iLoc0]; + measurementCopy.parameters()[boundLoc1] = output[iLoc0 + 1]; + measurementCopy.covariance()(boundLoc0, boundLoc0) = output[iVar0]; + measurementCopy.covariance()(boundLoc1, boundLoc1) = output[iVar0 + 1]; Acts::visit_measurement(measurement.size(), [&](auto N) -> void { constexpr std::size_t kMeasurementSize = decltype(N)::value; @@ -187,6 +185,7 @@ void ActsExamples::NeuralCalibrator::calibrate( measurementCopy.parameters(); trackState.calibratedCovariance() = measurementCopy.covariance(); - trackState.setProjector(measurementCopy.subspace().fullProjector()); + trackState.setSubspaceIndices( + measurementCopy.subspaceIndices()); }); } From f9b712a142bb1fbfd957a7955adfc8da84d5fbea Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 14 Aug 2024 18:03:33 +0200 Subject: [PATCH 20/23] make ci happy --- Core/include/Acts/EventData/SubspaceHelpers.hpp | 4 +++- Core/include/Acts/EventData/TrackStateProxy.hpp | 5 ----- .../Acts/TrackFitting/detail/GainMatrixUpdaterImpl.hpp | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Core/include/Acts/EventData/SubspaceHelpers.hpp b/Core/include/Acts/EventData/SubspaceHelpers.hpp index 85c21df6830..737c12211a5 100644 --- a/Core/include/Acts/EventData/SubspaceHelpers.hpp +++ b/Core/include/Acts/EventData/SubspaceHelpers.hpp @@ -75,7 +75,9 @@ class SubspaceHelperBase { return result; } - ProjectorBitset projectorBitset() const requires(kFullSize <= 8) { + ProjectorBitset projectorBitset() const + requires(kFullSize <= 8) + { return matrixToBitset(fullProjector()).to_ullong(); } diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index ea18f149631..19a8ca9905e 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -626,7 +626,6 @@ class TrackStateProxy { /// dimensions. The NxM submatrix, where N is the actual dimension of the /// measurement, is located in the top left corner, everything else is zero. /// @return The overallocated projector - /// @deprecated This will be swapped out in favor of `projectorMapping` in the future //[[deprecated("This will be swapped out in favor of projectorMapping in the // future")]] Projector projector() const; @@ -641,7 +640,6 @@ class TrackStateProxy { /// is of dimension \f$N\times M\f$, where \f$N\f$ is the actual dimension of the /// measurement. /// @return The effective projector - /// @deprecated This will be dropped in the future //[[deprecated("This will be dropped in the future")]] EffectiveProjector effectiveProjector() const { return projector().topLeftCorner(calibratedSize(), M); @@ -652,7 +650,6 @@ class TrackStateProxy { /// and store it. /// @param projector The projector in the form of a dense matrix /// @note @p projector is assumed to only have 0s or 1s as components. - /// @deprecated Use setProjector(span) instead template //[[deprecated("use setProjector(span) instead")]] void setProjector(const Eigen::MatrixBase& projector) @@ -688,7 +685,6 @@ class TrackStateProxy { /// to another. Use the `projector` or `effectiveProjector` method if /// you want to access the matrix. /// @return The projector bitset - /// @deprecated Use projector() instead //[[deprecated("use projector() instead")]] ProjectorBitset projectorBitset() const { return variableBoundSubspaceHelper().projectorBitset(); @@ -700,7 +696,6 @@ class TrackStateProxy { /// @note This is mainly to copy explicitly a projector from one state /// to another. If you have a projection matrix, set it with /// `setProjector`. - /// @deprecated Use setProjector(span) instead //[[deprecated("use setProjector(span) instead")]] void setProjectorBitset(ProjectorBitset proj) requires(!ReadOnly) diff --git a/Core/include/Acts/TrackFitting/detail/GainMatrixUpdaterImpl.hpp b/Core/include/Acts/TrackFitting/detail/GainMatrixUpdaterImpl.hpp index 90304d424e7..cc0f7b45596 100644 --- a/Core/include/Acts/TrackFitting/detail/GainMatrixUpdaterImpl.hpp +++ b/Core/include/Acts/TrackFitting/detail/GainMatrixUpdaterImpl.hpp @@ -35,13 +35,13 @@ std::tuple GainMatrixUpdater::visitMeasurementImpl( ACTS_VERBOSE("Calibrated measurement covariance:\n" << calibratedCovariance); std::span validSubspaceIndices( - trackState.projector.begin(), - trackState.projector.begin() + kMeasurementSize); - FixedBoundSubspaceHelper subspaceHelper( - validSubspaceIndices); + trackState.projector.begin(), + trackState.projector.begin() + kMeasurementSize); + FixedBoundSubspaceHelper subspaceHelper( + validSubspaceIndices); // TODO use subspace helper for projection instead - const auto H = subspaceHelper.projector(); + const auto H = subspaceHelper.projector(); ACTS_VERBOSE("Measurement projector H:\n" << H); From cc32c8a396fa67ce504bcd00ce3a960650525c63 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 19 Aug 2024 08:49:23 +0200 Subject: [PATCH 21/23] minor --- Core/include/Acts/Propagator/Navigator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index 4e33c6b1bc0..3b2def43002 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -988,7 +988,7 @@ class Navigator { << targetIntersection.position().x() << ", " << targetIntersection.position().y() << ", " << targetIntersection.position().z() << ")"); - /// get the target volume from the intersection + // get the target volume from the intersection auto tPosition = targetIntersection.position(); state.navigation.targetVolume = m_cfg.trackingGeometry->lowestTrackingVolume(state.geoContext, From 096144155520fe1a009e8c04048edfc825905d4f Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 19 Aug 2024 11:47:47 +0200 Subject: [PATCH 22/23] deprecation; hashes --- .../Acts/EventData/TrackStateProxy.hpp | 23 ++++++------- Examples/Python/tests/root_file_hashes.txt | 32 +++++++++---------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 19a8ca9905e..f3937094c45 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -626,9 +626,10 @@ class TrackStateProxy { /// dimensions. The NxM submatrix, where N is the actual dimension of the /// measurement, is located in the top left corner, everything else is zero. /// @return The overallocated projector - //[[deprecated("This will be swapped out in favor of projectorMapping in the - // future")]] - Projector projector() const; + [[deprecated( + "This will be swapped out in favor of projectorMapping in the " + "future")]] Projector + projector() const; /// Returns whether a projector is set /// @return Whether it is set @@ -640,8 +641,8 @@ class TrackStateProxy { /// is of dimension \f$N\times M\f$, where \f$N\f$ is the actual dimension of the /// measurement. /// @return The effective projector - //[[deprecated("This will be dropped in the future")]] - EffectiveProjector effectiveProjector() const { + [[deprecated("This will be dropped in the future")]] EffectiveProjector + effectiveProjector() const { return projector().topLeftCorner(calibratedSize(), M); } @@ -651,8 +652,8 @@ class TrackStateProxy { /// @param projector The projector in the form of a dense matrix /// @note @p projector is assumed to only have 0s or 1s as components. template - //[[deprecated("use setProjector(span) instead")]] - void setProjector(const Eigen::MatrixBase& projector) + [[deprecated("use setProjector(span) instead")]] void setProjector( + const Eigen::MatrixBase& projector) requires(!ReadOnly) { constexpr int rows = Eigen::MatrixBase::RowsAtCompileTime; @@ -685,8 +686,8 @@ class TrackStateProxy { /// to another. Use the `projector` or `effectiveProjector` method if /// you want to access the matrix. /// @return The projector bitset - //[[deprecated("use projector() instead")]] - ProjectorBitset projectorBitset() const { + [[deprecated("use projector() instead")]] ProjectorBitset projectorBitset() + const { return variableBoundSubspaceHelper().projectorBitset(); } @@ -696,8 +697,8 @@ class TrackStateProxy { /// @note This is mainly to copy explicitly a projector from one state /// to another. If you have a projection matrix, set it with /// `setProjector`. - //[[deprecated("use setProjector(span) instead")]] - void setProjectorBitset(ProjectorBitset proj) + [[deprecated("use setProjector(span) instead")]] void setProjectorBitset( + ProjectorBitset proj) requires(!ReadOnly) { BoundMatrix projMatrix = bitsetToMatrix(proj); diff --git a/Examples/Python/tests/root_file_hashes.txt b/Examples/Python/tests/root_file_hashes.txt index 3ee27a30f02..1719eb78b8b 100644 --- a/Examples/Python/tests/root_file_hashes.txt +++ b/Examples/Python/tests/root_file_hashes.txt @@ -19,8 +19,8 @@ test_propagation__propagation_steps.root: 665901379c73b468590ed49f00679708d9ace1 test_material_recording__geant4_material_tracks.root: c022b9362249b29f57a07926b20644e3ab4ab8ebcf03f773fbf46c446fc1a0a1 test_truth_tracking_gsf[generic]__trackstates_gsf.root: 1466671bee7b7cfffe90459d9aef316dcee104e6c32a2df4f2f11ea9f12ddc14 test_truth_tracking_gsf[generic]__tracksummary_gsf.root: b698e3d21eacc34fc8b0ce1d3fbe07405a4b8b549e07f0160573e64c3b401f04 -test_truth_tracking_gsf[odd]__trackstates_gsf.root: 194198c9c9657b02192e573ba9969230663f179104e32e180101ffcd677b4745 -test_truth_tracking_gsf[odd]__tracksummary_gsf.root: 80e60784d4d6eabe734f6fc1ffe04aefa0276cf8798430c590a06f40a07a484f +test_truth_tracking_gsf[odd]__trackstates_gsf.root: 847a60b97ef9c9328a73f27597085fea2434003e2c15d30f98ae7b3372eeb65f +test_truth_tracking_gsf[odd]__tracksummary_gsf.root: d8221a90ed24f9f136bf2001645ce50f3eacf18c73d7d515eec71962a555d14b test_particle_gun__particles.root: 5fe7dda2933ee6b9615b064d192322fe07831133cd998e5ed99a3b992b713a10 test_material_mapping__material-map_tracks.root: 938b1a855369e9304401cb10d2751df3fd7acf32a2573f2057eb1691cd94edf3 test_material_mapping__propagation-material.root: 5eacd0cb804d381171c8fb65d7b2d36e1d57db9f4cb2b58c0f24703479218cbf @@ -40,14 +40,14 @@ test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: 0df341f test_ckf_tracks_example[generic-truth_estimated]__performance_seeding.root: 1facb05c066221f6361b61f015cdf0918e94d9f3fce2269ec7b6a4dffeb2bc7e test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: 25b985218418c91782696daab1b3fd3eaf7d15cd05681c7dfe2e4c3e44977e16 test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: be592112183bd6554ed5e00dcb62eb4a5a5f4a9bb7efa4b1e1ce699dec13157b -test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 935359233aa503a077faf2394ba988d0da97ea5db4f6d3294a95fb93c5625c68 -test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 59537c52d23a77dbed9230c7b92cf653f7592c72fb882e8a24a2b33f1d27019e +test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 8c31d51cef775b4f92f99644895beecfd854db2e7925d5f394deafdcc8f2e629 +test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 3b27644bf25c20e5ed0d25f2273b68a470c63b07677a806cb176d4c91abd153e test_ckf_tracks_example[odd-full_seeding]__performance_seeding_trees.root: 43c58577aafe07645e5660c4f43904efadf91d8cda45c5c04c248bbe0f59814f -test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: 89fad58add1ead7c0d38a952391d3c4a720feda6e37c37ed53f994a99fe15f57 -test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 3a092423e717b1fe76f78f6b95eb6df67648a196e8c4da32158061d4bc490578 +test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: d980eebb7df9d7fd5a861228ca498f439bef4853a8dd9b8b590286781b69b8cb +test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: a5eecfb6907406286c56db4df19937539cb43e454307bc53bd1eda535526736c test_ckf_tracks_example[odd-truth_estimated]__performance_seeding.root: 1a36b7017e59f1c08602ef3c2cb0483c51df248f112e3780c66594110719c575 -test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: 268357818ee53cc13b26aa23af06d7f839d112e9dc2eb3ac4c5b6e6eda48e6af -test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: 98c9e97240f541c22dd41d05c2114d7e9455b117162d64baad2c3ecb5b7d52f7 +test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: 92a1367d2c5d90ead26d177206d9f644e285e42de5dea2615c7bc8aeb321419b +test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: 3dd1d9b1075a9c2b2ac7f4143329e13b6cb63f6e1dfe450f8a913a0d8110aa72 test_vertex_fitting_reading[Truth-False-100]__performance_vertexing.root: 76ef6084d758dfdfc0151ddec2170e12d73394424e3dac4ffe46f0f339ec8293 test_vertex_fitting_reading[Iterative-False-100]__performance_vertexing.root: 60372210c830a04f95ceb78c6c68a9b0de217746ff59e8e73053750c837b57eb test_vertex_fitting_reading[Iterative-True-100]__performance_vertexing.root: e34f217d524a5051dbb04a811d3407df3ebe2cc4bb7f54f6bda0847dbd7b52c3 @@ -85,11 +85,11 @@ test_truth_tracking_kalman[generic-True-0.0]__trackstates_kf.root: a87b908ee14a3 test_truth_tracking_kalman[generic-True-0.0]__tracksummary_kf.root: bf46a89e429fa77a380d5ee48babb8af2044196eff872825e84c0d4401357114 test_truth_tracking_kalman[generic-True-1000.0]__trackstates_kf.root: 5b945782c1ff59c7c30d3d2a23992292735bc3da27da6424309da9c9e9660322 test_truth_tracking_kalman[generic-True-1000.0]__tracksummary_kf.root: 055a74d2747d360398cc846cc2791204491528896de78cca66b188e3ff530dc1 -test_truth_tracking_kalman[odd-False-0.0]__trackstates_kf.root: 6e4a34638a4d76607597db1e02525f6c6a386ca44727cae255a0aa0c2b588c7f -test_truth_tracking_kalman[odd-False-0.0]__tracksummary_kf.root: a45dbd0b6d221ec1b153f6e90d84601fe7a799134604c63be8e94bf8cd22af43 -test_truth_tracking_kalman[odd-False-1000.0]__trackstates_kf.root: 7e0b19d1f8c818269925b95817b9c92c68af3b841fdbd21560aa55688ddec786 -test_truth_tracking_kalman[odd-False-1000.0]__tracksummary_kf.root: 15a542955428dec0776c8317a33b7ef6c14858888ffc7406b00ac7044694b137 -test_truth_tracking_kalman[odd-True-0.0]__trackstates_kf.root: 6e4a34638a4d76607597db1e02525f6c6a386ca44727cae255a0aa0c2b588c7f -test_truth_tracking_kalman[odd-True-0.0]__tracksummary_kf.root: a45dbd0b6d221ec1b153f6e90d84601fe7a799134604c63be8e94bf8cd22af43 -test_truth_tracking_kalman[odd-True-1000.0]__trackstates_kf.root: 7e0b19d1f8c818269925b95817b9c92c68af3b841fdbd21560aa55688ddec786 -test_truth_tracking_kalman[odd-True-1000.0]__tracksummary_kf.root: 15a542955428dec0776c8317a33b7ef6c14858888ffc7406b00ac7044694b137 +test_truth_tracking_kalman[odd-False-0.0]__trackstates_kf.root: 3f442d5f46cde700ced08ce1720b6b843ca84d7f0cdc372d8571f06e005144c2 +test_truth_tracking_kalman[odd-False-0.0]__tracksummary_kf.root: 7f1bb68b39e52da7a77ea295819fa3776e947568455338738c3a6436c2d7599c +test_truth_tracking_kalman[odd-False-1000.0]__trackstates_kf.root: 12b07b688b7b4cbfc1aa51668c6b693cfbae565c9116f4ad084241805384fbd1 +test_truth_tracking_kalman[odd-False-1000.0]__tracksummary_kf.root: 87eaae3192ab29e2c2542c017071b6477c7237c5b8eaff107e84caed2a5e5b7a +test_truth_tracking_kalman[odd-True-0.0]__trackstates_kf.root: 3f442d5f46cde700ced08ce1720b6b843ca84d7f0cdc372d8571f06e005144c2 +test_truth_tracking_kalman[odd-True-0.0]__tracksummary_kf.root: 7f1bb68b39e52da7a77ea295819fa3776e947568455338738c3a6436c2d7599c +test_truth_tracking_kalman[odd-True-1000.0]__trackstates_kf.root: 12b07b688b7b4cbfc1aa51668c6b693cfbae565c9116f4ad084241805384fbd1 +test_truth_tracking_kalman[odd-True-1000.0]__tracksummary_kf.root: 87eaae3192ab29e2c2542c017071b6477c7237c5b8eaff107e84caed2a5e5b7a From 3a694e3bdd9814daa01fe5ae1629c30f7a6bcc78 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 19 Aug 2024 13:19:04 +0200 Subject: [PATCH 23/23] relax deprecation --- Core/include/Acts/EventData/TrackStateProxy.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index f3937094c45..3358a94cf62 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -626,10 +626,7 @@ class TrackStateProxy { /// dimensions. The NxM submatrix, where N is the actual dimension of the /// measurement, is located in the top left corner, everything else is zero. /// @return The overallocated projector - [[deprecated( - "This will be swapped out in favor of projectorMapping in the " - "future")]] Projector - projector() const; + Projector projector() const; /// Returns whether a projector is set /// @return Whether it is set @@ -641,8 +638,7 @@ class TrackStateProxy { /// is of dimension \f$N\times M\f$, where \f$N\f$ is the actual dimension of the /// measurement. /// @return The effective projector - [[deprecated("This will be dropped in the future")]] EffectiveProjector - effectiveProjector() const { + EffectiveProjector effectiveProjector() const { return projector().topLeftCorner(calibratedSize(), M); }