diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index ef7b6b559c4..a3a5cd637e5 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -369,13 +369,6 @@ class Gx2Fitter { /// Calibration context for the fit const CalibrationContext* calibrationContext{nullptr}; - /// The current iteration of the fitter. - /// The variable is updated in fit(). - /// The actor needs to know the current iteration for adding new - /// trackStates. During the first iteration, each measurement surfaces will - /// be added to the track. - std::size_t nUpdate = Acts::MultiTrajectoryTraits::kInvalid; - /// @brief Gx2f actor operation /// /// @tparam propagator_state_t is the type of Propagator state @@ -648,7 +641,6 @@ class Gx2Fitter { gx2fActor.extensions = gx2fOptions.extensions; gx2fActor.calibrationContext = &gx2fOptions.calibrationContext.get(); gx2fActor.actorLogger = m_actorLogger.get(); - gx2fActor.nUpdate = nUpdate; auto propagatorState = m_propagator.makeState(params, propagatorOptions); @@ -797,6 +789,37 @@ class Gx2Fitter { ACTS_VERBOSE("final covariance:\n" << fullCovariancePredicted); + // Propagate again with the final covariance matrix. This is necessary to + // obtain the propagated covariance for each state. + if (gx2fOptions.nUpdateMax > 0) { + ACTS_VERBOSE("Propagate with the final covariance."); + // update covariance + ACTS_VERBOSE("finaldeltaParams:\n" << deltaParams); + params.covariance() = fullCovariancePredicted; + + // set up propagator and co + Acts::GeometryContext geoCtx = gx2fOptions.geoContext; + Acts::MagneticFieldContext magCtx = gx2fOptions.magFieldContext; + // Set options for propagator + PropagatorOptions propagatorOptions(geoCtx, magCtx); + auto& gx2fActor = propagatorOptions.actionList.template get(); + gx2fActor.inputMeasurements = &inputMeasurements; + gx2fActor.extensions = gx2fOptions.extensions; + gx2fActor.calibrationContext = &gx2fOptions.calibrationContext.get(); + gx2fActor.actorLogger = m_actorLogger.get(); + + auto propagatorState = m_propagator.makeState(params, propagatorOptions); + + auto& r = propagatorState.template get>(); + r.fittedStates = &trackContainer.trackStateContainer(); + + // Clear the track container. It could be more performant to update the + // existing states, but this needs some more thinking. + trackContainer.clear(); + + m_propagator.template propagate(propagatorState); + } + if (!trackContainer.hasColumn( Acts::hashString(Gx2fConstants::gx2fnUpdateColumn))) { trackContainer.template addColumn("Gx2fnUpdateColumn");