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 sys
0014 import time
0015 import DDG4
0016 from DDG4 import OutputLevel as Output
0017 from g4units import GeV, MeV
0018 #
0019 #
0020 """
0021 
0022    dd4hep example setup using the python configuration
0023 
0024    \author  M.Frank
0025    \version 1.0
0026 
0027 """
0028 
0029 
0030 def run():
0031   batch = False
0032   kernel = DDG4.Kernel()
0033   install_dir = os.environ['DD4hepExamplesINSTALL']
0034   geometry = "file:" + install_dir + "/examples/ClientTests/compact/MultiCollections.xml"
0035   kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG)
0036   kernel.setOutputLevel(str('Gun'), Output.INFO)
0037   for i in range(len(sys.argv)):
0038     if sys.argv[i] == '-compact':
0039       geometry = sys.argv[i + 1]
0040     elif sys.argv[i] == '-input':
0041       geometry = sys.argv[i + 1]
0042     elif sys.argv[i] == '-batch':
0043       batch = True
0044     elif sys.argv[i] == 'batch':
0045       batch = True
0046 
0047   kernel.loadGeometry(str(geometry))
0048   geant4 = DDG4.Geant4(kernel)
0049   geant4.printDetectors()
0050   geant4.setupCshUI()
0051   if batch:
0052     kernel.UI = ''
0053 
0054   # Configure field
0055   geant4.setupTrackingField(prt=True)
0056   # Configure I/O
0057   geant4.setupROOTOutput('RootOutput', 'Multi_coll_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True)
0058   # Setup particle gun
0059   geant4.setupGun("Gun", particle='pi-', energy=10 * GeV, multiplicity=1)
0060 
0061   # Now the test calorimeter with multiple collections
0062   seq, act = geant4.setupCalorimeter('TestCal')
0063 
0064   # And handle the simulation particles.
0065   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0066   kernel.generatorAction().adopt(part)
0067   part.MinimalKineticEnergy = 1 * MeV
0068   part.enableUI()
0069 
0070   # Now build the physics list:
0071   phys = kernel.physicsList()
0072   phys.extends = 'QGSP_BERT'
0073   phys.enableUI()
0074   phys.dump()
0075   # and run
0076   geant4.execute()
0077 
0078 
0079 if __name__ == "__main__":
0080   run()