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 : void
22 0 : register_detid(py::module& m)
23 : {
24 0 : py::class_<DetID> py_detid(m, "DetID");
25 0 : py_detid.def(py::init())
26 0 : .def(py::init<const DetID::Subdetector&>())
27 0 : .def("__repr__",
28 0 : [](const DetID& gid) {
29 0 : std::ostringstream oss;
30 0 : oss << "<detdataformats::DetID " << DetID::subdetector_to_string(gid.subdetector) << ">";
31 0 : return oss.str();
32 0 : })
33 0 : .def("subdetector_to_string", &DetID::subdetector_to_string)
34 0 : .def("string_to_subdetector", &DetID::string_to_subdetector);
35 :
36 0 : py::enum_<DetID::Subdetector>(py_detid, "Subdetector")
37 0 : .value("kUnknown", DetID::Subdetector::kUnknown)
38 0 : .value("kDAQ", DetID::Subdetector::kDAQ)
39 0 : .value("kHD_PDS", DetID::Subdetector::kHD_PDS)
40 0 : .value("kHD_TPC", DetID::Subdetector::kHD_TPC)
41 0 : .value("kHD_CRT", DetID::Subdetector::kHD_CRT)
42 0 : .value("kVD_CathodePDS", DetID::Subdetector::kVD_CathodePDS)
43 0 : .value("kVD_MembranePDS", DetID::Subdetector::kVD_MembranePDS)
44 0 : .value("kVD_BottomTPC", DetID::Subdetector::kVD_BottomTPC)
45 0 : .value("kVD_TopTPC", DetID::Subdetector::kVD_TopTPC)
46 0 : .value("kVD_BernCRT", DetID::Subdetector::kVD_BernCRT)
47 0 : .value("kVD_GrenobleCRT", DetID::Subdetector::kVD_GrenobleCRT)
48 0 : .value("kNDLAr_TPC", DetID::Subdetector::kNDLAr_TPC)
49 0 : .value("kNDLAr_PDS", DetID::Subdetector::kNDLAr_PDS)
50 0 : .value("kND_GAr", DetID::Subdetector::kND_GAr)
51 0 : .export_values();
52 :
53 0 : py_detid.def_readwrite("subdetector", &DetID::subdetector);
54 0 : }
55 :
56 : } // namespace dunedaq::detdataformats::python
|