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 # Intercept  --outputFile flag
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 # Remove '.edm4hep.root' and append '.txtevt' or use default name (if no --outputFile is given)
0020 outputFile = args.outputFile if args.outputFile else "output"
0021 if outputFile.endswith('.edm4hep.root'):
0022     outputFile = outputFile[:-len('.edm4hep.root')] + '.evt.txt'
0023 else:
0024     outputFile += '.evt.txt'
0025 
0026 print(f"Steering event display 'outputFile' = {outputFile}")
0027 
0028 # This is needed for stepping file
0029 SIM = DD4hepSimulation()
0030 
0031 # Need DDG4 kernel to add stepping
0032 kernel = DDG4.Kernel()
0033 
0034 # Instantiate the stepping action
0035 stepping = DDG4.SteppingAction(kernel, 'TextDumpingSteppingAction/MyStepper')
0036 stepping.OutputFileName = outputFile
0037 stepping.OnlyPrimary = False
0038 stepping.MomentumMin = 150
0039 stepping.VertexCut = True              # Cut tracks which vertex is outside z_min-z_max range
0040 stepping.VertexZMin = -5000            # [mm] Min Z for Vertex Cut. Will work only if VertexCut = True
0041 stepping.VertexZMax = 5000             # [mm] Max Z for Vertex Cut. Will work only if VertexCut = True
0042 
0043 kernel.steppingAction().add(stepping)
0044 
0045 print("== ENDED STEERING FILE ==")