better plotting

This commit is contained in:
Jan Kieseler
2024-08-23 11:22:50 +02:00
parent 905d5408ed
commit 9038c9521a
5 changed files with 51 additions and 191 deletions
+19 -4
View File
@@ -69,7 +69,7 @@ public:
class Layer {
public:
Layer() : thickness(0),sens_xwidth(0), sens_ywidth(0), material(""), nx(1), ny(1), isActive(false), physicalVolume(nullptr) {};
Layer() : thickness(0),sens_xwidth(0), sens_ywidth(0), material(""), nx(1), ny(1), isActive(false), physicalVolume(nullptr), position(0,0,0) {};
~Layer() {};
void setThickness(double thickness_cm);
@@ -84,6 +84,18 @@ public:
sensors.clear();
}
double getX() const {
return position.x();
}
double getY() const {
return position.y();
}
double getZ() const {
return position.z();
}
double thickness;
double sens_xwidth;
double sens_ywidth;
@@ -92,17 +104,19 @@ public:
int ny;
bool isActive;
G4VPhysicalVolume* physicalVolume;
std::string name;
G4ThreeVector position;
std::vector<Sensor> sensors;
pybind11::tuple __getstate__() const {
return pybind11::make_tuple(thickness, sens_xwidth, sens_ywidth, material, nx, ny, isActive, sensors);
return pybind11::make_tuple(thickness, sens_xwidth, sens_ywidth, material, nx, ny, isActive, position.x(), position.y(), position.z(), sensors);
}
static Layer __setstate__(pybind11::tuple t) {
if (t.size() != 8) throw std::runtime_error("Invalid state!");
if (t.size() != 11) throw std::runtime_error("Invalid state!");
Layer layer;
layer.thickness = t[0].cast<double>();
layer.sens_xwidth = t[1].cast<double>();
@@ -111,7 +125,8 @@ public:
layer.nx = t[4].cast<int>();
layer.ny = t[5].cast<int>();
layer.isActive = t[6].cast<bool>();
layer.sensors = t[7].cast<std::vector<Sensor>>();
layer.position = G4ThreeVector(t[7].cast<double>(), t[8].cast<double>(), t[9].cast<double>());
layer.sensors = t[10].cast<std::vector<Sensor>>();
layer.physicalVolume = nullptr; // Reset pointer
return layer;
}