77#pragma once
88
99// Project include(s).
10- #include < detray/utils/log.hpp>
11-
1210#include " traccc/edm/measurement.hpp"
1311#include " traccc/edm/track_candidate_collection.hpp"
1412#include " traccc/edm/track_state_helpers.hpp"
1715#include " traccc/finding/candidate_link.hpp"
1816#include " traccc/finding/details/combinatorial_kalman_filter_types.hpp"
1917#include " traccc/finding/finding_config.hpp"
18+ #include " traccc/finding/propagation_data.hpp"
2019#include " traccc/fitting/kalman_filter/gain_matrix_updater.hpp"
2120#include " traccc/fitting/kalman_filter/is_line_visitor.hpp"
2221#include " traccc/fitting/status_codes.hpp"
@@ -73,6 +72,8 @@ combinatorial_kalman_filter(
7372 " overstep tolerance" );
7473 assert (config.min_track_candidates_per_track >= 1 );
7574
75+ const float chi2_min{math::max (10 .f , 0 .1f * config.chi2_max )};
76+
7677 // / The algebra type
7778 using algebra_type = typename detector_t ::algebra_type;
7879 // / The scalar type
@@ -128,8 +129,11 @@ combinatorial_kalman_filter(
128129 std::vector<std::pair<unsigned int , unsigned int >> tips;
129130
130131 // Create propagator
132+ // @TODO: Turn off the mask tolerance scaling for now
133+ auto prop_config{config.propagation };
134+ prop_config.navigation .estimate_scattering_noise = false ;
131135 traccc::details::ckf_propagator_t <detector_t , bfield_t > propagator (
132- config. propagation );
136+ prop_config );
133137
134138 // Create the input seeds container.
135139 bound_track_parameters_collection_types::const_device seeds{seeds_view};
@@ -141,20 +145,19 @@ combinatorial_kalman_filter(
141145
142146 std::vector<bound_track_parameters<algebra_type>> out_params;
143147
144- std::vector<std:: uint8_t > in_is_edge (seeds.size (), false );
145- std::vector<std:: uint8_t > out_is_edge ;
148+ std::vector<propagation_data> in_prop_data (seeds.size ());
149+ std::vector<propagation_data> out_prop_data ;
146150
147151 for (unsigned int step = 0u ; step < config.max_track_candidates_per_track ;
148152 step++) {
149153
150- DETRAY_DEBUG_HOST (" PRPGAGATION STEP: " << step);
151154 TRACCC_VERBOSE (" Starting step "
152155 << step + 1 << " / "
153156 << config.max_track_candidates_per_track );
154157
155158 // Iterate over input parameters
156159 const std::size_t n_in_params = in_params.size ();
157- DETRAY_DEBUG_HOST ( " # PARAMS : " << n_in_params);
160+ TRACCC_VERBOSE ( " No. Params : " << n_in_params);
158161
159162 // Terminate if there is no parameter to proceed
160163 if (n_in_params == 0 ) {
@@ -163,23 +166,22 @@ combinatorial_kalman_filter(
163166
164167 // Rough estimation on out parameters size
165168 out_params.reserve (n_in_params);
166- out_is_edge .reserve (n_in_params);
169+ out_prop_data .reserve (n_in_params);
167170
168171 // Previous step ID
169172 std::fill (n_trks_per_seed.begin (), n_trks_per_seed.end (), 0u );
170173
171174 // Parameters updated by Kalman fitter
172175 std::vector<bound_track_parameters<algebra_type>> updated_params;
176+ std::vector<propagation_data> updated_prop_data;
173177
174178 for (unsigned int in_param_id = 0 ; in_param_id < n_in_params;
175179 in_param_id++) {
176180
177181 bound_track_parameters<algebra_type>& in_param =
178182 in_params[in_param_id];
179183
180- DETRAY_DEBUG_HOST (" PARAMS: " << in_param);
181-
182- const bool is_edge{in_is_edge[in_param_id] > 0u };
184+ const propagation_data& prop_data = in_prop_data[in_param_id];
183185
184186 assert (!in_param.is_invalid ());
185187
@@ -256,9 +258,9 @@ combinatorial_kalman_filter(
256258 best_links;
257259
258260 // Iterate over the measurements
259- DETRAY_DEBUG_HOST ( " # MEAS : " << (up - lo));
261+ TRACCC_VERBOSE ( " No. measurements : " << (up - lo));
260262 for (unsigned int meas_id = lo; meas_id < up; meas_id++) {
261- DETRAY_DEBUG_HOST ( " TESTING MEAS : " << meas_id);
263+ TRACCC_DEBUG ( " Testing measurement : " << meas_id);
262264
263265 // The measurement on surface to handle.
264266 const measurement& meas = measurements.at (meas_id);
@@ -276,13 +278,14 @@ combinatorial_kalman_filter(
276278
277279 const traccc::scalar chi2 = trk_state.filtered_chi2 ();
278280
279- DETRAY_DEBUG_HOST (" KF STATUS : " << fitter_debug_msg{res}());
281+ TRACCC_DEBUG (" KF status : " << fitter_debug_msg{res}());
280282
281283 // The chi2 from Kalman update should be less than chi2_max
282284 if (res == kalman_fitter_status::SUCCESS &&
283- chi2 < config.chi2_max ) {
285+ ((!prop_data.is_edge && chi2 <= config.chi2_max ) ||
286+ (chi2 <= chi2_min))) {
284287
285- DETRAY_DEBUG_HOST ( " FOUND MEAS : " << meas_id);
288+ TRACCC_VERBOSE ( " Found measurement : " << meas_id);
286289
287290 best_links.push_back (
288291 {{.step = step,
@@ -319,9 +322,10 @@ combinatorial_kalman_filter(
319322
320323 // Add the updated parameter to the updated parameters
321324 updated_params.push_back (filtered_params);
322- TRACCC_VERBOSE (" updated_params["
323- << updated_params.size () - 1
324- << " ] = " << updated_params.back ());
325+ updated_prop_data.push_back (prop_data);
326+ TRACCC_DEBUG (" updated_params["
327+ << updated_params.size () - 1
328+ << " ] = " << updated_params.back ());
325329 }
326330
327331 /* ****************************************************************
@@ -336,19 +340,22 @@ combinatorial_kalman_filter(
336340 .previous_candidate_idx = in_param_id,
337341 .meas_idx = std::numeric_limits<unsigned int >::max (),
338342 .seed_idx = orig_param_id,
339- .n_skipped = is_edge ? skip_counter : skip_counter + 1 ,
340- .n_consecutive_skipped = consecutive_skipped + 1 ,
341343 .n_cand = n_cand,
344+ .n_skipped =
345+ prop_data.is_edge ? skip_counter : skip_counter + 1 ,
346+ .n_consecutive_skipped = consecutive_skipped + 1 ,
342347 .chi2 = std::numeric_limits<traccc::scalar>::max (),
343348 .chi2_sum = prev_chi2_sum,
344349 .ndf_sum = prev_ndf_sum});
345350
346- DETRAY_DEBUG_HOST (" HOLE: " << std::boolalpha << !is_edge);
351+ TRACCC_VERBOSE (" Is hole: " << std::boolalpha
352+ << !prop_data.is_edge );
347353
348354 updated_params.push_back (in_param);
349- TRACCC_VERBOSE (" updated_params["
350- << updated_params.size () - 1
351- << " ] = " << updated_params.back ());
355+ updated_prop_data.push_back (prop_data);
356+ TRACCC_DEBUG (" updated_params["
357+ << updated_params.size () - 1
358+ << " ] = " << updated_params.back ());
352359 }
353360 }
354361
@@ -465,7 +472,7 @@ combinatorial_kalman_filter(
465472 }
466473
467474 if (this_is_dominated) {
468- DETRAY_DEBUG_HOST (" Track is DEAD !" );
475+ TRACCC_VERBOSE (" Track is dead (deduplication) !" );
469476 param_liveness.at (tracks.at (i)) = 0u ;
470477 break ;
471478 }
@@ -491,15 +498,20 @@ combinatorial_kalman_filter(
491498
492499 // If number of skips is larger than the maximum value, consider the
493500 // link to be a tip
494- if (links.at (step).at (link_id).n_skipped >
495- config.max_num_skipping_per_cand ) {
501+ if ((links.at (step).at (link_id).n_skipped >
502+ config.max_num_skipping_per_cand ) ||
503+ (links.at (step).at (link_id).n_consecutive_skipped >
504+ config.max_num_consecutive_skipped )) {
496505
497- DETRAY_DEBUG_HOST ( " MAKE TIP: MAX NO. HOLES " );
506+ TRACCC_WARNING ( " Create tip: max no. of holes reached " );
498507 tips.push_back ({step, link_id});
499508 continue ;
500509 }
501510
511+ assert (updated_params.size () == updated_prop_data.size ());
502512 const auto & param = updated_params[link_id];
513+ const propagation_data& prop_data = updated_prop_data[link_id];
514+
503515 // Create propagator state
504516 typename traccc::details::ckf_propagator_t <
505517 detector_t , bfield_t >::state propagation (param, field, det);
@@ -515,23 +527,25 @@ combinatorial_kalman_filter(
515527 typename interaction_register<
516528 traccc::details::ckf_interactor_t >::state s1{s2};
517529 typename detray::parameter_resetter<
518- typename detector_t ::algebra_type>::state s3{
519- config.propagation };
530+ typename detector_t ::algebra_type>::state s3{prop_config};
520531 typename detray::momentum_aborter<scalar_type>::state s4{};
521- typename ckf_aborter::state s5;
532+ typename ckf_aborter::state s5{};
533+
522534 // Update the actor config
523535 s4.min_pT (static_cast <scalar_type>(config.min_pT ));
524536 s4.min_p (static_cast <scalar_type>(config.min_p ));
537+ s5.prev_surface_index = prop_data.prev_surface ;
538+ s5.surface_index = param.surface_link ().index ();
525539 s5.min_step_length = config.min_step_length_for_next_surface ;
526540 s5.max_count = config.max_step_counts_for_next_surface ;
527541
528- DETRAY_DEBUG_HOST ( " PROPAGATING ... " );
542+ TRACCC_DEBUG ( " Propagating ... " );
529543 // Propagate to the next surface
530544 propagator.propagate (propagation,
531545 detray::tie (s0, s1, s2, s3, s4, s5));
532546
533- DETRAY_DEBUG_HOST (
534- " FINISHED PROPAGATING. PATH: " << s5.path_from_surface );
547+ TRACCC_DEBUG ( " Finished propagation: On surface "
548+ << s5.surface_index );
535549
536550 // If a surface found, add the parameter for the next
537551 // step
@@ -540,32 +554,32 @@ combinatorial_kalman_filter(
540554 assert (!propagation._stepping .bound_params ().is_invalid ());
541555
542556 out_params.push_back (propagation._stepping .bound_params ());
543- out_is_edge.push_back (
557+ out_prop_data.emplace_back (
558+ s5.prev_surface_index ,
544559 propagation._navigation .is_edge_candidate ());
545560 param_to_link[step].push_back (link_id);
546561 }
547562 // Unless the track found a surface, it is considered a
548563 // tip
549564 else if (!s5.success &&
550565 (step >= (config.min_track_candidates_per_track - 1u ))) {
551-
552- DETRAY_DEBUG_HOST (" MAKE TIP: NO SENSITIVE" );
566+ TRACCC_VERBOSE (" Create tip: No next sensitive found" );
553567 tips.push_back ({step, link_id});
554568 }
555569
556570 // If no more CKF step is expected, current candidate is
557571 // kept as a tip
558572 if (s5.success &&
559573 (step == (config.max_track_candidates_per_track - 1u ))) {
560- DETRAY_DEBUG_HOST ( " MAKE TIP: MAX CANDIDATES " );
574+ TRACCC_ERROR ( " Create tip: Max no. candidates " );
561575 tips.push_back ({step, link_id});
562576 }
563577 }
564578
565579 in_params = std::move (out_params);
566- in_is_edge = std::move (out_is_edge );
580+ in_prop_data = std::move (out_prop_data );
567581 out_params.clear ();
568- out_is_edge .clear ();
582+ out_prop_data .clear ();
569583 }
570584
571585 /* *********************
0 commit comments