Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:38:17

0001 """
0002 
0003    Perform a material scan using Geant4 shotting geantinos
0004 
0005    @author  M.Frank
0006    @version 1.0
0007 
0008 """
0009 from __future__ import absolute_import, unicode_literals
0010 import logging
0011 
0012 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0013 logger = logging.getLogger(__name__)
0014 
0015 
0016 def run():
0017   import os
0018   import DDG4
0019   import g4units
0020 
0021   kernel = DDG4.Kernel()
0022   install_dir = os.environ['DD4hepExamplesINSTALL']
0023   kernel.loadGeometry(str("file:" + install_dir + "/examples/LHeD/compact/compact.xml"))
0024   DDG4.Core.setPrintFormat(str("%-32s %6s %s"))
0025   geant4 = DDG4.Geant4(kernel)
0026   # Configure UI
0027   geant4.setupCshUI(ui=None)
0028   gun = geant4.setupGun("Gun",
0029                         Standalone=True,
0030                         particle='geantino',
0031                         energy=20 * g4units.GeV,
0032                         position=(0, 0, 0),
0033                         multiplicity=1,
0034                         isotrop=False)
0035   scan = DDG4.SteppingAction(kernel, 'Geant4MaterialScanner/MaterialScan')
0036   kernel.steppingAction().adopt(scan)
0037 
0038   # Now build the physics list:
0039   geant4.setupPhysics('QGSP_BERT')
0040   kernel.configure()
0041   kernel.initialize()
0042   kernel.NumEvents = 1
0043 
0044   # 3 shots in different directions:
0045   gun.direction = (0, 1, 0)
0046   kernel.run()
0047   gun.direction = (1, 0, 0)
0048   kernel.run()
0049   gun.direction = (1, 1, 1)
0050   kernel.run()
0051 
0052   kernel.terminate()
0053   logger.info('End of run. Terminating .......')
0054   logger.info('TEST_PASSED')
0055 
0056 
0057 if __name__ == "__main__":
0058   run()