Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:55

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 logging
0013 import DDG4
0014 import os
0015 from g4units import GeV, m
0016 
0017 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0018 logger = logging.getLogger(__name__)
0019 
0020 
0021 """
0022 
0023    dd4hep example setup using the python configuration
0024 
0025    \author  M.Frank
0026    \version 1.0
0027 
0028 """
0029 
0030 
0031 def run():
0032 
0033   kernel = DDG4.Kernel()
0034   install_dir = os.environ['DD4hepExamplesINSTALL']
0035   kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/SiliconBlock.xml"))
0036 
0037   DDG4.importConstants(kernel.detectorDescription(), debug=False)
0038 
0039   geant4 = DDG4.Geant4(kernel)
0040   ui = geant4.setupCshUI(vis=None)
0041 
0042   # Now the calorimeters
0043   act = DDG4.Action(kernel, str('PropertyTestAction/Test'))
0044   act.prop_str = 'Hello World!'
0045   act.prop_bool = True
0046   act.prop_int = 1234
0047   act.prop_long = 3456
0048   act.prop_ulong = 4567
0049   act.prop_float = 1234567.8
0050   act.prop_double = 1234567.8
0051   act.prop_XYZPoint = (1, 2, 3)
0052   act.prop_XYZVector = (1 * m, 2 * m, 3 * m)
0053   act.prop_PxPyPzEVector = (1 * GeV, 2 * GeV, 3 * GeV, 4 * GeV)
0054 
0055   act.map_str_str = {'a': 'AA', 'b': 'BB', 'c': 'CC'}
0056   act.map_str_bool = {'a': 1, 'b': 0, 'c': 1}
0057   act.map_str_int = {'a': 11, 'b': 22, 'c': 33}
0058   act.map_str_long = {'a': 111, 'b': 222, 'c': 333}
0059   #  act.map_str_ulong = {'a': 1111, 'b': 2222, 'c': 3333}
0060   act.map_str_float = {'a': 11.11, 'b': 22.22, 'c': 33.33}
0061   act.map_str_double = {'a': 11.111, 'b': 22.222, 'c': 33.333}
0062 
0063   act.map_int_str = {100: 'AA', 200: 'BB', 300: 'CC'}
0064   act.map_int_bool = {100: 1, 200: 0, 300: 1}
0065   act.map_int_int = {100: 11, 200: 22, 300: 33}
0066   act.map_int_long = {100: 111, 200: 222, 300: 333}
0067   #  act.map_int_ulong = {100: 1111, 200: 2222, 300: 3333}
0068   act.map_int_float = {100: 11.11, 200: 22.22, 300: 33.33}
0069   act.map_int_double = {100: 11.111, 200: 22.222, 300: 33.333}
0070 
0071   act.map_int_str = {100 * 10: 'AA', 200 * 10: 'BB', 300 * 10: 'CC'}
0072   act.map_int_bool = {100 * 10: 1, 200 * 10: 0, 300 * 10: 1}
0073   act.map_int_int = {100 * 10: 11, 200 * 10: 22, 300 * 10: 33}
0074   act.map_int_long = {100 * 10: 111, 200 * 10: 222, 300 * 10: 333}
0075   #  act.map_int_ulong = {100 * 10: 1111, 200 * 10: 2222, 300 * 10: 3333}
0076   act.map_int_float = {100 * 10: 11.11, 200 * 10: 22.22, 300 * 10: 33.33}
0077   act.map_int_double = {100 * 10: 11.111, 200 * 10: 22.222, 300 * 10: 33.333}
0078 
0079   act.set_str = ['aa', 'bb', 'cc', 'dd']
0080   act.set_bool = [0, 0, 0, 1, 1, 1]
0081   act.set_int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0082   act.set_long = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0083   #  act.set_ulong = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0084   act.set_float = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0085   act.set_double = [0 * m, 1 * m, 2 * m, 3 * m, 4 * m, 5 * m, 6 * m, 7 * m, 8 * m, 8 * m, 8 * m]
0086   act.set_XYZPoint = [(1, 2, 3), (11, 22, 33), (111, 222, 333), (1111, 2222, 3333)]
0087   act.set_XYZVector = [(1, 2, 3), (11, 22, 33), (111, 222, 333), (1111, 2222, 3333)]
0088   act.set_PxPyPzEVector = [(1 * GeV, 2 * GeV, 3 * GeV, 4 * GeV),
0089                            (11 * GeV, 22 * GeV, 33 * GeV, 44 * GeV),
0090                            (111 * GeV, 222 * GeV, 333 * GeV, 444 * GeV)]
0091 
0092   act.list_str = ['aa', 'bb', 'cc', 'dd']
0093   act.list_bool = [0, 0, 0, 1, 1, 1]
0094   act.list_int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0095   act.list_long = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0096   act.list_ulong = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0097   act.list_float = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0098   act.list_double = [0 * m, 1 * m, 2 * m, 3 * m, 4 * m, 5 * m, 6 * m, 7 * m, 8 * m, 8 * m, 8 * m]
0099   act.list_XYZPoint = [(1, 2, 3), (11, 22, 33), (111, 222, 333), (1111, 2222, 3333)]
0100   act.list_XYZVector = [(1, 2, 3), (11, 22, 33), (111, 222, 333), (1111, 2222, 3333)]
0101   act.list_PxPyPzEVector = [(1 * GeV, 2 * GeV, 3 * GeV, 4 * GeV),
0102                             (11 * GeV, 22 * GeV, 33 * GeV, 44 * GeV),
0103                             (111 * GeV, 222 * GeV, 333 * GeV, 444 * GeV)]
0104 
0105   act.vector_str = ['aa', 'bb', 'cc', 'dd']
0106   act.vector_bool = [0, 0, 0, 1, 1, 1]
0107   act.vector_int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0108   act.vector_long = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0109   act.vector_ulong = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0110   act.vector_float = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
0111   act.vector_double = [0 * m, 1 * m, 2 * m, 3 * m, 4 * m, 5 * m, 6 * m, 7 * m, 8 * m, 8 * m, 8 * m]
0112   act.vector_XYZPoint = [(1, 2, 3), (11, 22, 33), (111, 222, 333), (1111, 2222, 3333)]
0113   act.vector_XYZVector = [(1, 2, 3), (11, 22, 33), (111, 222, 333), (1111, 2222, 3333)]
0114   act.vector_PxPyPzEVector = [(1 * GeV, 2 * GeV, 3 * GeV, 4 * GeV),
0115                               (11 * GeV, 22 * GeV, 33 * GeV, 44 * GeV),
0116                               (111 * GeV, 222 * GeV, 333 * GeV, 444 * GeV)]
0117 
0118   act.enableUI()
0119 
0120   #  Check read access:
0121   logger.info('+{value}'.format(value='-------------------------------------------------------'))
0122   logger.info('|  {value}'.format(value=str(act.prop_str)))
0123   logger.info('|  {value}'.format(value=str(act.prop_bool)))
0124   logger.info('|  {value}'.format(value=str(act.prop_int)))
0125   logger.info('|  {value}'.format(value=str(act.prop_float)))
0126   logger.info('|  {value}'.format(value=str(act.prop_double)))
0127   logger.info('|  {value}'.format(value=str(act.prop_XYZPoint)))
0128   logger.info('|  {value}'.format(value=str(act.prop_XYZVector)))
0129   logger.info('|  {value}'.format(value=str(act.prop_PxPyPzEVector)))
0130   logger.info('+{value}'.format(value='-------------------------------------------------------'))
0131 
0132   phys = geant4.setupPhysics('FTFP_BERT')
0133   phys.dump()
0134   ui.Commands = ['/ddg4/Test/show', '/ddg4/Test/dumpProperties', '/ddg4/UI/exit']
0135   kernel.NumEvents = 0
0136   kernel.configure()
0137   kernel.initialize()
0138   kernel.run()
0139   kernel.terminate()
0140 
0141 
0142 if __name__ == "__main__":
0143   run()