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) 2024-2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Local include(s).
0009 #include "traccc/options/input_data.hpp"
0010 
0011 #include "traccc/examples/utils/printable.hpp"
0012 
0013 // System include(s).
0014 #include <format>
0015 #include <sstream>
0016 #include <stdexcept>
0017 
0018 namespace traccc::opts {
0019 
0020 /// Convenience namespace shorthand
0021 namespace po = boost::program_options;
0022 
0023 /// Type alias for the data format enumeration
0024 using data_format_type = std::string;
0025 /// Name of the data format option
0026 static const char *data_format_option = "input-data-format";
0027 
0028 input_data::input_data() : interface("Input Data Options") {
0029   m_desc.add_options()(
0030       "use-acts-geom-source",
0031       po::value(&use_acts_geom_source)->default_value(use_acts_geom_source),
0032       "Use acts geometry source");
0033   m_desc.add_options()(data_format_option,
0034                        po::value<data_format_type>()->default_value("csv"),
0035                        "Format of the input file(s)");
0036   m_desc.add_options()("input-directory",
0037                        po::value(&directory)->default_value(directory),
0038                        "Directory holding the input files");
0039   m_desc.add_options()("input-events",
0040                        po::value(&events)->default_value(events),
0041                        "Number of input events to process");
0042   m_desc.add_options()("input-skip", po::value(&skip)->default_value(skip),
0043                        "Number of input events to skip");
0044 }
0045 
0046 void input_data::read(const po::variables_map &vm) {
0047   // Decode the input data format.
0048   if (vm.count(data_format_option)) {
0049     const std::string input_format_string =
0050         vm[data_format_option].as<data_format_type>();
0051     if (input_format_string == "csv") {
0052       format = data_format::csv;
0053     } else if (input_format_string == "binary") {
0054       format = data_format::binary;
0055     } else if (input_format_string == "json") {
0056       format = data_format::json;
0057     } else {
0058       throw std::invalid_argument("Unknown input data format");
0059     }
0060   }
0061 }
0062 
0063 std::unique_ptr<configuration_printable> input_data::as_printable() const {
0064   auto cat = std::make_unique<configuration_category>(m_description);
0065 
0066   cat->add_child(std::make_unique<configuration_kv_pair>(
0067       "Use ACTS geometry source", std::format("{}", use_acts_geom_source)));
0068   std::ostringstream format_ss;
0069   format_ss << format;
0070   cat->add_child(std::make_unique<configuration_kv_pair>("Input data format",
0071                                                          format_ss.str()));
0072   cat->add_child(
0073       std::make_unique<configuration_kv_pair>("Input directory", directory));
0074   cat->add_child(std::make_unique<configuration_kv_pair>(
0075       "Number of input events", std::to_string(events)));
0076   cat->add_child(std::make_unique<configuration_kv_pair>(
0077       "Number of skipped events", std::to_string(skip)));
0078 
0079   return cat;
0080 }
0081 
0082 }  // namespace traccc::opts