Skip to content

Commit 0c782e2

Browse files
committed
Expand fitter error handling code
This commit updates the Kálmán fitter error handling code by explicitly marking failures in the forward and backwards fitting step. It also resolves an issue where the smoother would start from invalid track states.
1 parent a930d77 commit 0c782e2

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed

core/include/traccc/edm/track_fit_outcome.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ enum class track_fit_outcome : std::uint16_t {
1818
SUCCESS,
1919
FAILURE_NON_POSITIVE_NDF,
2020
FAILURE_NOT_ALL_SMOOTHED,
21+
// Failure in the forward fit, not otherwise specified.
22+
FAILURE_FORWARD,
23+
// Failure in the backward fit, not otherwise specified.
24+
FAILURE_BACKWARD,
2125
MAX_OUTCOME
2226
};
2327

core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ class kalman_fitter {
249249
// Run forward filtering
250250
propagator.propagate(propagation, fitter_state());
251251

252+
if (!fitter_state.m_fit_actor_state.is_complete()) {
253+
return kalman_fitter_status::ERROR_NOT_ALL_TRACK_STATES_FOUND;
254+
}
255+
252256
return kalman_fitter_status::SUCCESS;
253257
}
254258

@@ -272,14 +276,16 @@ class kalman_fitter {
272276
// Since the smoothed track parameter of the last surface can be
273277
// considered to be the filtered one, we can reversly iterate the
274278
// algorithm to obtain the smoothed parameter of other surfaces
275-
while (!fitter_state.m_fit_actor_state.is_complete() &&
276-
(!fitter_state.m_fit_actor_state.is_state() ||
277-
fitter_state.m_fit_actor_state().is_hole())) {
279+
while (
280+
!fitter_state.m_fit_actor_state.is_complete() &&
281+
(!fitter_state.m_fit_actor_state.is_state() ||
282+
fitter_state.m_fit_actor_state().is_hole() ||
283+
fitter_state.m_fit_actor_state().filtered_params().is_invalid())) {
278284
fitter_state.m_fit_actor_state.next();
279285
}
280286

281287
if (fitter_state.m_fit_actor_state.is_complete()) {
282-
return kalman_fitter_status::SUCCESS;
288+
return kalman_fitter_status::ERROR_TRACK_STATES_EMPTY;
283289
}
284290

285291
auto last = fitter_state.m_fit_actor_state();
@@ -352,6 +358,10 @@ class kalman_fitter {
352358

353359
propagator.propagate(propagation, fitter_state.backward_actor_state());
354360

361+
if (!fitter_state.m_fit_actor_state.is_complete()) {
362+
return kalman_fitter_status::ERROR_NOT_ALL_TRACK_STATES_FOUND;
363+
}
364+
355365
// Reset the backward mode to false
356366
fitter_state.m_fit_actor_state.backward_mode = false;
357367

core/include/traccc/fitting/status_codes.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ enum class kalman_fitter_status : uint32_t {
2222
ERROR_UPDATER_CHI2_NOT_FINITE,
2323
ERROR_BARCODE_SEQUENCE_OVERFLOW,
2424
ERROR_INVALID_TRACK_STATE,
25+
ERROR_TRACK_STATES_EMPTY,
26+
ERROR_NOT_ALL_TRACK_STATES_FOUND,
2527
ERROR_OTHER,
2628
MAX_STATUS
2729
};
@@ -61,6 +63,12 @@ struct fitter_debug_msg {
6163
return msg +
6264
"Invalid track state in forward pass (skipped or error)";
6365
}
66+
case ERROR_TRACK_STATES_EMPTY: {
67+
return msg + "List of track states was empty";
68+
}
69+
case ERROR_NOT_ALL_TRACK_STATES_FOUND: {
70+
return msg + "Not all track states were recovered in fit";
71+
}
6472
case ERROR_OTHER: {
6573
return msg + "Unspecified error";
6674
}

device/common/include/traccc/fitting/device/fit_backward.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ TRACCC_HOST_DEVICE inline void fit_backward(
5454

5555
track = fitter_state.m_fit_res;
5656
} else {
57+
fitter_state.m_fit_res.fit_outcome() =
58+
track_fit_outcome::FAILURE_BACKWARD;
5759
param_liveness.at(param_id) = 0u;
5860
}
5961

device/common/include/traccc/fitting/device/fit_forward.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ TRACCC_HOST_DEVICE inline void fit_forward(
4747
kalman_fitter_status fit_status = fitter.filter(params, fitter_state);
4848

4949
if (fit_status != kalman_fitter_status::SUCCESS) {
50+
fitter_state.m_fit_res.fit_outcome() =
51+
track_fit_outcome::FAILURE_FORWARD;
5052
param_liveness.at(param_id) = 0u;
5153
}
5254
}

examples/run/common/print_fitted_tracks_statistics.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ void print_fitted_tracks_statistics(
1414
const edm::track_container<default_algebra>::host& tracks,
1515
const Logger& log) {
1616

17+
std::size_t unknown = 0;
1718
std::size_t success = 0;
1819
std::size_t non_positive_ndf = 0;
1920
std::size_t not_all_smoothed = 0;
21+
std::size_t forward = 0;
22+
std::size_t backward = 0;
2023

2124
for (track_fit_outcome outcome : tracks.tracks.fit_outcome()) {
2225
if (outcome == track_fit_outcome::SUCCESS) {
@@ -25,13 +28,22 @@ void print_fitted_tracks_statistics(
2528
++non_positive_ndf;
2629
} else if (outcome == track_fit_outcome::FAILURE_NOT_ALL_SMOOTHED) {
2730
++not_all_smoothed;
31+
} else if (outcome == track_fit_outcome::FAILURE_FORWARD) {
32+
++forward;
33+
} else if (outcome == track_fit_outcome::FAILURE_BACKWARD) {
34+
++backward;
35+
} else {
36+
++unknown;
2837
}
2938
}
3039

3140
auto logger = [&log]() -> const Logger& { return log; };
3241
TRACCC_INFO("Success: " << success
3342
<< " Non positive NDF: " << non_positive_ndf
3443
<< " Not all smoothed: " << not_all_smoothed
44+
<< " Forward failure: " << forward
45+
<< " Backward failure: " << backward
46+
<< " Unknown: " << unknown
3547
<< " Total: " << tracks.tracks.size());
3648
}
3749

0 commit comments

Comments
 (0)