File indexing completed on 2025-04-02 08:02:48
0001 from DDSim.DD4hepSimulation import DD4hepSimulation
0002 from g4units import mm, GeV, MeV, m
0003 import DDG4
0004 import argparse
0005 import sys
0006
0007
0008
0009 print("== STARTED STEERING FILE ==")
0010 print(f"g4units: mm={mm}, GeV={GeV}, MeV={MeV}")
0011
0012
0013
0014
0015 parser = argparse.ArgumentParser()
0016 parser.add_argument('--outputFile', type=str, default="output", help='Output file name')
0017 args, _ = parser.parse_known_args()
0018
0019
0020 outputFile = args.outputFile if args.outputFile else "output"
0021 if outputFile.endswith('.edm4hep.root'):
0022 outputFile = outputFile[:-len('.edm4hep.root')] + '.firebird.json'
0023 else:
0024 outputFile = outputFile+'.firebird.json' if outputFile else 'output.firebird.json'
0025
0026 print(f"Steering event display 'outputFile' = {outputFile}")
0027
0028
0029 SIM = DD4hepSimulation()
0030
0031
0032
0033
0034
0035
0036 SIM.ui.commandsConfigure = [
0037 f'/tracking/storeTrajectory 3',
0038
0039 ]
0040
0041
0042 kernel = DDG4.Kernel()
0043
0044
0045
0046 event_action = DDG4.EventAction(kernel, 'FirebirdTrajectoryWriterEventAction/TrajectoryWriter')
0047 event_action.OutputFile = outputFile
0048 event_action.SaveOptical=True
0049 event_action.OnlyPrimary = False
0050 event_action.MomentumMin = 1
0051
0052
0053
0054
0055
0056 kernel.eventAction().add(event_action)
0057
0058
0059 print("== ENDED STEERING FILE ==")