diff --git a/core/include/traccc/finding/details/combinatorial_kalman_filter.hpp b/core/include/traccc/finding/details/combinatorial_kalman_filter.hpp index 27586ba155..ff38b0460d 100644 --- a/core/include/traccc/finding/details/combinatorial_kalman_filter.hpp +++ b/core/include/traccc/finding/details/combinatorial_kalman_filter.hpp @@ -126,8 +126,10 @@ combinatorial_kalman_filter( std::vector> tips; // Create propagator + auto prop_cfg{config.propagation}; + prop_cfg.navigation.estimate_scattering_noise = false; traccc::details::ckf_propagator_t propagator( - config.propagation); + prop_cfg); // Create the input seeds container. bound_track_parameters_collection_types::const_device seeds{seeds_view}; @@ -248,7 +250,7 @@ combinatorial_kalman_filter( auto trk_state = edm::make_track_state(measurements, meas_id); - const bool is_line = sf.template visit_mask(); + const bool is_line = detail::is_line(sf); // Run the Kalman update on a copy of the track parameters const kalman_fitter_status res = @@ -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::state s4{}; typename ckf_aborter::state s5; // Update the actor config @@ -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 diff --git a/core/include/traccc/fitting/details/kalman_fitting.hpp b/core/include/traccc/fitting/details/kalman_fitting.hpp index 2c0eab17bb..435f5b7ab1 100644 --- a/core/include/traccc/fitting/details/kalman_fitting.hpp +++ b/core/include/traccc/fitting/details/kalman_fitting.hpp @@ -88,7 +88,7 @@ typename edm::track_container::host kalman_fitting( result_tracks_device.at(result_tracks_device.size() - 1), typename edm::track_state_collection::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 diff --git a/core/include/traccc/fitting/kalman_filter/is_line_visitor.hpp b/core/include/traccc/fitting/kalman_filter/is_line_visitor.hpp index 34c3d5a14a..a4846c5774 100644 --- a/core/include/traccc/fitting/kalman_filter/is_line_visitor.hpp +++ b/core/include/traccc/fitting/kalman_filter/is_line_visitor.hpp @@ -7,20 +7,31 @@ #pragma once +#include #include +#include #include "traccc/definitions/qualifiers.hpp" -namespace traccc { +namespace traccc::detail { -struct is_line_visitor { - template - [[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> || - std::is_same_v>; +/// @returns true if the surface has "line" shape +template +[[nodiscard]] TRACCC_HOST_DEVICE bool constexpr is_line( + const detray::geometry::surface sf) { + using algebra_t = typename detector_t::algebra_type; + using straw_tube = detray::mask, algebra_t>; + using wire_cell = detray::mask, algebra_t>; + + if constexpr (detector_t::masks::template is_defined() || + detector_t::masks::template is_defined()) { + return (sf.shape_id() == + detector_t::masks::template get_id()) || + (sf.shape_id() == + detector_t::masks::template get_id()); + } else { + return false; } }; -} // namespace traccc +} // namespace traccc::detail diff --git a/core/include/traccc/fitting/kalman_filter/kalman_actor.hpp b/core/include/traccc/fitting/kalman_filter/kalman_actor.hpp index 94b70c1f91..65a1a23309 100644 --- a/core/include/traccc/fitting/kalman_filter/kalman_actor.hpp +++ b/core/include/traccc/fitting/kalman_filter/kalman_actor.hpp @@ -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(); + const bool is_line = detail::is_line(sf); kalman_fitter_status res = kalman_fitter_status::SUCCESS; @@ -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::um) { + navigation.set_high_trust(); + } } } }; diff --git a/core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp b/core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp index 06eddb4d85..f42c77df2e 100644 --- a/core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp +++ b/core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp @@ -110,11 +110,13 @@ class kalman_fitter { track_states, const measurement_collection_types::const_device& measurements, vecmem::data::vector_view - sequence_buffer) + sequence_buffer, + const detray::propagation::config& prop_cfg) : m_fit_actor_state{track, track_states, measurements}, m_sequencer_state( vecmem::device_vector( sequence_buffer)), + m_parameter_resetter{prop_cfg}, m_fit_res{track}, m_sequence_buffer(sequence_buffer) {} @@ -122,8 +124,8 @@ class kalman_fitter { 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 @@ -131,7 +133,8 @@ class kalman_fitter { 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 @@ -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::device::proxy_type diff --git a/device/common/include/traccc/finding/device/impl/find_tracks.ipp b/device/common/include/traccc/finding/device/impl/find_tracks.ipp index 52ca4aec37..3400936fd6 100644 --- a/device/common/include/traccc/finding/device/impl/find_tracks.ipp +++ b/device/common/include/traccc/finding/device/impl/find_tracks.ipp @@ -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(); + const bool is_line = detail::is_line(sf); // Run the Kalman update const kalman_fitter_status res = diff --git a/device/common/include/traccc/finding/device/impl/propagate_to_next_surface.ipp b/device/common/include/traccc/finding/device/impl/propagate_to_next_surface.ipp index eb4ddc91db..d9c64529ce 100644 --- a/device/common/include/traccc/finding/device/impl/propagate_to_next_surface.ipp +++ b/device/common/include/traccc/finding/device/impl/propagate_to_next_surface.ipp @@ -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); @@ -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 @@ -101,7 +102,7 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface( s5.min_p(static_cast(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) { diff --git a/device/common/include/traccc/fitting/device/fit_backward.hpp b/device/common/include/traccc/fitting/device/fit_backward.hpp index 70305decf9..83d2c90078 100644 --- a/device/common/include/traccc/fitting/device/fit_backward.hpp +++ b/device/common/include/traccc/fitting/device/fit_backward.hpp @@ -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); diff --git a/device/common/include/traccc/fitting/device/fit_forward.hpp b/device/common/include/traccc/fitting/device/fit_forward.hpp index 5b3495e05c..c67c035fb8 100644 --- a/device/common/include/traccc/fitting/device/fit_forward.hpp +++ b/device/common/include/traccc/fitting/device/fit_forward.hpp @@ -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); diff --git a/examples/options/src/track_propagation.cpp b/examples/options/src/track_propagation.cpp index c1221517f5..881d544754 100644 --- a/examples/options/src/track_propagation.cpp +++ b/examples/options/src/track_propagation.cpp @@ -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 / @@ -101,6 +120,7 @@ void track_propagation::read(const po::variables_map &) { m_config.navigation.min_mask_tolerance *= traccc::unit::mm; m_config.navigation.max_mask_tolerance *= traccc::unit::mm; m_config.navigation.search_window = m_search_window; + m_config.navigation.accumulated_error /= 100.f; m_config.stepping.min_stepsize *= traccc::unit::mm; m_config.stepping.path_limit *= traccc::unit::m; @@ -125,7 +145,7 @@ std::unique_ptr track_propagation::as_printable() traccc::unit::mm) + " mm")); cat_nav->add_child(std::make_unique( - "Mask tolerance scalar", + "Mask tolerance scaling", std::to_string(m_config.navigation.mask_tolerance_scalor))); cat_nav->add_child(std::make_unique( "Path tolerance", std::to_string(m_config.navigation.path_tolerance / @@ -140,6 +160,12 @@ std::unique_ptr 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( + "Scale factor for accumulated noise", + std::to_string(m_config.navigation.accumulated_error * 100.f) + " %")); + cat_nav->add_child(std::make_unique( + "# scattering stddevs to assume", + std::to_string(m_config.navigation.n_scattering_stddev))); auto cat_tsp = std::make_unique("Transport"); diff --git a/extern/algebra-plugins/CMakeLists.txt b/extern/algebra-plugins/CMakeLists.txt index 15869a9522..7707510a75 100644 --- a/extern/algebra-plugins/CMakeLists.txt +++ b/extern/algebra-plugins/CMakeLists.txt @@ -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} ) diff --git a/extern/detray/CMakeLists.txt b/extern/detray/CMakeLists.txt index c3ce19a867..19c60b9218 100644 --- a/extern/detray/CMakeLists.txt +++ b/extern/detray/CMakeLists.txt @@ -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} ) diff --git a/simulation/include/traccc/simulation/simulator.hpp b/simulation/include/traccc/simulation/simulator.hpp index d6ba2f8183..bbc9043fe0 100644 --- a/simulation/include/traccc/simulation/simulator.hpp +++ b/simulation/include/traccc/simulation/simulator.hpp @@ -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::state{ + m_cfg.propagation}; } config& get_config() { return m_cfg; } @@ -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()) { @@ -149,6 +158,7 @@ struct simulator { /// Actor states typename detray::momentum_aborter::state m_aborter_state{}; typename detray::random_scatterer::state m_scatterer{}; + typename detray::parameter_resetter::state m_resetter{}; }; } // namespace traccc diff --git a/tests/cpu/test_kalman_fitter_wire_chamber.cpp b/tests/cpu/test_kalman_fitter_wire_chamber.cpp index 4fa6e077d4..38ac359b18 100644 --- a/tests/cpu/test_kalman_fitter_wire_chamber.cpp +++ b/tests/cpu/test_kalman_fitter_wire_chamber.cpp @@ -132,6 +132,8 @@ TEST_P(KalmanFittingWireChamberTests, Run) { fit_cfg.propagation.navigation.min_mask_tolerance = static_cast(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);