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
+134
View File
@@ -0,0 +1,134 @@
#include "GeometryDescriptor.hh"
#include "G4VPhysicalVolume.hh"
Layer::Layer(){
thickness = 0;
material = "";
nx = 1;
ny = 1;
isActive = false;
physicalVolume = nullptr;
}
void Layer::setThickness(double thickness){
this->thickness = thickness;
}
void Layer::setMaterial(std::string material){
this->material = material;
}
void Layer::setNx(int nx){
this->nx = nx;
}
void Layer::setNy(int ny){
this->ny = ny;
}
void Layer::setIsActive(bool isActive){
this->isActive = isActive;
}
void Layer::assignPhysicalVolume(G4VPhysicalVolume* physicalVolume){
this->physicalVolume = physicalVolume;
}
GeometryDescriptor::GeometryDescriptor(double xy_width){
xywidth = xy_width;
}
void GeometryDescriptor::addLayer(double thickness, std::string material, bool isActive, int nx, int ny){
if(ny<0){
ny = nx;
}
Layer layer;
layer.setThickness(thickness);
layer.setMaterial(material);
layer.setIsActive(isActive);
if(!isActive){
nx = 1;
ny = 1;
}
layer.setNx(nx);
layer.setNy(ny);
layer.sens_xwidth = xywidth/(float)nx;
layer.sens_ywidth = xywidth/(float)ny;
layers.push_back(layer);
}
const std::vector<Layer> & GeometryDescriptor::getLayers() const{
return layers;
}
std::vector<Layer> & GeometryDescriptor::getLayers(){
return layers;
}
double GeometryDescriptor::getXYWidth() const{
return xywidth;
}
void GeometryDescriptor::resetSensorEnergies()const {
for(const auto & layer : layers){
for(const auto & sensor : layer.sensors){
sensor.energy = 0;
}
}
}
Layer* GeometryDescriptor::getLayerByVolume(G4VPhysicalVolume* volume){
for(auto & layer : layers){
if(layer.physicalVolume == volume){
return &layer;
}
}
return nullptr;
}
const Layer* GeometryDescriptor::getLayerByVolume(G4VPhysicalVolume* volume)const{
for(auto & layer : layers){
if(layer.physicalVolume == volume){
return &layer;
}
}
return nullptr;
}
Sensor* GeometryDescriptor::getSensorByVolume(G4VPhysicalVolume* volume){
int copyNo = volume->GetCopyNo();
auto layer = getLayerByVolume(volume);
if(layer == nullptr){
return nullptr;
}
if(copyNo >= layer->sensors.size()){
return nullptr;
}
return &layer->sensors[copyNo];
}
const Sensor* GeometryDescriptor::getSensorByVolume(G4VPhysicalVolume* volume)const{
int copyNo = volume->GetCopyNo();
auto layer = getLayerByVolume(volume);
if(layer == nullptr){
return nullptr;
}
if(copyNo >= layer->sensors.size()){
return nullptr;
}
return &layer->sensors[copyNo];
}
void GeometryDescriptor::printSensorEnergies()const{
for(const auto& layer: layers){
for(const auto& sensor: layer.sensors){
G4cout << sensor.energy << " ";
}
G4cout << G4endl;
}
}