Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 07:52:34

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 import logging
0013 #
0014 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0015 logger = logging.getLogger(__name__)
0016 #
0017 #
0018 """
0019 
0020    dd4hep simulation example setup using the python configuration
0021 
0022 """
0023 
0024 
0025 def run():
0026   import os
0027   import DDG4
0028   from DDG4 import OutputLevel as Output
0029   from g4units import GeV, keV
0030 
0031   kernel = DDG4.Kernel()
0032   install_dir = os.environ['DD4hepExamplesINSTALL']
0033   kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/SiliconBlock.xml"))
0034 
0035   DDG4.importConstants(kernel.detectorDescription(), debug=False)
0036   geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0037   geant4.registerInterruptHandler()
0038   geant4.printDetectors()
0039   # Configure UI
0040   geant4.setupUI(typ="tcsh", vis=False, macro=None, ui=False)
0041 
0042   # Configure field
0043   geant4.setupTrackingField(prt=True)
0044   # Configure Event actions
0045   prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0046   prt.OutputLevel = Output.DEBUG
0047   prt.OutputType = 3  # Print both: table and tree
0048   kernel.eventAction().adopt(prt)
0049 
0050   generator_output_level = Output.INFO
0051 
0052   # Configure G4 geometry setup
0053   seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo")
0054   act.DebugMaterials = True
0055   act.DebugElements = False
0056   act.DebugVolumes = True
0057   act.DebugShapes = True
0058   act.DebugSurfaces = True
0059 
0060   # Setup particle gun
0061   gun = geant4.setupGun("Gun", particle='gamma', energy=1 * GeV, multiplicity=1)
0062   gun.direction = (0.0, 0.0, 1.0)
0063   gun.OutputLevel = generator_output_level
0064   kernel.NumEvents = 10
0065 
0066   act = DDG4.EventAction(kernel, 'TestSignalAction/SigAction', True)
0067   act.signal_event = 3
0068   kernel.eventAction().add(act)
0069 
0070   # And handle the simulation particles.
0071   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0072   kernel.generatorAction().adopt(part)
0073   part.SaveProcesses = ['conv', 'Decay']
0074   part.MinimalKineticEnergy = 1 * keV
0075   part.KeepAllParticles = False
0076   part.PrintEndTracking = True
0077   part.enableUI()
0078 
0079   # Now build the physics list:
0080   phys = geant4.setupPhysics('QGSP_BERT')
0081   phys.dump()
0082   # Start the engine...
0083   geant4.execute()
0084 
0085 
0086 if __name__ == "__main__":
0087   run()