129 lines
2.8 KiB
C++
129 lines
2.8 KiB
C++
|
|
|
|
#include "ConstructionWrapper.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;
|
|
}
|
|
|
|
ConstructionWrapper::ConstructionWrapper(double xy_width){
|
|
xywidth = xy_width;
|
|
}
|
|
|
|
void ConstructionWrapper::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> & ConstructionWrapper::getLayers() const{
|
|
return layers;
|
|
}
|
|
|
|
std::vector<Layer> & ConstructionWrapper::getLayers(){
|
|
return layers;
|
|
}
|
|
|
|
void ConstructionWrapper::resetSensorEnergies()const {
|
|
for(const auto & layer : layers){
|
|
for(const auto & sensor : layer.sensors){
|
|
sensor.energy = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
Layer* ConstructionWrapper::getLayerByVolume(G4VPhysicalVolume* volume){
|
|
for(auto & layer : layers){
|
|
if(layer.physicalVolume == volume){
|
|
return &layer;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
const Layer* ConstructionWrapper::getLayerByVolume(G4VPhysicalVolume* volume)const{
|
|
for(auto & layer : layers){
|
|
if(layer.physicalVolume == volume){
|
|
return &layer;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Sensor* ConstructionWrapper::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* ConstructionWrapper::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 ConstructionWrapper::printSensorEnergies()const{
|
|
for(const auto& layer: layers){
|
|
for(const auto& sensor: layer.sensors){
|
|
G4cout << sensor.energy << " ";
|
|
}
|
|
G4cout << G4endl;
|
|
}
|
|
} |