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_container.hpp"
1214#include " traccc/edm/track_state_helpers.hpp"
@@ -126,8 +128,11 @@ combinatorial_kalman_filter(
126128 std::vector<std::pair<unsigned int , unsigned int >> tips;
127129
128130 // Create propagator
131+ // @TODO: Turn off the mask tolerance scaling for now
132+ auto prop_config{config.propagation };
133+ prop_config.navigation .estimate_scattering_noise = false ;
129134 traccc::details::ckf_propagator_t <detector_t , bfield_t > propagator (
130- config. propagation );
135+ prop_config );
131136
132137 // Create the input seeds container.
133138 bound_track_parameters_collection_types::const_device seeds{seeds_view};
@@ -139,15 +144,20 @@ combinatorial_kalman_filter(
139144
140145 std::vector<bound_track_parameters<algebra_type>> out_params;
141146
147+ std::vector<std::uint8_t > in_is_edge (seeds.size (), false );
148+ std::vector<std::uint8_t > out_is_edge;
149+
142150 for (unsigned int step = 0u ; step < config.max_track_candidates_per_track ;
143151 step++) {
144152
153+ DETRAY_DEBUG_HOST (" PRPGAGATION STEP: " << step);
145154 TRACCC_VERBOSE (" Starting step "
146155 << step + 1 << " / "
147156 << config.max_track_candidates_per_track );
148157
149158 // Iterate over input parameters
150159 const std::size_t n_in_params = in_params.size ();
160+ DETRAY_DEBUG_HOST (" # PARAMS: " << n_in_params);
151161
152162 // Terminate if there is no parameter to proceed
153163 if (n_in_params == 0 ) {
@@ -156,6 +166,7 @@ combinatorial_kalman_filter(
156166
157167 // Rough estimation on out parameters size
158168 out_params.reserve (n_in_params);
169+ out_is_edge.reserve (n_in_params);
159170
160171 // Previous step ID
161172 std::fill (n_trks_per_seed.begin (), n_trks_per_seed.end (), 0u );
@@ -169,13 +180,22 @@ combinatorial_kalman_filter(
169180 bound_track_parameters<algebra_type>& in_param =
170181 in_params[in_param_id];
171182
183+ DETRAY_DEBUG_HOST (" PARAMS: " << in_param);
184+
185+ const bool is_edge{in_is_edge[in_param_id] > 0u };
186+
172187 assert (!in_param.is_invalid ());
173188
174189 const unsigned int orig_param_id =
175190 (step == 0
176191 ? in_param_id
177192 : links[step - 1 ][param_to_link[step - 1 ][in_param_id]]
178193 .seed_idx );
194+ const unsigned int n_cand =
195+ (step == 0
196+ ? 0
197+ : links[step - 1 ][param_to_link[step - 1 ][in_param_id]]
198+ .n_cand );
179199 const unsigned int skip_counter =
180200 (step == 0
181201 ? 0
@@ -239,7 +259,9 @@ combinatorial_kalman_filter(
239259 best_links;
240260
241261 // Iterate over the measurements
262+ DETRAY_DEBUG_HOST (" # MEAS: " << (up - lo));
242263 for (unsigned int meas_id = lo; meas_id < up; meas_id++) {
264+ DETRAY_DEBUG_HOST (" TESTING MEAS: " << meas_id);
243265
244266 // The measurement on surface to handle.
245267 const measurement& meas = measurements.at (meas_id);
@@ -248,7 +270,7 @@ combinatorial_kalman_filter(
248270 auto trk_state =
249271 edm::make_track_state<algebra_type>(measurements, meas_id);
250272
251- const bool is_line = sf. template visit_mask <is_line_visitor>( );
273+ const bool is_line = detail::is_line (sf );
252274
253275 // Run the Kalman update on a copy of the track parameters
254276 const kalman_fitter_status res =
@@ -257,15 +279,20 @@ combinatorial_kalman_filter(
257279
258280 const traccc::scalar chi2 = trk_state.filtered_chi2 ();
259281
282+ DETRAY_DEBUG_HOST (" KF STATUS: " << fitter_debug_msg{res}());
283+
260284 // The chi2 from Kalman update should be less than chi2_max
261285 if (res == kalman_fitter_status::SUCCESS &&
262286 chi2 < config.chi2_max ) {
263287
288+ DETRAY_DEBUG_HOST (" FOUND MEAS: " << meas_id);
289+
264290 best_links.push_back (
265291 {{.step = step,
266292 .previous_candidate_idx = in_param_id,
267293 .meas_idx = meas_id,
268294 .seed_idx = orig_param_id,
295+ .n_cand = n_cand + 1 ,
269296 .n_skipped = skip_counter,
270297 .n_consecutive_skipped = 0 ,
271298 .chi2 = chi2,
@@ -312,12 +339,15 @@ combinatorial_kalman_filter(
312339 .previous_candidate_idx = in_param_id,
313340 .meas_idx = std::numeric_limits<unsigned int >::max (),
314341 .seed_idx = orig_param_id,
315- .n_skipped = skip_counter + 1 ,
342+ .n_cand = n_cand,
343+ .n_skipped = is_edge ? skip_counter : skip_counter + 1 ,
316344 .n_consecutive_skipped = consecutive_skipped + 1 ,
317345 .chi2 = std::numeric_limits<traccc::scalar>::max (),
318346 .chi2_sum = prev_chi2_sum,
319347 .ndf_sum = prev_ndf_sum});
320348
349+ DETRAY_DEBUG_HOST (" HOLE: " << std::boolalpha << !is_edge);
350+
321351 updated_params.push_back (in_param);
322352 TRACCC_VERBOSE (" updated_params["
323353 << updated_params.size () - 1
@@ -363,7 +393,7 @@ combinatorial_kalman_filter(
363393 prob (Lthisbase.chi2_sum ,
364394 static_cast <scalar>(Lthisbase.ndf_sum - 5 ));
365395
366- if (step + 1 - Lthisbase.n_skipped <=
396+ if (Lthisbase.n_cand <=
367397 config.duplicate_removal_minimum_length ||
368398 Lthisbase.ndf_sum <= 5 ) {
369399 continue ;
@@ -377,7 +407,7 @@ combinatorial_kalman_filter(
377407 auto Lthis = Lthisbase;
378408 auto Lthat = links.at (step).at (tracks.at (j));
379409
380- if (step + 1 - Lthat.n_skipped <=
410+ if (Lthat.n_cand <=
381411 config.duplicate_removal_minimum_length ||
382412 Lthisbase.ndf_sum <= 5 ) {
383413 continue ;
@@ -438,6 +468,7 @@ combinatorial_kalman_filter(
438468 }
439469
440470 if (this_is_dominated) {
471+ DETRAY_DEBUG_HOST (" Track is DEAD!" );
441472 param_liveness.at (tracks.at (i)) = 0u ;
442473 break ;
443474 }
@@ -465,6 +496,8 @@ combinatorial_kalman_filter(
465496 // link to be a tip
466497 if (links.at (step).at (link_id).n_skipped >
467498 config.max_num_skipping_per_cand ) {
499+
500+ DETRAY_DEBUG_HOST (" MAKE TIP: MAX NO. HOLES" );
468501 tips.push_back ({step, link_id});
469502 continue ;
470503 }
@@ -484,8 +517,8 @@ combinatorial_kalman_filter(
484517 traccc::details::ckf_interactor_t ::state s2;
485518 typename interaction_register<
486519 traccc::details::ckf_interactor_t >::state s1{s2};
487- // typename detray::parameter_resetter<
488- // typename detector_t::algebra_type>::state s3{};
520+ typename detray::parameter_resetter<
521+ typename detector_t ::algebra_type>::state s3{prop_config };
489522 typename detray::momentum_aborter<scalar_type>::state s4{};
490523 typename ckf_aborter::state s5;
491524 // Update the actor config
@@ -494,8 +527,13 @@ combinatorial_kalman_filter(
494527 s5.min_step_length = config.min_step_length_for_next_surface ;
495528 s5.max_count = config.max_step_counts_for_next_surface ;
496529
530+ DETRAY_DEBUG_HOST (" PROPAGATING... " );
497531 // Propagate to the next surface
498- propagator.propagate (propagation, detray::tie (s0, s1, s2, s4, s5));
532+ propagator.propagate (propagation,
533+ detray::tie (s0, s1, s2, s3, s4, s5));
534+
535+ DETRAY_DEBUG_HOST (
536+ " FINISHED PROPAGATING. PATH: " << s5.path_from_surface );
499537
500538 // If a surface found, add the parameter for the next
501539 // step
@@ -504,25 +542,32 @@ combinatorial_kalman_filter(
504542 assert (!propagation._stepping .bound_params ().is_invalid ());
505543
506544 out_params.push_back (propagation._stepping .bound_params ());
545+ out_is_edge.push_back (
546+ propagation._navigation .is_edge_candidate ());
507547 param_to_link[step].push_back (link_id);
508548 }
509549 // Unless the track found a surface, it is considered a
510550 // tip
511551 else if (!s5.success &&
512552 (step >= (config.min_track_candidates_per_track - 1u ))) {
553+
554+ DETRAY_DEBUG_HOST (" MAKE TIP: NO SENSITIVE" );
513555 tips.push_back ({step, link_id});
514556 }
515557
516558 // If no more CKF step is expected, current candidate is
517559 // kept as a tip
518560 if (s5.success &&
519561 (step == (config.max_track_candidates_per_track - 1u ))) {
562+ DETRAY_DEBUG_HOST (" MAKE TIP: MAX CANDIDATES" );
520563 tips.push_back ({step, link_id});
521564 }
522565 }
523566
524567 in_params = std::move (out_params);
568+ in_is_edge = std::move (out_is_edge);
525569 out_params.clear ();
570+ out_is_edge.clear ();
526571 }
527572
528573 /* *********************
@@ -538,7 +583,7 @@ combinatorial_kalman_filter(
538583 // Get the link corresponding to tip
539584 auto L = links.at (tip.first ).at (tip.second );
540585
541- const unsigned int n_cands = tip. first + 1 - L. n_skipped ;
586+ const unsigned int n_cands = L. n_cand ;
542587
543588 // Skip if the number of tracks candidates is too small
544589 if (n_cands < config.min_track_candidates_per_track ||
0 commit comments