Files
minicalosim/bind/bindings.cpp
T
Jan Kieseler 1be716e9ab check
2023-09-08 17:19:24 +02:00

32 lines
1.2 KiB
C++

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/operators.h>
#include "ConstructionWrapper.hh"
#include "SystemBuilder.hh"
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("getNSensors", &ConstructionWrapper::getNSensors);
}
template<class M>
void makeSystemBuilder(M& m, std::string name){
py::class_<SystemBuilder>(m, name.data()).def(py::init())
.def("init", &SystemBuilder::init, py::arg("cw"), py::arg("gui")=false)
.def("run_gui", &SystemBuilder::run_gui)
.def("run_batch", &SystemBuilder::run_batch, py::arg("nEvents"), py::arg("partSpecies"), py::arg("minEnergy"), py::arg("maxEnergy"))
.def("visualize", &SystemBuilder::visualize);
}
PYBIND11_MODULE(bindings, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
makeConstructionWrapper(m, "ConstructionWrapper");
makeSystemBuilder(m, "SystemBuilder");
}