Skip to content

Commit cc0aeb8

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 7ed18da commit cc0aeb8

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
@@ -243,6 +243,10 @@ class kalman_fitter {
243243
// Run forward filtering
244244
propagator.propagate(propagation, fitter_state());
245245

246+
if (!fitter_state.m_fit_actor_state.is_complete()) {
247+
return kalman_fitter_status::ERROR_NOT_ALL_TRACK_STATES_FOUND;
248+
}
249+
246250
return kalman_fitter_status::SUCCESS;
247251
}
248252

@@ -265,14 +269,16 @@ class kalman_fitter {
265269
// Since the smoothed track parameter of the last surface can be
266270
// considered to be the filtered one, we can reversly iterate the
267271
// algorithm to obtain the smoothed parameter of other surfaces
268-
while (!fitter_state.m_fit_actor_state.is_complete() &&
269-
(!fitter_state.m_fit_actor_state.is_state() ||
270-
fitter_state.m_fit_actor_state().is_hole())) {
272+
while (
273+
!fitter_state.m_fit_actor_state.is_complete() &&
274+
(!fitter_state.m_fit_actor_state.is_state() ||
275+
fitter_state.m_fit_actor_state().is_hole() ||
276+
fitter_state.m_fit_actor_state().filtered_params().is_invalid())) {
271277
fitter_state.m_fit_actor_state.next();
272278
}
273279

274280
if (fitter_state.m_fit_actor_state.is_complete()) {
275-
return kalman_fitter_status::SUCCESS;
281+
return kalman_fitter_status::ERROR_TRACK_STATES_EMPTY;
276282
}
277283

278284
auto last = fitter_state.m_fit_actor_state();
@@ -333,6 +339,10 @@ class kalman_fitter {
333339

334340
propagator.propagate(propagation, fitter_state.backward_actor_state());
335341

342+
if (!fitter_state.m_fit_actor_state.is_complete()) {
343+
return kalman_fitter_status::ERROR_NOT_ALL_TRACK_STATES_FOUND;
344+
}
345+
336346
// Reset the backward mode to false
337347
fitter_state.m_fit_actor_state.backward_mode = false;
338348

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
@@ -53,6 +53,8 @@ TRACCC_HOST_DEVICE inline void fit_backward(
5353

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

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_fit_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)