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 < 0: maxEnergy = minEnergy _G4System.run_visualize(self, particleSpec, minEnergy_GeV, maxEnergy_GeV) self.displayEvent() 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))