Commit a690381c authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Merge branch 'master' into tooling

parents d0eb7c64 515aa214
......@@ -90,10 +90,10 @@ def run(args):
if args.input_file == None:
gun = DDG4.GeneratorAction(kernel, 'Geant4ParticleGun/Gun')
gun.Standalone = False
gun.energy = 10 * GeV
gun.particle = 'mu-'
gun.energy = 5 * GeV
gun.particle = args.pgun_species
gun.isotrop = True
gun.Distribution = 'eta'
gun.Distribution = 'uniform'
gen_action.adopt(gun)
else:
params = {}
......@@ -166,6 +166,12 @@ def define_args(parser):
dest='run_ui',
help='run a UI'
)
parser.add_argument(
'-p', '--pgun',
dest='pgun_species',
default='mu-',
help='particle gun species'
)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='sieic_sim')
......
......@@ -2,6 +2,7 @@
import argparse
from array import array
import math
def run(args):
import ROOT, DDG4
......@@ -10,41 +11,144 @@ def run(args):
kernel.loadGeometry('file:' + args.compact_path)
dd = kernel.detectorDescription()
manager = dd.manager()
manager.CheckOverlaps(0.01)
manager.PrintOverlaps()
manager.SetVisDensity()
if not args.nocheck:
manager.CheckOverlaps(0.01)
manager.PrintOverlaps()
if args.input_file == None:
manager.SetVisDensity()
manager.SetVisLevel(2)
top_vol = manager.GetTopVolume()
top_vol.Draw('ogl')
viewer = ROOT.gPad.GetViewer3D()
viewer.SetCurrentCamera(ROOT.TGLViewer.kCameraOrthoZOY)
viewer.ToggleOrthoRotate()
if args.dark_theme:
viewer.SwitchColorSet()
overlay = viewer.GetCameraOverlay()
overlay.SetOrthographicMode(ROOT.TGLCameraOverlay.kAxis)
overlay.SetShowOrthographic(True)
if args.input_file == None:
overlay = viewer.GetCameraOverlay()
overlay.SetOrthographicMode(ROOT.TGLCameraOverlay.kAxis)
overlay.SetShowOrthographic(True)
clip_set = viewer.GetClipSet()
clip_type = ROOT.TGLClip.kClipPlane
clip_set.SetClipType(clip_type)
clip_state = array('d')
clip_state.extend([1,0,0,0,0,0])
clip_set.SetClipState(clip_type, clip_state)
clip_set = viewer.GetClipSet()
clip_type = ROOT.TGLClip.kClipPlane
clip_set.SetClipType(clip_type)
clip_state = array('d')
clip_state.extend([1,0,0,0,0,0])
clip_set.SetClipState(clip_type, clip_state)
else:
markers, lines = draw_event(args.input_file, args.input_event)
for marker in markers:
marker.Draw('same')
for line in lines:
line.Draw('same')
args.output_prefix += '_' + args.input_file + '_' + str(args.input_event)
viewer.ToggleOrthoRotate()
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')
overlay.SetShowOrthographic(False)
save_picture(viewer, args.output_prefix + '_angledNoOverlay.png')
if args.input_file == None:
overlay.SetShowOrthographic(False)
save_picture(viewer, args.output_prefix + '_angledNoOverlay.png')
def draw_event(input_file, input_event):
import ROOT
ROOT.gSystem.Load('liblcio')
ROOT.gInterpreter.ProcessLine("#include <lcio.h>")
ROOT.gInterpreter.ProcessLine("#include <EVENT/LCCollection.h>")
ROOT.gInterpreter.ProcessLine("#include <IMPL/SimTrackerHitImpl.h>")
ROOT.gInterpreter.ProcessLine("#include <IMPL/SimCalorimeterHitImpl.h>")
ROOT.gInterpreter.ProcessLine("#include <IMPL/MCParticleImpl.h>")
reader = ROOT.IOIMPL.LCFactory.getInstance().createLCReader()
reader.open(input_file)
reader.skipNEvents(input_event)
event = reader.readNextEvent()
markers = []
lines = []
coll_names = event.getCollectionNames()
for coll_name in coll_names:
coll = event.getCollection(coll_name)
type_name = coll.getTypeName()
if type_name == "SimTrackerHit":
n_hits = coll.getNumberOfElements()
tracker_hit_markers = ROOT.TPolyMarker3D()
markers.append(tracker_hit_markers)
tracker_hit_markers.SetMarkerSize(10)
tracker_hit_markers.SetMarkerColor(3)
tracker_hit_markers.SetMarkerStyle(2)
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.SetNextPoint(pos[0] / 10., pos[1] / 10., pos[2] / 10.)
elif type_name == "SimCalorimeterHit":
n_hits = coll.getNumberOfElements()
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 = 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):
part = coll.getElementAt(i)
part.__class__ = ROOT.IMPL.MCParticleImpl
if part.getGeneratorStatus() == 1:
vertex = part.getVertex()
vertex_marker = ROOT.TPolyMarker3D(1)
markers.append(vertex_marker)
vertex_marker.SetMarkerColor(3)
vertex_marker.SetMarkerStyle(7)
vertex_marker.SetPoint(0, vertex[0] / 10., vertex[1] / 10., vertex[2] / 10.)
vertex_marker.Draw('same')
momentum = part.getMomentum()
mag = math.sqrt(pow(momentum[0], 2) + pow(momentum[1], 2) + pow(momentum[2], 2))
line_len = 50
line_vec = array('d')
line_vec.extend([momentum[0] * line_len / mag, momentum[1] * line_len / mag, momentum[2] * line_len / mag])
part_line = ROOT.TPolyLine3D(2)
lines.append(part_line)
part_line.SetLineColor(1)
part_line.SetLineWidth(2)
part_line.SetPoint(0, vertex[0] / 10., vertex[1] / 10., vertex[2] / 10.)
part_line.SetPoint(1, line_vec[0], line_vec[1], line_vec[2])
part_line.Draw('same')
reader.close()
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):
......@@ -65,12 +169,31 @@ def define_args(parser):
dest='interactive',
help='run an interactive session. Must quit ROOT application from the menu.'
)
# parser.add_argument(
# '-i', '--input',
# dest='input_file',
# default=None,
# help='truth-level input path'
# )
parser.add_argument(
'-f', '--file',
dest='input_file',
default=None,
help='lcio file path containing event to visualize'
)
parser.add_argument(
'-e', '--event',
type=int,
dest='input_event',
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')
......
<?xml version="1.0" encoding="UTF-8"?>
<materials>
<!--
Air by weight from
......@@ -12,71 +11,60 @@
<fraction n="0.234" ref="O"/>
<fraction n="0.012" ref="Ar"/>
</material>
<!-- We model vakuum just as very thin air -->
<material name="Vacuum">
<D type="density" unit="g/cm3" value="0.0000000001" />
<material name="Vacuum">
<D type="density" unit="g/cm3" value="0.0000000001"/>
<fraction n="0.754" ref="N"/>
<fraction n="0.234" ref="O"/>
<fraction n="0.012" ref="Ar"/>
</material>
<material name="Epoxy">
<D type="density" value="1.3" unit="g/cm3"/>
<composite n="44" ref="H"/>
<composite n="15" ref="C"/>
<composite n="7" ref="O"/>
</material>
<material name="Quartz">
<D type="density" value="2.2" unit="g/cm3"/>
<composite n="1" ref="Si"/>
<composite n="2" ref="O"/>
</material>
<material name="G10">
<D type="density" value="1.7" unit="g/cm3"/>
<fraction n="0.08" ref="Cl"/>
<fraction n="0.773" ref="Quartz"/>
<fraction n="0.147" ref="Epoxy"/>
</material>
<material name="Polystyrene">
<D value="1.032" unit="g/cm3"/>
<composite n="19" ref="C"/>
<composite n="21" ref="H"/>
</material>
<material name="Steel235">
<D value="7.85" unit="g/cm3"/>
<fraction n="0.998" ref="Fe"/>
<fraction n=".002" ref="C"/>
</material>
<material name="SiliconOxide">
<D type="density" value="2.65" unit="g/cm3"/>
<composite n="1" ref="Si"/>
<composite n="2" ref="O"/>
</material>
<material name="BoronOxide">
<D type="density" value="2.46" unit="g/cm3"/>
<composite n="2" ref="B"/>
<composite n="3" ref="O"/>
</material>
<material name="SodiumOxide">
<D type="density" value="2.65" unit="g/cm3"/>
<composite n="2" ref="Na"/>
<composite n="1" ref="O"/>
</material>
<material name="AluminumOxide">
<D type="density" value="3.89" unit="g/cm3"/>
<composite n="2" ref="Al"/>
<composite n="3" ref="O"/>
</material>
<material name="PyrexGlass">
<D type="density" value="2.23" unit="g/cm3"/>
<fraction n="0.806" ref="SiliconOxide"/>
......@@ -84,19 +72,16 @@
<fraction n="0.040" ref="SodiumOxide"/>
<fraction n="0.023" ref="AluminumOxide"/>
</material>
<material name="CarbonFiber">
<D type="density" value="1.5" unit="g/cm3"/>
<fraction n="0.65" ref="C"/>
<fraction n="0.35" ref="Epoxy"/>
</material>
<material name="CarbonFiber_50D">
<D type="density" value="0.75" unit="g/cm3"/>
<fraction n="0.65" ref="C"/>
<fraction n="0.35" ref="Epoxy"/>
</material>
</material>
<material name="Rohacell31">
<D type="density" value="0.032" unit="g/cm3"/>
<composite n="9" ref="C"/>
......@@ -104,40 +89,84 @@
<composite n="2" ref="O"/>
<composite n="1" ref="N"/>
</material>
<material name="Rohacell31_50D">
<D type="density" value="0.016" unit="g/cm3"/>
<composite n="9" ref="C"/>
<composite n="13" ref="H"/>
<composite n="2" ref="O"/>
<composite n="1" ref="N"/>
</material>
</material>
<material name="RPCGasDefault" state="gas">
<D type="density" value="0.0037" unit="g/cm3"/>
<composite n="209" ref="C"/>
<composite n="239" ref="H"/>
<composite n="381" ref="F"/>
</material>
<material name="PolystyreneFoam">
<D type="density" value="0.0056" unit="g/cm3"/>
<fraction n="1.0" ref="Polystyrene"/>
</material>
<material name="Kapton">
<D value="1.43" unit="g/cm3" />
<D value="1.43" unit="g/cm3"/>
<composite n="22" ref="C"/>
<composite n="10" ref="H" />
<composite n="2" ref="N" />
<composite n="5" ref="O" />
<composite n="10" ref="H"/>
<composite n="2" ref="N"/>
<composite n="5" ref="O"/>
</material>
<material name="PEEK">
<D value="1.37" unit="g/cm3" />
<D value="1.37" unit="g/cm3"/>
<composite n="19" ref="C"/>
<composite n="12" ref="H" />
<composite n="3" ref="O" />
<composite n="12" ref="H"/>
<composite n="3" ref="O"/>
</material>
<material name="TungstenDens23">
<D value="17.7" unit="g / cm3"/>
<fraction n="0.925" ref="W"/>
<fraction n="0.066" ref="Ni"/>
<fraction n="0.009" ref="Fe"/>
</material>
<material name="TungstenDens24">
<D value="17.8" unit="g / cm3"/>
<fraction n="0.93" ref="W"/>
<fraction n="0.061" ref="Ni"/>
<fraction n="0.009" ref="Fe"/>
</material>
<material name="TungstenDens25">
<D value="18.2" unit="g / cm3"/>
<fraction n="0.950" ref="W"/>
<fraction n="0.044" ref="Ni"/>
<fraction n="0.006" ref="Fe"/>
</material>
<material name="CarbonFiber_25percent">
<D type="density" value="0.375" unit="g / cm3"/>
<fraction n="1.0" ref="CarbonFiber"/>
</material>
<material name="CarbonFiber_15percent">
<D type="density" value="0.225" unit="g / cm3"/>
<fraction n="1.0" ref="CarbonFiber"/>
</material>
<material name="Rohacell31_50percent">
<D type="density" value="0.016" unit="g / cm3"/>
<fraction n="1.0" ref="Rohacell31"/>
</material>
<material name="Rohacell31_15percent">
<D type="density" value="0.0048" unit="g / cm3"/>
<fraction n="1.0" ref="Rohacell31"/>
</material>
<material name="BoratedPolyethylene5">
<D value="0.93" unit="g / cm3"/>
<fraction n="0.612" ref="C"/>
<fraction n="0.222" ref="O"/>
<fraction n="0.116" ref="H"/>
<fraction n="0.050" ref="B"/>
</material>
<material name="SiliconCarbide">
<D value="3.1" unit="g / cm3"/>
<composite n="1" ref="Si"/>
<composite n="1" ref="C"/>
</material>
<material name="SiliconCarbide_6percent">
<D value="0.186" unit="g / cm3"/>
<fraction n="1.0" ref="SiliconCarbide"/>
</material>
</materials>
......@@ -88,71 +88,19 @@
<gdmlFile ref="elements.xml"/>
<gdmlFile ref="materials.xml"/>
</includes>
<materials>
<material name="TungstenDens23">
<D value="17.7" unit="g / cm3"/>
<fraction n="0.925" ref="W"/>
<fraction n="0.066" ref="Ni"/>
<fraction n="0.009" ref="Fe"/>
</material>
<material name="TungstenDens24">
<D value="17.8" unit="g / cm3"/>
<fraction n="0.93" ref="W"/>
<fraction n="0.061" ref="Ni"/>
<fraction n="0.009" ref="Fe"/>
</material>
<material name="TungstenDens25">
<D value="18.2" unit="g / cm3"/>
<fraction n="0.950" ref="W"/>
<fraction n="0.044" ref="Ni"/>
<fraction n="0.006" ref="Fe"/>
</material>
<material name="CarbonFiber_25percent">
<D type="density" value="0.375" unit="g / cm3"/>
<fraction n="1.0" ref="CarbonFiber"/>
</material>
<material name="CarbonFiber_15percent">
<D type="density" value="0.225" unit="g / cm3"/>
<fraction n="1.0" ref="CarbonFiber"/>
</material>
<material name="Rohacell31_50percent">
<D type="density" value="0.016" unit="g / cm3"/>
<fraction n="1.0" ref="Rohacell31"/>
</material>
<material name="Rohacell31_15percent">
<D type="density" value="0.0048" unit="g / cm3"/>
<fraction n="1.0" ref="Rohacell31"/>
</material>
<material name="BoratedPolyethylene5">
<D value="0.93" unit="g / cm3"/>
<fraction n="0.612" ref="C"/>
<fraction n="0.222" ref="O"/>
<fraction n="0.116" ref="H"/>
<fraction n="0.050" ref="B"/>
</material>
<material name="SiliconCarbide">
<D value="3.1" unit="g / cm3"/>
<composite n="1" ref="Si"/>
<composite n="1" ref="C"/>
</material>
<material name="SiliconCarbide_6percent">
<D value="0.186" unit="g / cm3"/>
<fraction n="1.0" ref="SiliconCarbide"/>
</material>
</materials>
<limits>
<limitset name="cal_limits">
<limit name="step_length_max" particles="*" value="5.0" unit="mm"/>
</limitset>
</limits>
<display>
<vis name="SiVertexVis" alpha="1" r="1" g="0" b="1"/>
<vis name="SiTrackerVis" alpha="1" r="0" g="0" b="0.5"/>
<vis name="EcalVis" alpha="0.5" r="0.25" g="0.75" b="0.1"/>
<vis name="HcalVis" alpha="0.5" r="0.75" g="0.25" b="0.1"/>
<vis name="SolenoidCoilVis" alpha="1" r="0.55" g="0.55" b="0.7"/>
<vis name="SolenoidYokeVis" alpha="0.5" r="0.6" g="0.4" b="0.4"/>
<vis name="RICHVis" alpha="0.5" r="1" g="0" b="1"/>
<vis name="SiVertexVis" alpha="0.05" r="1" g="0" b="1"/>
<vis name="SiTrackerVis" alpha="0.05" r="0" g="0" b="0.5"/>
<vis name="EcalVis" alpha="0.05" r="0.25" g="0.75" b="0.1"/>
<vis name="HcalVis" alpha="0.05" r="0.75" g="0.25" b="0.1"/>
<vis name="SolenoidCoilVis" alpha="0.05" r="0.55" g="0.55" b="0.7"/>
<vis name="SolenoidYokeVis" alpha="0.05" r="0.6" g="0.4" b="0.4"/>
<vis name="RICHVis" alpha="0.05" r="1" g="0" b="1"/>
</display>
<detectors>
<detector id="1" name="SiVertexBarrel" type="SiEIC_SiTrackerBarrel" readout="SiVertexBarrelHits" insideTrackingVolume="true">
......@@ -519,9 +467,9 @@
<ring r="142.0 * mm" zstart="trackerZScale * 834 * mm" nmodules="16" dz="0.011 * mm" module="SiTrackerForwardModule3"/>
</layer>
</detector>
<detector id="6" name="EcalBarrel" type="DD4hep_EcalBarrel" readout="EcalBarrelHits" calorimeterType="EM_BARREL">
<detector id="6" name="EcalBarrel" type="DD4hep_PolyhedraBarrelCalorimeter2" readout="EcalBarrelHits" calorimeterType="EM_BARREL" gap="0.*cm" vis="EcalVis">
<dimensions numsides="CaloSides" rmin="EcalBarrel_rmin" z="(EcalEndcap_zmin + EcalThickness) * 2"/>
<staves vis="EcalVis"/>
<staves/>
<layer repeat="1">
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
<slice material="Copper" thickness="EcalCopperThickness"/>
......@@ -545,7 +493,7 @@
<slice material="Air" thickness="EcalAir1Thickness"/>
</layer>
</detector>
<detector id="7" name="EcalEndcap" type="DD4hep_PolyhedraEndcapCalorimeter2" reflect="true" readout="EcalEndcapHits" vis="EcalVis" calorimeterType="EM_ENDCAP">
<detector id="7" name="EcalEndcap" type="DD4hep_PolyhedraEndcapCalorimeter2" reflect="true" readout="EcalEndcapHits" calorimeterType="EM_ENDCAP" vis="EcalVis">
<dimensions numsides="CaloSides" zmin="EcalEndcap_zmin" rmin="CaloInnerRadius" rmax="EcalBarrel_rmin / cos(Pi / CaloSides) - 1 * mm"/>
<layer repeat="1">
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
......@@ -597,11 +545,11 @@
<dimensions rmin="RICHRMin" rmax1="CaloInnerRadius" rmax2="CaloInnerRadius + tan(SolenoidYokeChamferAngle) * RICHDepth" zmin="RICHZMin" zmax="RICHZMin + RICHDepth"/>
</detector>
<detector id="13" name="ForwardEcal" type="SiEIC_PlanarCalo" vis="EcalVis">
<material name="TungstenDens24"/>
<material name="Air"/>
<dimensions inner_radius="ForwardEcalRInner" outer_radius="ForwardEcalROuter" angle="ForwardCaloAngle" zmin="ForwardEcalZMin" thickness="EcalThickness"/>
</detector>
<detector id="14" name="ForwardHcal" type="SiEIC_PlanarCalo" vis="HcalVis">
<material name="Steel235"/>
<material name="Air"/>
<dimensions inner_radius="ForwardHcalRInner" outer_radius="ForwardHcalROuter" angle="ForwardCaloAngle" zmin="ForwardHcalZMin" thickness="HcalThickness"/>
</detector>
<detector name="TempDiskTracker1" type="DD4hep_DiskTracker" insideTrackingVolume="false" reflect="false">
......
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