Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:45

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