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_container.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"
@@ -67,10 +66,6 @@ combinatorial_kalman_filter(
6766 const finding_config& config, vecmem::memory_resource& mr,
6867 const Logger& log) {
6968
70- assert (config.min_step_length_for_next_surface >
71- math::fabs (config.propagation .navigation .overstep_tolerance ) &&
72- " Min step length for the next surface should be higher than the "
73- " overstep tolerance" );
7469 assert (config.min_track_candidates_per_track >= 1 );
7570
7671 // / The algebra type
@@ -81,6 +76,10 @@ combinatorial_kalman_filter(
8176 // Create a logger.
8277 auto logger = [&log]() -> const Logger& { return log; };
8378
79+ // Minimum chi2 cut to use for measurements on surfaces that are edge hits
80+ // (don't accumulate pileup measurements)
81+ const float chi2_min{math::max (10 .f , 0 .1f * config.chi2_max )};
82+
8483 /* ****************************************************************
8584 * Measurement Operations
8685 *****************************************************************/
@@ -144,20 +143,18 @@ combinatorial_kalman_filter(
144143
145144 std::vector<bound_track_parameters<algebra_type>> out_params;
146145
147- std::vector<std:: uint8_t > in_is_edge (seeds.size (), false );
148- std::vector<std:: uint8_t > out_is_edge ;
146+ std::vector<propagation_data> in_prop_data (seeds.size ());
147+ std::vector<propagation_data> out_prop_data ;
149148
150149 for (unsigned int step = 0u ; step < config.max_track_candidates_per_track ;
151150 step++) {
152151
153- DETRAY_DEBUG_HOST (" PRPGAGATION STEP: " << step);
154152 TRACCC_VERBOSE (" Starting step "
155153 << step + 1 << " / "
156154 << config.max_track_candidates_per_track );
157155
158156 // Iterate over input parameters
159157 const std::size_t n_in_params = in_params.size ();
160- DETRAY_DEBUG_HOST (" # PARAMS: " << n_in_params);
161158
162159 // Terminate if there is no parameter to proceed
163160 if (n_in_params == 0 ) {
@@ -166,23 +163,22 @@ combinatorial_kalman_filter(
166163
167164 // Rough estimation on out parameters size
168165 out_params.reserve (n_in_params);
169- out_is_edge .reserve (n_in_params);
166+ out_prop_data .reserve (n_in_params);
170167
171168 // Previous step ID
172169 std::fill (n_trks_per_seed.begin (), n_trks_per_seed.end (), 0u );
173170
174171 // Parameters updated by Kalman fitter
175172 std::vector<bound_track_parameters<algebra_type>> updated_params;
173+ std::vector<propagation_data> updated_prop_data;
176174
177175 for (unsigned int in_param_id = 0 ; in_param_id < n_in_params;
178176 in_param_id++) {
179177
180178 bound_track_parameters<algebra_type>& in_param =
181179 in_params[in_param_id];
182180
183- DETRAY_DEBUG_HOST (" PARAMS: " << in_param);
184-
185- const bool is_edge{in_is_edge[in_param_id] > 0u };
181+ const propagation_data& prop_data = in_prop_data[in_param_id];
186182
187183 assert (!in_param.is_invalid ());
188184
@@ -259,9 +255,7 @@ combinatorial_kalman_filter(
259255 best_links;
260256
261257 // Iterate over the measurements
262- DETRAY_DEBUG_HOST (" # MEAS: " << (up - lo));
263258 for (unsigned int meas_id = lo; meas_id < up; meas_id++) {
264- DETRAY_DEBUG_HOST (" TESTING MEAS: " << meas_id);
265259
266260 // The measurement on surface to handle.
267261 const measurement& meas = measurements.at (meas_id);
@@ -279,13 +273,10 @@ combinatorial_kalman_filter(
279273
280274 const traccc::scalar chi2 = trk_state.filtered_chi2 ();
281275
282- DETRAY_DEBUG_HOST (" KF STATUS: " << fitter_debug_msg{res}());
283-
284276 // The chi2 from Kalman update should be less than chi2_max
285277 if (res == kalman_fitter_status::SUCCESS &&
286- chi2 < config.chi2_max ) {
287-
288- DETRAY_DEBUG_HOST (" FOUND MEAS: " << meas_id);
278+ ((!prop_data.is_edge && chi2 <= config.chi2_max ) ||
279+ (chi2 <= chi2_min))) {
289280
290281 best_links.push_back (
291282 {{.step = step,
@@ -322,6 +313,7 @@ combinatorial_kalman_filter(
322313
323314 // Add the updated parameter to the updated parameters
324315 updated_params.push_back (filtered_params);
316+ updated_prop_data.push_back (prop_data);
325317 TRACCC_VERBOSE (" updated_params["
326318 << updated_params.size () - 1
327319 << " ] = " << updated_params.back ());
@@ -340,15 +332,15 @@ combinatorial_kalman_filter(
340332 .meas_idx = std::numeric_limits<unsigned int >::max (),
341333 .seed_idx = orig_param_id,
342334 .n_cand = n_cand,
343- .n_skipped = is_edge ? skip_counter : skip_counter + 1 ,
335+ .n_skipped =
336+ prop_data.is_edge ? skip_counter : skip_counter + 1 ,
344337 .n_consecutive_skipped = consecutive_skipped + 1 ,
345338 .chi2 = std::numeric_limits<traccc::scalar>::max (),
346339 .chi2_sum = prev_chi2_sum,
347340 .ndf_sum = prev_ndf_sum});
348341
349- DETRAY_DEBUG_HOST (" HOLE: " << std::boolalpha << !is_edge);
350-
351342 updated_params.push_back (in_param);
343+ updated_prop_data.push_back (prop_data);
352344 TRACCC_VERBOSE (" updated_params["
353345 << updated_params.size () - 1
354346 << " ] = " << updated_params.back ());
@@ -468,7 +460,6 @@ combinatorial_kalman_filter(
468460 }
469461
470462 if (this_is_dominated) {
471- DETRAY_DEBUG_HOST (" Track is DEAD!" );
472463 param_liveness.at (tracks.at (i)) = 0u ;
473464 break ;
474465 }
@@ -497,12 +488,14 @@ combinatorial_kalman_filter(
497488 if (links.at (step).at (link_id).n_skipped >
498489 config.max_num_skipping_per_cand ) {
499490
500- DETRAY_DEBUG_HOST (" MAKE TIP: MAX NO. HOLES" );
501491 tips.push_back ({step, link_id});
502492 continue ;
503493 }
504494
495+ assert (updated_params.size () == updated_prop_data.size ());
505496 const auto & param = updated_params[link_id];
497+ const propagation_data& prop_data = updated_prop_data[link_id];
498+
506499 // Create propagator state
507500 typename traccc::details::ckf_propagator_t <
508501 detector_t , bfield_t >::state propagation (param, field, det);
@@ -524,50 +517,45 @@ combinatorial_kalman_filter(
524517 // Update the actor config
525518 s4.min_pT (static_cast <scalar_type>(config.min_pT ));
526519 s4.min_p (static_cast <scalar_type>(config.min_p ));
527- s5.min_step_length = config.min_step_length_for_next_surface ;
520+ s5.prev_surface_index = prop_data.prev_surface ;
521+ s5.surface_index = param.surface_link ().index ();
528522 s5.max_count = config.max_step_counts_for_next_surface ;
529523
530- DETRAY_DEBUG_HOST (" PROPAGATING... " );
531524 // Propagate to the next surface
532525 propagator.propagate (propagation,
533526 detray::tie (s0, s1, s2, s3, s4, s5));
534527
535- DETRAY_DEBUG_HOST (
536- " FINISHED PROPAGATING. PATH: " << s5.path_from_surface );
537-
538528 // If a surface found, add the parameter for the next
539529 // step
540530 if (s5.success ) {
541531 assert (propagation._navigation .is_on_sensitive ());
542532 assert (!propagation._stepping .bound_params ().is_invalid ());
543533
544534 out_params.push_back (propagation._stepping .bound_params ());
545- out_is_edge.push_back (
535+ out_prop_data.emplace_back (
536+ s5.prev_surface_index ,
546537 propagation._navigation .is_edge_candidate ());
547538 param_to_link[step].push_back (link_id);
548539 }
549540 // Unless the track found a surface, it is considered a
550541 // tip
551542 else if (!s5.success &&
552543 (step >= (config.min_track_candidates_per_track - 1u ))) {
553-
554- DETRAY_DEBUG_HOST (" MAKE TIP: NO SENSITIVE" );
555544 tips.push_back ({step, link_id});
556545 }
557546
558547 // If no more CKF step is expected, current candidate is
559548 // kept as a tip
560549 if (s5.success &&
561550 (step == (config.max_track_candidates_per_track - 1u ))) {
562- DETRAY_DEBUG_HOST (" MAKE TIP: MAX CANDIDATES" );
563551 tips.push_back ({step, link_id});
564552 }
565553 }
566554
567555 in_params = std::move (out_params);
568- in_is_edge = std::move (out_is_edge );
556+ in_prop_data = std::move (out_prop_data );
569557 out_params.clear ();
570- out_is_edge .clear ();
558+ out_prop_data .clear ();
571559 }
572560
573561 /* *********************
0 commit comments