more safety options for non existing materials

This commit is contained in:
Jan Kieseler
2023-10-10 18:05:35 +02:00
parent 19226f31e6
commit 9ded57e14a
2 changed files with 8 additions and 7 deletions
+4 -6
View File
@@ -1,12 +1,10 @@
from G4Calo import GeometryDescriptor, G4System
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
cw = GeometryDescriptor()
for _ in range(25):
cw.addLayer(0.5, "G4Pb", False)
cw.addLayer(1.,"G4_POLYSTYRENE",True,1)
#directly use G4System as a global singleton
G4System.init(cw)
G4System.displayEvent()
+4 -1
View File
@@ -129,7 +129,10 @@ void DetectorConstruction::DefineMaterials()
nistManager->FindOrBuildMaterial("G4_AIR");
auto cwLayers = cw->getLayers();
for(auto layer : cwLayers){
nistManager->FindOrBuildMaterial(layer.material);
auto ret = nistManager->FindOrBuildMaterial(layer.material);
if(ret == nullptr)
throw std::runtime_error("material not found: " + layer.material);
}
// Print materials