Files
minicalosim/bind/bindings.cpp
T
Jan Kieseler 90666bc1be changed to GeV
2023-09-19 09:34:56 +00:00

33 lines
1.3 KiB
C++

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/operators.h>
#include "ConstructionWrapper.hh"
#include "G4System.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 makeG4System(M& m, std::string name){
py::class_<G4System>(m, name.data()).def(py::init())
.def("init", &G4System::init, py::arg("cw"), py::arg("gui")=false)
.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("applyUICommand", &G4System::applyUICommand, py::arg("command"));
}
PYBIND11_MODULE(minicalo, m) {
m.doc() = "pybind11 plugin"; // optional module docstring
makeConstructionWrapper(m, "ConstructionWrapper");
makeG4System(m, "G4System");
}