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
main
(
int
argc,
char
const
*argv[])
13
{
14
15
CLI::App app{
"tapipe"
};
16
// argv = app.ensure_utf8(argv);
17
18
std::string input_file_path;
19
app.add_option(
"-i"
, input_file_path,
"Input TPStream file path"
)->required();
20
std::string output_file_path;
21
app.add_option(
"-o"
, output_file_path,
"Output TPStream file path"
)->required();
22
bool
verbose =
false
;
23
app.add_flag(
"-v"
, verbose);
24
CLI11_PARSE(app, argc, argv);
25
26
fmt::print(
"TPStream file: {}\n"
, input_file_path);
27
28
// Pointer to DD hdf5 file
29
std::unique_ptr<hdf5libs::HDF5RawDataFile> input_file, output_file;
30
31
try
{
32
input_file = std::make_unique<hdf5libs::HDF5RawDataFile>(input_file_path);
33
}
catch
(
const
hdf5libs::FileOpenFailed& e) {
34
fmt::print(
"ERROR: failed to open input file '{}'\n"
, input_file_path);
35
std::cerr << e.what() <<
'\n'
;
36
exit(-1);
37
}
38
39
if
(!input_file->is_timeslice_type()) {
40
fmt::print(
"ERROR: input file '{}' not of type 'TimeSlice'\n"
, input_file_path);
41
exit(-1);
42
}
43
44
auto
run_number = input_file->get_attribute<
daqdataformats::run_number_t
>(
"run_number"
);
45
auto
file_index = input_file->get_attribute<
size_t
>(
"file_index"
);
46
// auto creation_timestamp = input_file->get_attribute("creation_timestamp");
47
auto
application_name = input_file->get_attribute<std::string>(
"application_name"
);
48
49
fmt::print(
"Run Number: {}\nFile Index: {}\nApp name: '{}'\n"
, run_number, file_index, application_name);
50
51
try
{
52
output_file = std::make_unique<hdf5libs::HDF5RawDataFile>(
53
output_file_path,
54
input_file->get_attribute<
daqdataformats::run_number_t
>(
"run_number"
),
55
input_file->get_attribute<
size_t
>(
"file_index"
),
56
input_file->get_attribute<std::string>(
"application_name"
),
57
input_file->get_file_layout().get_file_layout_params(),
58
input_file->get_srcid_geoid_map()
59
);
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
77
/* code */
78
return
0;
79
}
HDF5RawDataFile.hpp
main
int main(int argc, char const *argv[])
Definition
copy_tpstream.cxx:12
dunedaq::daqdataformats::run_number_t
uint32_t run_number_t
Definition
Types.hpp:17
dunedaq
Including Qt Headers.
Definition
module.cpp:16
Generated on
for DUNE-DAQ by
1.17.0