file save

This commit is contained in:
Jan Kieseler
2024-05-07 09:51:05 +02:00
parent 32719f21c3
commit 39d35a1b56
+4 -2
View File
@@ -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 = []