Back to home page

EIC code displayed by LXR

 
 

    


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

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