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