diff --git a/examples/options/include/traccc/options/clusterization.hpp b/examples/options/include/traccc/options/clusterization.hpp index 135b3f65c..5ef9adb9f 100644 --- a/examples/options/include/traccc/options/clusterization.hpp +++ b/examples/options/include/traccc/options/clusterization.hpp @@ -32,14 +32,8 @@ class clusterization std::unique_ptr as_printable() const override; private: - /// @name Options - /// @{ - /// The number of cells to merge in a partition - unsigned int threads_per_partition; - unsigned int max_cells_per_thread; - unsigned int target_cells_per_thread; - unsigned int backup_size_multiplier; - /// @} + /// Internal configuration object + clustering_config m_config; }; // class clusterization } // namespace traccc::opts diff --git a/examples/options/include/traccc/options/track_finding.hpp b/examples/options/include/traccc/options/track_finding.hpp index d36b16698..abbf67e48 100644 --- a/examples/options/include/traccc/options/track_finding.hpp +++ b/examples/options/include/traccc/options/track_finding.hpp @@ -34,29 +34,11 @@ class track_finding : public interface, public config_provider { std::unique_ptr as_printable() const override; private: - /// @name Options - /// @{ - /// Max number of branches per seed - unsigned int max_num_branches_per_seed = 10; - /// Max number of branches per surface - unsigned int max_num_branches_per_surface = 10; - /// Number of track candidates per seed - opts::value_array track_candidates_range{3, 100}; - /// Minimum step length that track should make to reach the next surface. It - /// should be set higher than the overstep tolerance not to make it stay on - /// the same surface - float min_step_length_for_next_surface = 0.5f * detray::unit::mm; - /// Maximum step counts that track can make to reach the next surface - unsigned int max_step_counts_for_next_surface = 100; - /// Maximum chi2 for a measurement to be included in the track - float chi2_max = 10.f; - /// Maximum number of branches which each initial seed can have at a step - unsigned int nmax_per_seed = 10; - /// Maximum allowed number of skipped steps per candidate - unsigned int max_num_skipping_per_cand = 3; - /// PDG number for particle hypothesis (Default: muon) - int pdg_number = 13; - /// @} + /// The internal configuration + finding_config m_config; + /// Additional variables which we cannot simply store in the config + opts::value_array m_track_candidates_range{0, 0}; + int m_pdg_number = 0; }; // class track_finding } // namespace traccc::opts diff --git a/examples/options/include/traccc/options/track_propagation.hpp b/examples/options/include/traccc/options/track_propagation.hpp index 208b5aecf..d4ef1d0cb 100644 --- a/examples/options/include/traccc/options/track_propagation.hpp +++ b/examples/options/include/traccc/options/track_propagation.hpp @@ -40,7 +40,7 @@ class track_propagation : public interface, /// @name Options /// @{ /// Propagation configuration object - detray::propagation::config config; + detray::propagation::config m_config; /// @} /// Search window (helper variable) diff --git a/examples/options/src/clusterization.cpp b/examples/options/src/clusterization.cpp index 4a3768ebc..ae0d7e2d1 100644 --- a/examples/options/src/clusterization.cpp +++ b/examples/options/src/clusterization.cpp @@ -18,33 +18,30 @@ namespace traccc::opts { clusterization::clusterization() : interface("Clusterization Options") { - m_desc.add_options()("threads-per-partition", - boost::program_options::value(&threads_per_partition) - ->default_value(256), - "The number of threads per partition"); + m_desc.add_options()( + "threads-per-partition", + boost::program_options::value(&m_config.threads_per_partition) + ->default_value(m_config.threads_per_partition), + "The number of threads per partition"); m_desc.add_options()( "max-cells-per-thread", - boost::program_options::value(&max_cells_per_thread)->default_value(16), + boost::program_options::value(&m_config.max_cells_per_thread) + ->default_value(m_config.max_cells_per_thread), "The maximum number of cells per thread"); - m_desc.add_options()("target-cells-per-thread", - boost::program_options::value(&target_cells_per_thread) - ->default_value(8), - "The target number of cells per thread"); - m_desc.add_options()("backup-size-multiplier", - boost::program_options::value(&backup_size_multiplier) - ->default_value(256), - "The size multiplier of the backup scratch space"); + m_desc.add_options()( + "target-cells-per-thread", + boost::program_options::value(&m_config.target_cells_per_thread) + ->default_value(m_config.target_cells_per_thread), + "The target number of cells per thread"); + m_desc.add_options()( + "backup-size-multiplier", + boost::program_options::value(&m_config.backup_size_multiplier) + ->default_value(m_config.backup_size_multiplier), + "The size multiplier of the backup scratch space"); } clusterization::operator clustering_config() const { - clustering_config rv; - - rv.threads_per_partition = threads_per_partition; - rv.max_cells_per_thread = max_cells_per_thread; - rv.target_cells_per_thread = target_cells_per_thread; - rv.backup_size_multiplier = backup_size_multiplier; - - return rv; + return m_config; } clusterization::operator host::clusterization_algorithm::config_type() const { @@ -57,18 +54,20 @@ std::unique_ptr clusterization::as_printable() const { dynamic_cast(*cat).add_child( std::make_unique( - "Threads per partition", std::to_string(threads_per_partition))); + "Threads per partition", + std::to_string(m_config.threads_per_partition))); dynamic_cast(*cat).add_child( std::make_unique( "Target cells per thread", - std::to_string(target_cells_per_thread))); + std::to_string(m_config.target_cells_per_thread))); dynamic_cast(*cat).add_child( std::make_unique( - "Max cells per thread", std::to_string(max_cells_per_thread))); + "Max cells per thread", + std::to_string(m_config.max_cells_per_thread))); dynamic_cast(*cat).add_child( std::make_unique( "Scratch space multiplier", - std::to_string(backup_size_multiplier))); + std::to_string(m_config.backup_size_multiplier))); return cat; } diff --git a/examples/options/src/track_finding.cpp b/examples/options/src/track_finding.cpp index c5b1a3cba..e09764481 100644 --- a/examples/options/src/track_finding.cpp +++ b/examples/options/src/track_finding.cpp @@ -20,69 +20,67 @@ namespace traccc::opts { namespace po = boost::program_options; track_finding::track_finding() : interface("Track Finding Options") { + m_pdg_number = m_config.ptc_hypothesis.pdg_num(); + m_track_candidates_range[0] = m_config.min_track_candidates_per_track; + m_track_candidates_range[1] = m_config.max_track_candidates_per_track; - m_desc.add_options()("max-num-branches-per-seed", - po::value(&max_num_branches_per_seed) - ->default_value(max_num_branches_per_seed), - "Max number of branches per seed"); - m_desc.add_options()("max-num-branches-per-surface", - po::value(&max_num_branches_per_surface) - ->default_value(max_num_branches_per_surface), - "Max number of branches per surface"); + m_desc.add_options()( + "max-num-branches-per-seed", + po::value(&m_config.max_num_branches_per_seed) + ->default_value(m_config.max_num_branches_per_seed), + "Max number of branches per seed"); + m_desc.add_options()( + "max-num-branches-per-surface", + po::value(&m_config.max_num_branches_per_surface) + ->default_value(m_config.max_num_branches_per_surface), + "Max number of branches per surface"); m_desc.add_options()("track-candidates-range", - po::value(&track_candidates_range) + po::value(&m_track_candidates_range) ->value_name("MIN:MAX") - ->default_value(track_candidates_range), + ->default_value(m_track_candidates_range), "Range of track candidates number"); m_desc.add_options()( "min-step-length-for-next-surface", - po::value(&min_step_length_for_next_surface) - ->default_value(min_step_length_for_next_surface), + po::value(&m_config.min_step_length_for_next_surface) + ->default_value(m_config.min_step_length_for_next_surface), "Minimum step length that track should make to reach the next surface. " "This should be set higher than the overstep tolerance not to make it " "stay on the same surface"); m_desc.add_options()( "max-step-counts-for-next-surface", - po::value(&max_step_counts_for_next_surface) - ->default_value(max_step_counts_for_next_surface), + po::value(&m_config.max_step_counts_for_next_surface) + ->default_value(m_config.max_step_counts_for_next_surface), "Maximum step counts that track can make to reach the next surface"); m_desc.add_options()( - "chi2-max", po::value(&chi2_max)->default_value(chi2_max), + "chi2-max", + po::value(&m_config.chi2_max)->default_value(m_config.chi2_max), "Maximum Chi suqare that measurements can be included in the track"); m_desc.add_options()( "nmax-per-seed", - po::value(&nmax_per_seed)->default_value(nmax_per_seed), + po::value(&m_config.max_num_branches_per_seed) + ->default_value(m_config.max_num_branches_per_seed), "Maximum number of branches which each initial seed can have at a " "step."); m_desc.add_options()( "max-num-skipping-per-cand", - po::value(&max_num_skipping_per_cand) - ->default_value(max_num_skipping_per_cand), + po::value(&m_config.max_num_skipping_per_cand) + ->default_value(m_config.max_num_skipping_per_cand), "Maximum allowed number of skipped steps per candidate"); m_desc.add_options()( - "max-num-skipping-per-cand", - po::value(&max_num_skipping_per_cand) - ->default_value(max_num_skipping_per_cand), - "Maximum allowed number of skipped steps per candidate"); - m_desc.add_options()("particle-hypothesis", - po::value(&pdg_number)->default_value(pdg_number), - "PDG number for the particle hypothesis"); + "particle-hypothesis", + po::value(&m_pdg_number)->default_value(m_pdg_number), + "PDG number for the particle hypothesis"); } track_finding::operator finding_config() const { - finding_config out; - out.max_num_branches_per_seed = max_num_branches_per_seed; - out.max_num_branches_per_surface = max_num_branches_per_surface; - out.min_track_candidates_per_track = track_candidates_range[0]; - out.max_track_candidates_per_track = track_candidates_range[1]; - out.min_step_length_for_next_surface = min_step_length_for_next_surface; - out.max_step_counts_for_next_surface = max_step_counts_for_next_surface; - out.chi2_max = chi2_max; - out.max_num_branches_per_seed = nmax_per_seed; - out.max_num_skipping_per_cand = max_num_skipping_per_cand; + finding_config out = m_config; + + out.min_track_candidates_per_track = m_track_candidates_range[0]; + out.max_track_candidates_per_track = m_track_candidates_range[1]; out.ptc_hypothesis = - detail::particle_from_pdg_number(pdg_number); - return out; + detail::particle_from_pdg_number(m_pdg_number); + + return m_config; } std::unique_ptr track_finding::as_printable() const { @@ -92,37 +90,38 @@ std::unique_ptr track_finding::as_printable() const { dynamic_cast(*cat).add_child( std::make_unique( "Max branches per seed", - std::to_string(max_num_branches_per_seed))); + std::to_string(m_config.max_num_branches_per_seed))); dynamic_cast(*cat).add_child( std::make_unique( "Max branches at surface", - std::to_string(max_num_branches_per_surface))); + std::to_string(m_config.max_num_branches_per_surface))); std::stringstream candidate_ss; - candidate_ss << track_candidates_range; + candidate_ss << m_track_candidates_range; dynamic_cast(*cat).add_child( std::make_unique("Track candidate range", candidate_ss.str())); dynamic_cast(*cat).add_child( std::make_unique( "Min step length to next surface", - std::to_string(min_step_length_for_next_surface) + " mm")); + std::to_string(m_config.min_step_length_for_next_surface) + " mm")); dynamic_cast(*cat).add_child( std::make_unique( "Max step count to next surface", - std::to_string(max_step_counts_for_next_surface))); + std::to_string(m_config.max_step_counts_for_next_surface))); dynamic_cast(*cat).add_child( - std::make_unique("Max Chi2", - std::to_string(chi2_max))); + std::make_unique( + "Max Chi2", std::to_string(m_config.chi2_max))); dynamic_cast(*cat).add_child( - std::make_unique("Max branches per step", - std::to_string(nmax_per_seed))); + std::make_unique( + "Max branches per step", + std::to_string(m_config.max_num_branches_per_seed))); dynamic_cast(*cat).add_child( std::make_unique( "Max holes per candidate", - std::to_string(max_num_skipping_per_cand))); + std::to_string(m_config.max_num_skipping_per_cand))); dynamic_cast(*cat).add_child( std::make_unique("PDG number", - std::to_string(pdg_number))); + std::to_string(m_pdg_number))); return cat; } diff --git a/examples/options/src/track_propagation.cpp b/examples/options/src/track_propagation.cpp index a9991ce63..3e32e5b5e 100644 --- a/examples/options/src/track_propagation.cpp +++ b/examples/options/src/track_propagation.cpp @@ -23,44 +23,49 @@ namespace po = boost::program_options; track_propagation::track_propagation() : interface("Track Propagation Options") { + m_search_window[0] = m_config.navigation.search_window[0]; + m_search_window[1] = m_config.navigation.search_window[1]; m_desc.add_options()("constraint-step-size-mm", - po::value(&(config.stepping.step_constraint)) - ->default_value(std::numeric_limits::max()), + po::value(&(m_config.stepping.step_constraint)) + ->default_value(m_config.stepping.step_constraint), "The constrained step size [mm]"); - m_desc.add_options()("overstep-tolerance-um", - po::value(&(config.navigation.overstep_tolerance)) - ->default_value(-100.f), - "The overstep tolerance [um]"); - m_desc.add_options()("min-mask-tolerance-mm", - po::value(&(config.navigation.min_mask_tolerance)) - ->default_value(1e-5f), - "The minimum mask tolerance [mm]"); + m_desc.add_options()( + "overstep-tolerance-um", + po::value(&(m_config.navigation.overstep_tolerance)) + ->default_value(m_config.navigation.overstep_tolerance), + "The overstep tolerance [um]"); + m_desc.add_options()( + "min-mask-tolerance-mm", + po::value(&(m_config.navigation.min_mask_tolerance)) + ->default_value(m_config.navigation.min_mask_tolerance), + "The minimum mask tolerance [mm]"); m_desc.add_options()( "max-mask-tolerance-mm", - po::value(&(config.navigation.max_mask_tolerance))->default_value(1.f), + po::value(&(m_config.navigation.max_mask_tolerance)) + ->default_value(m_config.navigation.max_mask_tolerance), "The maximum mask tolerance [mm]"); m_desc.add_options()( "search-window", po::value(&m_search_window)->default_value(m_search_window), "Size of the grid surface search window"); - m_desc.add_options()( - "rk-tolerance", - po::value(&(config.stepping.rk_error_tol))->default_value(1e-4f), - "The Runge-Kutta stepper tolerance"); + m_desc.add_options()("rk-tolerance", + po::value(&(m_config.stepping.rk_error_tol)) + ->default_value(m_config.stepping.rk_error_tol), + "The Runge-Kutta stepper tolerance"); } void track_propagation::read(const po::variables_map &) { - config.stepping.step_constraint *= detray::unit::mm; - config.navigation.overstep_tolerance *= detray::unit::um; - config.navigation.min_mask_tolerance *= detray::unit::mm; - config.navigation.max_mask_tolerance *= detray::unit::mm; - config.navigation.search_window = m_search_window; + m_config.stepping.step_constraint *= detray::unit::mm; + m_config.navigation.overstep_tolerance *= detray::unit::um; + m_config.navigation.min_mask_tolerance *= detray::unit::mm; + m_config.navigation.max_mask_tolerance *= detray::unit::mm; + m_config.navigation.search_window = m_search_window; } track_propagation::operator detray::propagation::config() const { - return config; + return m_config; } std::unique_ptr track_propagation::as_printable() @@ -71,91 +76,92 @@ std::unique_ptr track_propagation::as_printable() dynamic_cast(*cat_nav).add_child( std::make_unique( "Min mask tolerance", - std::to_string(config.navigation.min_mask_tolerance / + std::to_string(m_config.navigation.min_mask_tolerance / detray::unit::mm) + " mm")); dynamic_cast(*cat_nav).add_child( std::make_unique( "Max mask tolerance", - std::to_string(config.navigation.max_mask_tolerance / + std::to_string(m_config.navigation.max_mask_tolerance / detray::unit::mm) + " mm")); dynamic_cast(*cat_nav).add_child( std::make_unique( "Mask tolerance scalar", - std::to_string(config.navigation.mask_tolerance_scalor))); + std::to_string(m_config.navigation.mask_tolerance_scalor))); dynamic_cast(*cat_nav).add_child( std::make_unique( - "Path tolerance", std::to_string(config.navigation.path_tolerance / - detray::unit::um) + - " um")); + "Path tolerance", + std::to_string(m_config.navigation.path_tolerance / + detray::unit::um) + + " um")); dynamic_cast(*cat_nav).add_child( std::make_unique( "Overstep tolerance", - std::to_string(config.navigation.overstep_tolerance / + std::to_string(m_config.navigation.overstep_tolerance / detray::unit::um) + " um")); dynamic_cast(*cat_nav).add_child( std::make_unique( "Search window", - std::to_string(config.navigation.search_window[0]) + " x " + - std::to_string(config.navigation.search_window[1]))); + std::to_string(m_config.navigation.search_window[0]) + " x " + + std::to_string(m_config.navigation.search_window[1]))); std::unique_ptr cat_tsp = std::make_unique("Transport"); dynamic_cast(*cat_tsp).add_child( std::make_unique( - "Min step size", std::to_string(config.stepping.min_stepsize / + "Min step size", std::to_string(m_config.stepping.min_stepsize / detray::unit::mm) + " mm")); dynamic_cast(*cat_tsp).add_child( std::make_unique( "Runge-Kutta tolerance", - std::to_string(config.stepping.rk_error_tol / + std::to_string(m_config.stepping.rk_error_tol / detray::unit::mm) + " mm")); dynamic_cast(*cat_tsp).add_child( std::make_unique( "Max step updates", - std::to_string(config.stepping.max_rk_updates))); + std::to_string(m_config.stepping.max_rk_updates))); dynamic_cast(*cat_tsp).add_child( std::make_unique( "Step size constraint", - std::to_string(config.stepping.step_constraint / + std::to_string(m_config.stepping.step_constraint / detray::unit::mm) + " mm")); dynamic_cast(*cat_tsp).add_child( std::make_unique( - "Path limit", std::to_string(config.stepping.path_limit / + "Path limit", std::to_string(m_config.stepping.path_limit / detray::unit::m) + " m")); dynamic_cast(*cat_tsp).add_child( std::make_unique( - "Min step size", std::to_string(config.stepping.min_stepsize / + "Min step size", std::to_string(m_config.stepping.min_stepsize / detray::unit::mm) + " mm")); dynamic_cast(*cat_tsp).add_child( std::make_unique( "Enable Bethe energy loss", - config.stepping.use_mean_loss ? "yes" : "no")); + m_config.stepping.use_mean_loss ? "yes" : "no")); dynamic_cast(*cat_tsp).add_child( std::make_unique( "Enable covariance transport", - config.stepping.do_covariance_transport ? "yes" : "no")); + m_config.stepping.do_covariance_transport ? "yes" : "no")); - if (config.stepping.do_covariance_transport) { + if (m_config.stepping.do_covariance_transport) { std::unique_ptr cat_cov = std::make_unique("Covariance transport"); dynamic_cast(*cat_cov).add_child( std::make_unique( "Enable energy loss gradient", - config.stepping.use_eloss_gradient ? "yes" : "no")); + m_config.stepping.use_eloss_gradient ? "yes" : "no")); dynamic_cast(*cat_cov).add_child( std::make_unique( "Enable B-field gradient", - config.stepping.use_field_gradient ? "yes" : "no")); + m_config.stepping.use_field_gradient ? "yes" : "no")); dynamic_cast(*cat_tsp).add_child( std::move(cat_cov));