From 9cdf2fe4d07161a80564808d1e1238eb8a8716c8 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 26 Jul 2023 17:05:27 +0200 Subject: [PATCH] fix: Allow CKF smoothing without a target surface (#2317) The current CKF implementation does not allow for smoothing without setting a target surface as this would result in a null pointer dereference. I try to fix that by handling the special case of not having a target surface. --- .../CombinatorialKalmanFilter.hpp | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) 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