Back to home page

EIC code displayed by LXR

 
 

    


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 # This printout is to check this steering file is using
0009 print("== STARTED STEERING FILE ==")
0010 print(f"g4units: mm={mm}, GeV={GeV}, MeV={MeV}")
0011 
0012 
0013 # Determine output file name
0014 # We intercept global dd4hep --outputFile flag to get base name for output file
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 # Add .firebird.json instead of .edm4hep.root or... whatever is there?
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 # This is needed for stepping file
0029 SIM = DD4hepSimulation()
0030 
0031 # Enable UI in the simulation. This might be needed but usually is not
0032 # SIM.enableUI()
0033 
0034 # Set Geant4 UI commands to enable trajectory storage.
0035 # (!) /tracking/storeTrajectory 3 is crucial for TrajectoryWriterEventAction to work
0036 SIM.ui.commandsConfigure = [
0037     f'/tracking/storeTrajectory 3',
0038     # '/tracking/verbose 1',
0039 ]
0040 
0041 # Need DDG4 kernel to add stepping
0042 kernel = DDG4.Kernel()
0043 
0044 
0045 # Instantiate the stepping action
0046 event_action = DDG4.EventAction(kernel, 'FirebirdTrajectoryWriterEventAction/TrajectoryWriter')
0047 event_action.OutputFile = outputFile
0048 event_action.SaveOptical=True
0049 event_action.OnlyPrimary = False         # When both SaveOptical=OnlyPrimary=True only Primary and Optical will be saved
0050 event_action.MomentumMin = 1
0051 
0052 # stepping.VertexCut = True              # Cut tracks which vertex is outside z_min-z_max range
0053 # stepping.VertexZMin = -5000            # [mm] Min Z for Vertex Cut. Will work only if VertexCut = True
0054 # stepping.VertexZMax = 5000             # [mm] Max Z for Vertex Cut. Will work only if VertexCut = True
0055 
0056 #kernel.steppingAction().add(stepping)
0057 kernel.eventAction().add(event_action)
0058 
0059 
0060 print("== ENDED STEERING FILE ==")