Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging infrastructure to all algorithms #824

Merged
merged 1 commit into from
Feb 25, 2025
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
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ traccc_add_library( traccc_core core TYPE SHARED
"src/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.cpp" )
target_link_libraries( traccc_core
PUBLIC Eigen3::Eigen vecmem::core detray::core detray::detectors
traccc::algebra )
traccc::algebra ActsCore )

# Prevent Eigen from getting confused when building code for a
# CUDA or HIP backend with SYCL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "traccc/edm/track_candidate.hpp"
#include "traccc/edm/track_state.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// Greedy ambiguity resolution adapted from ACTS code

Expand All @@ -45,7 +46,8 @@ namespace traccc {
/// 4) Back to square 1.
class greedy_ambiguity_resolution_algorithm
: public algorithm<track_state_container_types::host(
const typename track_state_container_types::host&)> {
const typename track_state_container_types::host&)>,
public messaging {

public:
struct config_t {
Expand Down Expand Up @@ -110,8 +112,10 @@ class greedy_ambiguity_resolution_algorithm
/// @param cfg Configuration object
// greedy_ambiguity_resolution_algorithm(const config_type& cfg) :
// _config(cfg) {}
greedy_ambiguity_resolution_algorithm(const config_t cfg = {})
: _config{cfg} {}
greedy_ambiguity_resolution_algorithm(
const config_t cfg,
std::unique_ptr<const Logger> logger = getDummyLogger().clone())
: messaging(std::move(logger)), _config{cfg} {}

/// Run the algorithm
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "traccc/edm/silicon_cell_collection.hpp"
#include "traccc/geometry/silicon_detector_description.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// VecMem include(s).
#include <vecmem/memory/memory_resource.hpp>
Expand All @@ -32,7 +33,8 @@ namespace traccc::host {
class clusterization_algorithm
: public algorithm<measurement_collection_types::host(
const edm::silicon_cell_collection::const_view&,
const silicon_detector_description::const_view&)> {
const silicon_detector_description::const_view&)>,
public messaging {

public:
using config_type = std::monostate;
Expand All @@ -41,7 +43,9 @@ class clusterization_algorithm
///
/// @param mr The memory resource to use for the result objects
///
clusterization_algorithm(vecmem::memory_resource& mr);
clusterization_algorithm(
vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Construct measurements for each detector module
///
Expand All @@ -67,7 +71,6 @@ class clusterization_algorithm

/// Reference to the host-accessible memory resource
std::reference_wrapper<vecmem::memory_resource> m_mr;

}; // class clusterization_algorithm

} // namespace traccc::host
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "traccc/edm/silicon_cluster_collection.hpp"
#include "traccc/geometry/silicon_detector_description.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// VecMem include(s).
#include <vecmem/memory/memory_resource.hpp>
Expand All @@ -32,14 +33,17 @@ class measurement_creation_algorithm
: public algorithm<measurement_collection_types::host(
const edm::silicon_cell_collection::const_view &,
const edm::silicon_cluster_collection::const_view &,
const silicon_detector_description::const_view &)> {
const silicon_detector_description::const_view &)>,
public messaging {

public:
/// Measurement_creation algorithm constructor
///
/// @param mr The memory resource to use in the algorithm
///
measurement_creation_algorithm(vecmem::memory_resource &mr);
measurement_creation_algorithm(
vecmem::memory_resource &mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Callable operator for the connected component, based on one single
/// module
Expand All @@ -57,7 +61,6 @@ class measurement_creation_algorithm
private:
/// The memory resource used by the algorithm
std::reference_wrapper<vecmem::memory_resource> m_mr;

}; // class measurement_creation_algorithm

} // namespace traccc::host
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// Library include(s).
#include "traccc/edm/measurement.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// VecMem include(s).
#include <vecmem/memory/memory_resource.hpp>
Expand All @@ -26,7 +27,8 @@ namespace traccc::host {
///
class measurement_sorting_algorithm
: public algorithm<measurement_collection_types::view(
const measurement_collection_types::view&)> {
const measurement_collection_types::view&)>,
public messaging {

public:
/// Callable operator performing the sorting on a container
Expand All @@ -35,7 +37,6 @@ class measurement_sorting_algorithm
///
output_type operator()(const measurement_collection_types::view&
measurements_view) const override;

}; // class measurement_sorting_algorithm

} // namespace traccc::host
9 changes: 6 additions & 3 deletions core/include/traccc/clusterization/sparse_ccl_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "traccc/edm/silicon_cell_collection.hpp"
#include "traccc/edm/silicon_cluster_collection.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// VecMem include(s).
#include <vecmem/memory/memory_resource.hpp>
Expand All @@ -27,14 +28,17 @@ namespace traccc::host {
///
class sparse_ccl_algorithm
: public algorithm<edm::silicon_cluster_collection::host(
const edm::silicon_cell_collection::const_view&)> {
const edm::silicon_cell_collection::const_view&)>,
public messaging {

public:
/// Constructor for component_connection
///
/// @param mr is the memory resource
///
sparse_ccl_algorithm(vecmem::memory_resource& mr);
sparse_ccl_algorithm(
vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// @name Operator(s) to use in host code
/// @{
Expand All @@ -53,7 +57,6 @@ class sparse_ccl_algorithm
private:
/// The memory resource used by the algorithm
std::reference_wrapper<vecmem::memory_resource> m_mr;

}; // class sparse_ccl_algorithm

} // namespace traccc::host
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "traccc/finding/finding_config.hpp"
#include "traccc/geometry/detector.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// Detray include(s).
#include <detray/detectors/bfield.hpp>
Expand All @@ -37,7 +38,8 @@ class combinatorial_kalman_filter_algorithm
const detray::bfield::const_field_t<
telescope_detector::host::scalar_type>::view_t&,
const measurement_collection_types::const_view&,
const bound_track_parameters_collection_types::const_view&)> {
const bound_track_parameters_collection_types::const_view&)>,
public messaging {

public:
/// Configuration type
Expand All @@ -46,7 +48,9 @@ class combinatorial_kalman_filter_algorithm
using output_type = track_candidate_container_types::host;

/// Constructor with the algorithm's configuration
explicit combinatorial_kalman_filter_algorithm(const config_type& config);
explicit combinatorial_kalman_filter_algorithm(
const config_type& config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Execute the algorithm
///
Expand Down Expand Up @@ -87,7 +91,6 @@ class combinatorial_kalman_filter_algorithm
private:
/// Algorithm configuration
config_type m_config;

}; // class combinatorial_kalman_filter_algorithm

} // namespace traccc::host
10 changes: 6 additions & 4 deletions core/include/traccc/fitting/kalman_fitting_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "traccc/fitting/fitting_config.hpp"
#include "traccc/geometry/detector.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// Detray include(s).
#include <detray/detectors/bfield.hpp>
Expand All @@ -36,7 +37,8 @@ class kalman_fitting_algorithm
const telescope_detector::host&,
const detray::bfield::const_field_t<
telescope_detector::host::scalar_type>::view_t&,
const track_candidate_container_types::const_view&)> {
const track_candidate_container_types::const_view&)>,
public messaging {

public:
/// Configuration type
Expand All @@ -48,8 +50,9 @@ class kalman_fitting_algorithm
///
/// @param config The configuration object
///
explicit kalman_fitting_algorithm(const config_type& config,
vecmem::memory_resource& mr);
explicit kalman_fitting_algorithm(
const config_type& config, vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Execute the algorithm
///
Expand Down Expand Up @@ -86,7 +89,6 @@ class kalman_fitting_algorithm
config_type m_config;
/// Memory resource to use in the algorithm
std::reference_wrapper<vecmem::memory_resource> m_mr;

}; // class kalman_fitting_algorithm

} // namespace traccc::host
9 changes: 7 additions & 2 deletions core/include/traccc/seeding/doublet_finding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "traccc/seeding/detail/spacepoint_type.hpp"
#include "traccc/seeding/doublet_finding_helper.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

namespace traccc {

Expand All @@ -23,7 +24,8 @@ template <details::spacepoint_type otherSpType>
struct doublet_finding
: public algorithm<std::pair<doublet_collection_types::host,
lin_circle_collection_types::host>(
const sp_grid&, const sp_location&)> {
const sp_grid&, const sp_location&)>,
public messaging {

static_assert(otherSpType == details::spacepoint_type::bottom ||
otherSpType == details::spacepoint_type::top);
Expand All @@ -32,7 +34,10 @@ struct doublet_finding
///
/// @param seedfinder_config is the configuration parameters
/// @param isp_container is the internal spacepoint container
doublet_finding(const seedfinder_config& config) : m_config(config) {}
doublet_finding(
const seedfinder_config& config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone())
: messaging(std::move(logger)), m_config(config) {}

/// Callable operator for doublet finding per middle spacepoint
///
Expand Down
8 changes: 5 additions & 3 deletions core/include/traccc/seeding/seed_filtering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
#include "traccc/seeding/detail/seeding_config.hpp"
#include "traccc/seeding/detail/spacepoint_grid.hpp"
#include "traccc/seeding/detail/triplet.hpp"
#include "traccc/utils/messaging.hpp"

namespace traccc {

/// Seed filtering to filter out the bad triplets
class seed_filtering {
class seed_filtering : public messaging {

public:
/// Constructor with the seed filter configuration
seed_filtering(const seedfilter_config& config);
seed_filtering(
const seedfilter_config& config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Callable operator for the seed filtering
///
Expand All @@ -39,7 +42,6 @@ class seed_filtering {
private:
/// Seed filter configuration
seedfilter_config m_filter_config;

}; // class seed_filtering

} // namespace traccc
11 changes: 7 additions & 4 deletions core/include/traccc/seeding/seed_finding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@
#include "traccc/seeding/seed_filtering.hpp"
#include "traccc/seeding/triplet_finding.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

namespace traccc {

/// Seed finding
class seed_finding
: public algorithm<seed_collection_types::host(
const spacepoint_collection_types::host&, const sp_grid&)> {
const spacepoint_collection_types::host&, const sp_grid&)>,
public messaging {

public:
/// Constructor for the seed finding
///
/// @param find_config is seed finder configuration parameters
/// @param filter_config is the seed filter configuration
///
seed_finding(const seedfinder_config& find_config,
const seedfilter_config& filter_config);
seed_finding(
const seedfinder_config& find_config,
const seedfilter_config& filter_config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Callable operator for the seed finding
///
Expand All @@ -52,7 +56,6 @@ class seed_finding
triplet_finding m_triplet_finding;
/// Algorithm performing the seed selection
seed_filtering m_seed_filtering;

}; // class seed_finding

} // namespace traccc
14 changes: 8 additions & 6 deletions core/include/traccc/seeding/seeding_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "traccc/seeding/seed_finding.hpp"
#include "traccc/seeding/spacepoint_binning.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/messaging.hpp"

// VecMem include(s).
#include <vecmem/memory/memory_resource.hpp>
Expand All @@ -21,17 +22,19 @@ namespace traccc {

/// Main algorithm for performing the track seeding on the CPU
class seeding_algorithm : public algorithm<seed_collection_types::host(
const spacepoint_collection_types::host&)> {
const spacepoint_collection_types::host&)>,
public messaging {

public:
/// Constructor for the seed finding algorithm
///
/// @param mr The memory resource to use
///
seeding_algorithm(const seedfinder_config& finder_config,
const spacepoint_grid_config& grid_config,
const seedfilter_config& filter_config,
vecmem::memory_resource& mr);
seeding_algorithm(
const seedfinder_config& finder_config,
const spacepoint_grid_config& grid_config,
const seedfilter_config& filter_config, vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Operator executing the algorithm.
///
Expand All @@ -46,7 +49,6 @@ class seeding_algorithm : public algorithm<seed_collection_types::host(
spacepoint_binning m_spacepoint_binning;
/// Sub-algorithm performing the seed finding
seed_finding m_seed_finding;

}; // class seeding_algorithm

} // namespace traccc
Loading
Loading