Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/examples/LHeD/scripts/LHeDScan.py was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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