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 time
0017 import DDG4
0018 from DDG4 import OutputLevel as Output
0019 from g4units import GeV, MeV, m
0020 #
0021 #
0022 """
0023 
0024    dd4hep simulation example setup using the python configuration
0025 
0026    @author  M.Frank
0027    @version 1.0
0028 
0029 """
0030 
0031 
0032 def run():
0033   kernel = DDG4.Kernel()
0034   install_dir = os.environ['DD4hepExamplesINSTALL']
0035   kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/Issue_786.xml"))
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   # Configure Event actions
0048   prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0049   prt.OutputLevel = Output.DEBUG
0050   prt.OutputType = 3  # Print both: table and tree
0051   kernel.eventAction().adopt(prt)
0052 
0053   generator_output_level = Output.INFO
0054 
0055   # Configure G4 geometry setup
0056   seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo")
0057   act.DebugMaterials = False
0058   act.DebugElements = False
0059   act.DebugVolumes = True
0060   act.DebugShapes = True
0061   act.DebugPlacements = True
0062 
0063   # Configure I/O
0064   geant4.setupROOTOutput('RootOutput', 'Issue_' + time.strftime('%Y-%m-%d_%H-%M'))
0065 
0066   # Setup particle gun
0067   gun = geant4.setupGun("Gun", particle='mu-', energy=20 * GeV, multiplicity=1)
0068   gun.OutputLevel = generator_output_level
0069 
0070   # And handle the simulation particles.
0071   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0072   kernel.generatorAction().adopt(part)
0073   part.SaveProcesses = ['Decay']
0074   part.MinimalKineticEnergy = 100 * MeV
0075   part.OutputLevel = Output.INFO  # generator_output_level
0076   part.enableUI()
0077   user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler")
0078   user.TrackingVolume_Zmax = 3.0 * m
0079   user.TrackingVolume_Rmax = 3.0 * m
0080   user.enableUI()
0081   part.adopt(user)
0082 
0083   geant4.setupTracker('Issue')
0084 
0085   # Now build the physics list:
0086   phys = geant4.setupPhysics('QGSP_BERT')
0087   ph = DDG4.PhysicsList(kernel, str('Geant4PhysicsList/Myphysics'))
0088   ph.addParticleConstructor(str('G4Geantino'))
0089   ph.addParticleConstructor(str('G4BosonConstructor'))
0090   ph.enableUI()
0091   phys.adopt(ph)
0092   phys.dump()
0093 
0094   geant4.execute()
0095 
0096 
0097 if __name__ == "__main__":
0098   run()