Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-02 08:02:48

0001 """
0002 Steering illustrates possible cuts and configurations for Firebird Dd4hep-Plugin
0003 """
0004 from DDSim.DD4hepSimulation import DD4hepSimulation
0005 from g4units import mm, GeV, MeV, m
0006 import DDG4
0007 import argparse
0008 import sys
0009 
0010 
0011 # This printout is to check this steering file is using
0012 print("== STARTED STEERING FILE ==")
0013 print(f"g4units: mm={mm}, GeV={GeV}, MeV={MeV}")
0014 
0015 
0016 # Determine output file name
0017 # We intercept global dd4hep --outputFile flag to get base name for output file
0018 parser = argparse.ArgumentParser()
0019 parser.add_argument('--outputFile', type=str, default="output", help='Output file name')
0020 args, _ = parser.parse_known_args()
0021 
0022 # Add .firebird.json instead of .edm4hep.root or... whatever is there?
0023 outputFile = args.outputFile if args.outputFile else "output"
0024 if outputFile.endswith('.edm4hep.root'):
0025     outputFile = outputFile[:-len('.edm4hep.root')] + '.firebird.json'
0026 else:
0027     outputFile = outputFile+'.firebird.json' if outputFile else 'output.firebird.json'
0028 
0029 print(f"Steering event display 'outputFile' = {outputFile}")
0030 
0031 # This is needed for stepping file
0032 SIM = DD4hepSimulation()
0033 
0034 # Enable UI in the simulation (you probably don't need it)
0035 # SIM.enableUI()
0036 
0037 # Set UI commands to enable trajectory storage
0038 # (!) It is mandatory to have f'/tracking/storeTrajectory 3' so that RICH points with time info are saved
0039 SIM.ui.commandsConfigure = [
0040     f'/tracking/storeTrajectory 3',
0041 ]
0042 
0043 # Need DDG4 kernel to add stepping
0044 kernel = DDG4.Kernel()
0045 
0046 # Instantiate the stepping action
0047 event_action = DDG4.EventAction(kernel, 'FirebirdTrajectoryWriterEventAction/TrajectoryWriter')
0048 event_action.ComponentName = "Geant4Trajectories"   # Tracks group name in firebird
0049 event_action.OutputFile = outputFile
0050 # ---- Particle Type Filtering ----
0051 # Set which particles to save - central detector tracking focuses on charged particles
0052 
0053 # Save only particles with the next PDG codes:
0054 event_action.SaveParticles = [11, -11, 22, 211, -211, 321, -321, 2212, -2212]
0055 event_action.SaveOptical = False                    # Don't save optical photons (reduces file size)
0056 
0057 # ---- Track Source Filtering ----
0058 event_action.OnlyPrimary = False                    # Save both primary and secondary tracks
0059 
0060 # ---- Momentum Filtering ----
0061 # Central tracking typically focuses on particles with reasonable momentum
0062 # Too low momentum particles curl too much, too high rarely occur
0063 event_action.MomentumMin = 200                      # Minimum momentum (MeV/c)
0064 event_action.MomentumMax = 15 * GeV                 # Maximum momentum
0065 event_action.TrackLengthMin = 50                    # Minimum track length (mm)
0066 
0067 # ---- Vertex Position Filtering ----
0068 # EIC central detector region - focus on interaction point
0069 event_action.VertexCut = True                       # Enable vertex position filtering
0070 event_action.VertexZMin = -150                      # IP region Z min (mm)
0071 event_action.VertexZMax = 150                       # IP region Z max (mm)
0072 
0073 # ---- Step Position Filtering ----
0074 # Only save track points(steps) within the central detector volume
0075 event_action.StepCut = True                         # Enable step position filtering
0076 event_action.StepZMin = -4000                       # Central detector Z min (mm)
0077 event_action.StepZMax = 4000                        # Central detector Z max (mm)
0078 event_action.StepRMax = 1800                        # Central detector radial limit (mm)
0079 
0080 # ---- Trajectory Extraction Configuration ----
0081 event_action.VerboseTimeExtraction = False          # Don't log details about time extraction
0082 
0083 # Add our configured event-action
0084 kernel.eventAction().add(event_action)
0085 
0086 print("== END OF STEERING FILE ==")