Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ combinatorial_kalman_filter(
std::vector<std::pair<unsigned int, unsigned int>> tips;

// Create propagator
auto prop_cfg{config.propagation};
prop_cfg.navigation.estimate_scattering_noise = false;
traccc::details::ckf_propagator_t<detector_t, bfield_t> propagator(
config.propagation);
prop_cfg);

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

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

// Run the Kalman update on a copy of the track parameters
const kalman_fitter_status res =
Expand Down Expand Up @@ -484,8 +486,8 @@ combinatorial_kalman_filter(
traccc::details::ckf_interactor_t::state s2;
typename interaction_register<
traccc::details::ckf_interactor_t>::state s1{s2};
// typename detray::parameter_resetter<
// typename detector_t::algebra_type>::state s3{};
typename detray::parameter_resetter<
typename detector_t::algebra_type>::state s3{prop_cfg};
typename detray::momentum_aborter<scalar_type>::state s4{};
typename ckf_aborter::state s5;
// Update the actor config
Expand All @@ -495,7 +497,8 @@ combinatorial_kalman_filter(
s5.max_count = config.max_step_counts_for_next_surface;

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

// If a surface found, add the parameter for the next
// step
Expand Down
2 changes: 1 addition & 1 deletion core/include/traccc/fitting/details/kalman_fitting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ typename edm::track_container<algebra_t>::host kalman_fitting(
result_tracks_device.at(result_tracks_device.size() - 1),
typename edm::track_state_collection<algebra_t>::device{
vecmem::get_data(result.states)},
measurements, seqs_buffer);
measurements, seqs_buffer, fitter.config().propagation);

// Run the fitter. The status that it returns is not used here. The main
// failure modes are saved onto the fitted track itself. Not sure what
Expand Down
29 changes: 20 additions & 9 deletions core/include/traccc/fitting/kalman_filter/is_line_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@

#pragma once

#include <detray/geometry/mask.hpp>
#include <detray/geometry/shapes/line.hpp>
#include <detray/geometry/surface.hpp>

#include "traccc/definitions/qualifiers.hpp"

namespace traccc {
namespace traccc::detail {

struct is_line_visitor {
template <typename mask_group_t, typename index_t>
[[nodiscard]] TRACCC_HOST_DEVICE inline bool operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/) const {
using shape_type = typename mask_group_t::value_type::shape;
return std::is_same_v<shape_type, detray::line<true>> ||
std::is_same_v<shape_type, detray::line<false>>;
/// @returns true if the surface has "line" shape
template <typename detector_t>
[[nodiscard]] TRACCC_HOST_DEVICE bool constexpr is_line(
const detray::geometry::surface<detector_t> sf) {
using algebra_t = typename detector_t::algebra_type;
using straw_tube = detray::mask<detray::line<false>, algebra_t>;
using wire_cell = detray::mask<detray::line<true>, algebra_t>;

if constexpr (detector_t::masks::template is_defined<straw_tube>() ||
detector_t::masks::template is_defined<wire_cell>()) {
return (sf.shape_id() ==
detector_t::masks::template get_id<straw_tube>()) ||
(sf.shape_id() ==
detector_t::masks::template get_id<wire_cell>());
} else {
return false;
}
};

} // namespace traccc
} // namespace traccc::detail
6 changes: 4 additions & 2 deletions core/include/traccc/fitting/kalman_filter/kalman_actor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct kalman_actor : detray::actor {
// Run Kalman Gain Updater
const auto sf = navigation.get_surface();

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

kalman_fitter_status res = kalman_fitter_status::SUCCESS;

Expand Down Expand Up @@ -215,7 +215,9 @@ struct kalman_actor : detray::actor {
actor_state.next();

// Flag renavigation of the current candidate
navigation.set_high_trust();
if (math::fabs(navigation()) > 1.f * unit<float>::um) {
navigation.set_high_trust();
}
}
}
};
Expand Down
12 changes: 8 additions & 4 deletions core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,31 @@ class kalman_fitter {
track_states,
const measurement_collection_types::const_device& measurements,
vecmem::data::vector_view<detray::geometry::barcode>
sequence_buffer)
sequence_buffer,
const detray::propagation::config& prop_cfg)
: m_fit_actor_state{track, track_states, measurements},
m_sequencer_state(
vecmem::device_vector<detray::geometry::barcode>(
sequence_buffer)),
m_parameter_resetter{prop_cfg},
m_fit_res{track},
m_sequence_buffer(sequence_buffer) {}

/// @return the actor chain state
TRACCC_HOST_DEVICE
typename forward_actor_chain_type::state_ref_tuple operator()() {
return detray::tie(m_aborter_state, m_interactor_state,
m_fit_actor_state, m_sequencer_state,
m_step_aborter_state);
m_fit_actor_state, m_parameter_resetter,
m_sequencer_state, m_step_aborter_state);
}

/// @return the actor chain state
TRACCC_HOST_DEVICE
typename backward_actor_chain_type::state_ref_tuple
backward_actor_state() {
return detray::tie(m_aborter_state, m_fit_actor_state,
m_interactor_state, m_step_aborter_state);
m_interactor_state, m_parameter_resetter,
m_step_aborter_state);
}

/// Individual actor states
Expand All @@ -140,6 +143,7 @@ class kalman_fitter {
typename forward_fit_actor::state m_fit_actor_state;
typename barcode_sequencer::state m_sequencer_state;
kalman_step_aborter::state m_step_aborter_state{};
typename resetter::state m_parameter_resetter{};

/// Fitting result per track
typename edm::track_collection<algebra_type>::device::proxy_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ TRACCC_HOST_DEVICE inline void find_tracks(

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

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

// Run the Kalman update
const kalman_fitter_status res =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
const bound_track_parameters<> in_par = params.at(param_id);

// Create propagator
propagator_t propagator(cfg.propagation);
auto prop_cfg{cfg.propagation};
prop_cfg.navigation.estimate_scattering_noise = false;
propagator_t propagator(prop_cfg);

// Create propagator state
typename propagator_t::state propagation(in_par, payload.field_data, det);
Expand All @@ -87,9 +89,8 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
typename detray::detail::tuple_element<2, actor_tuple_type>::type::state s2{
s3};
// Parameter resetter
// typename detray::detail::tuple_element<4, actor_tuple_type>::type::state
// s4{
// cfg.propagation};
typename detray::detail::tuple_element<4, actor_tuple_type>::type::state s4{
prop_cfg};
// Momentum aborter
typename detray::detail::tuple_element<5, actor_tuple_type>::type::state s5;
// CKF aborter
Expand All @@ -101,7 +102,7 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
s5.min_p(static_cast<scalar_t>(cfg.min_p));

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

// If a surface found, add the parameter for the next step
if (s6.success) {
Expand Down
3 changes: 2 additions & 1 deletion device/common/include/traccc/fitting/device/fit_backward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ TRACCC_HOST_DEVICE inline void fit_backward(
if (param_liveness.at(param_id) > 0u) {
typename fitter_t::state fitter_state(
track, tracks.states, tracks.measurements,
*(payload.barcodes_view.ptr() + param_id));
*(payload.barcodes_view.ptr() + param_id),
fitter.config().propagation);

kalman_fitter_status fit_status = fitter.smooth(fitter_state);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TRACCC_HOST_DEVICE inline void fit_forward(

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

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

Expand Down
28 changes: 27 additions & 1 deletion examples/options/src/track_propagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ track_propagation::track_propagation()
"search-window",
po::value(&m_search_window)->default_value(m_search_window),
"Size of the grid surface search window");
m_desc.add_options()(
"mask-tolerance-scaling",
po::value(&(m_config.navigation.mask_tolerance_scalor))
->default_value(m_config.navigation.mask_tolerance_scalor),
"Scale factor between min. and max. mask tolerance with surface "
"distance");

m_desc.add_options()(
"accumulated-noise-factor",
po::value(&(m_config.navigation.accumulated_error))
->default_value(m_config.navigation.accumulated_error),
"Scale factor on the total track path length to model accumualted "
"noise [%]");

m_desc.add_options()(
"scattering-stddevs",
po::value(&(m_config.navigation.n_scattering_stddev))
->default_value(m_config.navigation.n_scattering_stddev),
"Number of angle standard deviations to use for the noise modelling");
m_desc.add_options()("rk-tolerance-mm",
po::value(&(m_config.stepping.rk_error_tol))
->default_value(m_config.stepping.rk_error_tol /
Expand Down Expand Up @@ -101,6 +120,7 @@ void track_propagation::read(const po::variables_map &) {
m_config.navigation.min_mask_tolerance *= traccc::unit<float>::mm;
m_config.navigation.max_mask_tolerance *= traccc::unit<float>::mm;
m_config.navigation.search_window = m_search_window;
m_config.navigation.accumulated_error /= 100.f;

m_config.stepping.min_stepsize *= traccc::unit<float>::mm;
m_config.stepping.path_limit *= traccc::unit<float>::m;
Expand All @@ -125,7 +145,7 @@ std::unique_ptr<configuration_printable> track_propagation::as_printable()
traccc::unit<float>::mm) +
" mm"));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Mask tolerance scalar",
"Mask tolerance scaling",
std::to_string(m_config.navigation.mask_tolerance_scalor)));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Path tolerance", std::to_string(m_config.navigation.path_tolerance /
Expand All @@ -140,6 +160,12 @@ std::unique_ptr<configuration_printable> track_propagation::as_printable()
"Search window",
std::to_string(m_config.navigation.search_window[0]) + " x " +
std::to_string(m_config.navigation.search_window[1])));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"Scale factor for accumulated noise",
std::to_string(m_config.navigation.accumulated_error * 100.f) + " %"));
cat_nav->add_child(std::make_unique<configuration_kv_pair>(
"# scattering stddevs to assume",
std::to_string(m_config.navigation.n_scattering_stddev)));

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

Expand Down
2 changes: 1 addition & 1 deletion extern/algebra-plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message( STATUS "Building Algebra Plugins as part of the TRACCC project" )

# Declare where to get Algebra Plugins from.
set( TRACCC_ALGEBRA_PLUGINS_SOURCE
"URL;https://github.com/acts-project/algebra-plugins/archive/refs/tags/v0.28.0.tar.gz;URL_MD5;24fa671f564a332858599df60fb2228f"
"URL;https://github.com/acts-project/algebra-plugins/archive/refs/tags/v0.30.0.tar.gz;URL_MD5;d1ec191c6fea5bd0e73f62d4b0319b8c"
CACHE STRING "Source for Algebra Plugins, when built as part of this project" )
mark_as_advanced( TRACCC_ALGEBRA_PLUGINS_SOURCE )
FetchContent_Declare( AlgebraPlugins SYSTEM ${TRACCC_ALGEBRA_PLUGINS_SOURCE} )
Expand Down
2 changes: 1 addition & 1 deletion extern/detray/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message( STATUS "Building Detray as part of the TRACCC project" )

# Declare where to get Detray from.
set( TRACCC_DETRAY_SOURCE
"URL;https://github.com/acts-project/detray/archive/refs/tags/v0.103.0.tar.gz;URL_MD5;7df38072d676b63ee3f0f88bd84c0106"
"URL;https://github.com/acts-project/detray/archive/refs/tags/v0.104.1.tar.gz;URL_MD5;2233a3b9945122e1b3f16ac973c7d1be"
CACHE STRING "Source for Detray, when built as part of this project" )
mark_as_advanced( TRACCC_DETRAY_SOURCE )
FetchContent_Declare( Detray SYSTEM ${TRACCC_DETRAY_SOURCE} )
Expand Down
14 changes: 12 additions & 2 deletions simulation/include/traccc/simulation/simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ struct simulator {

m_cfg.ptc_type = ptc_type;
m_track_generator->config().charge(ptc_type.charge());

// Turn off tracking features
m_cfg.propagation.stepping.do_covariance_transport = false;
m_cfg.propagation.stepping.use_eloss_gradient = false;
m_cfg.propagation.stepping.use_field_gradient = false;
m_cfg.propagation.navigation.estimate_scattering_noise = false;

m_resetter = typename detray::parameter_resetter<algebra_type>::state{
m_cfg.propagation};
}

config& get_config() { return m_cfg; }
Expand All @@ -108,8 +117,8 @@ struct simulator {
m_scatterer.set_seed(event_id);
writer_state.set_seed(event_id);

auto actor_states =
detray::tie(m_aborter_state, m_scatterer, writer_state);
auto actor_states = detray::tie(m_aborter_state, m_scatterer,
m_resetter, writer_state);

for (auto track : *m_track_generator.get()) {

Expand Down Expand Up @@ -149,6 +158,7 @@ struct simulator {
/// Actor states
typename detray::momentum_aborter<scalar_type>::state m_aborter_state{};
typename detray::random_scatterer<algebra_type>::state m_scatterer{};
typename detray::parameter_resetter<algebra_type>::state m_resetter{};
};

} // namespace traccc
2 changes: 2 additions & 0 deletions tests/cpu/test_kalman_fitter_wire_chamber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ TEST_P(KalmanFittingWireChamberTests, Run) {
fit_cfg.propagation.navigation.min_mask_tolerance =
static_cast<float>(mask_tolerance);
fit_cfg.propagation.navigation.search_window = search_window;
// TODO: Disable until overlaps are handled correctly
fit_cfg.propagation.navigation.estimate_scattering_noise = false;
fit_cfg.ptc_hypothesis = ptc;
traccc::host::kalman_fitting_algorithm fitting(fit_cfg, host_mr, copy);

Expand Down
Loading