Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-31 07:50:19

0001 # ==========================================================================
0002 #  AIDA Detector description implementation
0003 # --------------------------------------------------------------------------
0004 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 # All rights reserved.
0006 #
0007 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 #
0010 # ==========================================================================
0011 #
0012 #
0013 import os
0014 import time
0015 import DDG4
0016 from DDG4 import OutputLevel as Output
0017 from g4units import GeV, mm, cm
0018 import logging
0019 
0020 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0021 logger = logging.getLogger(__name__)
0022 
0023 #
0024 #
0025 """
0026 
0027    dd4hep simulation example setup using the python configuration
0028 
0029    @author  M.Frank
0030    @version 1.0
0031 
0032 """
0033 
0034 
0035 def run():
0036   args = DDG4.CommandLine()
0037   kernel = DDG4.Kernel()
0038   description = kernel.detectorDescription()
0039 
0040   install_dir = os.environ['DD4hepExamplesINSTALL']
0041   kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/LheD_tracker.xml"))
0042 
0043   DDG4.importConstants(description, debug=False)
0044   geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0045   geant4.printDetectors()
0046 
0047   # Configure UI
0048   geant4.setupCshUI()
0049   # geant4.setupCshUI('csh',True,True)
0050   # geant4.setupCshUI('csh',True,True,'vis.mac')
0051   if args.batch:
0052     kernel.UI = ''
0053 
0054   # Configure field
0055   geant4.setupTrackingField(prt=True)
0056   # Configure Event actions
0057   prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0058   prt.OutputLevel = Output.WARNING  # Output.WARNING
0059   prt.OutputType = 3  # Print both: table and tree
0060   kernel.eventAction().adopt(prt)
0061 
0062   # Configure I/O
0063   geant4.setupROOTOutput('RootOutput', 'LHeD_tracker_' + time.strftime('%Y-%m-%d_%H-%M'))
0064   gen = geant4.setupGun("Gun", particle='geantino', energy=20 * GeV, position=(0 * mm, 0 * mm, 0 * cm), multiplicity=3)
0065   gen.isotrop = False
0066   gen.direction = (1, 0, 0)
0067   gen.OutputLevel = Output.WARNING
0068 
0069   # seq,act = geant4.setupTracker('SiVertexBarrel')
0070 
0071   # Now build the physics list:
0072   phys = geant4.setupPhysics('QGSP_BERT')
0073   ph = DDG4.PhysicsList(kernel, 'Geant4PhysicsList/Myphysics')
0074   ph.addParticleConstructor(str('G4Geantino'))
0075   ph.addParticleConstructor(str('G4BosonConstructor'))
0076   ph.enableUI()
0077   phys.adopt(ph)
0078   phys.dump()
0079 
0080   kernel.configure()
0081   kernel.initialize()
0082 
0083   # DDG4.setPrintLevel(Output.DEBUG)
0084   kernel.run()
0085   logger.info('End of run. Terminating .......')
0086   kernel.terminate()
0087 
0088 
0089 if __name__ == "__main__":
0090   run()