more safety options for non existing materials
This commit is contained in:
+4
-6
@@ -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()
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user