Add bindings & plotting
This commit is contained in:
+46
-8
@@ -8,27 +8,65 @@
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
|
||||
template<class M>
|
||||
void makeConstructionWrapper(M & m, std::string name){
|
||||
|
||||
py::class_<ConstructionWrapper>(m, name.data()).def(py::init())
|
||||
.def("addLayer", &ConstructionWrapper::addLayer, py::arg("thickness"), py::arg("material"), py::arg("isActive")=true, py::arg("nx")=1, py::arg("ny")=-1)
|
||||
.def("getXYWidth", &ConstructionWrapper::getXYWidth)
|
||||
// bind overloaded getLayers function
|
||||
.def("getLayers", (std::vector<Layer> & (ConstructionWrapper::*)()) &ConstructionWrapper::getLayers)
|
||||
.def("getLayers", (const std::vector<Layer> & (ConstructionWrapper::*)() const) &ConstructionWrapper::getLayers)
|
||||
.def("getNSensors", &ConstructionWrapper::getNSensors);
|
||||
|
||||
}
|
||||
template<class M>
|
||||
void makeG4System(M& m, std::string name){
|
||||
|
||||
|
||||
template <class M>
|
||||
void makeG4System(M &m, std::string name)
|
||||
{
|
||||
py::class_<G4System>(m, name.data()).def(py::init())
|
||||
.def("init", &G4System::init, py::arg("cw"))
|
||||
.def("run_gui", &G4System::run_gui)
|
||||
.def("run_batch", &G4System::run_batch, py::arg("nEvents"), py::arg("partSpecies"), py::arg("minEnergy_GeV"), py::arg("maxEnergy_GeV"))
|
||||
.def("run_visualize", &G4System::run_visualize, py::arg("partSpecies"), py::arg("minEnergy_GeV"), py::arg("maxEnergy_GeV"))
|
||||
.def("init", &G4System::init, py::arg("cw")).def("run_visualize", &G4System::run_visualize, py::arg("partSpecies"), py::arg("minEnergy_GeV"), py::arg("maxEnergy_GeV"))
|
||||
.def("run_gui", &G4System::run_gui).def("run_batch", &G4System::run_batch, py::arg("nEvents"), py::arg("partSpecies"), py::arg("minEnergy_GeV"), py::arg("maxEnergy_GeV"))
|
||||
.def("applyUICommand", &G4System::applyUICommand, py::arg("command"))
|
||||
.def("printMaterial", &G4System::printMaterial, py::arg("name"));
|
||||
.def("displayEvent", &G4System::displayEvent)
|
||||
.def("printMaterial", &G4System::printMaterial, py::arg("name"))
|
||||
.def("check", &G4System::check)
|
||||
.def_readwrite("cw", &G4System::cw);
|
||||
|
||||
}
|
||||
|
||||
PYBIND11_MODULE(minicalo, m) {
|
||||
// create bindings for Layer class
|
||||
template<class M>
|
||||
void makeLayer(M &m, std::string name){
|
||||
py::class_<Layer>(m, name.data()).def(py::init())
|
||||
.def_readwrite("thickness", &Layer::thickness)
|
||||
.def_readwrite("material", &Layer::material)
|
||||
.def_readwrite("nx", &Layer::nx)
|
||||
.def_readwrite("ny", &Layer::ny)
|
||||
.def_readwrite("isActive", &Layer::isActive)
|
||||
.def_readwrite("sens_xwidth", &Layer::sens_xwidth)
|
||||
.def_readwrite("sens_ywidth", &Layer::sens_ywidth)
|
||||
.def_readwrite("sensors", &Layer::sensors);
|
||||
}
|
||||
|
||||
// create bindings for sensor class
|
||||
template<class M>
|
||||
void makeSensor(M &m, std::string name){
|
||||
py::class_<Sensor>(m, name.data()).def(py::init())
|
||||
.def("getEnergy", &Sensor::getEnergy)
|
||||
.def("getPos", &Sensor::getPos)
|
||||
.def("getSize", &Sensor::getSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PYBIND11_MODULE(minicalo, m)
|
||||
{
|
||||
m.doc() = "pybind11 plugin"; // optional module docstring
|
||||
makeConstructionWrapper(m, "ConstructionWrapper");
|
||||
makeG4System(m, "G4System");
|
||||
makeSensor(m, "Sensor");
|
||||
makeLayer(m, "Layer");
|
||||
}
|
||||
Reference in New Issue
Block a user