Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 08:26:28

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 os
0013 import sys
0014 import DDG4
0015 from DDG4 import OutputLevel as Output
0016 from g4units import keV
0017 #
0018 #
0019 """
0020 
0021    dd4hep simulation example setup using the python configuration
0022 
0023    @author  M.Frank
0024    @version 1.0
0025 
0026 """
0027 
0028 
0029 def run():
0030   kernel = DDG4.Kernel()
0031   install_dir = os.environ['DD4hepExamplesINSTALL']
0032   kernel.loadGeometry(str("file:" + install_dir + "/examples/OpticalSurfaces/compact/ReadMaterialProperties.xml"))
0033 
0034   DDG4.importConstants(kernel.detectorDescription(), debug=False)
0035   geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0036   geant4.printDetectors()
0037   # Configure UI
0038   if len(sys.argv) > 1:
0039     geant4.setupCshUI(macro=sys.argv[1])
0040   else:
0041     geant4.setupCshUI()
0042 
0043   # Configure field
0044   geant4.setupTrackingField(prt=True)
0045   # Configure Event actions
0046   prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0047   prt.OutputLevel = Output.DEBUG
0048   prt.OutputType = 3  # Print both: table and tree
0049   kernel.eventAction().adopt(prt)
0050 
0051   generator_output_level = Output.INFO
0052 
0053   # Configure G4 geometry setup
0054   seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo")
0055   act.DebugMaterials = True
0056   act.DebugVolumes = True
0057   act.DebugShapes = True
0058 
0059   # Setup particle gun
0060   gun = geant4.setupGun("Gun", particle='gamma', energy=5 * keV, multiplicity=1)
0061   gun.OutputLevel = generator_output_level
0062 
0063   geant4.setupTracker('MaterialTester')
0064 
0065   # Now build the physics list:
0066   phys = geant4.setupPhysics('QGSP_BERT')
0067   phys.dump()
0068 
0069   geant4.execute()
0070 
0071 
0072 if __name__ == "__main__":
0073   run()