DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::detdataformats::python Namespace Reference

Functions

void register_daqethheader (py::module &m)
void register_daqheader (py::module &m)
void register_detid (py::module &m)
void register_hsi (py::module &m)
 PYBIND11_MODULE (_daq_detdataformats_py, m)
void register_detid (pybind11::module &)
void register_daqheader (pybind11::module &)
void register_daqethheader (pybind11::module &)
void register_hsi (pybind11::module &)

Function Documentation

◆ PYBIND11_MODULE()

dunedaq::detdataformats::python::PYBIND11_MODULE ( _daq_detdataformats_py ,
m  )

Definition at line 16 of file module.cpp.

17{
18
19 m.doc() = "c++ implementation of the dunedaq detdataformats modules"; // optional module docstring
20
24 register_hsi(m);
25}
void register_hsi(py::module &m)
Definition hsi.cpp:21
void register_daqethheader(py::module &m)
void register_daqheader(py::module &m)
Definition daqheader.cpp:25
void register_detid(py::module &m)
Definition detid.cpp:22

◆ register_daqethheader() [1/2]

void dunedaq::detdataformats::python::register_daqethheader ( py::module & m)

Definition at line 25 of file daqethheader.cpp.

26{
27
28 py::class_<DAQEthHeader>(m, "DAQEthHeader", py::buffer_protocol())
29 .def(py::init([](py::capsule capsule) {
30 auto hsfp = *static_cast<DAQEthHeader*>(capsule.get_pointer());
31 return hsfp;
32 }))
33 .def(py::init([](py::bytes bytes) {
34 py::buffer_info info(py::buffer(bytes).request());
35 auto wfp = *static_cast<DAQEthHeader*>(info.ptr);
36 return wfp;
37 }))
38 .def_property(
39 "version",
40 [](DAQEthHeader& self) -> uint32_t { return self.version; },
41 [](DAQEthHeader& self, uint32_t version) { self.version = version; })
42 .def_property(
43 "det_id",
44 [](DAQEthHeader& self) -> uint32_t { return self.det_id; },
45 [](DAQEthHeader& self, uint32_t det_id) { self.det_id = det_id; })
46 .def_property(
47 "crate_id",
48 [](DAQEthHeader& self) -> uint32_t { return self.crate_id; },
49 [](DAQEthHeader& self, uint32_t crate_id) { self.crate_id = crate_id; })
50 .def_property(
51 "slot_id",
52 [](DAQEthHeader& self) -> uint32_t { return self.slot_id; },
53 [](DAQEthHeader& self, uint32_t slot_id) { self.slot_id = slot_id; })
54 .def_property(
55 "stream_id",
56 [](DAQEthHeader& self) -> uint32_t { return self.stream_id; },
57 [](DAQEthHeader& self, uint32_t stream_id) { self.stream_id = stream_id; })
58 .def_property(
59 "reserved",
60 [](DAQEthHeader& self) -> uint32_t { return self.reserved; },
61 [](DAQEthHeader& self, uint32_t reserved) { self.reserved = reserved; })
62 .def_property(
63 "seq_id",
64 [](DAQEthHeader& self) -> uint32_t { return self.seq_id; },
65 [](DAQEthHeader& self, uint32_t seq_id) { self.seq_id = seq_id; })
66 .def_property(
67 "block_length",
68 [](DAQEthHeader& self) -> uint32_t { return self.block_length; },
69 [](DAQEthHeader& self, uint32_t block_length) { self.block_length = block_length; })
70 .def_property(
71 "timestamp",
72 [](DAQEthHeader& self) -> uint64_t { return self.timestamp; },
73 [](DAQEthHeader& self, uint64_t timestamp) { self.timestamp = timestamp; })
74 .def("get_timestamp", &DAQEthHeader::get_timestamp)
75 .def_static("sizeof", []() { return sizeof(DAQEthHeader); });
76}
DAQEthHeader is a versioned and unified structure for every FE electronics.

◆ register_daqethheader() [2/2]

void dunedaq::detdataformats::python::register_daqethheader ( pybind11::module & )

◆ register_daqheader() [1/2]

void dunedaq::detdataformats::python::register_daqheader ( py::module & m)

Definition at line 25 of file daqheader.cpp.

26{
27
28 py::class_<DAQHeader>(m, "DAQHeader", py::buffer_protocol())
29 .def(py::init<>())
30 .def_property(
31 "version",
32 [](DAQHeader& self) -> uint32_t { return self.version; },
33 [](DAQHeader& self, uint32_t version) { self.version = version; })
34 .def_property(
35 "det_id",
36 [](DAQHeader& self) -> uint32_t { return self.det_id; },
37 [](DAQHeader& self, uint32_t det_id) { self.det_id = det_id; })
38 .def_property(
39 "crate_id",
40 [](DAQHeader& self) -> uint32_t { return self.crate_id; },
41 [](DAQHeader& self, uint32_t crate_id) { self.crate_id = crate_id; })
42 .def_property(
43 "slot_id",
44 [](DAQHeader& self) -> uint32_t { return self.slot_id; },
45 [](DAQHeader& self, uint32_t slot_id) { self.slot_id = slot_id; })
46 .def_property(
47 "link_id",
48 [](DAQHeader& self) -> uint32_t { return self.link_id; },
49 [](DAQHeader& self, uint32_t link_id) { self.link_id = link_id; })
50 .def_property(
51 "timestamp_1",
52 [](DAQHeader&) -> uint32_t {
53 throw std::runtime_error("Cannot directly read timestamp_1; use get_timestamp() instead");
54 },
55 [](DAQHeader& self, uint32_t timestamp_1) { self.timestamp_1 = timestamp_1; })
56 .def_property(
57 "timestamp_2",
58 [](DAQHeader&) -> uint32_t {
59 throw std::runtime_error("Cannot directly read timestamp_2; use get_timestamp() instead");
60 },
61 [](DAQHeader& self, uint32_t timestamp_2) { self.timestamp_2 = timestamp_2; })
62 .def("get_timestamp", &DAQHeader::get_timestamp);
63}
DAQHeader is a versioned and unified structure for every FE electronics.
Definition DAQHeader.hpp:23

◆ register_daqheader() [2/2]

void dunedaq::detdataformats::python::register_daqheader ( pybind11::module & )

◆ register_detid() [1/2]

void dunedaq::detdataformats::python::register_detid ( py::module & m)

Definition at line 22 of file detid.cpp.

23{
24 py::class_<DetID> py_detid(m, "DetID");
25 py_detid.def(py::init())
26 .def(py::init<const DetID::Subdetector&>())
27 .def("__repr__",
28 [](const DetID& gid) {
29 std::ostringstream oss;
30 oss << "<detdataformats::DetID " << DetID::subdetector_to_string(gid.subdetector) << ">";
31 return oss.str();
32 })
33 .def("subdetector_to_string", &DetID::subdetector_to_string)
34 .def("string_to_subdetector", &DetID::string_to_subdetector);
35
36 py::enum_<DetID::Subdetector>(py_detid, "Subdetector")
37 .value("kUnknown", DetID::Subdetector::kUnknown)
38 .value("kDAQ", DetID::Subdetector::kDAQ)
39 .value("kHD_PDS", DetID::Subdetector::kHD_PDS)
40 .value("kHD_TPC", DetID::Subdetector::kHD_TPC)
41 .value("kHD_CRT", DetID::Subdetector::kHD_CRT)
42 .value("kVD_CathodePDS", DetID::Subdetector::kVD_CathodePDS)
43 .value("kVD_MembranePDS", DetID::Subdetector::kVD_MembranePDS)
44 .value("kVD_BottomTPC", DetID::Subdetector::kVD_BottomTPC)
45 .value("kVD_TopTPC", DetID::Subdetector::kVD_TopTPC)
46 .value("kVD_BernCRT", DetID::Subdetector::kVD_BernCRT)
47 .value("kVD_GrenobleCRT", DetID::Subdetector::kVD_GrenobleCRT)
48 .value("kNDLAr_TPC", DetID::Subdetector::kNDLAr_TPC)
49 .value("kNDLAr_PDS", DetID::Subdetector::kNDLAr_PDS)
50 .value("kND_GAr", DetID::Subdetector::kND_GAr)
51 .export_values();
52
53 py_detid.def_readwrite("subdetector", &DetID::subdetector);
54}
DetID is a structure containing the 6 bits field of the unique identifier for a subdetector in the ra...
Definition DetID.hpp:30
static std::string subdetector_to_string(const Subdetector &type)
Definition DetID.hxx:60
static Subdetector string_to_subdetector(const std::string &typestring)
Definition DetID.hxx:95
Subdetector subdetector
The general subdetector of the source of the data.
Definition DetID.hpp:56

◆ register_detid() [2/2]

void dunedaq::detdataformats::python::register_detid ( pybind11::module & )

◆ register_hsi() [1/2]

void dunedaq::detdataformats::python::register_hsi ( py::module & m)

Definition at line 21 of file hsi.cpp.

22{
23
24 py::class_<HSIFrame>(m, "HSIFrame", py::buffer_protocol())
25 .def(py::init())
26 .def(py::init([](py::capsule capsule) {
27 auto hsfp = *static_cast<HSIFrame*>(capsule.get_pointer());
28 return hsfp;
29 }))
30 .def(py::init([](py::bytes bytes) {
31 py::buffer_info info(py::buffer(bytes).request());
32 auto wfp = *static_cast<HSIFrame*>(info.ptr);
33 return wfp;
34 }))
35 .def("get_timestamp", &HSIFrame::get_timestamp)
36 .def_property_readonly("version", [](const HSIFrame& self) -> uint64_t { return self.version; })
37 .def_property_readonly("detector_id", [](const HSIFrame& self) -> uint64_t { return self.detector_id; })
38 .def_property_readonly("crate", [](const HSIFrame& self) -> uint64_t { return self.crate; })
39 .def_property_readonly("slot", [](const HSIFrame& self) -> uint64_t { return self.slot; })
40 .def_property_readonly("link", [](const HSIFrame& self) -> uint64_t { return self.link; })
41 .def_property_readonly("input_low", [](const HSIFrame& self) -> uint64_t { return self.input_low; })
42 .def_property_readonly("input_high", [](const HSIFrame& self) -> uint64_t { return self.input_high; })
43 .def_property_readonly("trigger", [](const HSIFrame& self) -> uint64_t { return self.trigger; })
44 .def_property_readonly("sequence", [](const HSIFrame& self) -> uint64_t { return self.sequence; })
45 .def_static("sizeof", []() { return sizeof(HSIFrame); });
46}

◆ register_hsi() [2/2]

void dunedaq::detdataformats::python::register_hsi ( pybind11::module & )