diff --git a/bind/example.py b/bind/example.py index 27cd686..9ec268f 100644 --- a/bind/example.py +++ b/bind/example.py @@ -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() \ No newline at end of file diff --git a/src/DetectorConstruction.cc b/src/DetectorConstruction.cc index 891162f..620aa31 100644 --- a/src/DetectorConstruction.cc +++ b/src/DetectorConstruction.cc @@ -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