@@ -148,6 +148,11 @@ class kalman_fitter {
148
148
// Reset the iterator of kalman actor
149
149
fitter_state.m_fit_actor_state .reset ();
150
150
151
+ // TODO: For multiple iterations, seed parameter should be set to
152
+ // the first track state which has either filtered or smoothed
153
+ // state. If the first track state is a hole, we need to back
154
+ // extrapolate from the filtered or smoothed state of next valid
155
+ // track state.
151
156
auto seed_params_cpy =
152
157
(i == 0 ) ? seed_params
153
158
: fitter_state.m_fit_actor_state .m_track_states [0 ]
@@ -161,6 +166,8 @@ class kalman_fitter {
161
166
res != kalman_fitter_status::SUCCESS) {
162
167
return res;
163
168
}
169
+
170
+ check_fitting_result (fitter_state);
164
171
}
165
172
166
173
return kalman_fitter_status::SUCCESS;
@@ -303,8 +310,13 @@ class kalman_fitter {
303
310
auto & fit_res = fitter_state.m_fit_res ;
304
311
auto & track_states = fitter_state.m_fit_actor_state .m_track_states ;
305
312
306
- // Fit parameter = smoothed track parameter at the first surface
307
- fit_res.fit_params = track_states[0 ].smoothed ();
313
+ // Fit parameter = smoothed track parameter of the first smoothed track
314
+ // state
315
+ for (const auto & st : track_states) {
316
+ if (st.is_smoothed ) {
317
+ fit_res.fit_params = st.smoothed ();
318
+ }
319
+ }
308
320
309
321
for (const auto & trk_state : track_states) {
310
322
@@ -321,6 +333,31 @@ class kalman_fitter {
321
333
fit_res.n_holes = fitter_state.m_fit_actor_state .n_holes ;
322
334
}
323
335
336
+ TRACCC_HOST_DEVICE
337
+ void check_fitting_result (state& fitter_state) {
338
+ auto & fit_res = fitter_state.m_fit_res ;
339
+ const auto & track_states =
340
+ fitter_state.m_fit_actor_state .m_track_states ;
341
+
342
+ // NDF should always be positive for fitting
343
+ if (fit_res.ndf > 0 ) {
344
+ for (const auto & trk_state : track_states) {
345
+ // Fitting fails if any of non-hole track states is not smoothed
346
+ if (!trk_state.is_hole && !trk_state.is_smoothed ) {
347
+ fit_res.fit_outcome =
348
+ fitter_outcome::FAILURE_NOT_ALL_SMOOTHED;
349
+ return ;
350
+ }
351
+ }
352
+
353
+ // Fitting succeeds if any of non-hole track states is not smoothed
354
+ fit_res.fit_outcome = fitter_outcome::SUCCESS;
355
+ }
356
+
357
+ fit_res.fit_outcome = fitter_outcome::FAILURE_NON_POSITIVE_NDF;
358
+ return ;
359
+ }
360
+
324
361
private:
325
362
// Detector object
326
363
const detector_type& m_detector;
0 commit comments