LCOV - code coverage report
Current view: top level - trgtools/apps - copy_tpstream.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 45 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 1 0

            Line data    Source code
       1              : #include "CLI/App.hpp"
       2              : #include "CLI/Config.hpp"
       3              : #include "CLI/Formatter.hpp"
       4              : 
       5              : #include <fmt/core.h>
       6              : #include <fmt/format.h>
       7              : 
       8              : #include "hdf5libs/HDF5RawDataFile.hpp"
       9              : 
      10              : using namespace dunedaq;
      11              : 
      12              : int
      13            0 : main(int argc, char const* argv[])
      14              : {
      15              : 
      16            0 :   CLI::App app{ "tapipe" };
      17              :   // argv = app.ensure_utf8(argv);
      18              : 
      19            0 :   std::string input_file_path;
      20            0 :   app.add_option("-i", input_file_path, "Input TPStream file path")->required();
      21            0 :   std::string output_file_path;
      22            0 :   app.add_option("-o", output_file_path, "Output TPStream file path")->required();
      23            0 :   bool verbose = false;
      24            0 :   app.add_flag("-v", verbose);
      25            0 :   CLI11_PARSE(app, argc, argv);
      26              : 
      27            0 :   fmt::print("TPStream file: {}\n", input_file_path);
      28              : 
      29              :   // Pointer to DD hdf5 file
      30            0 :   std::unique_ptr<hdf5libs::HDF5RawDataFile> input_file, output_file;
      31              : 
      32            0 :   try {
      33            0 :     input_file = std::make_unique<hdf5libs::HDF5RawDataFile>(input_file_path);
      34            0 :   } catch (const hdf5libs::FileOpenFailed& e) {
      35            0 :     fmt::print("ERROR: failed to open input file '{}'\n", input_file_path);
      36            0 :     std::cerr << e.what() << '\n';
      37            0 :     exit(-1);
      38            0 :   }
      39              : 
      40            0 :   if (!input_file->is_timeslice_type()) {
      41            0 :     fmt::print("ERROR: input file '{}' not of type 'TimeSlice'\n", input_file_path);
      42            0 :     exit(-1);
      43              :   }
      44              : 
      45            0 :   auto run_number = input_file->get_attribute<daqdataformats::run_number_t>("run_number");
      46            0 :   auto file_index = input_file->get_attribute<size_t>("file_index");
      47              :   // auto creation_timestamp = input_file->get_attribute("creation_timestamp");
      48            0 :   auto application_name = input_file->get_attribute<std::string>("application_name");
      49              : 
      50            0 :   fmt::print("Run Number: {}\nFile Index: {}\nApp name: '{}'\n", run_number, file_index, application_name);
      51              : 
      52            0 :   try {
      53            0 :     output_file =
      54            0 :       std::make_unique<hdf5libs::HDF5RawDataFile>(output_file_path,
      55            0 :                                                   input_file->get_attribute<daqdataformats::run_number_t>("run_number"),
      56            0 :                                                   input_file->get_attribute<size_t>("file_index"),
      57            0 :                                                   input_file->get_attribute<std::string>("application_name"),
      58            0 :                                                   input_file->get_file_layout().get_file_layout_params(),
      59            0 :                                                   input_file->get_srcid_geoid_map());
      60              : 
      61            0 :   } catch (const hdf5libs::FileOpenFailed& e) {
      62            0 :     std::cout << "ERROR: failed to open output file" << std::endl;
      63            0 :     std::cerr << e.what() << '\n';
      64            0 :     exit(-1);
      65            0 :   }
      66              : 
      67            0 :   auto records = input_file->get_all_record_ids();
      68              : 
      69            0 :   for (const auto& rid : records) {
      70            0 :     auto tsl = input_file->get_timeslice(rid);
      71            0 :     output_file->write(tsl);
      72              :     // Just 1, for testing
      73              :     // break;
      74            0 :   }
      75              : 
      76              :   /* code */
      77            0 :   return 0;
      78            0 : }
        

Generated by: LCOV version 2.0-1