77#pragma once
88
99// Project include(s).
10+ #include < detray/utils/log.hpp>
11+
1012#include " traccc/edm/measurement.hpp"
1113#include " traccc/edm/track_candidate_collection.hpp"
1214#include " traccc/edm/track_state_helpers.hpp"
@@ -139,15 +141,20 @@ combinatorial_kalman_filter(
139141
140142 std::vector<bound_track_parameters<algebra_type>> out_params;
141143
144+ std::vector<std::uint8_t > in_is_edge (seeds.size (), false );
145+ std::vector<std::uint8_t > out_is_edge;
146+
142147 for (unsigned int step = 0u ; step < config.max_track_candidates_per_track ;
143148 step++) {
144149
150+ DETRAY_DEBUG_HOST (" PRPGAGATION STEP: " << step);
145151 TRACCC_VERBOSE (" Starting step "
146152 << step + 1 << " / "
147153 << config.max_track_candidates_per_track );
148154
149155 // Iterate over input parameters
150156 const std::size_t n_in_params = in_params.size ();
157+ DETRAY_DEBUG_HOST (" # PARAMS: " << n_in_params);
151158
152159 // Terminate if there is no parameter to proceed
153160 if (n_in_params == 0 ) {
@@ -156,6 +163,7 @@ combinatorial_kalman_filter(
156163
157164 // Rough estimation on out parameters size
158165 out_params.reserve (n_in_params);
166+ out_is_edge.reserve (n_in_params);
159167
160168 // Previous step ID
161169 std::fill (n_trks_per_seed.begin (), n_trks_per_seed.end (), 0u );
@@ -169,13 +177,22 @@ combinatorial_kalman_filter(
169177 bound_track_parameters<algebra_type>& in_param =
170178 in_params[in_param_id];
171179
180+ DETRAY_DEBUG_HOST (" PARAMS: " << in_param);
181+
182+ const bool is_edge{in_is_edge[in_param_id] > 0u };
183+
172184 assert (!in_param.is_invalid ());
173185
174186 const unsigned int orig_param_id =
175187 (step == 0
176188 ? in_param_id
177189 : links[step - 1 ][param_to_link[step - 1 ][in_param_id]]
178190 .seed_idx );
191+ const unsigned int n_cand =
192+ (step == 0
193+ ? 0
194+ : links[step - 1 ][param_to_link[step - 1 ][in_param_id]]
195+ .n_cand );
179196 const unsigned int skip_counter =
180197 (step == 0
181198 ? 0
@@ -234,7 +251,9 @@ combinatorial_kalman_filter(
234251 best_links;
235252
236253 // Iterate over the measurements
254+ DETRAY_DEBUG_HOST (" # MEAS: " << (up - lo));
237255 for (unsigned int meas_id = lo; meas_id < up; meas_id++) {
256+ DETRAY_DEBUG_HOST (" TESTING MEAS: " << meas_id);
238257
239258 // The measurement on surface to handle.
240259 const measurement& meas = measurements.at (meas_id);
@@ -243,7 +262,7 @@ combinatorial_kalman_filter(
243262 auto trk_state =
244263 edm::make_track_state<algebra_type>(measurements, meas_id);
245264
246- const bool is_line = sf. template visit_mask <is_line_visitor>( );
265+ const bool is_line = detail::is_line (sf );
247266
248267 // Run the Kalman update on a copy of the track parameters
249268 const kalman_fitter_status res =
@@ -252,15 +271,20 @@ combinatorial_kalman_filter(
252271
253272 const traccc::scalar chi2 = trk_state.filtered_chi2 ();
254273
274+ DETRAY_DEBUG_HOST (" KF STATUS: " << fitter_debug_msg{res}());
275+
255276 // The chi2 from Kalman update should be less than chi2_max
256277 if (res == kalman_fitter_status::SUCCESS &&
257278 chi2 < config.chi2_max ) {
258279
280+ DETRAY_DEBUG_HOST (" FOUND MEAS: " << meas_id);
281+
259282 best_links.push_back (
260283 {{.step = step,
261284 .previous_candidate_idx = in_param_id,
262285 .meas_idx = meas_id,
263286 .seed_idx = orig_param_id,
287+ .n_cand = n_cand + 1 ,
264288 .n_skipped = skip_counter,
265289 .chi2 = chi2,
266290 .chi2_sum = prev_chi2_sum + chi2,
@@ -306,11 +330,14 @@ combinatorial_kalman_filter(
306330 .previous_candidate_idx = in_param_id,
307331 .meas_idx = std::numeric_limits<unsigned int >::max (),
308332 .seed_idx = orig_param_id,
309- .n_skipped = skip_counter + 1 ,
333+ .n_cand = n_cand,
334+ .n_skipped = is_edge ? skip_counter : skip_counter + 1 ,
310335 .chi2 = std::numeric_limits<traccc::scalar>::max (),
311336 .chi2_sum = prev_chi2_sum,
312337 .ndf_sum = prev_ndf_sum});
313338
339+ DETRAY_DEBUG_HOST (" HOLE: " << std::boolalpha << !is_edge);
340+
314341 updated_params.push_back (in_param);
315342 TRACCC_VERBOSE (" updated_params["
316343 << updated_params.size () - 1
@@ -356,7 +383,7 @@ combinatorial_kalman_filter(
356383 prob (Lthisbase.chi2_sum ,
357384 static_cast <scalar>(Lthisbase.ndf_sum - 5 ));
358385
359- if (step + 1 - Lthisbase.n_skipped <=
386+ if (Lthisbase.n_cand <=
360387 config.duplicate_removal_minimum_length ||
361388 Lthisbase.ndf_sum <= 5 ) {
362389 continue ;
@@ -370,7 +397,7 @@ combinatorial_kalman_filter(
370397 auto Lthis = Lthisbase;
371398 auto Lthat = links.at (step).at (tracks.at (j));
372399
373- if (step + 1 - Lthat.n_skipped <=
400+ if (Lthat.n_cand <=
374401 config.duplicate_removal_minimum_length ||
375402 Lthisbase.ndf_sum <= 5 ) {
376403 continue ;
@@ -431,6 +458,7 @@ combinatorial_kalman_filter(
431458 }
432459
433460 if (this_is_dominated) {
461+ DETRAY_DEBUG_HOST (" Track is DEAD!" );
434462 param_liveness.at (tracks.at (i)) = 0u ;
435463 break ;
436464 }
@@ -458,6 +486,8 @@ combinatorial_kalman_filter(
458486 // link to be a tip
459487 if (links.at (step).at (link_id).n_skipped >
460488 config.max_num_skipping_per_cand ) {
489+
490+ DETRAY_DEBUG_HOST (" MAKE TIP: MAX NO. HOLES" );
461491 tips.push_back ({step, link_id});
462492 continue ;
463493 }
@@ -477,8 +507,9 @@ combinatorial_kalman_filter(
477507 traccc::details::ckf_interactor_t ::state s2;
478508 typename interaction_register<
479509 traccc::details::ckf_interactor_t >::state s1{s2};
480- // typename detray::parameter_resetter<
481- // typename detector_t::algebra_type>::state s3{};
510+ typename detray::parameter_resetter<
511+ typename detector_t ::algebra_type>::state s3{
512+ config.propagation };
482513 typename detray::momentum_aborter<scalar_type>::state s4{};
483514 typename ckf_aborter::state s5;
484515 // Update the actor config
@@ -487,8 +518,13 @@ combinatorial_kalman_filter(
487518 s5.min_step_length = config.min_step_length_for_next_surface ;
488519 s5.max_count = config.max_step_counts_for_next_surface ;
489520
521+ DETRAY_DEBUG_HOST (" PROPAGATING... " );
490522 // Propagate to the next surface
491- propagator.propagate (propagation, detray::tie (s0, s1, s2, s4, s5));
523+ propagator.propagate (propagation,
524+ detray::tie (s0, s1, s2, s3, s4, s5));
525+
526+ DETRAY_DEBUG_HOST (
527+ " FINISHED PROPAGATING. PATH: " << s5.path_from_surface );
492528
493529 // If a surface found, add the parameter for the next
494530 // step
@@ -497,25 +533,32 @@ combinatorial_kalman_filter(
497533 assert (!propagation._stepping .bound_params ().is_invalid ());
498534
499535 out_params.push_back (propagation._stepping .bound_params ());
536+ out_is_edge.push_back (
537+ propagation._navigation .is_edge_candidate ());
500538 param_to_link[step].push_back (link_id);
501539 }
502540 // Unless the track found a surface, it is considered a
503541 // tip
504542 else if (!s5.success &&
505543 (step >= (config.min_track_candidates_per_track - 1u ))) {
544+
545+ DETRAY_DEBUG_HOST (" MAKE TIP: NO SENSITIVE" );
506546 tips.push_back ({step, link_id});
507547 }
508548
509549 // If no more CKF step is expected, current candidate is
510550 // kept as a tip
511551 if (s5.success &&
512552 (step == (config.max_track_candidates_per_track - 1u ))) {
553+ DETRAY_DEBUG_HOST (" MAKE TIP: MAX CANDIDATES" );
513554 tips.push_back ({step, link_id});
514555 }
515556 }
516557
517558 in_params = std::move (out_params);
559+ in_is_edge = std::move (out_is_edge);
518560 out_params.clear ();
561+ out_is_edge.clear ();
519562 }
520563
521564 /* *********************
@@ -531,7 +574,7 @@ combinatorial_kalman_filter(
531574 // Get the link corresponding to tip
532575 auto L = links.at (tip.first ).at (tip.second );
533576
534- const unsigned int n_cands = tip. first + 1 - L. n_skipped ;
577+ const unsigned int n_cands = L. n_cand ;
535578
536579 // Skip if the number of tracks candidates is too small
537580 if (n_cands < config.min_track_candidates_per_track ||
0 commit comments