diff --git a/bind/G4Calo.py b/bind/G4Calo.py index 96cd926..0c94120 100644 --- a/bind/G4Calo.py +++ b/bind/G4Calo.py @@ -12,9 +12,18 @@ class G4System(_G4System): def run_visualize(self,particleSpec : str, minEnergy_GeV: float, maxEnergy_GeV:float = -1.): if maxEnergy_GeV < 0: maxEnergy_GeV = minEnergy_GeV + #anpassen: run 1 event and get stuff from construction wrapper _G4System.run_visualize(self, particleSpec, minEnergy_GeV, maxEnergy_GeV) self.displayEvent() + def run_batch(self, nEvents: int, particleSpec : str, minEnergy_GeV: float, + maxEnergy_GeV:float = -1., outputFile:str = "dataframe.df"): + if maxEnergy_GeV < 0: + maxEnergy_GeV = minEnergy_GeV + _G4System.run_batch(self, nEvents, particleSpec, minEnergy_GeV, maxEnergy_GeV) + # here conversion from root to pandas dataframe + + def displayEvent(self): f_to_conv = max(filter(lambda x: x.endswith(".prim"), os.listdir()), key=os.path.getctime) diff --git a/bind/example.py b/bind/example.py index dd93507..1d6c950 100644 --- a/bind/example.py +++ b/bind/example.py @@ -8,6 +8,6 @@ cw.addLayer(10,"G4_Si",True, 3) #10 cm of Silicon, active, 3x3 segmentation G4s = G4System() G4s.init(cw) -#G4s.run_batch(100, "gamma", 1000, 5000) #100 events, photons, 1000 MeV to 5000 MeV +G4s.run_batch(100, "gamma", 1, 5) #100 events, photons, 1000 MeV to 5000 MeV -G4s.run_visualize("gamma", 1000, 5000) \ No newline at end of file +G4s.run_visualize("gamma", 1, 5) \ No newline at end of file diff --git a/include/DetectorConstruction.hh b/include/DetectorConstruction.hh index bba9cdb..082aba8 100644 --- a/include/DetectorConstruction.hh +++ b/include/DetectorConstruction.hh @@ -61,6 +61,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction { public: + //we have to pass around these global things... static DetectorConstruction* _global_detector_construction; static DetectorConstruction* getDetectorConstruction(){ return _global_detector_construction; @@ -75,7 +76,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction G4VPhysicalVolume* Construct() override; void ConstructSDandField() override; - void setConstructionWrapper(ConstructionWrapper* Cw){ + void setConstructionWrapper(ConstructionWrapper* Cw){ this->cw = Cw; }