diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 4dbed25de7d..cad4db4f1c5 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -497,26 +497,32 @@ class CombinatorialKalmanFilter { } result.smoothed = true; } + // -> then progress to target/reference surface and built the final // track parameters for found track indexed with iSmoothed - if (result.smoothed and targetReached(state, stepper, navigator, - *targetSurface, logger())) { + if (result.smoothed and (targetSurface == nullptr or + targetReached(state, stepper, navigator, + *targetSurface, logger()))) { ACTS_VERBOSE( "Completing the track with last measurement index = " << result.lastMeasurementIndices.at(result.iSmoothed)); - // Transport & bind the parameter to the final surface - auto res = stepper.boundState(state.stepping, *targetSurface); - if (!res.ok()) { - ACTS_ERROR("Error in finalize: " << res.error()); - result.result = res.error(); - return; + + if (targetSurface != nullptr) { + // Transport & bind the parameter to the final surface + auto res = stepper.boundState(state.stepping, *targetSurface); + if (!res.ok()) { + ACTS_ERROR("Error in finalize: " << res.error()); + result.result = res.error(); + return; + } + + auto fittedState = *res; + // Assign the fitted parameters + result.fittedParameters.emplace( + result.lastMeasurementIndices.at(result.iSmoothed), + std::get(fittedState)); } - auto fittedState = *res; - // Assign the fitted parameters - result.fittedParameters.emplace( - result.lastMeasurementIndices.at(result.iSmoothed), - std::get(fittedState)); // If there are more trajectories to handle: // -> set the targetReached status to false // -> set the smoothed status to false