DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
HDF5RawDataFile.hpp
Go to the documentation of this file.
1
10
11#ifndef HDF5LIBS_INCLUDE_HDF5LIBS_HDF5RAWDATAFILE_HPP_
12#define HDF5LIBS_INCLUDE_HDF5LIBS_HDF5RAWDATAFILE_HPP_
13
14// DUNE-DAQ
17
21#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
22
23// External Packages
24#include <highfive/H5DataSet.hpp>
25#include <highfive/H5File.hpp>
26#include <highfive/H5Group.hpp>
27#include <highfive/H5Object.hpp>
28#include <nlohmann/json.hpp>
29
30// System
31#include <filesystem>
32#include <functional>
33#include <iostream>
34#include <map>
35#include <memory>
36#include <optional>
37#include <set>
38#include <string>
39#include <sys/statvfs.h>
40#include <utility>
41#include <variant>
42#include <vector>
43
44namespace dunedaq {
45
47 DeprecatedUsage,
48 func_name << " is deprecated. " << message,
49 ((std::string)func_name)((std::string)message))
50
53 "Issue when opening file " << file << ": " << message,
54 ((std::string)file)((std::string)message))
55
57 IncompatibleOpenFlags,
58 "Issue when opening file " << file << ": "
59 << "bad open flags " << open_flags,
60 ((std::string)file)((unsigned)open_flags))
61
63 MissingFileLayout,
64 "No DUNEDAQ FileLayout information available." << " Assigning version " << version,
65 ((uint32_t)version)) // NOLINT(build/unsigned)
66
68 IncompatibleFileLayoutVersion,
69 "FileLayout version incompatibility. Found version " << version << " but min allowed version is "
70 << min_allowed << " and max allowed version is "
71 << max_allowed,
72 ((uint32_t)version)((uint32_t)min_allowed)((uint32_t)max_allowed)) // NOLINT(build/unsigned)
73
75 BadRecordType,
76 "Record type attribute " << rt_attr << " does not match file layout config record name prefix "
77 << rt_fl,
78 ((std::string)rt_attr)((std::string)rt_fl))
79
81 WrongRecordTypeRequested,
82 "Record type requested " << rname << " does not match file layout config record name prefix "
83 << rt_fl,
84 ((std::string)rname)((std::string)rt_fl))
85
87 RecordIDNotFound,
88 "Record ID with record number=" << rec_num << " and sequence number=" << seq_num << " not found.",
89 ((uint64_t)rec_num)((uint16_t)seq_num)) // NOLINT(build/unsigned)
90
91ERS_DECLARE_ISSUE(hdf5libs, InvalidHDF5Group, "Group " << name << " is invalid.", ((std::string)name))
92
94 InvalidHDF5Dataset,
95 "The HDF5 Dataset associated with name \"" << data_set << "\" is invalid. (file = " << filename
96 << ")",
97 ((std::string)data_set)((std::string)filename))
98
99ERS_DECLARE_ISSUE(hdf5libs, InvalidHDF5Attribute, "Attribute " << name << " not found.", ((std::string)name))
100
101ERS_DECLARE_ISSUE(hdf5libs, HDF5AttributeExists, "Attribute " << name << " already exists.", ((std::string)name))
102
104 InvalidFragmentTypeString,
105 "Fragment type name \"" << name << "\" does not map to a valid type.",
106 ((std::string)name))
107
109 InvalidSubdetectorString,
110 "Subdetector name \"" << name << "\" does not map to a valid detector ID.",
111 ((std::string)name))
112
113namespace hdf5libs {
114
119class HDF5RawDataFile
120{
121
122public:
123 enum
124 {
125 TLVL_BASIC = 2,
126 TLVL_FILE_SIZE = 5
127 };
128
129 // define a record number type
130 // that is a pair of the trigger record or timeslice number and sequence number
131 typedef std::pair<uint64_t, daqdataformats::sequence_number_t> record_id_t; // NOLINT(build/unsigned)
132 typedef std::set<record_id_t, std::less<>> record_id_set;
133
134 inline static const std::string s_inprogress_suffix = ".writing";
135
136 // constructor for writing
137 HDF5RawDataFile(std::string file_name,
139 size_t file_index,
140 std::string application_name,
141 HDF5FileLayoutParameters fl_params,
142 HDF5SourceIDHandler::source_id_geo_id_map_t srcid_geoid_map,
143 unsigned compression_level = 0,
144 std::string inprogress_filename_suffix = s_inprogress_suffix,
145 unsigned open_flags = HighFive::File::Create);
146
147 // constructor for reading and optional writing
148 explicit HDF5RawDataFile(const std::string& file_name, bool allow_writing = false);
149
150 ~HDF5RawDataFile();
151
152 std::string get_file_name() const { return m_file_ptr->getName(); }
153 std::string get_file_name_extension() const { return "hdf5"; }
154
155 size_t get_recorded_size() const noexcept { return m_recorded_size; }
156 size_t get_uncompressed_raw_data_size() const noexcept { return m_uncompressed_raw_data_size; }
157 size_t get_total_file_size() const noexcept { return m_total_file_size; }
158 unsigned get_compression_level() const noexcept { return m_compression_level; }
159
160 std::string get_record_type() const noexcept { return m_record_type; }
161
162 bool is_trigger_record_type() const noexcept { return m_record_type.compare("TriggerRecord") == 0; }
163 bool is_timeslice_type() const noexcept { return m_record_type.compare("TimeSlice") == 0; }
164
165 const HDF5FileLayout& get_file_layout() const { return *(m_file_layout_ptr.get()); }
166
167 uint32_t get_version() const // NOLINT(build/unsigned)
168 {
169 return m_file_layout_ptr->get_version();
170 }
171
172 // basic data writing methods
173public:
174 void write(const daqdataformats::TriggerRecord& tr);
175 void write(const daqdataformats::TimeSlice& ts);
176
177private:
178 HighFive::Group write(const daqdataformats::TriggerRecordHeader& trh,
179 HDF5SourceIDHandler::source_id_path_map_t& path_map);
180 HighFive::Group write(const daqdataformats::TimeSliceHeader& tsh,
181 HDF5SourceIDHandler::source_id_path_map_t& path_map);
182 void write(const daqdataformats::Fragment& frag, HDF5SourceIDHandler::source_id_path_map_t& path_map);
183
184public:
185 // attribute writers/getters
186 template<typename T>
187 void write_attribute(std::string name, T value);
188 template<typename T>
189 void write_attribute(HighFive::Group& grp, const std::string& name, T value);
190 template<typename T>
191 void write_attribute(HighFive::DataSet& dset, const std::string& name, T value);
192
193 std::vector<std::string> get_attribute_names();
194 template<typename T>
195 T get_attribute(const std::string& name);
196 template<typename T>
197 T get_attribute(const HighFive::Group& grp, const std::string& name);
198 template<typename T>
199 T get_attribute(const HighFive::DataSet& dset, std::string name);
200 // For backwards compatibility with files created before compression_level existed
201 template<typename T>
202 T get_attribute_if_exists(const std::string& name, const T& default_value);
203
204 std::vector<std::string> get_dataset_paths(std::string top_level_group_name = "");
205
206 record_id_set get_all_record_ids();
207 record_id_set get_all_trigger_record_ids();
208 record_id_set get_all_timeslice_ids();
209
210 std::set<uint64_t> get_all_record_numbers(); // NOLINT(build/unsigned)
211 std::set<daqdataformats::trigger_number_t> get_all_trigger_record_numbers();
212 std::set<daqdataformats::timeslice_number_t> get_all_timeslice_numbers();
213
214 std::vector<std::string> get_record_header_dataset_paths();
215 std::vector<std::string> get_trigger_record_header_dataset_paths();
216 std::vector<std::string> get_timeslice_header_dataset_paths();
217
218 std::string get_record_header_dataset_path(const record_id_t& rid);
219 std::string get_record_header_dataset_path(const uint64_t rec_num, // NOLINT (build/unsigned)
220 const daqdataformats::sequence_number_t seq_num = 0);
221 std::string get_trigger_record_header_dataset_path(const record_id_t& rid);
222 std::string get_trigger_record_header_dataset_path(const daqdataformats::trigger_number_t trig_num,
223 const daqdataformats::sequence_number_t seq_num = 0);
224 std::string get_timeslice_header_dataset_path(const record_id_t& rid);
225 std::string get_timeslice_header_dataset_path(const daqdataformats::timeslice_number_t trig_num);
226
227 // get all fragment dataset paths
228 std::vector<std::string> get_all_fragment_dataset_paths();
229
230 // get all fragment dataset paths for given record ID
231 std::vector<std::string> get_fragment_dataset_paths(const record_id_t& rid);
232 std::vector<std::string> get_fragment_dataset_paths(const uint64_t rec_num, // NOLINT (build/unsigned)
233 const daqdataformats::sequence_number_t seq_num = 0);
234
235 // get all fragment dataset paths for a Subsystem
236 std::vector<std::string> get_fragment_dataset_paths(const daqdataformats::SourceID::Subsystem subsystem);
237 std::vector<std::string> get_fragment_dataset_paths(const std::string& subsystem_name);
238
239 // get all fragment dataset paths for a record ID and Subsystem
240 std::vector<std::string> get_fragment_dataset_paths(const record_id_t& rid,
242 std::vector<std::string> get_fragment_dataset_paths(const record_id_t& rid, const std::string& subsystem_name);
243
244#if 0
245 // get all fragment dataset paths for a SourceID
246 std::vector<std::string> get_fragment_dataset_paths(const daqdataformats::SourceID& source_id);
247 std::vector<std::string> get_fragment_dataset_paths(const daqdataformats::SourceID::Subsystem type,
248 const uint32_t id); // NOLINT(build/unsigned)
249 std::vector<std::string> get_fragment_dataset_paths(const std::string& typestring,
250 const uint32_t id); // NOLINT(build/unsigned)
251
252 // get a list of all the source ids from a list of fragment dataset paths
253 std::set<daqdataformats::SourceID> get_source_ids(std::vector<std::string> const& frag_dataset_paths);
254#endif
255
256 HDF5SourceIDHandler::source_id_geo_id_map_t get_srcid_geoid_map() const;
257
258 // get a list of all the geo ids anywhere in the file
259 std::set<uint64_t> get_all_geo_ids() const; // NOLINT(build/unsigned)
260
261 // get GeoIDs in a record
262 std::set<uint64_t> get_geo_ids(const record_id_t& rid); // NOLINT(build/unsigned)
263 std::set<uint64_t> get_geo_ids(const uint64_t rec_num, // NOLINT(build/unsigned)
264 const daqdataformats::sequence_number_t seq_num = 0)
265 {
266 return get_geo_ids(std::make_pair(rec_num, seq_num));
267 }
268 std::set<uint64_t> get_geo_ids_for_subdetector(const record_id_t& rid, // NOLINT(build/unsigned)
270 std::set<uint64_t> get_geo_ids_for_subdetector(const uint64_t rec_num, // NOLINT(build/unsigned)
273 {
274 return get_geo_ids_for_subdetector(std::make_pair(rec_num, seq_num), subdet);
275 }
276 std::set<uint64_t> get_geo_ids_for_subdetector(const record_id_t& rid, // NOLINT(build/unsigned)
277 const std::string& subdet_name)
278 {
280 return get_geo_ids_for_subdetector(rid, subdet);
281 }
282 std::set<uint64_t> get_geo_ids_for_subdetector(const uint64_t rec_num, // NOLINT(build/unsigned)
284 const std::string& subdet_name)
285 {
286 return get_geo_ids_for_subdetector(std::make_pair(rec_num, seq_num), subdet_name);
287 }
288
289 // get SourceIDs in a record
290 std::set<daqdataformats::SourceID> get_source_ids(const record_id_t& rid);
291 std::set<daqdataformats::SourceID> get_source_ids(const uint64_t rec_num, // NOLINT(build/unsigned)
292 const daqdataformats::sequence_number_t seq_num = 0)
293 {
294 return get_source_ids(std::make_pair(rec_num, seq_num));
295 }
296
297 daqdataformats::SourceID get_record_header_source_id(const record_id_t& rid);
298 daqdataformats::SourceID get_record_header_source_id(const uint64_t rec_num, // NOLINT(build/unsigned)
299 const daqdataformats::sequence_number_t seq_num = 0)
300 {
301 return get_record_header_source_id(std::make_pair(rec_num, seq_num));
302 }
303
304 std::set<daqdataformats::SourceID> get_fragment_source_ids(const record_id_t& rid);
305 std::set<daqdataformats::SourceID> get_fragment_source_ids(const uint64_t rec_num, // NOLINT(build/unsigned)
306 const daqdataformats::sequence_number_t seq_num = 0)
307 {
308 return get_fragment_source_ids(std::make_pair(rec_num, seq_num));
309 }
310
311 // get SourceIDs for given subsystem in a record
312 std::set<daqdataformats::SourceID> get_source_ids_for_subsystem(const record_id_t& rid,
314 std::set<daqdataformats::SourceID> get_source_ids_for_subsystem(const record_id_t& rid,
315 const std::string& subsystem_name)
316 {
318 return get_source_ids_for_subsystem(rid, subsys);
319 }
320 std::set<daqdataformats::SourceID> get_source_ids_for_subsystem(const uint64_t rec_num, // NOLINT(build/unsigned)
323 {
324 return get_source_ids_for_subsystem(std::make_pair(rec_num, seq_num), subsystem);
325 }
326 std::set<daqdataformats::SourceID> get_source_ids_for_subsystem(const uint64_t rec_num, // NOLINT(build/unsigned)
328 const std::string& subsystem_name)
329 {
330 return get_source_ids_for_subsystem(std::make_pair(rec_num, seq_num), subsystem_name);
331 }
332
333 // get SourceIDs for given fragment type in a record
334 std::set<daqdataformats::SourceID> get_source_ids_for_fragment_type(const record_id_t& rid,
335 const daqdataformats::FragmentType frag_type);
336 std::set<daqdataformats::SourceID> get_source_ids_for_fragment_type(const record_id_t& rid,
337 const std::string& frag_type_name)
338 {
341 throw InvalidFragmentTypeString(ERS_HERE, frag_type_name);
342 return get_source_ids_for_fragment_type(rid, frag_type);
343 }
344 std::set<daqdataformats::SourceID> get_source_ids_for_fragment_type(const uint64_t rec_num, // NOLINT(build/unsigned)
346 const daqdataformats::FragmentType frag_type)
347 {
348 return get_source_ids_for_fragment_type(std::make_pair(rec_num, seq_num), frag_type);
349 }
350 std::set<daqdataformats::SourceID> get_source_ids_for_fragment_type(const uint64_t rec_num, // NOLINT(build/unsigned)
352 const std::string& frag_type_name)
353 {
354 return get_source_ids_for_fragment_type(std::make_pair(rec_num, seq_num), frag_type_name);
355 }
356
357 // get SourceIDs for given fragment type and subdetector in a record
358 std::set<daqdataformats::SourceID> get_source_ids_for_fragtype_and_subdetector(const record_id_t& rid,
359 const std::string& frag_type_name,
360 const std::string& subdet_name);
361
362 // get SourceIDs for given subdetector in a record
363 std::set<daqdataformats::SourceID> get_source_ids_for_subdetector(const record_id_t& rid,
365 std::set<daqdataformats::SourceID> get_source_ids_for_subdetector(const record_id_t& rid,
366 const std::string& subdet_name)
367 {
369 return get_source_ids_for_subdetector(rid, subdet);
370 }
371 std::set<daqdataformats::SourceID> get_source_ids_for_subdetector(const uint64_t rec_num, // NOLINT(build/unsigned)
374 {
375 return get_source_ids_for_subdetector(std::make_pair(rec_num, seq_num), subdet);
376 }
377 std::set<daqdataformats::SourceID> get_source_ids_for_subdetector(const uint64_t rec_num, // NOLINT(build/unsigned)
379 const std::string& subdet_name)
380 {
381 return get_source_ids_for_subdetector(std::make_pair(rec_num, seq_num), subdet_name);
382 }
383
384#if 0
385 // get SourceIDs for a system type
386 std::set<daqdataformats::SourceID> get_source_ids(const daqdataformats::SourceID::Subsystem type)
387 {
388 return get_source_ids(get_fragment_dataset_paths(type));
389 }
390 std::set<daqdataformats::SourceID> get_source_ids(const std::string& typestring)
391 {
392 return get_source_ids(get_fragment_dataset_paths(typestring));
393 }
394#endif
395
396 std::unique_ptr<char[]> get_dataset_raw_data(const std::string& dataset_path);
397
398 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const std::string& dataset_name);
399 std::unique_ptr<daqdataformats::TriggerRecordHeader> get_trh_ptr(const std::string& dataset_name);
400 std::unique_ptr<daqdataformats::TimeSliceHeader> get_tsh_ptr(const std::string& dataset_name);
401
402 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const record_id_t& rid,
403 const daqdataformats::SourceID& source_id);
404 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const uint64_t rec_num, // NOLINT(build/unsigned)
406 const daqdataformats::SourceID& source_id);
407 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const record_id_t& rid,
409 const uint32_t id); // NOLINT(build/unsigned)
410 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const uint64_t rec_num, // NOLINT(build/unsigned)
413 const uint32_t id); // NOLINT(build/unsigned)
414 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const record_id_t& rid,
415 const std::string& typestring,
416 const uint32_t id); // NOLINT(build/unsigned)
417 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const uint64_t rec_num, // NOLINT(build/unsigned)
419 const std::string& typestring,
420 const uint32_t id); // NOLINT(build/unsigned)
421
422 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const record_id_t& rid,
423 const uint64_t geo_id); // NOLINT(build/unsigned)
424 std::unique_ptr<daqdataformats::Fragment> get_frag_ptr(const uint64_t rec_num, // NOLINT(build/unsigned)
426 const uint64_t geo_id); // NOLINT(build/unsigned)
427
428 std::unique_ptr<daqdataformats::TriggerRecordHeader> get_trh_ptr(const record_id_t& rid);
429 std::unique_ptr<daqdataformats::TriggerRecordHeader> get_trh_ptr(const daqdataformats::trigger_number_t trig_num,
430 const daqdataformats::sequence_number_t seq_num = 0)
431 {
432 return get_trh_ptr(std::make_pair(trig_num, seq_num));
433 }
434
435 std::unique_ptr<daqdataformats::TimeSliceHeader> get_tsh_ptr(const record_id_t& rid);
436 std::unique_ptr<daqdataformats::TimeSliceHeader> get_tsh_ptr(const daqdataformats::timeslice_number_t ts_num)
437 {
438 return get_tsh_ptr(std::make_pair(ts_num, 0));
439 }
440
441 daqdataformats::TriggerRecord get_trigger_record(const record_id_t& rid);
442 daqdataformats::TriggerRecord get_trigger_record(const daqdataformats::trigger_number_t trig_num,
443 const daqdataformats::sequence_number_t seq_num = 0)
444 {
445 return get_trigger_record(std::make_pair(trig_num, seq_num));
446 }
447
449 daqdataformats::TimeSlice get_timeslice(const record_id_t& rid) { return get_timeslice(rid.first); }
450
451 std::vector<uint64_t> get_geo_ids_for_source_id(const record_id_t& rid, // NOLINT(build/unsigned)
452 const daqdataformats::SourceID& source_id);
453
454 daqdataformats::SourceID get_source_id_for_geo_id(const record_id_t& rid,
455 const uint64_t geo_id); // NOLINT(build/unsigned)
456
457 bool timeslice_already_exists(const daqdataformats::TimeSlice& timeslice) const
458 {
459 const std::string& timeslice_header_path{ m_file_layout_ptr->get_path_string(timeslice.get_header()) };
460 return m_file_ptr->exist(timeslice_header_path);
461 }
462
463private:
464 HDF5RawDataFile(const HDF5RawDataFile&) = delete;
465 HDF5RawDataFile& operator=(const HDF5RawDataFile&) = delete;
466 HDF5RawDataFile(HDF5RawDataFile&&) = delete;
467 HDF5RawDataFile& operator=(HDF5RawDataFile&&) = delete;
468
469 std::unique_ptr<HighFive::File> m_file_ptr;
470 std::unique_ptr<HDF5FileLayout> m_file_layout_ptr;
471 std::string m_bare_file_name;
472 unsigned m_compression_level;
473 unsigned m_open_flags;
474
475 // Total size of data being written
476 size_t m_recorded_size;
477 size_t m_uncompressed_raw_data_size;
478 size_t m_total_file_size;
479 std::string m_record_type;
480
481 // file layout writing/reading
482 void write_file_layout();
483 void read_file_layout();
484 void check_file_layout();
485
486 // checking function
487 void check_record_type(std::string);
488
489 // writing to datasets
490 std::tuple<size_t, std::string, HighFive::Group> do_write(std::vector<std::string> const&,
491 const char*,
492 size_t,
493 unsigned compression_level);
494
495 // unpacking groups when reading
496 void explore_subgroup(const HighFive::Group& parent_group,
497 std::string relative_path,
498 std::vector<std::string>& path_list);
499
500 // adds record-level information to caches, if needed
501 void add_record_level_info_to_caches_if_needed(record_id_t rid);
502
503 // caches of full-file and record-specific information
504 record_id_set m_all_record_ids_in_file;
505 HDF5SourceIDHandler::source_id_geo_id_map_t m_file_level_source_id_geo_id_map;
506 std::map<record_id_t, std::set<daqdataformats::SourceID>> m_source_id_cache;
507 std::map<record_id_t, daqdataformats::SourceID> m_record_header_source_id_cache;
508 std::map<record_id_t, std::set<daqdataformats::SourceID>> m_fragment_source_id_cache;
509 std::map<record_id_t, HDF5SourceIDHandler::source_id_path_map_t> m_source_id_path_cache;
510 std::map<record_id_t, HDF5SourceIDHandler::source_id_geo_id_map_t> m_source_id_geo_id_cache;
511 std::map<record_id_t, HDF5SourceIDHandler::subsystem_source_id_map_t> m_subsystem_source_id_cache;
512 std::map<record_id_t, HDF5SourceIDHandler::fragment_type_source_id_map_t> m_fragment_type_source_id_cache;
513 std::map<record_id_t, HDF5SourceIDHandler::subdetector_source_id_map_t> m_subdetector_source_id_cache;
514};
515
516// HDF5RawDataFile attribute writers/getters definitions
517template<typename T>
518void
519HDF5RawDataFile::write_attribute(std::string name, T value)
520{
521 if (!m_file_ptr->hasAttribute(name))
522 m_file_ptr->createAttribute(name, value);
523 else
524 ers::warning(HDF5AttributeExists(ERS_HERE, name));
525}
526
527template<typename T>
528void
529HDF5RawDataFile::write_attribute(HighFive::Group& grp, const std::string& name, T value)
530{
531 if (!(grp.hasAttribute(name)))
532 grp.createAttribute<T>(name, value);
533 else
534 ers::warning(HDF5AttributeExists(ERS_HERE, name));
535}
536
537template<typename T>
538void
539HDF5RawDataFile::write_attribute(HighFive::DataSet& dset, const std::string& name, T value)
540{
541 if (!dset.hasAttribute(name))
542 dset.createAttribute<T>(name, value);
543 else
544 ers::warning(HDF5AttributeExists(ERS_HERE, name));
545}
546
547template<typename T>
548T
549HDF5RawDataFile::get_attribute(const std::string& name)
550{
551 if (!m_file_ptr->hasAttribute(name)) {
552 throw InvalidHDF5Attribute(ERS_HERE, name);
553 }
554 auto attr = m_file_ptr->getAttribute(name);
555 T value;
556 attr.read(value);
557 return value;
558}
559
560template<typename T>
561T
562HDF5RawDataFile::get_attribute_if_exists(const std::string& name, const T& default_value)
563{
564 if (!m_file_ptr->hasAttribute(name)) {
565 TLOG_DEBUG(7) << "Debug: Attribute \"" << name << "\" not found. Defaulting to " << default_value;
566 return default_value;
567 }
568 auto attr = m_file_ptr->getAttribute(name);
569 T value;
570 attr.read(value);
571 TLOG_DEBUG(7) << "Debug: Attribute \"" << name << "\" found. Value: " << value;
572 return value;
573}
574
575template<typename T>
576T
577HDF5RawDataFile::get_attribute(const HighFive::Group& grp, const std::string& name)
578{
579 if (!(grp.hasAttribute(name))) {
580 throw InvalidHDF5Attribute(ERS_HERE, name);
581 }
582 auto attr = grp.getAttribute(name);
583 T value;
584 attr.read(value);
585 return value;
586}
587
588template<typename T>
589T
590HDF5RawDataFile::get_attribute(const HighFive::DataSet& dset, std::string name)
591{
592 if (!dset.hasAttribute(name)) {
593 throw InvalidHDF5Attribute(ERS_HERE, name);
594 }
595 auto attr = dset.getAttribute(name);
596 T value;
597 attr.read(value);
598 return value;
599}
600
601} // namespace hdf5libs
602
603} // namespace dunedaq
604
605#endif // HDF5LIBS_INCLUDE_HDF5LIBS_HDF5RAWDATAFILE_HPP_
606
607// Local Variables:
608// c-basic-offset: 2
609// End:
#define ERS_HERE
C++ Representation of a DUNE Fragment, wrapping the flat byte array that is the Fragment's "actual" f...
Definition Fragment.hpp:38
C++ Representation of a DUNE TimeSlice, consisting of a TimeSliceHeader object and a vector of pointe...
Definition TimeSlice.hpp:27
TimeSliceHeader get_header() const
Get a copy of the TimeSliceHeader struct.
Definition TimeSlice.hpp:44
C++ representation of a TriggerRecordHeader, which wraps a flat array that is the TriggerRecordHeader...
C++ Representation of a DUNE TriggerRecord, consisting of a TriggerRecordHeader object and a vector o...
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
FragmentType
All defined Fragment types.
uint64_t trigger_number_t
Definition Types.hpp:18
FragmentType string_to_fragment_type(const std::string &name)
uint16_t sequence_number_t
Type used to represent sequence within a trigger record.
Definition Types.hpp:38
uint64_t timeslice_number_t
Definition Types.hpp:40
The DUNE-DAQ namespace.
ERS_DECLARE_ISSUE(cibmodules, CIBCommunicationError, " CIB Hardware Communication Error: "<< descriptor,((std::string) descriptor)) ERS_DECLARE_ISSUE(cibmodules
void warning(const Issue &issue)
Definition ers.hpp:150
SourceID is a generalized representation of the source of a piece of data in the DAQ....
Definition SourceID.hpp:32
static Subsystem string_to_subsystem(const std::string &typestring)
Definition SourceID.hxx:81
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:40
Data fields associated with a TimeSliceHeader.
static Subdetector string_to_subdetector(const std::string &typestring)
Definition DetID.hxx:95
Subdetector
The Subdetector enum describes the kind of source we're dealing with.
Definition DetID.hpp:36