Skip to content

Commit 41b5dd9

Browse files
authored
update to detray v0.104.1 (#1166)
In the new detray version, the mask tolerances are scaled according to the positional and directional covariances found on the previous surfaces (scaled with the distance to the next surface, but not transported with a full Jacobian). This will allow to open (and close) the surface finding tolerances dynamically, according to how well known the track model is. Since this can lead to including more surfaces in the CKF on which ultimately no fitting measurement could be found (and hence would lead to the loss of the track due to an increased hole count), the navigator now knows if a surface was only included due to an "edge hit" in the tolerance band. In this case, no hole is flagged and the track can be kept alive. Any data like this, which needs to be retained after the propagation is halted, has been added to the new propagation_data struct that is passed between the different kernels. The last and second last sensitive visited is added to the CKF-aborter, so that no propagation loops on now overlapping surfaces occur. Edit: The mask tolerance scaling is turned off for the CKF but enabled for the KF (by the defaults in the propagation config).
1 parent 2908c3d commit 41b5dd9

File tree

14 files changed

+94
-34
lines changed

14 files changed

+94
-34
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ combinatorial_kalman_filter(
126126
std::vector<std::pair<unsigned int, unsigned int>> tips;
127127

128128
// Create propagator
129+
auto prop_cfg{config.propagation};
130+
prop_cfg.navigation.estimate_scattering_noise = false;
129131
traccc::details::ckf_propagator_t<detector_t, bfield_t> propagator(
130-
config.propagation);
132+
prop_cfg);
131133

132134
// Create the input seeds container.
133135
bound_track_parameters_collection_types::const_device seeds{seeds_view};
@@ -248,7 +250,7 @@ combinatorial_kalman_filter(
248250
auto trk_state =
249251
edm::make_track_state<algebra_type>(measurements, meas_id);
250252

251-
const bool is_line = sf.template visit_mask<is_line_visitor>();
253+
const bool is_line = detail::is_line(sf);
252254

253255
// Run the Kalman update on a copy of the track parameters
254256
const kalman_fitter_status res =
@@ -484,8 +486,8 @@ combinatorial_kalman_filter(
484486
traccc::details::ckf_interactor_t::state s2;
485487
typename interaction_register<
486488
traccc::details::ckf_interactor_t>::state s1{s2};
487-
// typename detray::parameter_resetter<
488-
// typename detector_t::algebra_type>::state s3{};
489+
typename detray::parameter_resetter<
490+
typename detector_t::algebra_type>::state s3{prop_cfg};
489491
typename detray::momentum_aborter<scalar_type>::state s4{};
490492
typename ckf_aborter::state s5;
491493
// Update the actor config
@@ -495,7 +497,8 @@ combinatorial_kalman_filter(
495497
s5.max_count = config.max_step_counts_for_next_surface;
496498

497499
// Propagate to the next surface
498-
propagator.propagate(propagation, detray::tie(s0, s1, s2, s4, s5));
500+
propagator.propagate(propagation,
501+
detray::tie(s0, s1, s2, s3, s4, s5));
499502

500503
// If a surface found, add the parameter for the next
501504
// step

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

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

9393
// Run the fitter. The status that it returns is not used here. The main
9494
// 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
@@ -164,7 +164,7 @@ struct kalman_actor : detray::actor {
164164
// Run Kalman Gain Updater
165165
const auto sf = navigation.get_surface();
166166

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

169169
kalman_fitter_status res = kalman_fitter_status::SUCCESS;
170170

@@ -215,7 +215,9 @@ struct kalman_actor : detray::actor {
215215
actor_state.next();
216216

217217
// Flag renavigation of the current candidate
218-
navigation.set_high_trust();
218+
if (math::fabs(navigation()) > 1.f * unit<float>::um) {
219+
navigation.set_high_trust();
220+
}
219221
}
220222
}
221223
};

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_collection<algebra_type>::device::proxy_type

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ TRACCC_HOST_DEVICE inline void find_tracks(
209209

210210
const detray::tracking_surface sf{det, in_par.surface_link()};
211211

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

214214
// Run the Kalman update
215215
const kalman_fitter_status res =

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
6262
const bound_track_parameters<> in_par = params.at(param_id);
6363

6464
// Create propagator
65-
propagator_t propagator(cfg.propagation);
65+
auto prop_cfg{cfg.propagation};
66+
prop_cfg.navigation.estimate_scattering_noise = false;
67+
propagator_t propagator(prop_cfg);
6668

6769
// Create propagator state
6870
typename propagator_t::state propagation(in_par, payload.field_data, det);
@@ -87,9 +89,8 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
8789
typename detray::detail::tuple_element<2, actor_tuple_type>::type::state s2{
8890
s3};
8991
// Parameter resetter
90-
// typename detray::detail::tuple_element<4, actor_tuple_type>::type::state
91-
// s4{
92-
// cfg.propagation};
92+
typename detray::detail::tuple_element<4, actor_tuple_type>::type::state s4{
93+
prop_cfg};
9394
// Momentum aborter
9495
typename detray::detail::tuple_element<5, actor_tuple_type>::type::state s5;
9596
// CKF aborter
@@ -101,7 +102,7 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
101102
s5.min_p(static_cast<scalar_t>(cfg.min_p));
102103

103104
// Propagate to the next surface
104-
propagator.propagate(propagation, detray::tie(s0, s2, s3, s5, s6));
105+
propagator.propagate(propagation, detray::tie(s0, s2, s3, s4, s5, s6));
105106

106107
// If a surface found, add the parameter for the next step
107108
if (s6.success) {

device/common/include/traccc/fitting/device/fit_backward.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ TRACCC_HOST_DEVICE inline void fit_backward(
3939
if (param_liveness.at(param_id) > 0u) {
4040
typename fitter_t::state fitter_state(
4141
track, tracks.states, tracks.measurements,
42-
*(payload.barcodes_view.ptr() + param_id));
42+
*(payload.barcodes_view.ptr() + param_id),
43+
fitter.config().propagation);
4344

4445
kalman_fitter_status fit_status = fitter.smooth(fitter_state);
4546

device/common/include/traccc/fitting/device/fit_forward.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ TRACCC_HOST_DEVICE inline void fit_forward(
4242

4343
typename fitter_t::state fitter_state(
4444
track, tracks.states, tracks.measurements,
45-
*(payload.barcodes_view.ptr() + param_id));
45+
*(payload.barcodes_view.ptr() + param_id), fitter.config().propagation);
4646

4747
kalman_fitter_status fit_status = fitter.filter(params, fitter_state);
4848

examples/options/src/track_propagation.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ track_propagation::track_propagation()
5252
"search-window",
5353
po::value(&m_search_window)->default_value(m_search_window),
5454
"Size of the grid surface search window");
55+
m_desc.add_options()(
56+
"mask-tolerance-scaling",
57+
po::value(&(m_config.navigation.mask_tolerance_scalor))
58+
->default_value(m_config.navigation.mask_tolerance_scalor),
59+
"Scale factor between min. and max. mask tolerance with surface "
60+
"distance");
61+
62+
m_desc.add_options()(
63+
"accumulated-noise-factor",
64+
po::value(&(m_config.navigation.accumulated_error))
65+
->default_value(m_config.navigation.accumulated_error),
66+
"Scale factor on the total track path length to model accumualted "
67+
"noise [%]");
68+
69+
m_desc.add_options()(
70+
"scattering-stddevs",
71+
po::value(&(m_config.navigation.n_scattering_stddev))
72+
->default_value(m_config.navigation.n_scattering_stddev),
73+
"Number of angle standard deviations to use for the noise modelling");
5574
m_desc.add_options()("rk-tolerance-mm",
5675
po::value(&(m_config.stepping.rk_error_tol))
5776
->default_value(m_config.stepping.rk_error_tol /
@@ -101,6 +120,7 @@ void track_propagation::read(const po::variables_map &) {
101120
m_config.navigation.min_mask_tolerance *= traccc::unit<float>::mm;
102121
m_config.navigation.max_mask_tolerance *= traccc::unit<float>::mm;
103122
m_config.navigation.search_window = m_search_window;
123+
m_config.navigation.accumulated_error /= 100.f;
104124

105125
m_config.stepping.min_stepsize *= traccc::unit<float>::mm;
106126
m_config.stepping.path_limit *= traccc::unit<float>::m;
@@ -125,7 +145,7 @@ std::unique_ptr<configuration_printable> track_propagation::as_printable()
125145
traccc::unit<float>::mm) +
126146
" mm"));
127147
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
128-
"Mask tolerance scalar",
148+
"Mask tolerance scaling",
129149
std::to_string(m_config.navigation.mask_tolerance_scalor)));
130150
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
131151
"Path tolerance", std::to_string(m_config.navigation.path_tolerance /
@@ -140,6 +160,12 @@ std::unique_ptr<configuration_printable> track_propagation::as_printable()
140160
"Search window",
141161
std::to_string(m_config.navigation.search_window[0]) + " x " +
142162
std::to_string(m_config.navigation.search_window[1])));
163+
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
164+
"Scale factor for accumulated noise",
165+
std::to_string(m_config.navigation.accumulated_error * 100.f) + " %"));
166+
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
167+
"# scattering stddevs to assume",
168+
std::to_string(m_config.navigation.n_scattering_stddev)));
143169

144170
auto cat_tsp = std::make_unique<configuration_category>("Transport");
145171

0 commit comments

Comments
 (0)