From 39d35a1b56d523f3a107591c1df7ad53bb4d5c77 Mon Sep 17 00:00:00 2001 From: Jan Kieseler Date: Tue, 7 May 2024 09:51:05 +0200 Subject: [PATCH] file save --- bind/G4Calo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 = []