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"
@@ -81,6 +80,10 @@ combinatorial_kalman_filter(
8180 // Create a logger.
8281 auto logger = [&log]() -> const Logger& { return log; };
8382
83+ // Minimum chi2 cut to use for measurements on surfaces that are edge hits
84+ // (don't accumulate pileup measurements)
85+ const float chi2_min{math::max (10 .f , 0 .1f * config.chi2_max )};
86+
8487 /* ****************************************************************
8588 * Measurement Operations
8689 *****************************************************************/
@@ -144,20 +147,18 @@ combinatorial_kalman_filter(
144147
145148 std::vector<bound_track_parameters<algebra_type>> out_params;
146149
147- std::vector<std:: uint8_t > in_is_edge (seeds.size (), false );
148- std::vector<std:: uint8_t > out_is_edge ;
150+ std::vector<propagation_data> in_prop_data (seeds.size ());
151+ std::vector<propagation_data> out_prop_data ;
149152
150153 for (unsigned int step = 0u ; step < config.max_track_candidates_per_track ;
151154 step++) {
152155
153- DETRAY_DEBUG_HOST (" PRPGAGATION STEP: " << step);
154156 TRACCC_VERBOSE (" Starting step "
155157 << step + 1 << " / "
156158 << config.max_track_candidates_per_track );
157159
158160 // Iterate over input parameters
159161 const std::size_t n_in_params = in_params.size ();
160- DETRAY_DEBUG_HOST (" # PARAMS: " << n_in_params);
161162
162163 // Terminate if there is no parameter to proceed
163164 if (n_in_params == 0 ) {
@@ -166,23 +167,22 @@ combinatorial_kalman_filter(
166167
167168 // Rough estimation on out parameters size
168169 out_params.reserve (n_in_params);
169- out_is_edge .reserve (n_in_params);
170+ out_prop_data .reserve (n_in_params);
170171
171172 // Previous step ID
172173 std::fill (n_trks_per_seed.begin (), n_trks_per_seed.end (), 0u );
173174
174175 // Parameters updated by Kalman fitter
175176 std::vector<bound_track_parameters<algebra_type>> updated_params;
177+ std::vector<propagation_data> updated_prop_data;
176178
177179 for (unsigned int in_param_id = 0 ; in_param_id < n_in_params;
178180 in_param_id++) {
179181
180182 bound_track_parameters<algebra_type>& in_param =
181183 in_params[in_param_id];
182184
183- DETRAY_DEBUG_HOST (" PARAMS: " << in_param);
184-
185- const bool is_edge{in_is_edge[in_param_id] > 0u };
185+ const propagation_data& prop_data = in_prop_data[in_param_id];
186186
187187 assert (!in_param.is_invalid ());
188188
@@ -259,9 +259,7 @@ combinatorial_kalman_filter(
259259 best_links;
260260
261261 // Iterate over the measurements
262- DETRAY_DEBUG_HOST (" # MEAS: " << (up - lo));
263262 for (unsigned int meas_id = lo; meas_id < up; meas_id++) {
264- DETRAY_DEBUG_HOST (" TESTING MEAS: " << meas_id);
265263
266264 // The measurement on surface to handle.
267265 const measurement& meas = measurements.at (meas_id);
@@ -279,13 +277,10 @@ combinatorial_kalman_filter(
279277
280278 const traccc::scalar chi2 = trk_state.filtered_chi2 ();
281279
282- DETRAY_DEBUG_HOST (" KF STATUS: " << fitter_debug_msg{res}());
283-
284280 // The chi2 from Kalman update should be less than chi2_max
285281 if (res == kalman_fitter_status::SUCCESS &&
286- chi2 < config.chi2_max ) {
287-
288- DETRAY_DEBUG_HOST (" FOUND MEAS: " << meas_id);
282+ ((!prop_data.is_edge && chi2 <= config.chi2_max ) ||
283+ (chi2 <= chi2_min))) {
289284
290285 best_links.push_back (
291286 {{.step = step,
@@ -322,6 +317,7 @@ combinatorial_kalman_filter(
322317
323318 // Add the updated parameter to the updated parameters
324319 updated_params.push_back (filtered_params);
320+ updated_prop_data.push_back (prop_data);
325321 TRACCC_VERBOSE (" updated_params["
326322 << updated_params.size () - 1
327323 << " ] = " << updated_params.back ());
@@ -340,15 +336,15 @@ combinatorial_kalman_filter(
340336 .meas_idx = std::numeric_limits<unsigned int >::max (),
341337 .seed_idx = orig_param_id,
342338 .n_cand = n_cand,
343- .n_skipped = is_edge ? skip_counter : skip_counter + 1 ,
339+ .n_skipped =
340+ prop_data.is_edge ? skip_counter : skip_counter + 1 ,
344341 .n_consecutive_skipped = consecutive_skipped + 1 ,
345342 .chi2 = std::numeric_limits<traccc::scalar>::max (),
346343 .chi2_sum = prev_chi2_sum,
347344 .ndf_sum = prev_ndf_sum});
348345
349- DETRAY_DEBUG_HOST (" HOLE: " << std::boolalpha << !is_edge);
350-
351346 updated_params.push_back (in_param);
347+ updated_prop_data.push_back (prop_data);
352348 TRACCC_VERBOSE (" updated_params["
353349 << updated_params.size () - 1
354350 << " ] = " << updated_params.back ());
@@ -468,7 +464,6 @@ combinatorial_kalman_filter(
468464 }
469465
470466 if (this_is_dominated) {
471- DETRAY_DEBUG_HOST (" Track is DEAD!" );
472467 param_liveness.at (tracks.at (i)) = 0u ;
473468 break ;
474469 }
@@ -497,12 +492,14 @@ combinatorial_kalman_filter(
497492 if (links.at (step).at (link_id).n_skipped >
498493 config.max_num_skipping_per_cand ) {
499494
500- DETRAY_DEBUG_HOST (" MAKE TIP: MAX NO. HOLES" );
501495 tips.push_back ({step, link_id});
502496 continue ;
503497 }
504498
499+ assert (updated_params.size () == updated_prop_data.size ());
505500 const auto & param = updated_params[link_id];
501+ const propagation_data& prop_data = updated_prop_data[link_id];
502+
506503 // Create propagator state
507504 typename traccc::details::ckf_propagator_t <
508505 detector_t , bfield_t >::state propagation (param, field, det);
@@ -524,50 +521,46 @@ combinatorial_kalman_filter(
524521 // Update the actor config
525522 s4.min_pT (static_cast <scalar_type>(config.min_pT ));
526523 s4.min_p (static_cast <scalar_type>(config.min_p ));
524+ s5.prev_surface_index = prop_data.prev_surface ;
525+ s5.surface_index = param.surface_link ().index ();
527526 s5.min_step_length = config.min_step_length_for_next_surface ;
528527 s5.max_count = config.max_step_counts_for_next_surface ;
529528
530- DETRAY_DEBUG_HOST (" PROPAGATING... " );
531529 // Propagate to the next surface
532530 propagator.propagate (propagation,
533531 detray::tie (s0, s1, s2, s3, s4, s5));
534532
535- DETRAY_DEBUG_HOST (
536- " FINISHED PROPAGATING. PATH: " << s5.path_from_surface );
537-
538533 // If a surface found, add the parameter for the next
539534 // step
540535 if (s5.success ) {
541536 assert (propagation._navigation .is_on_sensitive ());
542537 assert (!propagation._stepping .bound_params ().is_invalid ());
543538
544539 out_params.push_back (propagation._stepping .bound_params ());
545- out_is_edge.push_back (
540+ out_prop_data.emplace_back (
541+ s5.prev_surface_index ,
546542 propagation._navigation .is_edge_candidate ());
547543 param_to_link[step].push_back (link_id);
548544 }
549545 // Unless the track found a surface, it is considered a
550546 // tip
551547 else if (!s5.success &&
552548 (step >= (config.min_track_candidates_per_track - 1u ))) {
553-
554- DETRAY_DEBUG_HOST (" MAKE TIP: NO SENSITIVE" );
555549 tips.push_back ({step, link_id});
556550 }
557551
558552 // If no more CKF step is expected, current candidate is
559553 // kept as a tip
560554 if (s5.success &&
561555 (step == (config.max_track_candidates_per_track - 1u ))) {
562- DETRAY_DEBUG_HOST (" MAKE TIP: MAX CANDIDATES" );
563556 tips.push_back ({step, link_id});
564557 }
565558 }
566559
567560 in_params = std::move (out_params);
568- in_is_edge = std::move (out_is_edge );
561+ in_prop_data = std::move (out_prop_data );
569562 out_params.clear ();
570- out_is_edge .clear ();
563+ out_prop_data .clear ();
571564 }
572565
573566 /* *********************
0 commit comments