DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
trgtools
apps
copy_tpstream.cxx
Go to the documentation of this file.
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
main
(
int
argc,
char
const
* argv[])
14
{
15
16
CLI::App app{
"tapipe"
};
17
// argv = app.ensure_utf8(argv);
18
19
std::string input_file_path;
20
app.add_option(
"-i"
, input_file_path,
"Input TPStream file path"
)->required();
21
std::string output_file_path;
22
app.add_option(
"-o"
, output_file_path,
"Output TPStream file path"
)->required();
23
bool
verbose =
false
;
24
app.add_flag(
"-v"
, verbose);
25
CLI11_PARSE(app, argc, argv);
26
27
fmt::print(
"TPStream file: {}\n"
, input_file_path);
28
29
// Pointer to DD hdf5 file
30
std::unique_ptr<hdf5libs::HDF5RawDataFile> input_file, output_file;
31
32
try
{
33
input_file = std::make_unique<hdf5libs::HDF5RawDataFile>(input_file_path);
34
}
catch
(
const
hdf5libs::FileOpenFailed& e) {
35
fmt::print(
"ERROR: failed to open input file '{}'\n"
, input_file_path);
36
std::cerr << e.what() <<
'\n'
;
37
exit(-1);
38
}
39
40
if
(!input_file->is_timeslice_type()) {
41
fmt::print(
"ERROR: input file '{}' not of type 'TimeSlice'\n"
, input_file_path);
42
exit(-1);
43
}
44
45
auto
run_number = input_file->get_attribute<
daqdataformats::run_number_t
>(
"run_number"
);
46
auto
file_index = input_file->get_attribute<
size_t
>(
"file_index"
);
47
// auto creation_timestamp = input_file->get_attribute("creation_timestamp");
48
auto
application_name = input_file->get_attribute<std::string>(
"application_name"
);
49
50
fmt::print(
"Run Number: {}\nFile Index: {}\nApp name: '{}'\n"
, run_number, file_index, application_name);
51
52
try
{
53
output_file =
54
std::make_unique<hdf5libs::HDF5RawDataFile>(output_file_path,
55
input_file->get_attribute<
daqdataformats::run_number_t
>(
"run_number"
),
56
input_file->get_attribute<
size_t
>(
"file_index"
),
57
input_file->get_attribute<std::string>(
"application_name"
),
58
input_file->get_file_layout().get_file_layout_params(),
59
input_file->get_srcid_geoid_map());
60
61
}
catch
(
const
hdf5libs::FileOpenFailed& e) {
62
std::cout <<
"ERROR: failed to open output file"
<< std::endl;
63
std::cerr << e.what() <<
'\n'
;
64
exit(-1);
65
}
66
67
auto
records = input_file->get_all_record_ids();
68
69
for
(
const
auto
& rid : records) {
70
auto
tsl = input_file->get_timeslice(rid);
71
output_file->write(tsl);
72
// Just 1, for testing
73
// break;
74
}
75
76
/* code */
77
return
0;
78
}
HDF5RawDataFile.hpp
main
int main(int argc, char *argv[])
Definition
emu_confgen.cxx:228
dunedaq::daqdataformats::run_number_t
uint32_t run_number_t
Definition
Types.hpp:17
dunedaq
The DUNE-DAQ namespace.
Definition
cib_utilities.cpp:5
Generated on
for DUNE-DAQ by
1.18.0