Skip to content

Commit 3e32fda

Browse files
committed
new stuff
1 parent fb0537f commit 3e32fda

File tree

11 files changed

+136
-48
lines changed

11 files changed

+136
-48
lines changed

core/include/traccc/finding/actors/ckf_aborter.hpp

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
#include "traccc/definitions/qualifiers.hpp"
1313

1414
// detray include(s)
15+
#include <detray/definitions/indexing.hpp>
1516
#include <detray/propagator/base_actor.hpp>
17+
#include <detray/utils/log.hpp>
18+
19+
// vecmem include(s)
20+
#include <vecmem/containers/device_vector.hpp>
1621

1722
// System include(s)
1823
#include <limits>
@@ -22,45 +27,73 @@ namespace traccc {
2227
/// Aborter triggered when the next surface is reached
2328
struct ckf_aborter : detray::actor {
2429
struct state {
30+
31+
TRACCC_HOST_DEVICE
32+
explicit state(vecmem::data::vector_view<const unsigned int> meas_view)
33+
: meas_ranges{meas_view} {}
2534
// minimal step length to prevent from staying on the same surface
26-
scalar min_step_length = 0.5f;
35+
/*scalar min_step_length = 0.5f;
36+
2737
/// Maximum step counts that track can make to reach the next surface
28-
unsigned int max_count = 100;
38+
unsigned int max_count = 100u;
39+
unsigned int count = 0u;*/
2940

41+
/// Previous sensitive surface index
42+
detray::dindex prev_surface_index{detray::dindex_invalid};
43+
/// Current sensitive surface index
44+
detray::dindex surface_index{detray::dindex_invalid};
45+
/// Access to the measurements index ranges per surface
46+
vecmem::device_vector<const unsigned int> meas_ranges;
47+
/// Whether a surface was found
3048
bool success = false;
31-
unsigned int count = 0;
32-
33-
scalar path_from_surface{0.f};
3449
};
3550

3651
template <typename propagator_state_t>
3752
TRACCC_HOST_DEVICE void operator()(state &abrt_state,
3853
propagator_state_t &prop_state) const {
3954

4055
auto &navigation = prop_state._navigation;
41-
const auto &stepping = prop_state._stepping;
4256

43-
abrt_state.count++;
44-
abrt_state.path_from_surface += stepping.step_size();
57+
// abrt_state.count++;
4558

46-
// Stop at the next sensitive surface
47-
if (navigation.is_on_sensitive() &&
48-
abrt_state.path_from_surface > abrt_state.min_step_length) {
49-
prop_state._heartbeat &= navigation.pause();
50-
abrt_state.success = navigation.is_alive();
51-
}
59+
DETRAY_DEBUG_HOST("Checking CKF aborter...");
60+
DETRAY_DEBUG_HOST(
61+
"=> second last sensitive: " << abrt_state.prev_surface_index);
62+
DETRAY_DEBUG_HOST("=> last sensitive: " << abrt_state.surface_index);
5263

53-
// Reset path from surface
64+
// Stop at the next sensitive surface
5465
if (navigation.is_on_sensitive()) {
55-
abrt_state.path_from_surface = 0.f;
66+
// Are there any measurements on this surface?
67+
const detray::dindex sf_idx{navigation.barcode().index()};
68+
const unsigned int lo{
69+
sf_idx == 0u ? 0u : abrt_state.meas_ranges[sf_idx - 1]};
70+
const unsigned int up{abrt_state.meas_ranges[sf_idx]};
71+
72+
if ((up - lo) > 0u && (abrt_state.surface_index != sf_idx) &&
73+
(abrt_state.prev_surface_index != sf_idx)) {
74+
abrt_state.prev_surface_index = abrt_state.surface_index;
75+
abrt_state.surface_index = sf_idx;
76+
77+
DETRAY_DEBUG_HOST(
78+
"FOUND SURFACE : " << abrt_state.surface_index);
79+
prop_state._heartbeat &= navigation.pause();
80+
abrt_state.success = true;
81+
82+
assert(abrt_state.surface_index <
83+
navigation.detector().surfaces().size());
84+
DETRAY_DEBUG_HOST("=> second last sensitive: "
85+
<< abrt_state.prev_surface_index);
86+
DETRAY_DEBUG_HOST(
87+
"=> last sensitive: " << abrt_state.surface_index);
88+
}
5689
}
5790

58-
if (abrt_state.count > abrt_state.max_count) {
91+
/*if (abrt_state.count > abrt_state.max_count) {
5992
prop_state._heartbeat &= navigation.abort(
6093
"CKF: Maximum number of steps to reach next sensitive surface "
6194
"exceeded");
6295
abrt_state.success = false;
63-
}
96+
}*/
6497
}
6598
};
6699

core/include/traccc/finding/details/combinatorial_kalman_filter.hpp

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "traccc/finding/candidate_link.hpp"
1818
#include "traccc/finding/details/combinatorial_kalman_filter_types.hpp"
1919
#include "traccc/finding/finding_config.hpp"
20+
#include "traccc/finding/propagation_data.hpp"
2021
#include "traccc/fitting/kalman_filter/gain_matrix_updater.hpp"
2122
#include "traccc/fitting/kalman_filter/is_line_visitor.hpp"
2223
#include "traccc/fitting/status_codes.hpp"
@@ -67,10 +68,10 @@ combinatorial_kalman_filter(
6768
const finding_config& config, vecmem::memory_resource& mr,
6869
const Logger& log) {
6970

70-
assert(config.min_step_length_for_next_surface >
71+
/*assert(config.min_step_length_for_next_surface >
7172
math::fabs(config.propagation.navigation.overstep_tolerance) &&
7273
"Min step length for the next surface should be higher than the "
73-
"overstep tolerance");
74+
"overstep tolerance");*/
7475
assert(config.min_track_candidates_per_track >= 1);
7576

7677
/// The algebra type
@@ -128,6 +129,8 @@ combinatorial_kalman_filter(
128129
std::vector<std::pair<unsigned int, unsigned int>> tips;
129130

130131
// Create propagator
132+
// auto config_alt{config.propagation};
133+
// config_alt.navigation.estimate_scattering_noise = false;
131134
traccc::details::ckf_propagator_t<detector_t, bfield_t> propagator(
132135
config.propagation);
133136

@@ -141,8 +144,8 @@ combinatorial_kalman_filter(
141144

142145
std::vector<bound_track_parameters<algebra_type>> out_params;
143146

144-
std::vector<std::uint8_t> in_is_edge(seeds.size(), false);
145-
std::vector<std::uint8_t> out_is_edge;
147+
std::vector<propagation_data> in_prop_data(seeds.size());
148+
std::vector<propagation_data> out_prop_data;
146149

147150
for (unsigned int step = 0u; step < config.max_track_candidates_per_track;
148151
step++) {
@@ -163,13 +166,14 @@ 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++) {
@@ -179,7 +183,7 @@ combinatorial_kalman_filter(
179183

180184
DETRAY_DEBUG_HOST("PARAMS: " << in_param);
181185

182-
const bool is_edge{in_is_edge[in_param_id] > 0u};
186+
const propagation_data& prop_data = in_prop_data[in_param_id];
183187

184188
assert(!in_param.is_invalid());
185189

@@ -319,6 +323,7 @@ combinatorial_kalman_filter(
319323

320324
// Add the updated parameter to the updated parameters
321325
updated_params.push_back(filtered_params);
326+
updated_prop_data.push_back(prop_data);
322327
TRACCC_VERBOSE("updated_params["
323328
<< updated_params.size() - 1
324329
<< "] = " << updated_params.back());
@@ -336,16 +341,19 @@ combinatorial_kalman_filter(
336341
.previous_candidate_idx = in_param_id,
337342
.meas_idx = std::numeric_limits<unsigned int>::max(),
338343
.seed_idx = orig_param_id,
339-
.n_skipped = is_edge ? skip_counter : skip_counter + 1,
340-
.n_consecutive_skipped = consecutive_skipped + 1,
341344
.n_cand = n_cand,
345+
.n_skipped =
346+
prop_data.is_edge ? skip_counter : skip_counter + 1,
347+
.n_consecutive_skipped = consecutive_skipped + 1,
342348
.chi2 = std::numeric_limits<traccc::scalar>::max(),
343349
.chi2_sum = prev_chi2_sum,
344350
.ndf_sum = prev_ndf_sum});
345351

346-
DETRAY_DEBUG_HOST("HOLE: " << std::boolalpha << !is_edge);
352+
DETRAY_DEBUG_HOST("HOLE: " << std::boolalpha
353+
<< !prop_data.is_edge);
347354

348355
updated_params.push_back(in_param);
356+
updated_prop_data.push_back(prop_data);
349357
TRACCC_VERBOSE("updated_params["
350358
<< updated_params.size() - 1
351359
<< "] = " << updated_params.back());
@@ -499,7 +507,10 @@ combinatorial_kalman_filter(
499507
continue;
500508
}
501509

510+
assert(updated_params.size() == updated_prop_data.size());
502511
const auto& param = updated_params[link_id];
512+
const propagation_data& prop_data = updated_prop_data[link_id];
513+
503514
// Create propagator state
504515
typename traccc::details::ckf_propagator_t<
505516
detector_t, bfield_t>::state propagation(param, field, det);
@@ -518,20 +529,23 @@ combinatorial_kalman_filter(
518529
typename detector_t::algebra_type>::state s3{
519530
config.propagation};
520531
typename detray::momentum_aborter<scalar_type>::state s4{};
521-
typename ckf_aborter::state s5;
532+
typename ckf_aborter::state s5{vecmem::get_data(meas_ranges)};
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));
525-
s5.min_step_length = config.min_step_length_for_next_surface;
526-
s5.max_count = config.max_step_counts_for_next_surface;
537+
s5.prev_surface_index = prop_data.prev_surface;
538+
s5.surface_index = param.surface_link().index();
539+
// s5.min_step_length = config.min_step_length_for_next_surface;
540+
// s5.max_count = config.max_step_counts_for_next_surface;
527541

528542
DETRAY_DEBUG_HOST("PROPAGATING... ");
529543
// Propagate to the next surface
530544
propagator.propagate(propagation,
531545
detray::tie(s0, s1, s2, s3, s4, s5));
532546

533547
DETRAY_DEBUG_HOST(
534-
"FINISHED PROPAGATING. PATH: " << s5.path_from_surface);
548+
"FINISHED PROPAGATING. SF: " << s5.surface_index);
535549

536550
// If a surface found, add the parameter for the next
537551
// step
@@ -540,7 +554,8 @@ 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
}
@@ -563,9 +578,9 @@ combinatorial_kalman_filter(
563578
}
564579

565580
in_params = std::move(out_params);
566-
in_is_edge = std::move(out_is_edge);
581+
in_prop_data = std::move(out_prop_data);
567582
out_params.clear();
568-
out_is_edge.clear();
583+
out_prop_data.clear();
569584
}
570585

571586
/**********************

core/include/traccc/finding/finding_config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct finding_config {
2727

2828
/// Min/Max number of track candidates per track
2929
unsigned int min_track_candidates_per_track = 3;
30-
unsigned int max_track_candidates_per_track = 100;
30+
unsigned int max_track_candidates_per_track = 200;
3131

3232
/// Maximum allowed number of skipped steps per candidate
3333
unsigned int max_num_skipping_per_cand = 3;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Detray include(s).
11+
#include <detray/definitions/indexing.hpp>
12+
13+
namespace traccc {
14+
15+
/// Data from the propagation loop that has to be kept between CKF steps
16+
struct propagation_data {
17+
/// The surface that was visited before the current one (overlaps resolution)
18+
detray::dindex prev_surface{detray::dindex_invalid};
19+
20+
/// Is the current surface hit in the extended tolerance band?
21+
bool is_edge{false};
22+
};
23+
24+
} // namespace traccc

core/include/traccc/fitting/kalman_filter/gain_matrix_updater.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#pragma once
99

1010
// Project include(s).
11+
#include <detray/utils/log.hpp>
12+
1113
#include "traccc/definitions/qualifiers.hpp"
1214
#include "traccc/definitions/track_parametrization.hpp"
1315
#include "traccc/edm/measurement.hpp"
@@ -161,6 +163,11 @@ struct gain_matrix_updater {
161163
trk_state.filtered_params().set_covariance(filtered_cov);
162164
trk_state.filtered_chi2() = getter::element(chi2, 0, 0);
163165

166+
DETRAY_DEBUG_HOST("MEASUREMENT POS: " << meas_local);
167+
DETRAY_DEBUG_HOST("MEASUREMENT VARIANCE: " << V);
168+
DETRAY_DEBUG_HOST("FILTERED PARAM: " << trk_state.filtered_params());
169+
DETRAY_DEBUG_HOST("CHI2: " << trk_state.filtered_chi2());
170+
164171
// Wrap the phi in the range of [-pi, pi]
165172
wrap_phi(trk_state.filtered_params());
166173

device/common/include/traccc/finding/device/impl/find_tracks.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,9 @@ TRACCC_HOST_DEVICE inline void find_tracks(
593593
.previous_candidate_idx = prev_link_idx,
594594
.meas_idx = std::numeric_limits<unsigned int>::max(),
595595
.seed_idx = seed_idx,
596+
.n_cand = n_cand,
596597
.n_skipped = is_edge ? n_skipped : n_skipped + 1,
597598
.n_consecutive_skipped = n_consecutive_skipped + 1,
598-
.n_cand = n_cand,
599599
.chi2 = std::numeric_limits<traccc::scalar>::max(),
600600
.chi2_sum = prev_chi2_sum,
601601
.ndf_sum = prev_ndf_sum};

device/common/include/traccc/finding/device/impl/propagate_to_next_surface.ipp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
6565
const bound_track_parameters<> in_par = params.at(param_id);
6666

6767
// Create propagator
68-
auto alt_prop_cfg{cfg.propagation};
69-
alt_prop_cfg.navigation.estimate_scattering_noise = false;
70-
propagator_t propagator(alt_prop_cfg);
68+
propagator_t propagator(cfg.propagation);
7169

7270
// Create propagator state
7371
typename propagator_t::state propagation(in_par, payload.field_data, det);
@@ -93,15 +91,18 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
9391
s3};
9492
// Parameter resetter
9593
typename detray::detail::tuple_element<4, actor_tuple_type>::type::state s4{
96-
alt_prop_cfg};
94+
cfg.propagation};
9795
// Momentum aborter
9896
typename detray::detail::tuple_element<5, actor_tuple_type>::type::state s5;
9997
// CKF aborter
100-
typename detray::detail::tuple_element<6, actor_tuple_type>::type::state s6;
101-
s6.min_step_length = cfg.min_step_length_for_next_surface;
102-
s6.max_count = cfg.max_step_counts_for_next_surface;
98+
typename detray::detail::tuple_element<6, actor_tuple_type>::type::state s6{
99+
payload.measurement_ranges_view};
100+
103101
s5.min_pT(static_cast<scalar_t>(cfg.min_pT));
104102
s5.min_p(static_cast<scalar_t>(cfg.min_p));
103+
s6.surface_index = in_par.surface_link().index();
104+
// s6.min_step_length = cfg.min_step_length_for_next_surface;
105+
// s6.max_count = cfg.max_step_counts_for_next_surface;
105106

106107
// Propagate to the next surface
107108
propagator.propagate(propagation, detray::tie(s0, s2, s3, s4, s5, s6));

device/common/include/traccc/finding/device/propagate_to_next_surface.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// Project include(s).
1414
#include "traccc/definitions/qualifiers.hpp"
15+
#include "traccc/edm/measurement.hpp"
1516
#include "traccc/edm/track_parameters.hpp"
1617
#include "traccc/finding/candidate_link.hpp"
1718
#include "traccc/finding/finding_config.hpp"
@@ -76,6 +77,11 @@ struct propagate_to_next_surface_payload {
7677
*/
7778
unsigned int n_in_params;
7879

80+
/**
81+
* @brief View object to the vector of measurement index ranges per surface
82+
*/
83+
vecmem::data::vector_view<const unsigned int> measurement_ranges_view;
84+
7985
/**
8086
* @brief View object to the vector of tips
8187
*/

device/cuda/src/finding/combinatorial_kalman_filter.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ combinatorial_kalman_filter(
420420
.prev_links_idx = step_to_link_idx_map[step],
421421
.step = step,
422422
.n_in_params = n_candidates,
423+
.measurement_ranges_view = meas_ranges_buffer,
423424
.tips_view = tips_buffer,
424425
.tip_lengths_view = tip_length_buffer};
425426

0 commit comments

Comments
 (0)