This commit is contained in:
Jan Kieseler
2023-10-07 11:14:45 +02:00
parent 34a0305601
commit 51001d1b59
15 changed files with 69 additions and 69 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
from minicalo import ConstructionWrapper
from minicalo import GeometryDescriptor
from minicalo import G4System as _G4System
import plotly.graph_objects as go
@@ -47,7 +47,7 @@ class __G4System(_G4System):
z0=0
# loop over materials
for layer_i, layer in enumerate(self.getConstructionWrapper().getLayers()):
for layer_i, layer in enumerate(self.getGeometryDescriptor().getLayers()):
#layer_i = len(self.cw.getLayers()) - layer_i -1
print(layer_i)
+11 -11
View File
@@ -3,23 +3,23 @@
#include <pybind11/stl.h>
#include <pybind11/operators.h>
#include "ConstructionWrapper.hh"
#include "GeometryDescriptor.hh"
#include "G4System.hh"
namespace py = pybind11;
template<class M>
void makeConstructionWrapper(M & m, std::string name){
void makeGeometryDescriptor(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)
py::class_<GeometryDescriptor>(m, name.data()).def(py::init())
.def("addLayer", &GeometryDescriptor::addLayer, py::arg("thickness"), py::arg("material"), py::arg("isActive")=true, py::arg("nx")=1, py::arg("ny")=-1)
.def("getXYWidth", &GeometryDescriptor::getXYWidth)
// bind overloaded getLayers function
.def("getLayers", (std::vector<Layer> & (ConstructionWrapper::*)()) &ConstructionWrapper::getLayers)
.def("getLayers", (const std::vector<Layer> & (ConstructionWrapper::*)() const) &ConstructionWrapper::getLayers)
.def("isAssigned", &ConstructionWrapper::isAssigned)
.def("getNSensors", &ConstructionWrapper::getNSensors);
.def("getLayers", (std::vector<Layer> & (GeometryDescriptor::*)()) &GeometryDescriptor::getLayers)
.def("getLayers", (const std::vector<Layer> & (GeometryDescriptor::*)() const) &GeometryDescriptor::getLayers)
.def("isAssigned", &GeometryDescriptor::isAssigned)
.def("getNSensors", &GeometryDescriptor::getNSensors);
}
@@ -34,7 +34,7 @@ void makeG4System(M &m, std::string name)
.def("displayEvent", &G4System::displayEvent)
// .def("printMaterial", &G4System::printMaterial, py::arg("name"))
//.def("check", &G4System::check)
.def("getConstructionWrapper", &G4System::getConstructionWrapper);
.def("getGeometryDescriptor", &G4System::getGeometryDescriptor);
}
@@ -66,7 +66,7 @@ void makeSensor(M &m, std::string name){
PYBIND11_MODULE(minicalo, m)
{
m.doc() = "pybind11 plugin"; // optional module docstring
makeConstructionWrapper(m, "ConstructionWrapper");
makeGeometryDescriptor(m, "GeometryDescriptor");
makeG4System(m, "G4System");
makeSensor(m, "Sensor");
makeLayer(m, "Layer");
+2 -2
View File
@@ -977,9 +977,9 @@
}
],
"source": [
"from G4Calo import ConstructionWrapper, G4System\n",
"from G4Calo import GeometryDescriptor, G4System\n",
"\n",
"cw = ConstructionWrapper() #the width of the calorimeter is 50 cm times 50 cm (also steerable, but I'd leave it)\n",
"cw = GeometryDescriptor() #the width of the calorimeter is 50 cm times 50 cm (also steerable, but I'd leave it)\n",
"\n",
"cw.addLayer(3,\"G4_Si\",True, 7)\n",
"cw.addLayer(4,\"G4_Pb\",False) \n",
+2 -2
View File
@@ -1,7 +1,7 @@
from G4Calo import ConstructionWrapper, G4System
from G4Calo import GeometryDescriptor, G4System
cw = ConstructionWrapper()#the width of the calorimeter is 50 cm times 50 cm (also steerable, but I'd leave it)
cw = GeometryDescriptor()#the width of the calorimeter is 50 cm times 50 cm (also steerable, but I'd leave it)
cw.addLayer(10,"G4_Si",True) #10 cm of Silicon, active
cw.addLayer(1,"G4_Pb",False) #1 cm of Lead, passive
cw.addLayer(10,"G4_Si",True, 3) #10 cm of Silicon, active, 3x3 segmentation