from minicalo import ConstructionWrapper from minicalo import G4System as _G4System import os import subprocess from IPython.display import Image, display 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) # Convert the .prim file to an eps graphic. subprocess.run(["dawn", "-d", f_to_conv], stderr=subprocess.DEVNULL) # Convert the eps graphic to png graphic. subprocess.run(["gs", "-DEPSCrop", "-dSAFER", "-sDEVICE=png256", "-r600", "-o", "event_raw.png", f_to_conv.replace(".prim", ".eps")], stdout=subprocess.DEVNULL) subprocess.run(["convert", "event_raw.png", "-trim", "event.png" ]) display(Image("event.png", width=500))