Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:58

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