File indexing completed on 2026-05-17 07:37:32
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
0021 import logging
0022
0023 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0024 logger = logging.getLogger(__name__)
0025
0026
0027 def run():
0028 import CLICSid
0029 import DDG4
0030 import os
0031 import sys
0032 from DDG4 import OutputLevel as Output
0033
0034 sid = CLICSid.CLICSid(no_physics=False)
0035 geant4 = sid.geant4
0036 kernel = sid.kernel
0037 sid.loadGeometry()
0038 geant4.printDetectors()
0039 kernel.UI = 'UI'
0040 if len(sys.argv) >= 2 and sys.argv[1] == "batch":
0041 DDG4.setPrintLevel(DDG4.OutputLevel.WARNING)
0042 kernel.UI = ''
0043 geant4.setupCshUI()
0044 sid.setupField(quiet=False)
0045 DDG4.importConstants(kernel.detectorDescription(), debug=False)
0046
0047 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0048 prt.OutputLevel = Output.INFO
0049 prt.OutputType = 3
0050 kernel.eventAction().adopt(prt)
0051
0052
0053 gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0054 kernel.generatorAction().adopt(gen)
0055 input_action = DDG4.GeneratorAction(kernel, "Geant4InputAction/Input")
0056 fname = os.environ['DD4hepExamplesINSTALL'] + '/examples/DDG4/data/hepmc_geant4.dat'
0057 input_action.Input = "Geant4EventReaderHepMC|" + fname
0058 input_action.MomentumScale = 1.0
0059 input_action.Mask = 1
0060 kernel.generatorAction().adopt(input_action)
0061
0062
0063 merger = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0064 merger.enableUI()
0065 kernel.generatorAction().adopt(merger)
0066
0067 logger.info("# Finally generate Geant4 primaries")
0068 gen = DDG4.GeneratorAction(kernel, "Geant4PrimaryHandler/PrimaryHandler")
0069 gen.OutputLevel = 4
0070 gen.enableUI()
0071 kernel.generatorAction().adopt(gen)
0072
0073
0074 part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0075 kernel.generatorAction().adopt(part)
0076 part.OutputLevel = Output.INFO
0077 part.enableUI()
0078
0079 logger.info("# Configure Event actions")
0080 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0081 prt.OutputLevel = Output.INFO
0082 prt.OutputType = 3
0083 kernel.eventAction().adopt(prt)
0084
0085 user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler")
0086 user.TrackingVolume_Zmax = DDG4.EcalEndcap_zmin
0087 user.TrackingVolume_Rmax = DDG4.EcalBarrel_rmin
0088 user.enableUI()
0089 part.adopt(user)
0090
0091 sid.setupDetectors()
0092 sid.setupPhysics('QGSP_BERT')
0093 sid.test_run(have_geo=True, num_events=1)
0094
0095
0096 if __name__ == "__main__":
0097 run()