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/output_data.hpp"
0010 
0011 #include "traccc/examples/utils/printable.hpp"
0012 
0013 // System include(s).
0014 #include <sstream>
0015 #include <stdexcept>
0016 
0017 namespace traccc::opts {
0018 
0019 /// Convenience namespace shorthand
0020 namespace po = boost::program_options;
0021 
0022 /// Type alias for the data format enumeration
0023 using data_format_type = std::string;
0024 /// Name of the data format option
0025 static const char* data_format_option = "output-data-format";
0026 
0027 output_data::output_data(traccc::data_format f, std::string_view d)
0028     : interface("Output Data Options"), format(f), directory(d) {
0029   m_desc.add_options()(data_format_option,
0030                        po::value<data_format_type>()->default_value("csv"),
0031                        "Format of the output file(s)");
0032   m_desc.add_options()("output-directory",
0033                        po::value(&directory)->default_value(directory),
0034                        "Directory to store the output files");
0035 }
0036 
0037 void output_data::read(const boost::program_options::variables_map& vm) {
0038   // Decode the input data format.
0039   if (vm.count(data_format_option)) {
0040     const std::string input_format_string =
0041         vm[data_format_option].as<data_format_type>();
0042     if (input_format_string == "csv") {
0043       format = data_format::csv;
0044     } else if (input_format_string == "binary") {
0045       format = data_format::binary;
0046     } else if (input_format_string == "json") {
0047       format = data_format::json;
0048     } else if (input_format_string == "obj") {
0049       format = data_format::obj;
0050     } else {
0051       throw std::invalid_argument("Unknown input data format");
0052     }
0053   }
0054 }
0055 
0056 std::unique_ptr<configuration_printable> output_data::as_printable() const {
0057   auto cat = std::make_unique<configuration_category>(m_description);
0058 
0059   std::ostringstream format_ss;
0060   format_ss << format;
0061   cat->add_child(std::make_unique<configuration_kv_pair>("Output data format",
0062                                                          format_ss.str()));
0063   cat->add_child(
0064       std::make_unique<configuration_kv_pair>("Output directory", directory));
0065 
0066   return cat;
0067 }
0068 
0069 }  // namespace traccc::opts