file save
This commit is contained in:
+4
-2
@@ -22,11 +22,13 @@ class __G4System(_G4System):
|
|||||||
particleSpec: str,
|
particleSpec: str,
|
||||||
minEnergy_GeV: float,
|
minEnergy_GeV: float,
|
||||||
maxEnergy_GeV: float = -1.0,
|
maxEnergy_GeV: float = -1.0,
|
||||||
|
filename: str = "",
|
||||||
):
|
):
|
||||||
|
|
||||||
if maxEnergy_GeV < 0:
|
if maxEnergy_GeV < 0:
|
||||||
maxEnergy_GeV = minEnergy_GeV
|
maxEnergy_GeV = minEnergy_GeV
|
||||||
|
|
||||||
|
save_file = len(filename) > 0
|
||||||
# filename without file ending(!)
|
# filename without file ending(!)
|
||||||
filename = "_" + str(time.perf_counter_ns()) + ".root"
|
filename = "_" + str(time.perf_counter_ns()) + ".root"
|
||||||
_G4System.run_batch(self, nEvents, particleSpec, minEnergy_GeV, maxEnergy_GeV, filename=filename)
|
_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"])
|
df = index_out_of_bounds_workaround(ttree["Hits;1"])
|
||||||
|
|
||||||
# save to pickle and delete root file
|
# 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)
|
os.system("rm "+filename)
|
||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def displayEvent(self, logE = False, renderer=None):
|
def displayEvent(self, logE = False, renderer=None):
|
||||||
# for loop over all layers
|
# for loop over all layers
|
||||||
to_plot = []
|
to_plot = []
|
||||||
|
|||||||
Reference in New Issue
Block a user