File indexing completed on 2025-02-25 09:20:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 """
0013
0014 Subtest using CLICSid showing the usage of the G4Particle gun using
0015 the Geant4GeneratorWrapper object.
0016
0017 @author M.Frank
0018 @version 1.0
0019
0020 """
0021 from __future__ import absolute_import, unicode_literals
0022
0023 import logging
0024
0025 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0026 logger = logging.getLogger(__name__)
0027
0028
0029 def run():
0030 import CLICSid
0031 import DDG4
0032 from DDG4 import OutputLevel as Output
0033
0034 sid = CLICSid.CLICSid()
0035 geant4 = sid.geant4
0036 kernel = sid.kernel
0037 sid.loadGeometry()
0038 geant4.printDetectors()
0039 kernel.UI = "UI"
0040 geant4.setupCshUI()
0041 sid.setupField(quiet=False)
0042 DDG4.importConstants(kernel.detectorDescription(), debug=False)
0043
0044 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0045 prt.OutputLevel = Output.INFO
0046 prt.OutputType = 3
0047 kernel.eventAction().adopt(prt)
0048
0049 gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0050 kernel.generatorAction().adopt(gen)
0051 logger.info("# First particle generator: gun")
0052 gun = DDG4.GeneratorAction(kernel, "Geant4GeneratorWrapper/Gun")
0053 gun.Uses = 'G4ParticleGun'
0054 gun.Mask = 1
0055 kernel.generatorAction().adopt(gun)
0056
0057
0058 merger = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0059 merger.enableUI()
0060 kernel.generatorAction().adopt(merger)
0061
0062
0063 part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0064 kernel.generatorAction().adopt(part)
0065 part.OutputLevel = Output.INFO
0066 part.enableUI()
0067 user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler")
0068 user.TrackingVolume_Zmax = DDG4.EcalEndcap_zmin
0069 user.TrackingVolume_Rmax = DDG4.EcalBarrel_rmin
0070 user.enableUI()
0071 part.adopt(user)
0072
0073 sid.setupDetectors()
0074 sid.setupPhysics('QGSP_BERT')
0075 sid.test_config()
0076 gun.generator()
0077 kernel.run()
0078 kernel.terminate()
0079
0080
0081 if __name__ == "__main__":
0082 run()