Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 08:25:29

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