FairShip
Loading...
Searching...
No Matches
eventDisplay.IO Class Reference

Public Member Functions

None __init__ (self)
None nextEvent (self, event=None)
None toggleMCTracks (self)
None toggle (self, x)

Public Attributes

 master = tkinter.Tk()
 fram1 = tkinter.Frame(self.master)
 contents = tkinter.IntVar()
int n = 0
 nextEvent
dict lbut = {}
 geoscene = ROOT.gEve.GetScenes().FindChild("Geometry scene")

Detailed Description

Definition at line 581 of file eventDisplay.py.

Constructor & Destructor Documentation

◆ __init__()

None eventDisplay.IO.__init__ ( self)

Definition at line 582 of file eventDisplay.py.

582 def __init__(self) -> None:
583 self.master = tkinter.Tk()
584 self.master.title("SHiP Event Display GUI")
585 self.master.geometry("320x580+165+820")
586 self.fram1 = tkinter.Frame(self.master)
587 b = tkinter.Button(self.fram1, text="Next Event", command=self.nextEvent)
588 b.pack(fill=tkinter.BOTH, expand=1)
589 label = tkinter.Label(self.fram1, text="Event number:")
590 label["relief"] = tkinter.RAISED
591 entry = tkinter.Entry(self.fram1)
592 entry["foreground"] = "blue"
593 label.pack(side=tkinter.LEFT)
594 entry.pack(side=tkinter.RIGHT)
595 self.contents = tkinter.IntVar()
596 # set it to some value
597 self.n = 0
598 self.contents.set(self.n)
599 # tell the entry widget to watch this variable
600 entry["textvariable"] = self.contents
601 # and here we get a callback when the user hits return.
602 # we will have the program print out the value of the
603 # application variable when the user hits return
604 entry.bind("<Key-Return>", self.nextEvent)
605 self.lbut = {}
606 x = "withMC"
607 a = tkinter.IntVar()
608 if globals()["withMCTracks"]:
609 a.set(1)
610 else:
611 a.set(0)
612 self.lbut[x] = tkinter.Checkbutton(self.master, text="with MC Tracks", compound=tkinter.LEFT, variable=a)
613 self.lbut[x].var = a # pyrefly: ignore # dynamic attribute, read back by toggleMCTracks / toggle
614 self.lbut[x]["command"] = self.toggleMCTracks
615 self.lbut[x].pack(side=tkinter.TOP)
616 self.geoscene = ROOT.gEve.GetScenes().FindChild("Geometry scene")
617 for v in top.GetNodes():
618 x = v.GetName()
619 a = tkinter.IntVar()
620 assembly = "Assembly" in v.GetVolume().__str__()
621 if v.IsVisible() or (assembly and v.IsVisDaughters()):
622 a.set(1)
623 else:
624 a.set(0)
625 self.lbut[x] = tkinter.Checkbutton(self.master, text=x.replace("_1", ""), compound=tkinter.LEFT, variable=a)
626 self.lbut[x].var = a
627 self.lbut[x]["command"] = lambda x=x: self.toggle(x)
628 self.lbut[x].pack(side=tkinter.BOTTOM)
629 self.fram1.pack()
630 # add ship actions to eve display
631 gEve = ROOT.gEve
632 slot = ROOT.TEveWindow.CreateWindowInTab(gEve.GetBrowser().GetTabLeft())
633 slot.SetShowTitleBar(ROOT.kFALSE)
634 packs = slot.MakePack()
635 packs.SetShowTitleBar(ROOT.kFALSE)
636 packs.SetElementName("SHiP actions")
637 packs.SetHorizontal()
638 slot = packs.NewSlot()
639 frame = slot.MakeFrame()
640 frame.SetElementName("commands")
641 frame.SetShowTitleBar(ROOT.kFALSE)
642 cf = frame.GetGUICompositeFrame()
643 hf = ROOT.TGVerticalFrame(cf)
644 hf.SetCleanup(ROOT.kLocalCleanup)
645 hf.SetWidth(150)
646 cf.AddFrame(hf)
647 guiFrame = ROOT.TGVerticalFrame(hf)
648 hf.AddFrame(guiFrame, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
649 guiFrame.SetCleanup(ROOT.kDeepCleanup)
650 b = ROOT.TGTextButton(guiFrame, "Add particle follower")
651 b.SetWidth(150)
652 b.SetToolTipText("start new window with top projection and energy loss")
653 b.SetCommand('TPython::ExecScript("' + os.environ["FAIRSHIP"] + '/macro/evd_addParticleFollower.py")')
654 guiFrame.AddFrame(b, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
655 bn = ROOT.TGTextButton(guiFrame, "fill histogram")
656 bn.SetWidth(150)
657 bn.SetToolTipText("Fill histogram with energy along flight path")
658 bn.SetCommand('TPython::ExecScript("' + os.environ["FAIRSHIP"] + '/macro/evd_fillEnergy.py")')
659 guiFrame.AddFrame(bn, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
660 bt = ROOT.TGTextButton(guiFrame, "switch transparent mode on/off")
661 bt.SetWidth(150)
662 bt.SetToolTipText("switch transparent mode on/off for better visibility of tracks")
663 bt.SetCommand('TPython::ExecScript("' + os.environ["FAIRSHIP"] + '/macro/evd_transparentMode.py")')
664 guiFrame.AddFrame(bt, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
665 bnx = ROOT.TGTextButton(guiFrame, "next event")
666 bnx.SetWidth(150)
667 bnx.SetToolTipText("click for next event")
668 bnx.SetCommand('TPython::ExecScript("' + os.environ["FAIRSHIP"] + '/macro/evd_nextEvent.py")')
669 guiFrame.AddFrame(bnx, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
670 #
671 cf.MapSubwindows()
672 cf.Layout()
673 cf.MapWindow()
674

Member Function Documentation

◆ nextEvent()

None eventDisplay.IO.nextEvent ( self,
event = None )

Definition at line 675 of file eventDisplay.py.

675 def nextEvent(self, event=None) -> None:
676 i = int(self.contents.get())
677 if i == self.n:
678 self.n += 1
679 else:
680 self.n = i
681 self.contents.set(self.n)
682 SHiPDisplay.NextEvent(self.n)
683

◆ toggle()

None eventDisplay.IO.toggle ( self,
x )

Definition at line 700 of file eventDisplay.py.

700 def toggle(self, x) -> None:
701 v = top.GetNode(x)
702 assembly = "Assembly" in v.GetVolume().__str__()
703 if v.IsVisible() > 0 or (assembly and v.IsVisDaughters() > 0):
704 print("switch off ", x)
705 v.SetVisibility(0)
706 v.SetVisDaughters(0)
707 self.lbut[x].var.set(0)
708 else:
709 print("switch on ", x)
710 if assembly:
711 v.SetVisDaughters(1)
712 else:
713 v.SetVisibility(1)
714 self.lbut[x].var.set(1)
715 gEve.ElementChanged(self.geoscene, True, True)
716 for v in top.GetNodes():
717 x = v.GetName()
718 if x in self.lbut:
719 assembly = "Assembly" in v.GetVolume().__str__()
720 if v.IsVisible() > 0 or (assembly and v.IsVisDaughters() > 0):
721 self.lbut[x].var.set(1)
722 else:
723 self.lbut[x].var.set(0)
724
725
726#

◆ toggleMCTracks()

None eventDisplay.IO.toggleMCTracks ( self)

Definition at line 684 of file eventDisplay.py.

684 def toggleMCTracks(self) -> None:
685 if fRun is None:
686 raise RuntimeError("toggleMCTracks called before fRun was initialised")
687 tl = fRun.GetMainTask().GetListOfTasks()
688 geoTask = tl.FindObject("GeoTracks")
689 if globals()["withMCTracks"]:
690 globals()["withMCTracks"] = False
691 self.lbut["withMC"].var.set(0)
692 if geoTask:
693 geoTask.SetActive(0)
694 else:
695 globals()["withMCTracks"] = True
696 self.lbut["withMC"].var.set(1)
697 if geoTask:
698 geoTask.SetActive(1)
699

Member Data Documentation

◆ contents

eventDisplay.IO.contents = tkinter.IntVar()

Definition at line 595 of file eventDisplay.py.

◆ fram1

eventDisplay.IO.fram1 = tkinter.Frame(self.master)

Definition at line 586 of file eventDisplay.py.

◆ geoscene

eventDisplay.IO.geoscene = ROOT.gEve.GetScenes().FindChild("Geometry scene")

Definition at line 616 of file eventDisplay.py.

◆ lbut

dict eventDisplay.IO.lbut = {}

Definition at line 605 of file eventDisplay.py.

◆ master

eventDisplay.IO.master = tkinter.Tk()

Definition at line 583 of file eventDisplay.py.

◆ n

eventDisplay.IO.n = 0

Definition at line 597 of file eventDisplay.py.

◆ nextEvent

eventDisplay.IO.nextEvent

Definition at line 604 of file eventDisplay.py.


The documentation for this class was generated from the following file: