diff --git a/bind/G4Calo.py b/bind/G4Calo.py index eca3820..18c6b8e 100644 --- a/bind/G4Calo.py +++ b/bind/G4Calo.py @@ -22,11 +22,13 @@ class __G4System(_G4System): particleSpec: str, minEnergy_GeV: float, maxEnergy_GeV: float = -1.0, + filename: str = "", ): if maxEnergy_GeV < 0: maxEnergy_GeV = minEnergy_GeV + save_file = len(filename) > 0 # filename without file ending(!) filename = "_" + str(time.perf_counter_ns()) + ".root" _G4System.run_batch(self, nEvents, particleSpec, minEnergy_GeV, maxEnergy_GeV, filename=filename) @@ -49,13 +51,13 @@ class __G4System(_G4System): df = index_out_of_bounds_workaround(ttree["Hits;1"]) # save to pickle and delete root file - df.to_pickle(filename.replace(".root", ".pkl")) + if save_file: + df.to_pickle(filename.replace(".root", ".pkl")) os.system("rm "+filename) return df - def displayEvent(self, logE = False, renderer=None): # for loop over all layers to_plot = []