Skip to content

Commit

Permalink
Unified the setup of the command line option reading code.
Browse files Browse the repository at this point in the history
Made all structs behave the same way, and introduced print operators
for all of them.
  • Loading branch information
krasznaa committed Mar 5, 2024
1 parent 8d13bd8 commit b341d05
Show file tree
Hide file tree
Showing 21 changed files with 727 additions and 348 deletions.
15 changes: 10 additions & 5 deletions examples/options/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TRACCC library, part of the ACTS project (R&D line)
#
# (c) 2022-2023 CERN for the benefit of the ACTS project
# (c) 2022-2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

Expand All @@ -9,23 +9,28 @@ traccc_add_library( traccc_options options TYPE SHARED
# header files
"include/traccc/options/common_options.hpp"
"include/traccc/options/detector_input_options.hpp"
"include/traccc/options/finding_input_options.hpp"
"include/traccc/options/full_tracking_input_options.hpp"
"include/traccc/options/handle_argument_errors.hpp"
"include/traccc/options/mt_options.hpp"
"include/traccc/options/options.hpp"
"include/traccc/options/particle_gen_options.hpp"
"include/traccc/options/propagation_options.hpp"
"include/traccc/options/finding_input_options.hpp"
"include/traccc/options/seeding_input_options.hpp"
"include/traccc/options/full_tracking_input_options.hpp"
"include/traccc/options/telescope_detector_options.hpp"
"include/traccc/options/throughput_options.hpp"
# source files
"src/options/common_options.cpp"
"src/options/detector_input_options.cpp"
"src/options/finding_input_options.cpp"
"src/options/full_tracking_input_options.cpp"
"src/options/handle_argument_errors.cpp"
"src/options/mt_options.cpp"
"src/options/particle_gen_options.cpp"
"src/options/propagation_options.cpp"
"src/options/seeding_input_options.cpp"
"src/options/full_tracking_input_options.cpp"
"src/options/telescope_detector_options.cpp"
"src/options/throughput_options.cpp"
)
target_link_libraries( traccc_options PUBLIC traccc::io
target_link_libraries( traccc_options PUBLIC traccc::io
traccc::performance Boost::program_options)
46 changes: 35 additions & 11 deletions examples/options/include/traccc/options/common_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,48 @@
// Project include(s)
#include "traccc/io/data_format.hpp"

// Boost
// Boost include(s).
#include <boost/program_options.hpp>

namespace traccc {
// System include(s).
#include <iosfwd>
#include <string>

namespace po = boost::program_options;
namespace traccc {

/// Common options for the example applications
struct common_options {

/// The input data format
traccc::data_format input_data_format = traccc::data_format::csv;
/// The data input directory
std::string input_directory;
/// The number of events to process
unsigned int events;
int skip;
unsigned short target_cells_per_partition;
bool check_performance;
bool perform_ambiguity_resolution;
/// The number of events to skip
unsigned int skip = 0;
/// The number of cells to merge in a partition
unsigned short target_cells_per_partition = 1024;
/// Whether to check the reconstructions performance
bool check_performance = false;
/// Whether to perform ambiguity resolution
bool perform_ambiguity_resolution = true;

/// Constructor on top of a common @c program_options object
///
/// @param desc The program options to add to
///
common_options(boost::program_options::options_description& desc);

/// Read/process the command line options
///
/// @param vm The command line options to interpret/read
///
void read(const boost::program_options::variables_map& vm);

}; // struct common_options

common_options(po::options_description& desc);
void read(const po::variables_map& vm);
};
/// Printout helper for @c traccc::common_options
std::ostream& operator<<(std::ostream& out, const common_options& opt);

} // namespace traccc
} // namespace traccc
38 changes: 30 additions & 8 deletions examples/options/include/traccc/options/detector_input_options.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Boost
#pragma once

// Boost include(s).
#include <boost/program_options.hpp>

namespace traccc {
// System include(s).
#include <iosfwd>
#include <string>

namespace po = boost::program_options;
namespace traccc {

/// Options for the detector description
struct detector_input_options {

/// The file containing the detector description
std::string detector_file;
/// The file containing the material description
std::string material_file;
/// The file containing the surface grid description
std::string grid_file;

detector_input_options(po::options_description& desc);
void read(const po::variables_map& vm);
};
/// Constructor on top of a common @c program_options object
///
/// @param desc The program options to add to
///
detector_input_options(boost::program_options::options_description& desc);

/// Read/process the command line options
///
/// @param vm The command line options to interpret/read
///
void read(const boost::program_options::variables_map& vm);

}; // struct detector_input_options

/// Printout helper for @c traccc::detector_input_options
std::ostream& operator<<(std::ostream& out, const detector_input_options& opt);

} // namespace traccc
} // namespace traccc
71 changes: 34 additions & 37 deletions examples/options/include/traccc/options/finding_input_options.hpp
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "traccc/options/options.hpp"

// Boost
// Boost include(s).
#include <boost/program_options.hpp>

// System include(s).
#include <iosfwd>
#include <limits>

namespace traccc {

namespace po = boost::program_options;

template <typename scalar_t>
struct finding_input_config {
Reals<unsigned int, 2> track_candidates_range;
scalar_t chi2_max;
unsigned int nmax_per_seed;

finding_input_config(po::options_description& desc) {

desc.add_options()("track-candidates-range",
po::value<Reals<unsigned int, 2>>()
->value_name("MIN:MAX")
->default_value({3, 100}),
"Range of track candidates number");
desc.add_options()(
"chi2-max",
po::value<scalar_t>()->value_name("chi2-max")->default_value(30.f),
"Maximum Chi suqare that measurements can be included in the "
"track");
desc.add_options()(
"nmax_per_seed",
po::value<unsigned int>()
->value_name("nmax_per_seed")
->default_value(std::numeric_limits<unsigned int>::max()),
"Maximum number of branches which each initial seed can have at a "
"step.");
}
void read(const po::variables_map& vm) {
track_candidates_range =
vm["track-candidates-range"].as<Reals<unsigned int, 2>>();
chi2_max = vm["chi2-max"].as<scalar_t>();
nmax_per_seed = vm["nmax_per_seed"].as<unsigned int>();
}
};
/// Configuration for track finding
struct finding_input_options {

/// Number of track candidates per seed
Reals<unsigned int, 2> track_candidates_range{3, 100};
/// Maximum chi2 for a measurement to be included in the track
float chi2_max = 30.f;
/// Maximum number of branches which each initial seed can have at a step
unsigned int nmax_per_seed = std::numeric_limits<unsigned int>::max();

/// Constructor on top of a common @c program_options object
///
/// @param desc The program options to add to
///
finding_input_options(boost::program_options::options_description& desc);

/// Read/process the command line options
///
/// @param vm The command line options to interpret/read
///
void read(const boost::program_options::variables_map& vm);

}; // struct finding_input_options

/// Printout helper for @c traccc::finding_input_options
std::ostream& operator<<(std::ostream& out, const finding_input_options& opt);

} // namespace traccc
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Boost
#pragma once

// Boost include(s).
#include <boost/program_options.hpp>

// System include(s).
#include <iosfwd>
#include <string>

namespace traccc {

namespace po = boost::program_options;
/// Configuration for a full tracking chain
struct full_tracking_input_options {

struct full_tracking_input_config {
std::string detector_file;
/// The digitization configuration file
std::string digitization_config_file;

full_tracking_input_config(po::options_description& desc);
void read(const po::variables_map& vm);
};
/// Constructor on top of a common @c program_options object
///
/// @param desc The program options to add to
///
full_tracking_input_options(
boost::program_options::options_description& desc);

/// Read/process the command line options
///
/// @param vm The command line options to interpret/read
///
void read(const boost::program_options::variables_map& vm);

}; // struct full_tracking_input_config

/// Printout helper for @c traccc::full_tracking_input_options
std::ostream& operator<<(std::ostream& out,
const full_tracking_input_options& opt);

} // namespace traccc
} // namespace traccc
4 changes: 2 additions & 2 deletions examples/options/include/traccc/options/mt_options.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand Down Expand Up @@ -28,7 +28,7 @@ struct mt_options {
///
mt_options(boost::program_options::options_description& desc);

/// Read the command line options
/// Read/process the command line options
///
/// @param vm The command line options to interpret/read
///
Expand Down
Loading

0 comments on commit b341d05

Please sign in to comment.