Line data Source code
1 : /**
2 : * @file wib.cpp
3 : *
4 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "hdf5libs/HDF5RawDataFile.hpp"
10 :
11 : #include <pybind11/pybind11.h>
12 : #include <pybind11/stl.h>
13 : #include <pybind11/stl/filesystem.h>
14 : #include <pybind11/stl_bind.h>
15 :
16 : #include <string>
17 :
18 : namespace py = pybind11;
19 :
20 : namespace dunedaq {
21 : namespace hdf5libs {
22 : namespace python {
23 :
24 : void
25 0 : register_hdf5rawdatafile(py::module& m)
26 : {
27 :
28 0 : py::class_<HDF5RawDataFile>(m, "_HDF5RawDataFile")
29 0 : .def(py::init<std::filesystem::path>())
30 :
31 0 : .def("get_attribute_names",
32 0 : &HDF5RawDataFile::get_attribute_names,
33 : "Get a list of attribute names")
34 :
35 0 : .def("get_attribute",
36 : py::overload_cast<const std::string&>
37 0 : (&HDF5RawDataFile::get_attribute<std::string>),
38 : "Get attribute")
39 :
40 0 : .def("get_int_attribute",
41 : py::overload_cast<const std::string&>
42 0 : (&HDF5RawDataFile::get_attribute<size_t>),
43 : "Get integer attribute")
44 :
45 0 : .def("get_file_name",
46 0 : &HDF5RawDataFile::get_file_name,"Get file name")
47 0 : .def("get_recorded_size",
48 0 : &HDF5RawDataFile::get_recorded_size,"Get recorded size")
49 0 : .def("get_record_type",
50 0 : &HDF5RawDataFile::get_record_type,"Get record type")
51 0 : .def("is_trigger_record_type",
52 0 : &HDF5RawDataFile::is_trigger_record_type,"Is record type TriggerRecord")
53 0 : .def("is_timeslice_type",
54 0 : &HDF5RawDataFile::is_timeslice_type,"Is record type TimeSlice")
55 0 : .def("get_version",
56 0 : &HDF5RawDataFile::get_version,"FileLayout version number")
57 :
58 0 : .def("get_dataset_paths",
59 0 : &HDF5RawDataFile::get_dataset_paths,
60 : "Get all dataset paths under specified top group in file",
61 0 : py::arg("top_level_group_name")="")
62 :
63 0 : .def("get_all_record_ids",
64 0 : &HDF5RawDataFile::get_all_record_ids,"Get all record/sequence number pairs.")
65 0 : .def("get_all_trigger_record_ids",
66 0 : &HDF5RawDataFile::get_all_trigger_record_ids,"Get all trigger record/sequence number pairs.")
67 0 : .def("get_all_timeslice_ids",
68 0 : &HDF5RawDataFile::get_all_timeslice_ids,"Get all timeslice/sequence number pairs.")
69 :
70 0 : .def("get_record_header_dataset_paths",
71 0 : &HDF5RawDataFile::get_record_header_dataset_paths,"Get all paths to record header datasets")
72 0 : .def("get_trigger_record_header_dataset_paths",
73 0 : &HDF5RawDataFile::get_trigger_record_header_dataset_paths,"Get all paths to TriggerRecordHeader datasets")
74 0 : .def("get_timeslice_header_dataset_paths",
75 0 : &HDF5RawDataFile::get_timeslice_header_dataset_paths,"Get all paths to TimeSliceHeader datasets")
76 :
77 0 : .def("get_record_header_dataset_path",
78 0 : py::overload_cast<const HDF5RawDataFile::record_id_t&>(&HDF5RawDataFile::get_record_header_dataset_path),
79 : "Get record header path for record id")
80 0 : .def("get_record_header_dataset_path",
81 : py::overload_cast<const uint64_t,const daqdataformats::sequence_number_t> //NOLINT(build/unsigned)
82 0 : (&HDF5RawDataFile::get_record_header_dataset_path),
83 : "Get record header path for record number and sequence number",
84 0 : py::arg("rec_num"),py::arg("seq_num")=0)
85 :
86 0 : .def("get_trigger_record_header_dataset_path",
87 0 : py::overload_cast<const HDF5RawDataFile::record_id_t&>(&HDF5RawDataFile::get_trigger_record_header_dataset_path),
88 : "Get record header path for trigger record id")
89 0 : .def("get_trigger_record_header_dataset_path",
90 : py::overload_cast<const daqdataformats::trigger_number_t,const daqdataformats::sequence_number_t>
91 0 : (&HDF5RawDataFile::get_trigger_record_header_dataset_path),
92 : "Get record header path for trigger record number and sequence number",
93 0 : py::arg("trig_num"),py::arg("seq_num")=0)
94 :
95 0 : .def("get_timeslice_header_dataset_path",
96 0 : py::overload_cast<const HDF5RawDataFile::record_id_t&>(&HDF5RawDataFile::get_timeslice_header_dataset_path),
97 : "Get record header path for timeslice record id")
98 0 : .def("get_timeslice_header_dataset_path",
99 : py::overload_cast<const daqdataformats::timeslice_number_t>
100 0 : (&HDF5RawDataFile::get_timeslice_header_dataset_path),
101 : "Get record header path for timeslice number")
102 :
103 0 : .def("get_all_fragment_dataset_paths",
104 0 : &HDF5RawDataFile::get_all_fragment_dataset_paths,
105 : "Get all paths to Fragment datasets")
106 0 : .def("get_fragment_dataset_paths",
107 0 : py::overload_cast<const HDF5RawDataFile::record_id_t&>(&HDF5RawDataFile::get_fragment_dataset_paths),
108 : "Get fragment datasets for record ID")
109 0 : .def("get_fragment_dataset_paths",
110 : py::overload_cast<const uint64_t,const daqdataformats::sequence_number_t> //NOLINT(build/unsigned)
111 0 : (&HDF5RawDataFile::get_fragment_dataset_paths),
112 : "Get fragment datasets for record number and sequence number",
113 0 : py::arg("rec_num"),py::arg("seq_num")=0)
114 0 : .def("get_fragment_dataset_paths",
115 : py::overload_cast<const HDF5RawDataFile::record_id_t&,const daqdataformats::SourceID::Subsystem>
116 0 : (&HDF5RawDataFile::get_fragment_dataset_paths),
117 : "Get fragment datasets for record ID and SourceID Subsystem")
118 0 : .def("get_fragment_dataset_paths",
119 : py::overload_cast<const HDF5RawDataFile::record_id_t&,const std::string&>
120 0 : (&HDF5RawDataFile::get_fragment_dataset_paths),
121 : "Get fragment datasets for record ID and SourceID Subsystem string")
122 : #if 0
123 : .def("get_fragment_dataset_paths",
124 : py::overload_cast<const daqdataformats::SourceID::Subsystem>(&HDF5RawDataFile::get_fragment_dataset_paths),
125 : "Get fragment datasets for SourceID Subsystem")
126 : .def("get_fragment_dataset_paths",
127 : py::overload_cast<const std::string&>(&HDF5RawDataFile::get_fragment_dataset_paths),
128 : "Get fragment datasets for SourceID Subsystem string")
129 : .def("get_fragment_dataset_paths",
130 : py::overload_cast<const daqdataformats::SourceID>(&HDF5RawDataFile::get_fragment_dataset_paths),
131 : "Get fragment datasets for SourceID")
132 : .def("get_fragment_dataset_paths",
133 : py::overload_cast<const daqdataformats::SourceID::Subsystem,const uint32_t> //NOLINT(build/unsigned)
134 : (&HDF5RawDataFile::get_fragment_dataset_paths),
135 : "Get fragment datasets for SourceID Subsystem")
136 : .def("get_fragment_dataset_paths",
137 : py::overload_cast<const std::string&,const uint32_t> //NOLINT(build/unsigned)
138 : (&HDF5RawDataFile::get_fragment_dataset_paths),
139 : "Get fragment datasets for SourceID Subsystem string")
140 : #endif
141 0 : .def("get_geo_ids",
142 : py::overload_cast<const HDF5RawDataFile::record_id_t&>
143 0 : (&HDF5RawDataFile::get_geo_ids),
144 : "Get all GeoIDs in a record id")
145 0 : .def("get_geo_ids",
146 : py::overload_cast<const uint64_t,const daqdataformats::sequence_number_t> //NOLINT(build/unsigned)
147 0 : (&HDF5RawDataFile::get_geo_ids),
148 : "Get all GeoIDs in a record/sequence number")
149 0 : .def("get_geo_ids_for_subdetector",
150 : py::overload_cast<const HDF5RawDataFile::record_id_t&,const detdataformats::DetID::Subdetector>
151 0 : (&HDF5RawDataFile::get_geo_ids_for_subdetector),
152 : "Get all GeoIDs in a record id with the specified Subdetector type")
153 0 : .def("get_source_ids",
154 : py::overload_cast<const HDF5RawDataFile::record_id_t&>
155 0 : (&HDF5RawDataFile::get_source_ids),
156 : "Get all source IDs in a record id")
157 0 : .def("get_source_ids",
158 : py::overload_cast<const uint64_t,const daqdataformats::sequence_number_t> //NOLINT(build/unsigned)
159 0 : (&HDF5RawDataFile::get_source_ids),
160 : "Get all source IDs in a record/sequence number")
161 0 : .def("get_source_ids_for_fragment_type",
162 : py::overload_cast<const HDF5RawDataFile::record_id_t&,const std::string&>
163 0 : (&HDF5RawDataFile::get_source_ids_for_fragment_type),
164 : "Get all source IDs in a record id with a given fragment type")
165 0 : .def("get_source_ids_for_fragtype_and_subdetector",
166 : py::overload_cast<const HDF5RawDataFile::record_id_t&,const std::string&,const std::string&>
167 0 : (&HDF5RawDataFile::get_source_ids_for_fragtype_and_subdetector),
168 : "Get all source IDs in a record id matching the specified fragment and subdetector types")
169 : #if 0
170 : .def("get_source_ids",
171 : py::overload_cast<const HDF5RawDataFile::record_id_t&,const daqdataformats::SourceID::Subsystem>
172 : (&HDF5RawDataFile::get_source_ids),
173 : "Get all source IDs in a record id with a given SourceID Subsystem")
174 : .def("get_source_ids",
175 : py::overload_cast<const uint64_t,const daqdataformats::sequence_number_t, //NOLINT(build/unsigned)
176 : const daqdataformats::SourceID::Subsystem>
177 : (&HDF5RawDataFile::get_source_ids),
178 : "Get all source IDs in a record/sequence number with a given SourceID Subsystem")
179 : .def("get_source_ids",
180 : py::overload_cast<const HDF5RawDataFile::record_id_t&,const std::string&>
181 : (&HDF5RawDataFile::get_source_ids),
182 : "Get all source IDs in a record id with a given SourceID Subsystem string")
183 : .def("get_source_ids",
184 : py::overload_cast<const uint64_t,const daqdataformats::sequence_number_t, //NOLINT(build/unsigned)
185 : const std::string&>
186 : (&HDF5RawDataFile::get_source_ids),
187 : "Get all source IDs in a record/sequence number with a given SourceID Subsystem string")
188 : .def("get_source_ids",
189 : py::overload_cast<const daqdataformats::SourceID::Subsystem>
190 : (&HDF5RawDataFile::get_source_ids),
191 : "Get all source IDs with a given SourceID Subsystem")
192 : .def("get_source_ids",
193 : py::overload_cast<const std::string&>
194 : (&HDF5RawDataFile::get_source_ids),
195 : "Get all source IDs with a given SourceID Subsystem string")
196 : #endif
197 :
198 : // .def("get_frag_ptr", py::overload_cast<const std::string & >
199 : // (&HDF5RawDataFile::get_frag_ptr),
200 : // "Get Fragment from dataset")
201 0 : .def("get_frag",
202 : py::overload_cast<const std::string & >
203 0 : (&HDF5RawDataFile::get_frag_ptr),
204 : "Get Fragment from dataset")
205 0 : .def("get_frag",
206 : py::overload_cast<const uint64_t, //NOLINT(build/unsigned)
207 : const daqdataformats::sequence_number_t,
208 : const daqdataformats::SourceID&>
209 0 : (&HDF5RawDataFile::get_frag_ptr),
210 : "Get Fragment from record/sequence number and SourceID")
211 0 : .def("get_frag",
212 : py::overload_cast<const HDF5RawDataFile::record_id_t&,
213 : const daqdataformats::SourceID&>
214 0 : (&HDF5RawDataFile::get_frag_ptr),
215 : "Get Fragment from record id and SourceID")
216 :
217 0 : .def("get_frag",
218 : py::overload_cast<const uint64_t, //NOLINT(build/unsigned)
219 : const daqdataformats::sequence_number_t,
220 : const daqdataformats::SourceID::Subsystem,
221 : const uint32_t> //NOLINT(build/unsigned)
222 0 : (&HDF5RawDataFile::get_frag_ptr),
223 : "Get Fragment from record/sequence number and SourceID elements")
224 0 : .def("get_frag",
225 : py::overload_cast<const HDF5RawDataFile::record_id_t&,
226 : const daqdataformats::SourceID::Subsystem,
227 : const uint32_t> //NOLINT(build/unsigned)
228 0 : (&HDF5RawDataFile::get_frag_ptr),
229 : "Get Fragment from record id and SourceID elements")
230 :
231 0 : .def("get_frag",
232 : py::overload_cast<const uint64_t, //NOLINT(build/unsigned)
233 : const daqdataformats::sequence_number_t,
234 : const std::string&,
235 : const uint32_t> //NOLINT(build/unsigned)
236 0 : (&HDF5RawDataFile::get_frag_ptr),
237 : "Get Fragment from record/sequence number and SourceID elements")
238 0 : .def("get_frag",
239 : py::overload_cast<const HDF5RawDataFile::record_id_t&,
240 : const std::string&,
241 : const uint32_t> //NOLINT(build/unsigned)
242 0 : (&HDF5RawDataFile::get_frag_ptr),
243 : "Get Fragment from record id and SourceID elements")
244 :
245 0 : .def("get_frag",
246 : py::overload_cast<const HDF5RawDataFile::record_id_t&,
247 : const uint64_t> //NOLINT(build/unsigned)
248 0 : (&HDF5RawDataFile::get_frag_ptr),
249 : "Get Fragment from record id and GeoID")
250 0 : .def("get_frag",
251 : py::overload_cast<const uint64_t, //NOLINT(build/unsigned)
252 : const daqdataformats::sequence_number_t,
253 : const uint64_t> //NOLINT(build/unsigned)
254 0 : (&HDF5RawDataFile::get_frag_ptr),
255 : "Get Fragment from record/sequence number and GeoID")
256 :
257 : // .def("get_trh_ptr",
258 : // py::overload_cast<const std::string & >(&HDF5RawDataFile::get_trh_ptr),
259 : // "Get TriggerRecordHeader from datset")
260 0 : .def("get_trh",
261 : py::overload_cast<const std::string & >
262 0 : (&HDF5RawDataFile::get_trh_ptr),
263 : "Get TriggerRecordHeader from dataset")
264 0 : .def("get_trh",
265 : py::overload_cast<const HDF5RawDataFile::record_id_t&>
266 0 : (&HDF5RawDataFile::get_trh_ptr),
267 : "Get TriggerRecordHeader from record id")
268 0 : .def("get_trh",
269 : py::overload_cast<const daqdataformats::trigger_number_t,daqdataformats::sequence_number_t>
270 0 : (&HDF5RawDataFile::get_trh_ptr),
271 : "Get TriggerRecordHeader from record/sequence number")
272 : // .def("get_tsh_ptr", py::overload_cast<const std::string & >(&HDF5RawDataFile::get_tsh_ptr),
273 : // "Get TimeSliceHeader from datset")
274 0 : .def("get_tsh",
275 : py::overload_cast<const std::string & >
276 0 : (&HDF5RawDataFile::get_tsh_ptr),
277 : "Get TimeSliceHeader from datset")
278 0 : .def("get_tsh",
279 : py::overload_cast<const HDF5RawDataFile::record_id_t&>
280 0 : (&HDF5RawDataFile::get_tsh_ptr),
281 : "Get TimeSliceHeader from record id")
282 0 : .def("get_tsh",
283 : py::overload_cast<const daqdataformats::timeslice_number_t> //NOLINT(build/unsigned)
284 0 : (&HDF5RawDataFile::get_tsh_ptr),
285 : "Get TimeSliceHeader from timeslince number")
286 :
287 0 : .def("get_trigger_record",
288 : py::overload_cast<const HDF5RawDataFile::record_id_t&>
289 0 : (&HDF5RawDataFile::get_trigger_record),
290 : "Get TriggerRecord object from record id")
291 0 : .def("get_trigger_record",
292 : py::overload_cast<const daqdataformats::trigger_number_t,
293 : const daqdataformats::sequence_number_t>
294 0 : (&HDF5RawDataFile::get_trigger_record),
295 : "Get TriggerRecord object from record/sequence number")
296 0 : .def("get_timeslice",
297 : py::overload_cast<const HDF5RawDataFile::record_id_t&>
298 0 : (&HDF5RawDataFile::get_timeslice),
299 : "Get TimeSlice object from record id")
300 0 : .def("get_timeslice",
301 : py::overload_cast<const daqdataformats::timeslice_number_t>
302 0 : (&HDF5RawDataFile::get_timeslice),
303 : "Get TimeSlice object from timeslice number")
304 : ;
305 :
306 0 : } //NOLINT
307 :
308 : } // namespace python
309 : } // namespace hdf5libs
310 : } // namespace dunedaq
|