Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:13

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2022-2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Library include(s).
0009 #include "traccc/options/throughput.hpp"
0010 
0011 #include "traccc/examples/utils/printable.hpp"
0012 
0013 // System include(s).
0014 #include <format>
0015 
0016 namespace traccc::opts {
0017 
0018 /// Convenience namespace shorthand
0019 namespace po = boost::program_options;
0020 
0021 /// Type alias for the reconstruction stage enumeration
0022 using stage_type = std::string;
0023 /// Name of the reconstruction stage option
0024 static const char* stage_option = "reco-stage";
0025 
0026 throughput::throughput() : interface("Throughput Measurement Options") {
0027   m_desc.add_options()(stage_option,
0028                        po::value<stage_type>()->default_value("full"),
0029                        "Reconstruction stage to run (\"seeding\" or \"full\")");
0030   m_desc.add_options()(
0031       "processed-events",
0032       po::value(&processed_events)->default_value(processed_events),
0033       "Number of events to process");
0034   m_desc.add_options()(
0035       "cold-run-events",
0036       po::value(&cold_run_events)->default_value(cold_run_events),
0037       "Number of events to run 'cold'");
0038   m_desc.add_options()("deterministic",
0039                        po::value<bool>(&deterministic_event_order)
0040                            ->default_value(deterministic_event_order),
0041                        "Process events in deterministic order");
0042   m_desc.add_options()("random-seed",
0043                        po::value(&random_seed)->default_value(random_seed),
0044                        "Seed for event randomization (0 to use time)");
0045   m_desc.add_options()(
0046       "log-file", po::value(&log_file),
0047       "File where result logs will be printed (in append mode).");
0048 }
0049 
0050 void throughput::read(const po::variables_map& vm) {
0051   // Decode the input data format.
0052   if (vm.count(stage_option)) {
0053     const std::string stage_string = vm[stage_option].as<stage_type>();
0054     if (stage_string == "full") {
0055       reco_stage = stage::full;
0056     } else if (stage_string == "seeding") {
0057       reco_stage = stage::seeding;
0058     } else {
0059       throw std::invalid_argument("Unknown reconstruction stage");
0060     }
0061   }
0062 }
0063 
0064 std::unique_ptr<configuration_printable> throughput::as_printable() const {
0065   auto cat = std::make_unique<configuration_category>(m_description);
0066 
0067   std::string reco_stage_string;
0068   switch (reco_stage) {
0069     case stage::seeding:
0070       reco_stage_string = "seeding";
0071       break;
0072     case stage::full:
0073       reco_stage_string = "full";
0074       break;
0075     default:
0076       reco_stage_string = "unknown";
0077       break;
0078   }
0079   cat->add_child(std::make_unique<configuration_kv_pair>("Reconstruction stage",
0080                                                          reco_stage_string));
0081   cat->add_child(std::make_unique<configuration_kv_pair>(
0082       "Cold run events", std::to_string(cold_run_events)));
0083   cat->add_child(std::make_unique<configuration_kv_pair>(
0084       "Processed events", std::to_string(processed_events)));
0085   cat->add_child(std::make_unique<configuration_kv_pair>("Log file", log_file));
0086   cat->add_child(std::make_unique<configuration_kv_pair>(
0087       "Deterministic ordering", std::format("{}", deterministic_event_order)));
0088   cat->add_child(std::make_unique<configuration_kv_pair>(
0089       "Random seed",
0090       random_seed == 0 ? "time-based" : std::to_string(random_seed)));
0091 
0092   return cat;
0093 }
0094 
0095 }  // namespace traccc::opts