Line data Source code
1 : /**
2 : * @file detid.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 "detdataformats/DetID.hpp"
10 :
11 : #include <pybind11/operators.h>
12 : #include <pybind11/pybind11.h>
13 : #include <pybind11/stl.h>
14 :
15 : #include <sstream>
16 :
17 : namespace py = pybind11;
18 :
19 : namespace dunedaq::detdataformats::python {
20 :
21 0 : void register_detid(py::module& m) {
22 0 : py::class_<DetID> py_detid(m, "DetID");
23 0 : py_detid.def(py::init())
24 0 : .def(py::init<const DetID::Subdetector&>())
25 0 : .def("__repr__", [](const DetID& gid) {
26 0 : std::ostringstream oss;
27 0 : oss << "<detdataformats::DetID " << gid.to_string() << ">";
28 0 : return oss.str();
29 0 : })
30 0 : .def("to_string", &DetID::to_string)
31 0 : .def("is_in_valid_state", &DetID::is_in_valid_state)
32 0 : .def("subdetector_to_string", &DetID::subdetector_to_string)
33 0 : .def("string_to_subdetector", &DetID::string_to_subdetector);
34 :
35 0 : py::enum_<DetID::Subdetector>(py_detid, "Subdetector")
36 0 : .value("kUnknown", DetID::Subdetector::kUnknown)
37 0 : .value("kDAQ", DetID::Subdetector::kDAQ)
38 0 : .value("kHD_PDS", DetID::Subdetector::kHD_PDS)
39 0 : .value("kHD_TPC", DetID::Subdetector::kHD_TPC)
40 0 : .value("kHD_CRT", DetID::Subdetector::kHD_CRT)
41 0 : .value("kVD_CathodePDS", DetID::Subdetector::kVD_CathodePDS)
42 0 : .value("kVD_MembranePDS", DetID::Subdetector::kVD_MembranePDS)
43 0 : .value("kVD_BottomTPC", DetID::Subdetector::kVD_BottomTPC)
44 0 : .value("kVD_TopTPC", DetID::Subdetector::kVD_TopTPC)
45 0 : .value("kNDLAr_TPC", DetID::Subdetector::kNDLAr_TPC)
46 0 : .value("kNDLAr_PDS", DetID::Subdetector::kNDLAr_PDS)
47 0 : .value("kND_GAr", DetID::Subdetector::kND_GAr)
48 0 : .export_values();
49 :
50 0 : py_detid.def_readwrite("version", &DetID::version)
51 0 : .def_readwrite("subdetector", &DetID::subdetector);
52 0 : }
53 :
54 : } // namespace dunedaq::detdataformats::python
55 :
|