Commit 3655fe89 authored by David Blyth's avatar David Blyth
Browse files

SiEIC Concept: sieic_vis: energy-dep calo marker size, more default views

parent 6ce2f6cd
......@@ -11,8 +11,9 @@ def run(args):
kernel.loadGeometry('file:' + args.compact_path)
dd = kernel.detectorDescription()
manager = dd.manager()
manager.CheckOverlaps(0.01)
manager.PrintOverlaps()
if not args.nocheck:
manager.CheckOverlaps(0.01)
manager.PrintOverlaps()
if args.input_file == None:
manager.SetVisDensity()
manager.SetVisLevel(2)
......@@ -22,6 +23,8 @@ def run(args):
viewer = ROOT.gPad.GetViewer3D()
viewer.SetCurrentCamera(ROOT.TGLViewer.kCameraOrthoZOY)
viewer.ToggleOrthoRotate()
if args.dark_theme:
viewer.SwitchColorSet()
if args.input_file == None:
overlay = viewer.GetCameraOverlay()
......@@ -40,15 +43,19 @@ def run(args):
marker.Draw('same')
for line in lines:
line.Draw('same')
args.output_prefix += '_' + args.input_file + '_' + str(args.input_event)
viewer.UpdateScene()
if args.interactive:
ROOT.gApplication.Run()
else:
save_picture(viewer, args.output_prefix + '.png')
save_picture(viewer, args.output_prefix + '_perp.png')
camera = viewer.CurrentCamera()
camera.RotateRad(-0.25, -0.4)
camera.RotateRad(0, ROOT.TMath.Pi() / 2.)
save_picture(viewer, args.output_prefix + '_long.png')
camera.RotateRad(0, -ROOT.TMath.Pi() / 2.)
camera.RotateRad(-0.25, 0.4)
save_picture(viewer, args.output_prefix + '_angled.png')
if args.input_file == None:
overlay.SetShowOrthographic(False)
......@@ -78,7 +85,7 @@ def draw_event(input_file, input_event):
type_name = coll.getTypeName()
if type_name == "SimTrackerHit":
n_hits = coll.getNumberOfElements()
tracker_hit_markers = ROOT.TPolyMarker3D(n_hits)
tracker_hit_markers = ROOT.TPolyMarker3D()
markers.append(tracker_hit_markers)
tracker_hit_markers.SetMarkerSize(10)
tracker_hit_markers.SetMarkerColor(3)
......@@ -86,22 +93,31 @@ def draw_event(input_file, input_event):
for i in range(0, n_hits):
hit = coll.getElementAt(i)
hit.__class__ = ROOT.IMPL.SimTrackerHitImpl
energy = hit.getEDep()
if energy == 0:
continue
pos = hit.getPosition()
tracker_hit_markers.SetPoint(i, pos[0] / 10., pos[1] / 10., pos[2] / 10.)
tracker_hit_markers.SetNextPoint(pos[0] / 10., pos[1] / 10., pos[2] / 10.)
elif type_name == "SimCalorimeterHit":
n_hits = coll.getNumberOfElements()
calo_hit_markers = ROOT.TPolyMarker3D()
markers.append(calo_hit_markers)
calo_hit_markers.SetMarkerSize(4)
calo_hit_markers.SetMarkerColor(6)
if coll_name.startswith("Hcal"):
calo_hit_markers.SetMarkerColor(7)
calo_hit_markers.SetMarkerStyle(4)
for i in range(0, n_hits):
hit = coll.getElementAt(i)
hit.__class__ = ROOT.IMPL.SimCalorimeterHitImpl
energy = hit.getEnergy()
if energy == 0:
continue
marker_size = math.log(energy * 1e12) * 0.25
if(marker_size <= 0):
continue
pos = hit.getPosition()
calo_hit_markers.SetPoint(i, pos[0] / 10., pos[1] / 10., pos[2] / 10.)
calo_hit_markers = ROOT.TPolyMarker3D(1)
markers.append(calo_hit_markers)
calo_hit_markers.SetMarkerSize(marker_size)
calo_hit_markers.SetMarkerColor(6)
if coll_name.startswith("Hcal"):
calo_hit_markers.SetMarkerColor(7)
calo_hit_markers.SetMarkerStyle(4)
calo_hit_markers.SetPoint(0, pos[0] / 10., pos[1] / 10., pos[2] / 10.)
elif type_name == "MCParticle":
n_parts = coll.getNumberOfElements()
for i in range(0, n_parts):
......@@ -132,7 +148,7 @@ def draw_event(input_file, input_event):
return markers, lines
def save_picture(viewer, filename):
viewer.SavePictureUsingFBO(filename, 1920, 1080)
viewer.SavePictureUsingFBO(filename, 1360, 720)
print("Saved file: " + filename)
def define_args(parser):
......@@ -166,6 +182,18 @@ def define_args(parser):
default=0,
help='event to visualize'
)
parser.add_argument(
'-n', '--nocheck',
action='store_true',
dest='nocheck',
help='do not check geometry for overlaps'
)
parser.add_argument(
'-d', '--dark',
action='store_true',
dest='dark_theme',
help='use a black background'
)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='sieic_vis')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment