File indexing completed on 2025-01-30 09:17:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 """
0013
0014 Subtest using CLICSid showing the usage the HEPMC file reader
0015
0016 @author M.Frank
0017 @version 1.0
0018
0019 """
0020 from __future__ import absolute_import, unicode_literals
0021
0022 import logging
0023
0024 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0025 logger = logging.getLogger(__name__)
0026
0027
0028 def run():
0029 import CLICSid
0030 import DDG4
0031 import os
0032 import sys
0033 from DDG4 import OutputLevel as Output
0034
0035 sid = CLICSid.CLICSid(no_physics=False)
0036 geant4 = sid.geant4
0037 kernel = sid.kernel
0038 sid.loadGeometry()
0039 geant4.printDetectors()
0040 kernel.UI = 'UI'
0041 if len(sys.argv) >= 2 and sys.argv[1] == "batch":
0042 DDG4.setPrintLevel(DDG4.OutputLevel.WARNING)
0043 kernel.UI = ''
0044 geant4.setupCshUI()
0045 sid.setupField(quiet=False)
0046 DDG4.importConstants(kernel.detectorDescription(), debug=False)
0047
0048 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0049 prt.OutputLevel = Output.INFO
0050 prt.OutputType = 3
0051 kernel.eventAction().adopt(prt)
0052
0053
0054 gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0055 kernel.generatorAction().adopt(gen)
0056 input_action = DDG4.GeneratorAction(kernel, "Geant4InputAction/Input")
0057 fname = os.environ['DD4hepExamplesINSTALL'] + '/examples/DDG4/data/hepmc_geant4.dat'
0058 input_action.Input = "Geant4EventReaderHepMC|" + fname
0059 input_action.MomentumScale = 1.0
0060 input_action.Mask = 1
0061 kernel.generatorAction().adopt(input_action)
0062
0063
0064 merger = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0065 merger.enableUI()
0066 kernel.generatorAction().adopt(merger)
0067
0068 logger.info("# Finally generate Geant4 primaries")
0069 gen = DDG4.GeneratorAction(kernel, "Geant4PrimaryHandler/PrimaryHandler")
0070 gen.OutputLevel = 4
0071 gen.enableUI()
0072 kernel.generatorAction().adopt(gen)
0073
0074
0075 part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0076 kernel.generatorAction().adopt(part)
0077 part.OutputLevel = Output.INFO
0078 part.enableUI()
0079
0080 logger.info("# Configure Event actions")
0081 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0082 prt.OutputLevel = Output.INFO
0083 prt.OutputType = 3
0084 kernel.eventAction().adopt(prt)
0085
0086 user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler")
0087 user.TrackingVolume_Zmax = DDG4.EcalEndcap_zmin
0088 user.TrackingVolume_Rmax = DDG4.EcalBarrel_rmin
0089 user.enableUI()
0090 part.adopt(user)
0091
0092 sid.setupDetectors()
0093 sid.setupPhysics('QGSP_BERT')
0094 sid.test_run(have_geo=True, num_events=1)
0095
0096
0097 if __name__ == "__main__":
0098 run()