Back to home page

EIC code displayed by LXR

 
 

    


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

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 from __future__ import absolute_import, unicode_literals
0012 import os
0013 import time
0014 import DDG4
0015 from DDG4 import OutputLevel as Output
0016 from g4units import GeV, MeV
0017 #
0018 #
0019 """
0020 
0021    dd4hep example setup using the python configuration
0022 
0023    \author  M.Frank
0024    \version 1.0
0025 
0026 """
0027 
0028 
0029 def run():
0030   args = DDG4.CommandLine()
0031   kernel = DDG4.Kernel()
0032   install_dir = os.environ['DD4hepExamplesINSTALL']
0033   kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG)
0034   kernel.setOutputLevel(str('Gun'), Output.INFO)
0035   kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/NestedDetectors.xml"))
0036 
0037   geant4 = DDG4.Geant4(kernel)
0038   geant4.printDetectors()
0039   geant4.setupCshUI()
0040   if args.batch:
0041     kernel.UI = ''
0042 
0043   # Configure field
0044   geant4.setupTrackingField(prt=True)
0045   # Configure I/O
0046   geant4.setupROOTOutput('RootOutput', 'Nested_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True)
0047   # Setup particle gun
0048   geant4.setupGun("Gun", particle='pi-', energy=100 * GeV, multiplicity=1)
0049   # Now the calorimeters
0050   seq, act = geant4.setupTracker('SiTrackerBarrel')
0051   seq, act = geant4.setupTracker('SiVertexBarrel')
0052   # And handle the simulation particles.
0053   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0054   kernel.generatorAction().adopt(part)
0055   part.SaveProcesses = ['conv', 'Decay']
0056   part.MinimalKineticEnergy = 1 * MeV
0057   part.enableUI()
0058 
0059   # Now build the physics list:
0060   phys = kernel.physicsList()
0061   phys.extends = 'QGSP_BERT'
0062   phys.enableUI()
0063   phys.dump()
0064   # and run
0065   geant4.execute()
0066 
0067 
0068 if __name__ == "__main__":
0069   run()