Skip to content

Commit 0b210f4

Browse files
committed
update to detray v0.104.1
1 parent 7a19579 commit 0b210f4

File tree

23 files changed

+223
-71
lines changed

23 files changed

+223
-71
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct ckf_aborter : detray::actor {
4747
if (navigation.is_on_sensitive() &&
4848
abrt_state.path_from_surface > abrt_state.min_step_length) {
4949
prop_state._heartbeat &= navigation.pause();
50-
abrt_state.success = true;
50+
abrt_state.success = navigation.is_alive();
5151
}
5252

5353
// Reset path from surface
@@ -59,6 +59,7 @@ struct ckf_aborter : detray::actor {
5959
prop_state._heartbeat &= navigation.abort(
6060
"CKF: Maximum number of steps to reach next sensitive surface "
6161
"exceeded");
62+
abrt_state.success = false;
6263
}
6364
}
6465
};

core/include/traccc/finding/candidate_link.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ struct candidate_link {
2828
// Index to the initial seed
2929
unsigned int seed_idx;
3030

31+
// How many candidates were added to the track
32+
unsigned int n_cand;
33+
3134
// How many times it skipped a surface
3235
unsigned int n_skipped;
3336

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

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
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_candidate_collection.hpp"
1214
#include "traccc/edm/track_state_helpers.hpp"
@@ -139,15 +141,20 @@ combinatorial_kalman_filter(
139141

140142
std::vector<bound_track_parameters<algebra_type>> out_params;
141143

144+
std::vector<std::uint8_t> in_is_edge(seeds.size(), false);
145+
std::vector<std::uint8_t> out_is_edge;
146+
142147
for (unsigned int step = 0u; step < config.max_track_candidates_per_track;
143148
step++) {
144149

150+
DETRAY_DEBUG_HOST("PRPGAGATION STEP: " << step);
145151
TRACCC_VERBOSE("Starting step "
146152
<< step + 1 << " / "
147153
<< config.max_track_candidates_per_track);
148154

149155
// Iterate over input parameters
150156
const std::size_t n_in_params = in_params.size();
157+
DETRAY_DEBUG_HOST("# PARAMS: " << n_in_params);
151158

152159
// Terminate if there is no parameter to proceed
153160
if (n_in_params == 0) {
@@ -156,6 +163,7 @@ combinatorial_kalman_filter(
156163

157164
// Rough estimation on out parameters size
158165
out_params.reserve(n_in_params);
166+
out_is_edge.reserve(n_in_params);
159167

160168
// Previous step ID
161169
std::fill(n_trks_per_seed.begin(), n_trks_per_seed.end(), 0u);
@@ -169,13 +177,22 @@ combinatorial_kalman_filter(
169177
bound_track_parameters<algebra_type>& in_param =
170178
in_params[in_param_id];
171179

180+
DETRAY_DEBUG_HOST("PARAMS: " << in_param);
181+
182+
const bool is_edge{in_is_edge[in_param_id] > 0u};
183+
172184
assert(!in_param.is_invalid());
173185

174186
const unsigned int orig_param_id =
175187
(step == 0
176188
? in_param_id
177189
: links[step - 1][param_to_link[step - 1][in_param_id]]
178190
.seed_idx);
191+
const unsigned int n_cand =
192+
(step == 0
193+
? 0
194+
: links[step - 1][param_to_link[step - 1][in_param_id]]
195+
.n_cand);
179196
const unsigned int skip_counter =
180197
(step == 0
181198
? 0
@@ -234,7 +251,9 @@ combinatorial_kalman_filter(
234251
best_links;
235252

236253
// Iterate over the measurements
254+
DETRAY_DEBUG_HOST("# MEAS: " << (up - lo));
237255
for (unsigned int meas_id = lo; meas_id < up; meas_id++) {
256+
DETRAY_DEBUG_HOST("TESTING MEAS: " << meas_id);
238257

239258
// The measurement on surface to handle.
240259
const measurement& meas = measurements.at(meas_id);
@@ -243,7 +262,7 @@ combinatorial_kalman_filter(
243262
auto trk_state =
244263
edm::make_track_state<algebra_type>(measurements, meas_id);
245264

246-
const bool is_line = sf.template visit_mask<is_line_visitor>();
265+
const bool is_line = detail::is_line(sf);
247266

248267
// Run the Kalman update on a copy of the track parameters
249268
const kalman_fitter_status res =
@@ -252,15 +271,20 @@ combinatorial_kalman_filter(
252271

253272
const traccc::scalar chi2 = trk_state.filtered_chi2();
254273

274+
DETRAY_DEBUG_HOST("KF STATUS: " << fitter_debug_msg{res}());
275+
255276
// The chi2 from Kalman update should be less than chi2_max
256277
if (res == kalman_fitter_status::SUCCESS &&
257278
chi2 < config.chi2_max) {
258279

280+
DETRAY_DEBUG_HOST("FOUND MEAS: " << meas_id);
281+
259282
best_links.push_back(
260283
{{.step = step,
261284
.previous_candidate_idx = in_param_id,
262285
.meas_idx = meas_id,
263286
.seed_idx = orig_param_id,
287+
.n_cand = n_cand + 1,
264288
.n_skipped = skip_counter,
265289
.chi2 = chi2,
266290
.chi2_sum = prev_chi2_sum + chi2,
@@ -306,11 +330,14 @@ combinatorial_kalman_filter(
306330
.previous_candidate_idx = in_param_id,
307331
.meas_idx = std::numeric_limits<unsigned int>::max(),
308332
.seed_idx = orig_param_id,
309-
.n_skipped = skip_counter + 1,
333+
.n_cand = n_cand,
334+
.n_skipped = is_edge ? skip_counter : skip_counter + 1,
310335
.chi2 = std::numeric_limits<traccc::scalar>::max(),
311336
.chi2_sum = prev_chi2_sum,
312337
.ndf_sum = prev_ndf_sum});
313338

339+
DETRAY_DEBUG_HOST("HOLE: " << std::boolalpha << !is_edge);
340+
314341
updated_params.push_back(in_param);
315342
TRACCC_VERBOSE("updated_params["
316343
<< updated_params.size() - 1
@@ -356,7 +383,7 @@ combinatorial_kalman_filter(
356383
prob(Lthisbase.chi2_sum,
357384
static_cast<scalar>(Lthisbase.ndf_sum - 5));
358385

359-
if (step + 1 - Lthisbase.n_skipped <=
386+
if (Lthisbase.n_cand <=
360387
config.duplicate_removal_minimum_length ||
361388
Lthisbase.ndf_sum <= 5) {
362389
continue;
@@ -370,7 +397,7 @@ combinatorial_kalman_filter(
370397
auto Lthis = Lthisbase;
371398
auto Lthat = links.at(step).at(tracks.at(j));
372399

373-
if (step + 1 - Lthat.n_skipped <=
400+
if (Lthat.n_cand <=
374401
config.duplicate_removal_minimum_length ||
375402
Lthisbase.ndf_sum <= 5) {
376403
continue;
@@ -431,6 +458,7 @@ combinatorial_kalman_filter(
431458
}
432459

433460
if (this_is_dominated) {
461+
DETRAY_DEBUG_HOST("Track is DEAD!");
434462
param_liveness.at(tracks.at(i)) = 0u;
435463
break;
436464
}
@@ -458,6 +486,8 @@ combinatorial_kalman_filter(
458486
// link to be a tip
459487
if (links.at(step).at(link_id).n_skipped >
460488
config.max_num_skipping_per_cand) {
489+
490+
DETRAY_DEBUG_HOST("MAKE TIP: MAX NO. HOLES");
461491
tips.push_back({step, link_id});
462492
continue;
463493
}
@@ -477,8 +507,9 @@ combinatorial_kalman_filter(
477507
traccc::details::ckf_interactor_t::state s2;
478508
typename interaction_register<
479509
traccc::details::ckf_interactor_t>::state s1{s2};
480-
// typename detray::parameter_resetter<
481-
// typename detector_t::algebra_type>::state s3{};
510+
typename detray::parameter_resetter<
511+
typename detector_t::algebra_type>::state s3{
512+
config.propagation};
482513
typename detray::momentum_aborter<scalar_type>::state s4{};
483514
typename ckf_aborter::state s5;
484515
// Update the actor config
@@ -487,8 +518,13 @@ combinatorial_kalman_filter(
487518
s5.min_step_length = config.min_step_length_for_next_surface;
488519
s5.max_count = config.max_step_counts_for_next_surface;
489520

521+
DETRAY_DEBUG_HOST("PROPAGATING... ");
490522
// Propagate to the next surface
491-
propagator.propagate(propagation, detray::tie(s0, s1, s2, s4, s5));
523+
propagator.propagate(propagation,
524+
detray::tie(s0, s1, s2, s3, s4, s5));
525+
526+
DETRAY_DEBUG_HOST(
527+
"FINISHED PROPAGATING. PATH: " << s5.path_from_surface);
492528

493529
// If a surface found, add the parameter for the next
494530
// step
@@ -497,25 +533,32 @@ combinatorial_kalman_filter(
497533
assert(!propagation._stepping.bound_params().is_invalid());
498534

499535
out_params.push_back(propagation._stepping.bound_params());
536+
out_is_edge.push_back(
537+
propagation._navigation.is_edge_candidate());
500538
param_to_link[step].push_back(link_id);
501539
}
502540
// Unless the track found a surface, it is considered a
503541
// tip
504542
else if (!s5.success &&
505543
(step >= (config.min_track_candidates_per_track - 1u))) {
544+
545+
DETRAY_DEBUG_HOST("MAKE TIP: NO SENSITIVE");
506546
tips.push_back({step, link_id});
507547
}
508548

509549
// If no more CKF step is expected, current candidate is
510550
// kept as a tip
511551
if (s5.success &&
512552
(step == (config.max_track_candidates_per_track - 1u))) {
553+
DETRAY_DEBUG_HOST("MAKE TIP: MAX CANDIDATES");
513554
tips.push_back({step, link_id});
514555
}
515556
}
516557

517558
in_params = std::move(out_params);
559+
in_is_edge = std::move(out_is_edge);
518560
out_params.clear();
561+
out_is_edge.clear();
519562
}
520563

521564
/**********************
@@ -531,7 +574,7 @@ combinatorial_kalman_filter(
531574
// Get the link corresponding to tip
532575
auto L = links.at(tip.first).at(tip.second);
533576

534-
const unsigned int n_cands = tip.first + 1 - L.n_skipped;
577+
const unsigned int n_cands = L.n_cand;
535578

536579
// Skip if the number of tracks candidates is too small
537580
if (n_cands < config.min_track_candidates_per_track ||

core/include/traccc/fitting/details/kalman_fitting.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ typename edm::track_fit_container<algebra_t>::host kalman_fitting(
9191
result_tracks_device.at(result_tracks_device.size() - 1),
9292
typename edm::track_state_collection<algebra_t>::device{
9393
vecmem::get_data(result.states)},
94-
measurements, seqs_buffer);
94+
measurements, seqs_buffer, fitter.config().propagation);
9595

9696
// Run the fitter. The status that it returns is not used here. The main
9797
// failure modes are saved onto the fitted track itself. Not sure what

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,31 @@
77

88
#pragma once
99

10+
#include <detray/geometry/mask.hpp>
1011
#include <detray/geometry/shapes/line.hpp>
12+
#include <detray/geometry/surface.hpp>
1113

1214
#include "traccc/definitions/qualifiers.hpp"
1315

14-
namespace traccc {
16+
namespace traccc::detail {
1517

16-
struct is_line_visitor {
17-
template <typename mask_group_t, typename index_t>
18-
[[nodiscard]] TRACCC_HOST_DEVICE inline bool operator()(
19-
const mask_group_t& /*mask_group*/, const index_t& /*index*/) const {
20-
using shape_type = typename mask_group_t::value_type::shape;
21-
return std::is_same_v<shape_type, detray::line<true>> ||
22-
std::is_same_v<shape_type, detray::line<false>>;
18+
/// @returns true if the surface has "line" shape
19+
template <typename detector_t>
20+
[[nodiscard]] TRACCC_HOST_DEVICE bool constexpr is_line(
21+
const detray::geometry::surface<detector_t> sf) {
22+
using algebra_t = typename detector_t::algebra_type;
23+
using straw_tube = detray::mask<detray::line<false>, algebra_t>;
24+
using wire_cell = detray::mask<detray::line<true>, algebra_t>;
25+
26+
if constexpr (detector_t::masks::template is_defined<straw_tube>() ||
27+
detector_t::masks::template is_defined<wire_cell>()) {
28+
return (sf.shape_id() ==
29+
detector_t::masks::template get_id<straw_tube>()) ||
30+
(sf.shape_id() ==
31+
detector_t::masks::template get_id<wire_cell>());
32+
} else {
33+
return false;
2334
}
2435
};
2536

26-
} // namespace traccc
37+
} // namespace traccc::detail

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct kalman_actor : detray::actor {
161161
// Run Kalman Gain Updater
162162
const auto sf = navigation.get_surface();
163163

164-
const bool is_line = sf.template visit_mask<is_line_visitor>();
164+
const bool is_line = detail::is_line(sf);
165165

166166
kalman_fitter_status res = kalman_fitter_status::SUCCESS;
167167

@@ -212,7 +212,9 @@ struct kalman_actor : detray::actor {
212212
actor_state.next();
213213

214214
// Flag renavigation of the current candidate
215-
navigation.set_high_trust();
215+
if (math::fabs(navigation()) > 1.f * unit<float>::um) {
216+
navigation.set_high_trust();
217+
}
216218
}
217219
}
218220
};

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,31 @@ class kalman_fitter {
110110
track_states,
111111
const measurement_collection_types::const_device& measurements,
112112
vecmem::data::vector_view<detray::geometry::barcode>
113-
sequence_buffer)
113+
sequence_buffer,
114+
const detray::propagation::config& prop_cfg)
114115
: m_fit_actor_state{track, track_states, measurements},
115116
m_sequencer_state(
116117
vecmem::device_vector<detray::geometry::barcode>(
117118
sequence_buffer)),
119+
m_parameter_resetter{prop_cfg},
118120
m_fit_res{track},
119121
m_sequence_buffer(sequence_buffer) {}
120122

121123
/// @return the actor chain state
122124
TRACCC_HOST_DEVICE
123125
typename forward_actor_chain_type::state_ref_tuple operator()() {
124126
return detray::tie(m_aborter_state, m_interactor_state,
125-
m_fit_actor_state, m_sequencer_state,
126-
m_step_aborter_state);
127+
m_fit_actor_state, m_parameter_resetter,
128+
m_sequencer_state, m_step_aborter_state);
127129
}
128130

129131
/// @return the actor chain state
130132
TRACCC_HOST_DEVICE
131133
typename backward_actor_chain_type::state_ref_tuple
132134
backward_actor_state() {
133135
return detray::tie(m_aborter_state, m_fit_actor_state,
134-
m_interactor_state, m_step_aborter_state);
136+
m_interactor_state, m_parameter_resetter,
137+
m_step_aborter_state);
135138
}
136139

137140
/// Individual actor states
@@ -140,6 +143,7 @@ class kalman_fitter {
140143
typename forward_fit_actor::state m_fit_actor_state;
141144
typename barcode_sequencer::state m_sequencer_state;
142145
kalman_step_aborter::state m_step_aborter_state{};
146+
typename resetter::state m_parameter_resetter{};
143147

144148
/// Fitting result per track
145149
typename edm::track_fit_collection<algebra_type>::device::proxy_type

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ struct two_filters_smoother {
185185

186186
// Calculate backward chi2
187187
const matrix_type<D, D> R = (I_m - H * K) * V;
188-
// assert(matrix::determinant(R) != 0.f);
188+
assert(matrix::determinant(R) != 0.f);
189189
assert(std::isfinite(matrix::determinant(R)));
190190
const matrix_type<1, 1> chi2 =
191191
algebra::matrix::transposed_product<true, false>(

0 commit comments

Comments
 (0)