DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
HDF5TestUtils.hpp
Go to the documentation of this file.
1
11#ifndef HDF5LIBS_TESTUTILITIES_HPP_
12#define HDF5LIBS_TESTUTILITIES_HPP_
13
15
16#include <vector>
17#include <string>
18#include <filesystem>
19#include <regex>
20
21namespace dunedaq {
22
23namespace hdf5libs {
24
25std::vector<std::string>
26get_files_matching_pattern(const std::string& path, const std::string& pattern)
27{
28 std::regex regex_search_pattern(pattern);
29 std::vector<std::string> file_list;
30 for (const auto& entry : std::filesystem::directory_iterator(path)) {
31 if (std::regex_match(entry.path().filename().string(), regex_search_pattern)) {
32 file_list.push_back(entry.path());
33 }
34 }
35 return file_list;
36}
37
38std::vector<std::string>
39delete_files_matching_pattern(const std::string& path, const std::string& pattern)
40{
41 std::regex regex_search_pattern(pattern);
42 std::vector<std::string> file_list;
43 for (const auto& entry : std::filesystem::directory_iterator(path)) {
44 if (std::regex_match(entry.path().filename().string(), regex_search_pattern)) {
45 if (std::filesystem::remove(entry.path())) {
46 file_list.push_back(entry.path());
47 }
48 }
49 }
50 return file_list;
51}
52
53uint64_t
54encode_geoid(int det_id, int crate_id, int slot_id, int stream_id)
55{
56 return (static_cast<uint64_t>(stream_id) << 48) | (static_cast<uint64_t>(slot_id) << 32) |
57 (static_cast<uint64_t>(crate_id) << 16) | det_id;
58}
59
62{
64
67
68 sid.id = 0;
69 map[sid].push_back(encode_geoid(3, 1, 0, 0));
70
71 sid.id = 1;
72 map[sid].push_back(encode_geoid(3, 1, 0, 1));
73
74 sid.id = 3;
75 map[sid].push_back(encode_geoid(3, 1, 1, 0));
76
77 sid.id = 4;
78 map[sid].push_back(encode_geoid(3, 1, 1, 1));
79
80 sid.id = 4;
81 map[sid].push_back(encode_geoid(2, 1, 0, 0));
82
83 sid.id = 5;
84 map[sid].push_back(encode_geoid(2, 1, 0, 1));
85
86 sid.id = 6;
87 map[sid].push_back(encode_geoid(2, 1, 1, 0));
88
89 sid.id = 7;
90 map[sid].push_back(encode_geoid(2, 1, 1, 1));
91
92 return map;
93}
94
95} // namespace hdf5libs
96
97} // namespace dunedaq
98
99#endif // HDF5LIBS_TESTUTILITIES_HPP_
std::map< daqdataformats::SourceID, std::vector< uint64_t > > source_id_geo_id_map_t
HDF5SourceIDHandler::source_id_geo_id_map_t create_srcid_geoid_map()
std::vector< std::string > get_files_matching_pattern(const std::string &path, const std::string &pattern)
uint64_t encode_geoid(int det_id, int crate_id, int slot_id, int stream_id)
std::vector< std::string > delete_files_matching_pattern(const std::string &path, const std::string &pattern)
Including Qt Headers.
SourceID is a generalized representation of the source of a piece of data in the DAQ....
Definition SourceID.hpp:32
Subsystem subsystem
The general subsystem of the source of the data.
Definition SourceID.hpp:69
ID_t id
Unique identifier of the source of the data.
Definition SourceID.hpp:74