Skip to content
Snippets Groups Projects

SiEIC Concept: Added UI option to simulation

Merged David Blyth requested to merge sieic_sim into master
1 file
+ 25
12
Compare changes
  • Side-by-side
  • Inline
@@ -7,11 +7,20 @@ import struct
from SystemOfUnits import *
def run(compact_path, n_events, input_file, output_file):
def run(args):
import DDG4
kernel = DDG4.Kernel()
kernel.NumEvents = n_events
kernel.NumEvents = args.n_events
# UI
if args.run_ui:
ui_action = DDG4.Action(kernel, 'Geant4UIManager/UI')
ui_action.HaveVIS = False
ui_action.HaveUI = True
ui_action.SessionType = 'csh'
kernel.registerGlobalAction(ui_action)
kernel.UI = "UI"
# Random
rand_action = DDG4.Action(kernel, 'Geant4Random/R1')
@@ -23,7 +32,7 @@ def run(compact_path, n_events, input_file, output_file):
rand_action.showStatus()
# Geometry
kernel.loadGeometry('file:' + compact_path)
kernel.loadGeometry('file:' + args.compact_path)
dd = kernel.detectorDescription()
DDG4.importConstants(dd)
@@ -68,7 +77,7 @@ def run(compact_path, n_events, input_file, output_file):
run_header['DateUTC'] = str(datetime.datetime.utcnow()) + ' UTC'
output_action = DDG4.EventAction(kernel, 'Geant4Output2LCIO/LCIOOutput', True)
output_action.Control = True
output_action.Output = output_file
output_action.Output = args.output_file
output_action.RunHeader = run_header
kernel.eventAction().add(output_action)
@@ -78,7 +87,7 @@ def run(compact_path, n_events, input_file, output_file):
gen_init = DDG4.GeneratorAction(kernel, 'Geant4GeneratorActionInit/GenerationInit')
gen_action.adopt(gen_init)
if input_file == None:
if args.input_file == None:
gun = DDG4.GeneratorAction(kernel, 'Geant4ParticleGun/Gun')
gun.Standalone = False
gun.energy = 10 * GeV
@@ -91,7 +100,7 @@ def run(compact_path, n_events, input_file, output_file):
params['MCParticleCollectionName'] = 'MCParticle'
mc = DDG4.GeneratorAction(kernel, 'LCIOInputAction/LCIOInput')
mc.Parameters = params
mc.Input = 'LCIOFileReader|' + input_file
mc.Input = 'LCIOFileReader|' + args.input_file
gen_action.adopt(mc)
vertex_boost = DDG4.GeneratorAction(kernel, 'Geant4InteractionVertexBoost')
@@ -130,10 +139,12 @@ def run(compact_path, n_events, input_file, output_file):
def define_args(parser):
parser.add_argument(
'compact_path',
metavar='CompactPath',
help='file with compact XML detector description'
)
parser.add_argument(
'n_events',
metavar='NEvents',
type=int,
help='number of events to simulate'
)
@@ -149,15 +160,17 @@ def define_args(parser):
default='test_output.slcio',
help='output path'
)
parser.add_argument(
'-u', '--ui',
action='store_true',
dest='run_ui',
help='run a UI'
)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='sieic_sim')
define_args(parser)
args = parser.parse_args()
run(
args.compact_path,
args.n_events,
args.input_file,
args.output_file
)
print(args)
run(args)
Loading