diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 7c0404ffa62..7546a84e0ad 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -572,7 +572,9 @@ class CombinatorialKalmanFilter { if (!boundStateRes.ok()) { return boundStateRes.error(); } - auto boundState = *boundStateRes; + auto& boundState = *boundStateRes; + auto& [boundParams, jacobian, pathLength] = boundState; + boundParams.covariance() = state.stepping.cov; // Retrieve the previous tip and its state // The states created on this surface will have the common previous tip @@ -940,9 +942,7 @@ class CombinatorialKalmanFilter { const auto& [boundParams, jacobian, pathLength] = boundState; // Fill the track state trackStateProxy.predicted() = boundParams.parameters(); - if (boundParams.covariance().has_value()) { - trackStateProxy.predictedCovariance() = *boundParams.covariance(); - } + trackStateProxy.predictedCovariance() = boundParams.covariance().value(); trackStateProxy.jacobian() = jacobian; trackStateProxy.pathLength() = pathLength; // Set the surface diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index b7950994766..6259e755133 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -447,17 +447,14 @@ class Gx2Fitter { result.result = res.error(); return; } - auto& [boundParams, jacobian, pathLength] = *res; + const auto& [boundParams, jacobian, pathLength] = *res; // Fill the track state - trackStateProxy.predicted() = std::move(boundParams.parameters()); - if (boundParams.covariance().has_value()) { - trackStateProxy.predictedCovariance() = - std::move(*boundParams.covariance()); - } + trackStateProxy.predicted() = boundParams.parameters(); + trackStateProxy.predictedCovariance() = state.stepping.cov; - trackStateProxy.jacobian() = std::move(jacobian); - trackStateProxy.pathLength() = std::move(pathLength); + trackStateProxy.jacobian() = jacobian; + trackStateProxy.pathLength() = pathLength; } // We have predicted parameters, so calibrate the uncalibrated input diff --git a/Core/include/Acts/TrackFitting/KalmanFitter.hpp b/Core/include/Acts/TrackFitting/KalmanFitter.hpp index 297cf3a6c74..02895541377 100644 --- a/Core/include/Acts/TrackFitting/KalmanFitter.hpp +++ b/Core/include/Acts/TrackFitting/KalmanFitter.hpp @@ -744,17 +744,14 @@ class KalmanFitter { if (!res.ok()) { return res.error(); } - auto& [boundParams, jacobian, pathLength] = *res; + const auto& [boundParams, jacobian, pathLength] = *res; // Fill the track state - trackStateProxy.predicted() = std::move(boundParams.parameters()); - if (boundParams.covariance().has_value()) { - trackStateProxy.predictedCovariance() = - std::move(*boundParams.covariance()); - } + trackStateProxy.predicted() = boundParams.parameters(); + trackStateProxy.predictedCovariance() = state.stepping.cov; - trackStateProxy.jacobian() = std::move(jacobian); - trackStateProxy.pathLength() = std::move(pathLength); + trackStateProxy.jacobian() = jacobian; + trackStateProxy.pathLength() = pathLength; } // We have predicted parameters, so calibrate the uncalibrated input diff --git a/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp b/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp index 5b7cc8785ef..4e3c6628128 100644 --- a/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp +++ b/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp @@ -10,6 +10,7 @@ #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/SourceLink.hpp" +#include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/CalibrationContext.hpp" @@ -59,17 +60,14 @@ auto kalmanHandleMeasurement( << " failed: " << res.error()); return res.error(); } - auto &[boundParams, jacobian, pathLength] = *res; + const auto &[boundParams, jacobian, pathLength] = *res; // Fill the track state - trackStateProxy.predicted() = std::move(boundParams.parameters()); - if (boundParams.covariance().has_value()) { - trackStateProxy.predictedCovariance() = - std::move(*boundParams.covariance()); - } + trackStateProxy.predicted() = boundParams.parameters(); + trackStateProxy.predictedCovariance() = state.stepping.cov; - trackStateProxy.jacobian() = std::move(jacobian); - trackStateProxy.pathLength() = std::move(pathLength); + trackStateProxy.jacobian() = jacobian; + trackStateProxy.pathLength() = pathLength; } // We have predicted parameters, so calibrate the uncalibrated input @@ -154,17 +152,14 @@ auto kalmanHandleNoMeasurement( if (!res.ok()) { return res.error(); } - auto &[boundParams, jacobian, pathLength] = *res; + const auto &[boundParams, jacobian, pathLength] = *res; // Fill the track state - trackStateProxy.predicted() = std::move(boundParams.parameters()); - if (boundParams.covariance().has_value()) { - trackStateProxy.predictedCovariance() = - std::move(*boundParams.covariance()); - } + trackStateProxy.predicted() = boundParams.parameters(); + trackStateProxy.predictedCovariance() = state.stepping.cov; - trackStateProxy.jacobian() = std::move(jacobian); - trackStateProxy.pathLength() = std::move(pathLength); + trackStateProxy.jacobian() = jacobian; + trackStateProxy.pathLength() = pathLength; // Set the filtered parameter index to be the same with predicted // parameter diff --git a/Core/src/Propagator/detail/CovarianceEngine.cpp b/Core/src/Propagator/detail/CovarianceEngine.cpp index 741b6ff71d6..984eae2f580 100644 --- a/Core/src/Propagator/detail/CovarianceEngine.cpp +++ b/Core/src/Propagator/detail/CovarianceEngine.cpp @@ -50,8 +50,6 @@ Result detail::boundState( // Covariance transport std::optional cov = std::nullopt; if (covTransport) { - // Initialize the jacobian from start local to final local - fullTransportJacobian = BoundMatrix::Identity(); // Calculate the jacobian and transport the covarianceMatrix to final local. // Then reinitialize the transportJacobian, derivatives and the // boundToFreeJacobian @@ -59,8 +57,6 @@ Result detail::boundState( fullTransportJacobian, freeTransportJacobian, freeToPathDerivatives, boundToFreeJacobian, freeParameters, freeToBoundCorrection); - } - if (boundCovariance != BoundSquareMatrix::Zero()) { cov = boundCovariance; } @@ -82,16 +78,12 @@ CurvilinearState detail::curvilinearState( // Covariance transport std::optional cov = std::nullopt; if (covTransport) { - // Initialize the jacobian from start local to final local - fullTransportJacobian = BoundMatrix::Identity(); // Calculate the jacobian and transport the covarianceMatrix to final local. // Then reinitialize the transportJacobian, derivatives and the // boundToFreeJacobian transportCovarianceToCurvilinear( boundCovariance, fullTransportJacobian, freeTransportJacobian, freeToPathDerivatives, boundToFreeJacobian, direction); - } - if (boundCovariance != BoundSquareMatrix::Zero()) { cov = boundCovariance; } diff --git a/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp b/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp index 7dbe9b979d9..a7cd0e2de39 100644 --- a/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp +++ b/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp @@ -110,12 +110,10 @@ BOOST_AUTO_TEST_CASE(covariance_engine_test) { BOOST_CHECK_EQUAL(parameters, startParameters); // Produce a curvilinear state without covariance matrix - auto covarianceBefore = covariance; auto curvResult = detail::curvilinearState( covariance, jacobian, transportJacobian, derivatives, boundToFreeJacobian, parameters, particleHypothesis, false, 1337.); - BOOST_CHECK(std::get<0>(curvResult).covariance().has_value()); - BOOST_CHECK_EQUAL(*(std::get<0>(curvResult).covariance()), covarianceBefore); + BOOST_CHECK(!std::get<0>(curvResult).covariance().has_value()); BOOST_CHECK_EQUAL(std::get<2>(curvResult), 1337.); // Reset @@ -136,7 +134,7 @@ BOOST_AUTO_TEST_CASE(covariance_engine_test) { BOOST_CHECK_EQUAL(std::get<2>(curvResult), 1337.); // Produce a bound state without covariance matrix - covarianceBefore = covariance; + auto covarianceBefore = covariance; auto boundResult = detail::boundState(tgContext, *surface, covariance, jacobian, transportJacobian, derivatives, boundToFreeJacobian,