11ROOT.gROOT.ProcessLine(
'#include "FairEventHeader.h"')
14from argparse
import ArgumentParser
15from array
import array
20from ShipGeoConfig
import load_from_root_file
27 """Check whether a file exists (local or remote via XRootD)."""
28 if path.startswith(
"root://"):
29 from urllib.parse
import urlparse
31 from XRootD
import client
as xrd_client
33 parsed = urlparse(path)
34 fs = xrd_client.FileSystem(f
"{parsed.scheme}://{parsed.netloc}")
35 status, _ = fs.stat(parsed.path)
37 return os.path.exists(path)
41 """Prevent double delete due to a FairRoot bug."""
43 if ROOT.addressof(ROOT.gEve) == 0:
45 ROOT.SetOwnership(fMan,
False)
48atexit.register(evExit)
52pdg = ROOT.TDatabasePDG.Instance()
55gEnv.SetValue(
"Eve.Viewer.HideMenus",
"off")
63transparentMaterials = {
67 "STTmix9010_2bar": 95,
81parser = ArgumentParser()
83parser.add_argument(
"-f",
"--inputFile", dest=
"InputFile", help=
"Input file (MC simulation)", required=
True)
85 "-r",
"--recoFile", dest=
"recoFile", help=
"Reconstruction file (will be used as friend tree)", required=
False
87parser.add_argument(
"-g",
"--geoFile", dest=
"geoFile", help=
"ROOT geofile", required=
True)
92 help=
"FairRoot param file",
99 help=
"Switch on debugging",
113 dest=
"HiddenParticleID",
114 help=
"HiddenParticle ID",
119options = parser.parse_args()
120if options.InputFile.find(
"_D") > 0:
124if not options.recoFile:
126 if options.InputFile.find(
"_rec.root") > 0:
127 options.recoFile = options.InputFile
128 options.InputFile = options.InputFile.replace(
"_rec.root",
".root")
130 candidate = options.InputFile.replace(
".root",
"_rec.root")
132 options.recoFile = candidate
138 " %6i %7i %6.3F %6.3F %7.3F %7.3F %7.3F %7.3F %6i "
145 mcp.GetStartX() / u.m,
146 mcp.GetStartY() / u.m,
147 mcp.GetStartZ() / u.m,
153def dump(pcut: float = 0) ->
None:
154 print(
" # pid px py pz vx vy vz mid")
156 for mcp
in sTree.MCTrack:
158 if mcp.GetP() / u.GeV < pcut:
164 print(
" # converged Ndf chi2/Ndf P Pt MCid")
166 for ft
in sTree.FitTracks:
168 fitStatus = ft.getFitStatus()
169 fitState = ft.getFittedState()
170 mom = fitState.getMom()
172 "%3i %6i %4i %6.3F %6.3F %6.3F %6i "
175 fitStatus.isFitConverged(),
177 fitStatus.getChi2() / fitStatus.getNdf(),
180 sTree.fitTrack2MC[n],
186 print(
" # P Pt[GeV/c] DOCA[mm] Rsq Vz[m] d1 d2")
188 for aP
in sTree.Particles:
191 if aP.GetMother(1) == 99:
193 Rsq = (aP.Vx() / (2.45 * u.m)) ** 2 + (aP.Vy() / ((10.0 / 2.0 - 0.05) * u.m)) ** 2
195 "%3i %6.3F %6.3F %9.3F %6.3F %6.3F %4i %4i "
213 self.
comp = ROOT.TEveCompound(
"Veto Digis")
214 gEve.AddElement(self.
comp)
215 sc = gEve.GetScenes()
222 self.comp.DestroyElements()
223 self.comp.OpenCompound()
224 nav = ROOT.gGeoManager.GetCurrentNavigator()
225 for digi
in sTree.Digi_SBTHits:
226 if not digi.isValid():
228 node = digi.GetNode()
229 shape = node.GetVolume().GetShape()
230 bx = ROOT.TEveBox(node.GetName())
231 bx.SetPickable(ROOT.kTRUE)
232 bx.SetTitle(digi.__repr__())
233 bx.SetMainColor(ROOT.kMagenta + 3)
234 dx, dy, dz = shape.GetDX(), shape.GetDY(), shape.GetDZ()
235 o = shape.GetOrigin()
236 master = array(
"d", [0, 0, 0])
248 origin = array(
"d", [edge[0] + o[0], edge[1] + o[1], edge[2] + o[2]])
249 nav.LocalToMaster(origin, master)
250 bx.SetVertex(n, master[0], master[1], master[2])
252 self.comp.AddElement(bx)
253 self.comp.CloseCompound()
254 gEve.ElementChanged(self.evscene,
True,
True)
257 self.
comp.OpenCompound()
258 DTrack = ROOT.TEveLine()
259 DTrack.SetPickable(ROOT.kTRUE)
260 DTrack.SetMainColor(ROOT.kCyan)
261 DTrack.SetLineWidth(4)
262 aP = sTree.Particles[n]
263 DTrack.SetTitle(aP.__repr__())
264 DTrack.SetName(
"Prtcle_" + str(n))
265 DTrack.SetNextPoint(aP.Vx(), aP.Vy(), aP.Vz())
266 lam = (self.Targetz - aP.Vz()) / aP.Pz()
267 DTrack.SetNextPoint(aP.Vx() + lam * aP.Px(), aP.Vy() + lam * aP.Py(), self.Targetz)
268 self.
comp.AddElement(DTrack)
269 self.
comp.CloseCompound()
270 gEve.ElementChanged(self.
evscene,
True,
True)
279 self.
comp = ROOT.TEveCompound(
"Tracks")
280 gEve.AddElement(self.
comp)
287 dv = top.GetNode(
"DecayVolume_1")
292 T1Lid = ns.FindObject(
"T1Lid_1").GetMatrix()
294 except AttributeError:
298 muonDet = top.GetNode(
"MuonDetector_1")
300 self.
z_end = muonDet.GetMatrix().GetTranslation()[2] + muonDet.GetVolume().GetShape().GetDZ()
301 elif hasattr(ShipGeo,
"MuonStation3"):
302 self.
z_end = ShipGeo[
"MuonStation3"].z
303 elif top.GetNode(
"VMuonBox_1"):
304 xx = top.GetNode(
"VMuonBox_1")
305 self.
z_end = xx.GetMatrix().GetTranslation()[2] + xx.GetVolume().GetShape().GetDZ()
306 magNode = top.GetNode(
"MCoil_1")
308 self.
z_mag = magNode.GetMatrix().GetTranslation()[2]
309 elif hasattr(ShipGeo,
"Bfield"):
310 self.
z_mag = ShipGeo[
"Bfield"].z
316 sc = gEve.GetScenes()
318 targetNode = top.GetNode(
"TargetArea_1")
320 self.
Targetz = targetNode.GetMatrix().GetTranslation()[2]
321 elif hasattr(ShipGeo,
"target"):
322 self.
Targetz = ShipGeo[
"target"].z0
330 self.comp.DestroyElements()
331 self.comp.OpenCompound()
332 if (sTree.FindBranch(
"FitTracks")
or sTree.FindBranch(
"FitTracks_PR"))
and len(sTree.FitTracks) > 0:
333 self.DrawFittedTracks()
334 if not sTree.FindBranch(
"GeoTracks")
and len(sTree.MCTrack) > 0
and globals()[
"withMCTracks"]:
335 if top.GetNode(
"Tunnel_1"):
339 self.comp.CloseCompound()
340 gEve.ElementChanged(self.evscene,
True,
True)
343 self.
comp.OpenCompound()
344 DTrack = ROOT.TEveLine()
345 DTrack.SetPickable(ROOT.kTRUE)
346 DTrack.SetMainColor(ROOT.kCyan)
347 DTrack.SetLineWidth(4)
348 aP = sTree.Particles[n]
349 DTrack.SetTitle(aP.__repr__())
350 DTrack.SetName(
"Prtcle_" + str(n))
351 DTrack.SetNextPoint(aP.Vx(), aP.Vy(), aP.Vz())
352 lam = (self.
Targetz - aP.Vz()) / aP.Pz()
353 DTrack.SetNextPoint(aP.Vx() + lam * aP.Px(), aP.Vy() + lam * aP.Py(), self.
Targetz)
354 self.
comp.AddElement(DTrack)
357 self.
comp.OpenCompound()
358 fT = sTree.MCTrack[n]
359 DTrack = ROOT.TEveLine()
360 DTrack.SetPickable(ROOT.kTRUE)
361 DTrack.SetTitle(fT.__repr__())
362 p = pdg.GetParticle(fT.GetPdgCode())
366 pName = str(fT.GetPdgCode())
367 DTrack.SetName(
"MCTrck_" + str(n) +
"_" + pName)
368 fPos = ROOT.TVector3()
369 fMom = ROOT.TVector3()
370 fT.GetStartVertex(fPos)
374 for da
in sTree.MCTrack:
375 if da.GetMotherId() == n:
378 DTrack.SetNextPoint(fPos.X(), fPos.Y(), fPos.Z())
379 if evVx
and abs(da.GetStartZ() - fPos.Z()) > 1 * u.cm:
380 DTrack.SetNextPoint(da.GetStartX(), da.GetStartY(), da.GetStartZ())
385 lam = (zEx + fPos.Z()) / fMom.Z()
386 DTrack.SetNextPoint(fPos.X() + lam * fMom.X(), fPos.Y() + lam * fMom.Y(), zEx + fPos.Z())
388 DTrack.SetMainColor(c)
389 DTrack.SetLineWidth(3)
390 self.
comp.AddElement(DTrack)
391 self.
comp.CloseCompound()
392 gEve.ElementChanged(self.
evscene,
True,
True)
397 fPos = ROOT.TVector3()
398 fMom = ROOT.TVector3()
399 for fT
in sTree.MCTrack:
401 DTrack = ROOT.TEveLine()
402 DTrack.SetPickable(ROOT.kTRUE)
403 DTrack.SetTitle(fT.__repr__())
404 fT.GetStartVertex(fPos)
406 hitlist[fPos.Z()] = [fPos.X(), fPos.Y()]
408 if abs(fT.GetPdgCode()) == options.HiddenParticleID:
409 for da
in sTree.MCTrack:
410 if da.GetMotherId() == n:
413 da.GetStartVertex(fPos)
414 hitlist[fPos.Z()] = [fPos.X(), fPos.Y()]
422 "SiliconTargetPoint",
425 if not sTree.GetBranch(P):
427 c = eval(
"sTree." + P)
429 if p.GetTrackID() == n:
430 if hasattr(p,
"LastPoint"):
432 if lp.x() == lp.y()
and lp.x() == lp.z()
and lp.x() == 0:
434 hitlist[p.GetZ()] = [p.GetX(), p.GetY()]
436 hitlist[lp.z()] = [lp.x(), lp.y()]
437 hitlist[2.0 * p.GetZ() - lp.z()] = [
438 2.0 * p.GetX() - lp.x(),
439 2.0 * p.GetY() - lp.y(),
442 hitlist[p.GetZ()] = [p.GetX(), p.GetY()]
443 if len(hitlist) == 1:
444 if fT.GetMotherId() < 0:
446 if abs(sTree.MCTrack[fT.GetMotherId()].GetPdgCode()) == options.HiddenParticleID:
450 for da
in sTree.MCTrack:
451 if da.GetMotherId() == n:
455 hitlist[da.GetStartZ()] = [da.GetStartX(), da.GetStartY()]
459 lam = (zEx + fPos.Z()) / fMom.Z()
460 hitlist[zEx + fPos.Z()] = [
461 fPos.X() + lam * fMom.X(),
462 fPos.Y() + lam * fMom.Y(),
465 lz = list(hitlist.keys())
469 DTrack.SetNextPoint(hitlist[z][0], hitlist[z][1], z)
470 p = pdg.GetParticle(fT.GetPdgCode())
474 pName = str(fT.GetPdgCode())
475 DTrack.SetName(
"MCTrack_" + str(n) +
"_" + pName)
477 if abs(fT.GetPdgCode()) == options.HiddenParticleID:
479 DTrack.SetMainColor(c)
480 DTrack.SetLineWidth(3)
481 self.
comp.AddElement(DTrack)
483 print(
"draw ", ntot,
" MC tracks")
487 for fT
in sTree.FitTracks:
489 fst = fT.getFitStatus()
490 if not fst.isFitConverged():
492 if fst.getNdf() < 20:
494 DTrack = ROOT.TEveLine()
495 DTrack.SetPickable(ROOT.kTRUE)
496 DTrack.SetTitle(fT.__repr__())
497 fstate = fT.getFittedState(0)
498 fPos = fstate.getPos()
499 fMom = fstate.getMom()
502 pid = fstate.getPDG()
504 for i
in range(self.
niter):
507 DTrack.SetNextPoint(newpos.X(), newpos.Y(), newpos.Z())
509 print(
"error with extrapolation: z=", zs)
511 px, py, pz = mom.X(), mom.Y(), mom.Z()
512 lam = (zs - pos.Z()) / pz
513 DTrack.SetNextPoint(pos.X() + lam * px, pos.Y() + lam * py, zs)
515 DTrack.SetName(
"FitTrack_" + str(n))
519 DTrack.SetMainColor(c)
520 DTrack.SetLineWidth(3)
521 self.
comp.AddElement(DTrack)
523 print(
"draw ", ntot,
" fitted tracks")
525 for aP
in sTree.Particles:
529 if aP.GetMother(1) == 99:
530 if aP.T() > 3 * u.cm:
532 for k
in range(aP.GetNDaughters()):
535 fT = sTree.FitTracks[aP.GetDaughter(k)]
536 fst = fT.getFitStatus()
537 if not fst.isFitConverged():
539 if fst.getNdf() < 20:
543 DTrack = ROOT.TEveLine()
544 DTrack.SetPickable(ROOT.kTRUE)
545 DTrack.SetMainColor(ROOT.kCyan)
546 DTrack.SetLineWidth(4)
547 DTrack.SetName(
"Particle_" + str(n))
548 DTrack.SetTitle(aP.__repr__())
549 DTrack.SetNextPoint(aP.Vx(), aP.Vy(), aP.Vz())
550 lam = (self.
Targetz - aP.Vz()) / aP.Pz()
551 DTrack.SetNextPoint(aP.Vx() + lam * aP.Px(), aP.Vy() + lam * aP.Py(), self.
Targetz)
552 self.
comp.AddElement(DTrack)
562 self.
master.title(
"SHiP Event Display GUI")
563 self.
master.geometry(
"320x580+165+820")
565 b = tkinter.Button(self.
fram1, text=
"Next Event", command=self.
nextEvent)
566 b.pack(fill=tkinter.BOTH, expand=1)
567 label = tkinter.Label(self.
fram1, text=
"Event number:")
568 label[
"relief"] = tkinter.RAISED
569 entry = tkinter.Entry(self.
fram1)
570 entry[
"foreground"] =
"blue"
571 label.pack(side=tkinter.LEFT)
572 entry.pack(side=tkinter.RIGHT)
578 entry[
"textvariable"] = self.
contents
582 entry.bind(
"<Key-Return>", self.
nextEvent)
586 if globals()[
"withMCTracks"]:
590 self.
lbut[x] = tkinter.Checkbutton(self.
master, text=
"with MC Tracks", compound=tkinter.LEFT, variable=a)
593 self.
lbut[x].pack(side=tkinter.TOP)
594 self.
geoscene = ROOT.gEve.GetScenes().FindChild(
"Geometry scene")
595 for v
in top.GetNodes():
598 assembly =
"Assembly" in v.GetVolume().__str__()
599 if v.IsVisible()
or (assembly
and v.IsVisDaughters()):
603 self.
lbut[x] = tkinter.Checkbutton(self.
master, text=x.replace(
"_1",
""), compound=tkinter.LEFT, variable=a)
605 self.
lbut[x][
"command"] =
lambda x=x: self.
toggle(x)
606 self.
lbut[x].pack(side=tkinter.BOTTOM)
610 slot = ROOT.TEveWindow.CreateWindowInTab(gEve.GetBrowser().GetTabLeft())
611 slot.SetShowTitleBar(ROOT.kFALSE)
612 packs = slot.MakePack()
613 packs.SetShowTitleBar(ROOT.kFALSE)
614 packs.SetElementName(
"SHiP actions")
615 packs.SetHorizontal()
616 slot = packs.NewSlot()
617 frame = slot.MakeFrame()
618 frame.SetElementName(
"commands")
619 frame.SetShowTitleBar(ROOT.kFALSE)
620 cf = frame.GetGUICompositeFrame()
621 hf = ROOT.TGVerticalFrame(cf)
622 hf.SetCleanup(ROOT.kLocalCleanup)
625 guiFrame = ROOT.TGVerticalFrame(hf)
626 hf.AddFrame(guiFrame, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
627 guiFrame.SetCleanup(ROOT.kDeepCleanup)
628 b = ROOT.TGTextButton(guiFrame,
"Add particle follower")
630 b.SetToolTipText(
"start new window with top projection and energy loss")
631 b.SetCommand(
'TPython::ExecScript("' + os.environ[
"FAIRSHIP"] +
'/macro/evd_addParticleFollower.py")')
632 guiFrame.AddFrame(b, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
633 bn = ROOT.TGTextButton(guiFrame,
"fill histogram")
635 bn.SetToolTipText(
"Fill histogram with energy along flight path")
636 bn.SetCommand(
'TPython::ExecScript("' + os.environ[
"FAIRSHIP"] +
'/macro/evd_fillEnergy.py")')
637 guiFrame.AddFrame(bn, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
638 bt = ROOT.TGTextButton(guiFrame,
"switch transparent mode on/off")
640 bt.SetToolTipText(
"switch transparent mode on/off for better visibility of tracks")
641 bt.SetCommand(
'TPython::ExecScript("' + os.environ[
"FAIRSHIP"] +
'/macro/evd_transparentMode.py")')
642 guiFrame.AddFrame(bt, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
643 bnx = ROOT.TGTextButton(guiFrame,
"next event")
645 bnx.SetToolTipText(
"click for next event")
646 bnx.SetCommand(
'TPython::ExecScript("' + os.environ[
"FAIRSHIP"] +
'/macro/evd_nextEvent.py")')
647 guiFrame.AddFrame(bnx, ROOT.TGLayoutHints(ROOT.kLHintsExpandX))
660 SHiPDisplay.NextEvent(self.
n)
663 tl = fRun.GetMainTask().GetListOfTasks()
664 geoTask = tl.FindObject(
"GeoTracks")
665 if globals()[
"withMCTracks"]:
666 globals()[
"withMCTracks"] =
False
667 self.
lbut[
"withMC"].var.set(1)
671 globals()[
"withMCTracks"] =
True
672 self.
lbut[
"withMC"].var.set(0)
678 assembly =
"Assembly" in v.GetVolume().__str__()
679 if v.IsVisible() > 0
or (assembly
and v.IsVisDaughters() > 0):
680 print(
"switch off ", x)
683 self.
lbut[x].var.set(0)
685 print(
"switch on ", x)
690 self.
lbut[x].var.set(1)
691 gEve.ElementChanged(self.
geoscene,
True,
True)
692 for v
in top.GetNodes():
695 assembly =
"Assembly" in v.GetVolume().__str__()
696 if v.IsVisible() > 0
or (assembly
and v.IsVisDaughters() > 0):
697 self.
lbut[x].var.set(1)
699 self.
lbut[x].var.set(0)
709 if sGeo.GetVolume(
"volTarget"):
718 v1 = gEve.GetDefaultViewer()
719 v1.GetEveFrame().HideAllDecorations()
720 tr = gEve.GetBrowser().GetTabRight()
722 t0.SetText(ROOT.TGString(
"3D"))
729 fRun.Run(self.
n, self.
n + 1)
731 if sTree.GetBranch(
"FitTracks_PR"):
732 sTree.FitTracks = sTree.FitTracks_PR
733 if sTree.GetBranch(
"fitTrack2MC_PR"):
734 sTree.fitTrack2MC = sTree.fitTrack2MC_PR
735 if sTree.GetBranch(
"Particles_PR"):
736 sTree.Particles = sTree.Particles_PR
737 if hasattr(self,
"tracks"):
739 if sTree.FindBranch(
"Digi_SBTHits"):
740 self.
veto.ExecuteTask()
741 if ROOT.gROOT.FindObject(
"Root Canvas EnergyLoss"):
743 print(
"Event %i ready" % (self.
n))
746 p = ROOT.gEve.GetCurrentEvent().FindChild(mcHits[x].GetName())
748 p.SetPickable(ROOT.kTRUE)
749 p.SetTitle(p.__repr__())
751 def rotateView(self, hor: float | int = 0, ver: float | int = 0) ->
None:
752 v = ROOT.gEve.GetDefaultGLViewer()
753 cam = v.CurrentCamera()
755 if hor != 0
or ver != 0:
756 cam.RotateRad(hor, ver)
778 for m
in transparentMaterials:
779 mat = ROOT.gGeoManager.GetMaterial(m)
782 if mode.lower() ==
"on" or mode == 1:
783 mat.SetTransparency(transparentMaterials[m])
786 mat.SetTransparency(
"\x00")
788 sc = gEve.GetScenes()
789 geoscene = sc.FindChild(
"Geometry scene")
791 gEve.ElementChanged(geoscene,
True,
True)
798 s = ROOT.gEve.SpawnNewScene(
"Projected Event")
799 ROOT.gEve.GetDefaultViewer().AddScene(s)
800 v = ROOT.gEve.GetDefaultGLViewer()
801 v.SetCurrentCamera(ROOT.TGLViewer.kCameraOrthoXOY)
802 cam = v.CurrentCamera()
803 cam.SetZoomMinMax(0.2, 20)
805 mng = ROOT.TEveProjectionManager(ROOT.TEveProjection.kPT_RPhi)
807 axes = ROOT.TEveProjectionAxes(mng)
808 axes.SetTitle(
"TEveProjections demo")
810 ROOT.gEve.AddToListTree(axes, ROOT.kTRUE)
811 ROOT.gEve.AddToListTree(mng, ROOT.kTRUE)
816 v = gEve.GetViewers()
817 vw = v.FindChild(
"Viewer 1")
820 sev = ROOT.gEve.SpawnNewViewer(
"Scaled 2D")
821 smng = ROOT.TEveProjectionManager(ROOT.TEveProjection.kPP_Plane)
822 sp = smng.GetProjection()
823 sp.SetUsePreScale(ROOT.kTRUE)
824 sp.AddPreScaleEntry(2, 100000000.0, 0.1)
825 ss = ROOT.gEve.SpawnNewScene(
"Scaled Geom")
828 N = sGeo.GetTopNode()
829 TNod = ROOT.TEveGeoTopNode(sGeo, N, 1, 3, 10)
831 eventscene = ROOT.gEve.SpawnNewScene(
"Scaled event")
832 eventscene.AddElement(ROOT.FairEventManager.Instance())
833 sev.AddScene(eventscene)
834 eventscene.AddElement(smng)
835 ROOT.gEve.GetBrowser().GetTabRight().SetTab(1)
836 ROOT.gEve.FullRedraw3D(ROOT.kTRUE)
840 f = ROOT.TFile.Open(fname,
"RECREATE")
841 cam = ROOT.gEve.GetDefaultGLViewer().CurrentCamera()
847 f = ROOT.TFile.Open(fname)
848 cam = ROOT.gEve.GetDefaultGLViewer().CurrentCamera()
849 f.GetKey(cam.ClassName()).Read(cam)
851 gEve.GetDefaultGLViewer().RequestDraw()
856 for x
in [
"wire",
"gas",
"rockD",
"rockS",
"rockSFe"]:
857 xvol = sGeo.GetVolume(x)
859 xvol.SetVisibility(0)
860 for k
in range(1, 7):
861 va = sGeo.GetVolume(
"T" + str(k))
864 for x
in va.GetNodes():
866 if not nm.find(
"Inner") < 0
and k < 3:
867 x.SetVisDaughters(
False)
868 x.SetVisibility(
False)
869 if not nm.find(
"LiSc") < 0:
870 x.SetVisDaughters(
False)
871 if not nm.find(
"RibPhi") < 0:
872 x.SetVisDaughters(
False)
878 xvol = sGeo.GetVolume(x)
881 xvol.SetVisDaughters(0)
882 xvol.SetVisibility(1)
883 sc = gEve.GetScenes()
884 geoscene = sc.FindChild(
"Geometry scene")
885 gEve.ElementChanged(geoscene,
True,
True)
889 sc = gEve.GetScenes()
890 geoscene = sc.FindChild(
"Geometry scene")
891 for v
in top.GetNodes():
893 if not vname.find(tag) < 0:
896 gEve.ElementChanged(geoscene,
True,
True)
900 sc = gEve.GetScenes()
901 geoscene = sc.FindChild(
"Geometry scene")
902 for v
in top.GetNodes():
904 if not vname.find(tag) < 0:
905 print(
"switch on ", vname)
908 gEve.ElementChanged(geoscene,
True,
True)
912 sc = gEve.GetScenes()
913 geoscene = sc.FindChild(
"Geometry scene")
914 v = sGeo.FindVolumeFast(
"vleft")
917 for v
in sGeo.GetListOfVolumes():
918 if v.GetName().find(
"wallVeto") > 0:
921 gEve.ElementChanged(geoscene,
True,
True)
926 sc = gEve.GetScenes()
927 geoscene = sc.FindChild(
"Geometry scene")
928 for x
in [
"rockD",
"rockS"]:
929 v = sGeo.FindVolumeFast(x)
931 gEve.ElementChanged(geoscene,
True,
True)
935 sc = gEve.GetScenes()
936 geoscene = sc.FindChild(
"Geometry scene")
937 for v
in top.GetNodes():
939 if not vname.find(
"cave") < 0:
943 if not tag.find(vname) < 0:
948 gEve.ElementChanged(geoscene,
True,
True)
952 sc = gEve.GetScenes()
953 geoscene = sc.FindChild(
"Geometry scene")
954 for v
in top.GetNodes():
956 if not vname.find(
"cave") < 0:
960 if not tag.find(vname) < 0:
965 gEve.ElementChanged(geoscene,
True,
True)
970 for v
in sGeo.GetListOfVolumes():
972 if not vname.find(pattern) < 0:
979 if not x.find(tag) < 0:
983def rename(name: str =
"ship.TGeant4.root") ->
None:
984 f = ROOT.TFile(name,
"UPDATE")
986 for x
in t.GetListOfBranches():
987 nm = x.GetName().replace(
"_1",
"")
997 self.
ruler = ROOT.TEveCompound(
"Rulers")
998 gEve.AddElement(self.
ruler)
1000 def show(self, xy: int = 0, ticks: int = 5) ->
None:
1001 self.
ruler.DestroyElements()
1002 self.
ruler.OpenCompound()
1003 xpos, ypos = -500.0, -1500.0
1004 zstart = ShipGeo.target.z0
1005 zlength = ShipGeo.MuonStation3.z - zstart + 10 * u.m
1006 a1 = ROOT.TEveLine()
1007 a1.SetNextPoint(xpos, ypos, zstart)
1008 a1.SetNextPoint(xpos, ypos, zstart + zlength)
1009 a1.SetMainColor(ROOT.kAzure - 9)
1013 for i
in range(int(zlength / 100 / ticks)):
1015 m.SetNextPoint(xpos, ypos, z)
1016 m.SetNextPoint(xpos - 1 * u.m, ypos, z)
1017 m.SetMainColor(ROOT.kRed)
1019 self.
ruler.AddElement(m)
1020 t1 = ROOT.TEveText(str(i * ticks) +
"m")
1021 t1.SetMainColor(ROOT.kGray + 3)
1023 t1.RefMainTrans().SetPos(xpos - 0.1 * u.m, ypos + 0.2 * u.m, z)
1024 self.
ruler.AddElement(t1)
1026 xpos, ypos = 0.0, 0.0
1028 z = ShipGeo.MuonStation3.z + 6 * u.m
1032 a2 = ROOT.TEveLine()
1033 a2.SetNextPoint(xpos, -ylength, z)
1034 a2.SetNextPoint(xpos, ylength, z)
1035 a2.SetMainColor(ROOT.kAzure - 9)
1039 for i
in range(-int(ylength / 100), int(ylength / 100), 1):
1041 m.SetNextPoint(xpos, ypos, z)
1042 m.SetNextPoint(xpos + 0.05 * u.m, ypos, z)
1043 m.SetMainColor(ROOT.kRed)
1045 self.
ruler.AddElement(m)
1046 t1 = ROOT.TEveText(str(i) +
"m")
1047 t1.SetMainColor(ROOT.kGray + 3)
1049 t1.RefMainTrans().SetPos(xpos - 0.5 * u.m, ypos, z)
1050 self.
ruler.AddElement(t1)
1052 ty = ROOT.TEveText(
"y-axis")
1054 ty.RefMainTrans().SetPos(0.0, ypos + 1 * u.m, z)
1055 ty.SetMainColor(ROOT.kRed - 2)
1056 self.
ruler.AddElement(ty)
1057 xpos, ypos = 0.0, 0.0
1059 z = ShipGeo.MuonStation3.z + 10 * u.m
1061 a3 = ROOT.TEveLine()
1062 a3.SetNextPoint(-xlength, 0, z)
1063 a3.SetNextPoint(xlength, 0, z)
1064 a3.SetMainColor(ROOT.kAzure - 9)
1068 for i
in range(-int(xlength / 100), int(xlength / 100), 1):
1070 m.SetNextPoint(xpos, ypos, z)
1071 m.SetNextPoint(xpos, ypos - 0.05 * u.m, z)
1072 m.SetMainColor(ROOT.kRed)
1074 self.
ruler.AddElement(m)
1075 t1 = ROOT.TEveText(str(i) +
"m")
1076 t1.SetMainColor(ROOT.kGray + 3)
1078 t1.RefMainTrans().SetPos(xpos, ypos - 0.1 * u.m, z)
1079 self.
ruler.AddElement(t1)
1081 tx = ROOT.TEveText(
"x-axis")
1083 tx.RefMainTrans().SetPos(xpos + 1 * u.m, 0.0, z)
1084 tx.SetMainColor(ROOT.kRed - 2)
1085 self.
ruler.AddElement(tx)
1086 t1 = ROOT.TEveText(
"SHiP")
1088 t1.RefMainTrans().SetPos(0.0, 600.0, ShipGeo.TrackStation1.z - 10 * u.m)
1089 t1.PtrMainTrans().RotateLF(1, 3, ROOT.TMath.PiOver2())
1090 t1.SetMainColor(ROOT.kOrange - 2)
1091 t1.SetFontMode(ROOT.TGLFont.kExtrude)
1092 t1.SetLighting(ROOT.kTRUE)
1093 self.
ruler.AddElement(t1)
1094 self.
ruler.CloseCompound()
1095 sc = ROOT.gEve.GetScenes()
1096 geoscene = sc.FindChild(
"Geometry scene")
1097 ROOT.gEve.ElementChanged(geoscene,
True,
True)
1100 self.
ruler.DestroyElements()
1104 t = g.FindObjectAny(
"cbmsim")
1105 nev = t.GetEntriesFast()
1108 for i
in range(min(5, nev)):
1110 for gTr
in t.GeoTracks:
1113 lorv = ROOT.TLorentzVector()
1125 for i
in range(min(5, nev)):
1127 for gMCTr
in t.MCTrack:
1129 print(gMCTr.GetPdgCode(), gMCTr.GetMass(), gMCTr.GetP())
1131 for i
in range(nev):
1134 t.MCEventHeader.GetEventID(),
1135 t.MCEventHeader.GetRunID(),
1136 t.MCEventHeader.GetZ(),
1139 sGeo = ROOT.gGeoManager
1140 cave = sGeo.GetTopVolume()
1145 sc = gEve.GetScenes()
1146 geoscene = sc.FindChild(
"Geometry scene")
1147 topnode = geoscene.FindChild(
"cave_1")
1148 topnode.SetVisLevel(4)
1149 gEve.ElementChanged(geoscene,
True,
True)
1153 sGeo = ROOT.gGeoManager
1154 vols = sGeo.GetListOfVolumes()
1155 sTree = g.FindObjectAny(
"cbmsim")
1157 for s
in sTree.strawtubesPoint:
1158 print(vols[s.GetDetectorID() - 1].GetName())
1162ROOT.gSystem.Load(
"libEGPythia6.so")
1163ROOT.gSystem.Load(
"libPythia6.so")
1164ROOT.gSystem.Load(
"libpythia8.so")
1166ROOT.gInterpreter.Declare(
'#include "VectorMCPointSource.h"')
1169fRun = ROOT.FairRunAna()
1171 fRun.SetGeomFile(options.geoFile)
1173inFile = ROOT.FairFileSource(options.InputFile)
1174fRun.SetSource(inFile)
1175if options.OutputFile
is None:
1176 options.OutputFile = ROOT.TMemFile(
"event_display_output",
"recreate")
1177fRun.SetSink(ROOT.FairRootFileSink(options.OutputFile))
1180 rtdb = fRun.GetRuntimeDb()
1181 parInput1 = ROOT.FairParRootFileIo()
1182 parInput1.open(options.ParFile)
1183 rtdb.setFirstInput(parInput1)
1185fMan = ROOT.FairEventManager()
1186fMan.SetMaxEnergy(400.0)
1187fMan.SetMinEnergy(0.1)
1188fMan.SetEvtMaxEnergy(400.0)
1189fMan.SetPriOnly(
False)
1194 Track = ROOT.FairMCTracksDraw(
"Monte-Carlo Tracks")
1195 GTrack = ROOT.FairGeoTracksDraw(
"GeoTracks")
1196 fMan.AddTask(GTrack)
1200ShipGeo = load_from_root_file(fRun.GetGeoFile(),
"ShipGeo")
1203_tmpFile = ROOT.TFile.Open(options.InputFile)
1204_tmpTree = _tmpFile.Get(
"cbmsim")
if _tmpFile
else None
1208 "VetoPoints": (
"vetoPoint", ROOT.kBlue, ROOT.kFullDiamond),
1209 "TimeDetPoints": (
"TimeDetPoint", ROOT.kBlue, ROOT.kFullDiamond),
1210 "StrawPoints": (
"strawtubesPoint", ROOT.kGreen, ROOT.kFullCircle),
1211 "TargetPoints": (
"TargetPoint", ROOT.kRed, ROOT.kFullSquare),
1212 "MTCDetPoint": (
"MTCDetPoint", ROOT.kGreen, ROOT.kFullSquare),
1213 "SiliconTargetPoint": (
"SiliconTargetPoint", ROOT.kCyan, ROOT.kFullSquare),
1215for key, (branch, colour, marker)
in _candidates.items():
1216 if _tmpTree
and _tmpTree.GetBranch(branch):
1217 source = ROOT.VectorMCPointSource[branch](branch)
1218 mcHits[key] = ROOT.FairMCPointDraw(branch, source, colour, marker)
1224 fMan.AddTask(mcHits[x])
1233fRman = ROOT.FairRootManager.Instance()
1234sTree = fRman.GetInChain()
1236 sTree.AddFriend(
"ship_reco_sim", options.recoFile)
1237lsOfGlobals = ROOT.gROOT.GetListOfGlobals()
1238lsOfGlobals.Add(sTree)
1239sGeo = ROOT.gGeoManager
1240top = sGeo.GetTopVolume()
1245if hasattr(ShipGeo,
"Bfield"):
1246 if hasattr(ShipGeo.Bfield,
"fieldMap"):
1247 ROOT.gSystem.Load(
"libG4clhep.so")
1248 ROOT.gSystem.Load(
"libgeant4vmc.so")
1252 bfield = ROOT.genfit.FairShipFields()
1253 bfield.setField(fieldMaker.getGlobalField())
1255 bellField = ROOT.ShipBellField(
1256 "bellfield", ShipGeo.Bfield.max, ShipGeo.Bfield.z, 2, ShipGeo.Bfield.y / 2.0 * u.m
1258 compField = ROOT.ShipCompField(
"compfield", bellField)
1259 bfield = ROOT.genfit.FairShipFields()
1260 bfield.setField(compField)
1261 geoMat = ROOT.genfit.TGeoMaterialInterface()
1262 ROOT.genfit.MaterialEffects.getInstance().init(geoMat)
1263 fM = ROOT.genfit.FieldManager.getInstance()
1266import TrackExtrapolateTool
1268br = gEve.GetBrowser()
1270br.SetWindowName(
"SHiP Eve Window")
1273if sGeo.FindVolumeFast(
"T2LiSc"):
1279eveGlobal.SHiPDisplay = SHiPDisplay
1280SHiPDisplay.SetName(
"SHiP Displayer")
1281lsOfGlobals.Add(SHiPDisplay)
1282SHiPDisplay.InitTask()
1286print(
"Help on GL viewer can be found by pressing Help button followed by help on GL viewer")
1287print(
"With the camera button, you can switch to different views.")
1301 for aTrack
in sTree.MCTrack:
1305 if aTrack.GetMotherId() == 1:
1306 pa = pdg.GetParticle(sTree.MCTrack[i].GetPdgCode())
1307 if pa.Lifetime() > 1.0e-12:
1308 print(sTree.MCTrack[i])
1309 SHiPDisplay.tracks.DrawMCTrack(i)
1313 comp = SHiPDisplay.tracks.comp
1317 fPos = ROOT.TVector3()
1318 fMom = ROOT.TVector3()
1320 for fT
in sTree.MCTrack:
1322 DTrack = ROOT.TEveLine()
1323 DTrack.SetPickable(ROOT.kTRUE)
1324 DTrack.SetTitle(fT.__repr__())
1325 fT.GetStartVertex(fPos)
1326 fT.GetMomentum(fMom)
1328 hitlist[fPos.Z()] = [fPos.X(), fPos.Y()]
1330 slx, sly = fMom.X() / fMom.Z(), fMom.Y() / fMom.Z()
1331 hitlist[z] = [fPos.X() + slx * delZ, fPos.Y() + sly * delZ]
1333 DTrack.SetNextPoint(hitlist[z][0], hitlist[z][1], z)
1334 p = pdg.GetParticle(fT.GetPdgCode())
1338 pName = str(fT.GetPdgCode())
1339 DTrack.SetName(
"MCTrack_" + str(n) +
"_" + pName)
1341 DTrack.SetMainColor(c)
1342 DTrack.SetLineWidth(3)
1343 comp.AddElement(DTrack)
1345 comp.CloseCompound()
1346 gEve.ElementChanged(SHiPDisplay.tracks.evscene,
True,
True)
1358 mode=ROOT.TGLFont.kExtrude,
1361 tt = ROOT.TEveText(txt)
1362 tt.SetFontSize(size)
1363 tt.RefMainTrans().SetPos(x, y, z)
1364 tt.PtrMainTrans().RotateLF(1, 3, angle)
1365 tt.SetMainColor(color)
1366 tt.SetFontMode(mode)
1367 tt.SetLighting(light)
1374 "moreShieldingSide",
1375 "moreShieldingTopBot",
1380 vol = ROOT.gGeoManager.FindVolumeFast(x)
1381 vol.SetVisibility(0)
1382 ROOT.gGeoManager.GetMaterial(
"Concrete").SetTransparency(0)
1387 xpos, ypos = -500.0, -1500.0
1388 zstart = ShipGeo.target.z0
1389 zlength = ShipGeo.MuonStation3.z - zstart + 10 * u.m
1391 for i
in range(int(zlength / 100 / ticks)):
1393 m.SetNextPoint(xpos, ypos, z)
1394 m.SetNextPoint(xpos - 1 * u.m, ypos, z)
1395 m.SetMainColor(ROOT.kRed)
1398 t1 = ROOT.TEveText(str(i * ticks) +
"m")
1399 t1.SetMainColor(ROOT.kGray + 3)
1401 t1.RefMainTrans().SetPos(xpos - 0.1 * u.m, ypos + 0.2 * u.m, z)
1404 xpos, ypos = 0.0, 0.0
1405 z = ShipGeo.MuonStation3.z + 6 * u.m
1408 for i
in range(-int(ylength / 100), int(ylength / 100), 1):
1410 m.SetNextPoint(xpos, ypos, z)
1411 m.SetNextPoint(xpos + 0.05 * u.m, ypos, z)
1412 m.SetMainColor(ROOT.kRed)
1415 t1 = ROOT.TEveText(str(i) +
"m")
1416 t1.SetMainColor(ROOT.kGray + 3)
1418 t1.RefMainTrans().SetPos(xpos - 0.5 * u.m, ypos, z)
1421 ty = ROOT.TEveText(
"y-axis")
1423 ty.RefMainTrans().SetPos(0.0, ypos + 1 * u.m, z)
1424 ty.SetMainColor(ROOT.kRed - 2)
1426 xpos, ypos = 0.0, 0.0
1427 z = ShipGeo.MuonStation3.z + 10 * u.m
1430 for i
in range(-int(xlength / 100), int(xlength / 100), 1):
1432 m.SetNextPoint(xpos, ypos, z)
1433 m.SetNextPoint(xpos, ypos - 0.05 * u.m, z)
1434 m.SetMainColor(ROOT.kRed)
1437 t1 = ROOT.TEveText(str(i) +
"m")
1438 t1.SetMainColor(ROOT.kGray + 3)
1440 t1.RefMainTrans().SetPos(xpos, ypos - 0.1 * u.m, z)
1443 tx = ROOT.TEveText(
"x-axis")
1445 tx.RefMainTrans().SetPos(xpos + 1 * u.m, 0.0, z)
1446 tx.SetMainColor(ROOT.kRed - 2)
1448 rotAngle = ROOT.TMath.Pi() + ROOT.TMath.PiOver2() * 5.0 / 2.0
1453 ShipGeo.TrackStation1.z - 20 * u.m,
1463 ShipGeo.TrackStation1.z - 40 * u.m,
1465 "Vacuum decay vessel",
1469 positionText(r, 0.0, 100.0, ShipGeo.target.z - 6 * u.m, rotAngle,
"Target", 200, ROOT.kBlue)
1474 ShipGeo.muShield.z - 10 * u.m,
1476 "Active muon shield",
1484 ShipGeo.tauMudet.zMudetC - 10 * u.m,
1486 "Tau neutrino detector",
1494 ShipGeo.Bfield.z - 5 * u.m,
1504 ShipGeo.TrackStation3.z - 2 * u.m,
1510 positionText(r, 0.0, 700.0, ShipGeo.MuonFilter2.z, rotAngle,
"Muon", 200, ROOT.kGreen + 2)
1512 sc = gEve.GetScenes()
1513 geoscene = sc.FindChild(
"Geometry scene")
1514 gEve.ElementChanged(geoscene,
True,
True)
None ExecuteTask(self, str option="")
None DrawFittedTracks(self, str option="")
None DrawMCTrack(self, int n)
None DrawMCTracks(self, str option="")
None DrawParticle(self, n)
None ExecuteTask(self, str option="")
None DrawParticle(self, n)
None rotateView(self, float|int hor=0, float|int ver=0)
None transparentMode(self, str mode="on")
None NextEvent(self, int i=-1)
None toggleMCTracks(self)
None nextEvent(self, event=None)
None show(self, int xy=0, int ticks=5)
None rename(str name="ship.TGeant4.root")
None storeCameraSetting(str fname="camSetting.root")
None projection_prescale()
bool _file_accessible(str path)
None hidePlasticScintillator()
None readCameraSetting(str fname="camSetting.root")
None positionText(r, float x, float y, z, angle, str txt, int size=200, color=ROOT.kBlue, mode=ROOT.TGLFont.kExtrude, light=ROOT.kTRUE)
None printMCTrack(int n, MCTrack)
None DrawSimpleMCTracks()
def addVMCFields(shipGeo, str controlFile="", bool verbose=False, bool withVirtualMC=True)
None configure(darkphoton=None)