Skip to content

Commit

Permalink
Named the host track finding traccc::host::ckf_algorithm.
Browse files Browse the repository at this point in the history
Switched to implementing the reconstruction code for different
Detray detector and Covfie magnetic field types as overloads on
the call operator of a single "CKF algorithm".

Updated all clients to use this new name.

Split the source file, to parallelize compilation, and hopefully
reduce memory usage in individual build processes.
  • Loading branch information
krasznaa committed Oct 22, 2024
1 parent d6a8231 commit e1a8b5e
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 56 deletions.
5 changes: 2 additions & 3 deletions benchmarks/cpu/toy_detector_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "traccc/geometry/detector.hpp"

// Traccc algorithm include(s).
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/seeding/seeding_algorithm.hpp"
#include "traccc/seeding/track_params_estimation.hpp"
Expand Down Expand Up @@ -62,8 +62,7 @@ BENCHMARK_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
// Algorithms
traccc::seeding_algorithm sa(seeding_cfg, grid_cfg, filter_cfg, host_mr);
traccc::track_params_estimation tp(host_mr);
traccc::host::default_detector_const_field_ckf_algorithm host_finding(
finding_cfg);
traccc::host::ckf_algorithm host_finding(finding_cfg);
traccc::fitting_algorithm<host_fitter_type> host_fitting(fitting_cfg);

for (auto _ : state) {
Expand Down
6 changes: 4 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ traccc_add_library( traccc_core core TYPE SHARED
"include/traccc/finding/actors/ckf_aborter.hpp"
"include/traccc/finding/actors/interaction_register.hpp"
"src/finding/find_tracks.hpp"
"include/traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
"src/finding/default_detector_const_field_ckf_algorithm.cpp"
"include/traccc/finding/ckf_algorithm.hpp"
"src/finding/ckf_algorithm.cpp"
"src/finding/ckf_algorithm_defdet_cfield.cpp"
"src/finding/ckf_algorithm_teldet_cfield.cpp"
# Fitting algorithmic code
"include/traccc/fitting/kalman_filter/gain_matrix_smoother.hpp"
"include/traccc/fitting/kalman_filter/gain_matrix_updater.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,70 @@

namespace traccc::host {

/// CKF track finding with a default Detray detector and constant magnetic field
/// CKF track finding algorithm
///
/// This is the main host-based track finding algorithm of the project. More
/// documentation to be written later...
///
class default_detector_const_field_ckf_algorithm
class ckf_algorithm
: public algorithm<track_candidate_container_types::host(
const default_detector::host&,
const detray::bfield::const_field_t::view_t&,
const measurement_collection_types::const_view&,
const bound_track_parameters_collection_types::const_view&)>,
public algorithm<track_candidate_container_types::host(
const telescope_detector::host&,
const detray::bfield::const_field_t::view_t&,
const measurement_collection_types::const_view&,
const bound_track_parameters_collection_types::const_view&)> {

public:
/// Configuration type
using config_type = finding_config;
/// Output type
using output_type = track_candidate_container_types::host;

/// Constructor with the algorithm's configuration
default_detector_const_field_ckf_algorithm(const config_type& config);
ckf_algorithm(const config_type& config);

/// Execute the algorithm
///
/// @param det The detector object
/// @param field The magnetic field object
/// @param det The (default) detector object
/// @param field The (constant) magnetic field object
/// @param measurements All measurements in an event
/// @param seeds All seeds in an event to start the track finding with
/// @param seeds All seeds in an event to start the track finding
/// with
///
/// @return A container of the found track candidates
///
output_type operator()(
const default_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds) const;
const bound_track_parameters_collection_types::const_view& seeds)
const override;

/// Execute the algorithm
///
/// @param det The (telescope) detector object
/// @param field The (constant) magnetic field object
/// @param measurements All measurements in an event
/// @param seeds All seeds in an event to start the track finding
/// with
///
/// @return A container of the found track candidates
///
output_type operator()(
const telescope_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds)
const override;

private:
/// Algorithm configuration
config_type m_config;

}; // class default_detector_ckf_algorithm
}; // class ckf_algorithm

} // namespace traccc::host
15 changes: 15 additions & 0 deletions core/src/finding/ckf_algorithm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Local include(s).
#include "traccc/finding/ckf_algorithm.hpp"

namespace traccc::host {

ckf_algorithm::ckf_algorithm(const config_type& config) : m_config{config} {}

} // namespace traccc::host
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,19 @@
*/

// Local include(s).
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"

#include "find_tracks.hpp"
#include "traccc/finding/ckf_algorithm.hpp"

// Detray include(s).
#include <detray/core/detector.hpp>
#include <detray/detectors/bfield.hpp>
#include <detray/io/frontend/detector_reader.hpp>
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/propagator.hpp>
#include <detray/propagator/rk_stepper.hpp>

namespace traccc::host {

default_detector_const_field_ckf_algorithm::
default_detector_const_field_ckf_algorithm(const config_type& config)
: m_config{config} {}

default_detector_const_field_ckf_algorithm::output_type
default_detector_const_field_ckf_algorithm::operator()(
ckf_algorithm::output_type ckf_algorithm::operator()(
const default_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
Expand Down
36 changes: 36 additions & 0 deletions core/src/finding/ckf_algorithm_teldet_cfield.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Local include(s).
#include "find_tracks.hpp"
#include "traccc/finding/ckf_algorithm.hpp"

// Detray include(s).
#include <detray/core/detector.hpp>
#include <detray/detectors/bfield.hpp>
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/propagator.hpp>
#include <detray/propagator/rk_stepper.hpp>

namespace traccc::host {

ckf_algorithm::output_type ckf_algorithm::operator()(
const telescope_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds) const {

// Perform the track finding using the templated implementation.
return details::find_tracks<
detray::rk_stepper<detray::bfield::const_field_t::view_t,
telescope_detector::host::algebra_type,
detray::constrained_step<>>,
detray::navigator<const telescope_detector::host>>(
det, field, measurements, seeds, m_config);
}

} // namespace traccc::host
6 changes: 3 additions & 3 deletions core/src/finding/find_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "traccc/finding/actors/ckf_aborter.hpp"
#include "traccc/finding/actors/interaction_register.hpp"
#include "traccc/finding/candidate_link.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/fitting/kalman_filter/gain_matrix_updater.hpp"
#include "traccc/sanity/contiguous_on.hpp"
#include "traccc/utils/particle.hpp"
Expand Down Expand Up @@ -69,7 +70,7 @@ track_candidate_container_types::host find_tracks(
using interactor_type = detray::pointwise_material_interactor<algebra_type>;

using actor_type = detray::actor_chain<
std::tuple, detray::pathlimit_aborter, transporter_type,
detray::tuple, detray::pathlimit_aborter, transporter_type,
interaction_register<interactor_type>, interactor_type, ckf_aborter>;

using propagator_type =
Expand All @@ -83,8 +84,7 @@ track_candidate_container_types::host find_tracks(
measurement_collection_types::const_device measurements{measurements_view};

// Check contiguity of the measurements
assert(
is_contiguous_on(measurement_module_projection(), measurements));
assert(is_contiguous_on(measurement_module_projection(), measurements));

// Get copy of barcode uniques
std::vector<measurement> uniques;
Expand Down
5 changes: 2 additions & 3 deletions examples/run/cpu/full_chain_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "traccc/clusterization/clusterization_algorithm.hpp"
#include "traccc/edm/silicon_cell_collection.hpp"
#include "traccc/edm/track_state.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/fitting/kalman_filter/kalman_fitter.hpp"
#include "traccc/geometry/detector.hpp"
Expand Down Expand Up @@ -64,8 +64,7 @@ class full_chain_algorithm : public algorithm<track_state_container_types::host(
traccc::host::spacepoint_formation_algorithm<
traccc::default_detector::host>;
/// Track finding algorithm type
using finding_algorithm =
traccc::host::default_detector_const_field_ckf_algorithm;
using finding_algorithm = traccc::host::ckf_algorithm;
/// Track fitting algorithm type
using fitting_algorithm = traccc::fitting_algorithm<
traccc::kalman_fitter<stepper_type, navigator_type>>;
Expand Down
4 changes: 2 additions & 2 deletions examples/run/cpu/seeding_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// algorithms
#include "traccc/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/seeding/seeding_algorithm.hpp"
#include "traccc/seeding/track_params_estimation.hpp"
Expand Down Expand Up @@ -129,7 +129,7 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
traccc::finding_config cfg(finding_opts);
cfg.propagation = propagation_config;

traccc::host::default_detector_const_field_ckf_algorithm host_finding(cfg);
traccc::host::ckf_algorithm host_finding(cfg);

// Fitting algorithm object
typename traccc::fitting_algorithm<host_fitter_type>::config_type fit_cfg;
Expand Down
5 changes: 2 additions & 3 deletions examples/run/cpu/seq_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// algorithms
#include "traccc/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.hpp"
#include "traccc/clusterization/clusterization_algorithm.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/seeding/seeding_algorithm.hpp"
#include "traccc/seeding/spacepoint_formation_algorithm.hpp"
Expand Down Expand Up @@ -107,8 +107,7 @@ int seq_run(const traccc::opts::input_data& input_opts,
detray::constrained_step<>>;
using navigator_type =
detray::navigator<const traccc::default_detector::host>;
using finding_algorithm =
traccc::host::default_detector_const_field_ckf_algorithm;
using finding_algorithm = traccc::host::ckf_algorithm;
using fitting_algorithm = traccc::fitting_algorithm<
traccc::kalman_fitter<stepper_type, navigator_type>>;

Expand Down
4 changes: 2 additions & 2 deletions examples/run/cpu/truth_finding_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "traccc/definitions/common.hpp"
#include "traccc/definitions/primitives.hpp"
#include "traccc/efficiency/finding_performance_writer.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/fitting/kalman_filter/kalman_fitter.hpp"
#include "traccc/io/read_detector.hpp"
Expand Down Expand Up @@ -109,7 +109,7 @@ int seq_run(const traccc::opts::track_finding& finding_opts,
cfg.propagation = propagation_config;

// Finding algorithm object
traccc::host::default_detector_const_field_ckf_algorithm host_finding(cfg);
traccc::host::ckf_algorithm host_finding(cfg);

// Fitting algorithm object
typename traccc::fitting_algorithm<host_fitter_type>::config_type fit_cfg;
Expand Down
4 changes: 2 additions & 2 deletions examples/run/cuda/seeding_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "traccc/efficiency/nseed_performance_writer.hpp"
#include "traccc/efficiency/seeding_performance_writer.hpp"
#include "traccc/efficiency/track_filter.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/io/read_detector.hpp"
#include "traccc/io/read_detector_description.hpp"
Expand Down Expand Up @@ -174,7 +174,7 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
cfg.propagation = propagation_config;

// Finding algorithm object
traccc::host::default_detector_const_field_ckf_algorithm host_finding(cfg);
traccc::host::ckf_algorithm host_finding(cfg);
traccc::cuda::finding_algorithm<rk_stepper_type, device_navigator_type>
device_finding(cfg, mr, async_copy, stream);

Expand Down
5 changes: 2 additions & 3 deletions examples/run/cuda/seq_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "traccc/cuda/utils/stream.hpp"
#include "traccc/device/container_d2h_copy_alg.hpp"
#include "traccc/efficiency/seeding_performance_writer.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/io/read_cells.hpp"
#include "traccc/io/read_detector.hpp"
Expand Down Expand Up @@ -136,8 +136,7 @@ int seq_run(const traccc::opts::detector& detector_opts,
using device_navigator_type =
detray::navigator<const traccc::default_detector::device>;

using host_finding_algorithm =
traccc::host::default_detector_const_field_ckf_algorithm;
using host_finding_algorithm = traccc::host::ckf_algorithm;
using device_finding_algorithm =
traccc::cuda::finding_algorithm<stepper_type, device_navigator_type>;

Expand Down
7 changes: 3 additions & 4 deletions examples/run/cuda/truth_finding_example_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "traccc/device/container_d2h_copy_alg.hpp"
#include "traccc/device/container_h2d_copy_alg.hpp"
#include "traccc/efficiency/finding_performance_writer.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/fitting/kalman_filter/kalman_fitter.hpp"
#include "traccc/io/read_detector.hpp"
Expand Down Expand Up @@ -151,7 +151,7 @@ int seq_run(const traccc::opts::track_finding& finding_opts,
cfg.propagation = propagation_config;

// Finding algorithm object
traccc::host::default_detector_const_field_ckf_algorithm host_finding(cfg);
traccc::host::ckf_algorithm host_finding(cfg);
traccc::cuda::finding_algorithm<rk_stepper_type, device_navigator_type>
device_finding(cfg, mr, async_copy, stream);

Expand Down Expand Up @@ -240,8 +240,7 @@ int seq_run(const traccc::opts::track_finding& finding_opts,
track_state_d2h(track_states_cuda_buffer);

// CPU containers
traccc::host::default_detector_const_field_ckf_algorithm::output_type
track_candidates;
traccc::host::ckf_algorithm::output_type track_candidates;
traccc::fitting_algorithm<host_fitter_type>::output_type track_states;

if (accelerator_opts.compare_with_cpu) {
Expand Down
5 changes: 2 additions & 3 deletions examples/run/sycl/full_chain_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Project include(s).
#include "traccc/edm/silicon_cell_collection.hpp"
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/fitting/kalman_filter/kalman_fitter.hpp"
#include "traccc/geometry/detector.hpp"
Expand Down Expand Up @@ -73,8 +73,7 @@ class full_chain_algorithm
/// Clustering algorithm type
using clustering_algorithm = clusterization_algorithm;
/// Track finding algorithm type
using finding_algorithm =
traccc::host::default_detector_const_field_ckf_algorithm;
using finding_algorithm = traccc::host::ckf_algorithm;
/// Track fitting algorithm type
using fitting_algorithm = traccc::fitting_algorithm<
traccc::kalman_fitter<stepper_type, navigator_type>>;
Expand Down
8 changes: 3 additions & 5 deletions tests/cpu/test_ckf_combinatorics_telescope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Project include(s).
#include "traccc/finding/default_detector_const_field_ckf_algorithm.hpp"
#include "traccc/finding/ckf_algorithm.hpp"
#include "traccc/fitting/fitting_algorithm.hpp"
#include "traccc/io/read_measurements.hpp"
#include "traccc/io/utils.hpp"
Expand Down Expand Up @@ -121,10 +121,8 @@ TEST_P(CpuCkfCombinatoricsTelescopeTests, Run) {
cfg_limit.chi2_max = 30.f;

// Finding algorithm object
traccc::host::default_detector_const_field_ckf_algorithm host_finding(
cfg_no_limit);
traccc::host::default_detector_const_field_ckf_algorithm host_finding_limit(
cfg_limit);
traccc::host::ckf_algorithm host_finding(cfg_no_limit);
traccc::host::ckf_algorithm host_finding_limit(cfg_limit);

// Iterate over events
for (std::size_t i_evt = 0; i_evt < n_events; i_evt++) {
Expand Down
Loading

0 comments on commit e1a8b5e

Please sign in to comment.