Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 08:24:11

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    dd4hep example setup using the python configuration
0013 
0014    \author  M.Frank
0015    \version 1.0
0016 
0017 """
0018 import logging
0019 import sys
0020 
0021 
0022 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0023 
0024 
0025 def show_help():
0026   logging.info("Check_shape.py -option [-option]                           ")
0027   logging.info("       -geometry   <geometry file>   Geometry file         ")
0028   logging.info("       -vis                          Enable visualization  ")
0029   logging.info("       -batch                        Batch execution       ")
0030 
0031 
0032 def run():
0033   cnt = 0
0034   geo = None
0035   vis = False
0036   batch = False
0037   for i in sys.argv:
0038     cnt = cnt + 1
0039     c = i.upper()
0040     if c.find('BATCH') < 2 and c.find('BATCH') >= 0:
0041       batch = True
0042     elif c[:4] == '-GEO':
0043       geo = sys.argv[cnt]
0044     elif c[:4] == '-VIS':
0045       vis = True
0046 
0047   if not geo:
0048     show_help()
0049     sys.exit(1)
0050 
0051   import DDG4
0052   kernel = DDG4.Kernel()
0053   # Configure UI
0054   geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0055   if batch:
0056     ui = geant4.setupCshUI(typ=None, ui=None, vis=None)
0057     kernel.UI = 'UI'
0058   else:
0059     ui = geant4.setupCshUI(vis=vis)
0060   kernel.loadGeometry(geo)
0061   # Configure field
0062   geant4.setupTrackingField(prt=True)
0063   # Now build the physics list:
0064   geant4.setupPhysics('')
0065   kernel.physicsList().enableUI()
0066   DDG4.setPrintLevel(DDG4.OutputLevel.DEBUG)
0067   #
0068   ui.Commands = [
0069       '/ddg4/ConstructGeometry/printVolume /world_volume_1',
0070       '/ddg4/ConstructGeometry/printMaterial Air',
0071       '/ddg4/ConstructGeometry/printMaterial Vacuum',
0072       '/ddg4/UI/exit'
0073       ]
0074   kernel.NumEvents = 0
0075   kernel.configure()
0076   kernel.initialize()
0077   kernel.run()
0078   kernel.terminate()
0079 
0080 
0081 # Main entry point:
0082 if __name__ == "__main__":
0083   run()