File indexing completed on 2025-01-18 09:14:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 from __future__ import absolute_import, unicode_literals
0013 import os
0014 import sys
0015 import DDG4
0016 from DDG4 import OutputLevel as Output
0017 from g4units import keV
0018
0019
0020 """
0021
0022 dd4hep simulation example setup using the python configuration
0023
0024 @author M.Frank
0025 @version 1.0
0026
0027 """
0028
0029
0030 def run():
0031 kernel = DDG4.Kernel()
0032 install_dir = os.environ['DD4hepExamplesINSTALL']
0033 kernel.loadGeometry(str("file:" + install_dir + "/examples/OpticalSurfaces/compact/OpNovice.xml"))
0034
0035 DDG4.importConstants(kernel.detectorDescription(), debug=False)
0036 geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0037 geant4.printDetectors()
0038
0039 if len(sys.argv) > 1:
0040 geant4.setupCshUI(macro=sys.argv[1])
0041 else:
0042 geant4.setupCshUI()
0043
0044
0045 geant4.setupTrackingField(prt=True)
0046
0047 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0048 prt.OutputLevel = Output.DEBUG
0049 prt.OutputType = 3
0050 kernel.eventAction().adopt(prt)
0051
0052 generator_output_level = Output.INFO
0053
0054
0055 seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo")
0056 act.DebugMaterials = True
0057 act.DebugElements = False
0058 act.DebugVolumes = True
0059 act.DebugShapes = True
0060 act.DebugSurfaces = True
0061
0062
0063
0064
0065
0066 gun = geant4.setupGun("Gun", particle='gamma', energy=5 * keV, multiplicity=1)
0067 gun.OutputLevel = generator_output_level
0068
0069
0070 """
0071 part = DDG4.GeneratorAction(kernel,"Geant4ParticleHandler/ParticleHandler")
0072 kernel.generatorAction().adopt(part)
0073 part.SaveProcesses = ['Decay']
0074 part.MinimalKineticEnergy = 100*MeV
0075 part.OutputLevel = Output.INFO #generator_output_level
0076 part.enableUI()
0077 user = DDG4.Action(kernel,"Geant4TCUserParticleHandler/UserParticleHandler")
0078 user.TrackingVolume_Zmax = 3.0*m
0079 user.TrackingVolume_Rmax = 3.0*m
0080 user.enableUI()
0081 part.adopt(user)
0082 """
0083 geant4.setupTracker('BubbleDevice')
0084
0085
0086 phys = geant4.setupPhysics('')
0087 ph = DDG4.PhysicsList(kernel, 'Geant4OpticalPhotonPhysics/OpticalGammaPhys')
0088 ph.VerboseLevel = 2
0089 ph.addParticleGroup('G4BosonConstructor')
0090 ph.addParticleGroup('G4LeptonConstructor')
0091 ph.addParticleGroup('G4MesonConstructor')
0092 ph.addParticleGroup('G4BaryonConstructor')
0093 ph.addParticleGroup('G4IonConstructor')
0094 ph.addParticleConstructor('G4OpticalPhoton')
0095
0096 ph.addDiscreteParticleProcess('gamma', 'G4GammaConversion')
0097 ph.addDiscreteParticleProcess('gamma', 'G4ComptonScattering')
0098 ph.addDiscreteParticleProcess('gamma', 'G4PhotoElectricEffect')
0099 ph.addParticleProcess(str('e[+-]'), str('G4eMultipleScattering'), -1, 1, 1)
0100 ph.addParticleProcess(str('e[+-]'), str('G4eIonisation'), -1, 2, 2)
0101 ph.addParticleProcess(str('e[+-]'), str('G4eBremsstrahlung'), -1, 3, 3)
0102 ph.addParticleProcess(str('e+'), str('G4eplusAnnihilation'), 0, -1, 4)
0103 ph.addParticleProcess(str('mu[+-]'), str('G4MuMultipleScattering'), -1, 1, 1)
0104 ph.addParticleProcess(str('mu[+-]'), str('G4MuIonisation'), -1, 2, 2)
0105 ph.addParticleProcess(str('mu[+-]'), str('G4MuBremsstrahlung'), -1, 3, 3)
0106 ph.addParticleProcess(str('mu[+-]'), str('G4MuPairProduction'), -1, 4, 4)
0107 ph.enableUI()
0108 phys.adopt(ph)
0109
0110 ph = DDG4.PhysicsList(kernel, 'Geant4ScintillationPhysics/ScintillatorPhys')
0111 ph.ScintillationYieldFactor = 1.0
0112 ph.ScintillationExcitationRatio = 1.0
0113 ph.TrackSecondariesFirst = False
0114 ph.VerboseLevel = 2
0115 ph.enableUI()
0116 phys.adopt(ph)
0117
0118 ph = DDG4.PhysicsList(kernel, 'Geant4CerenkovPhysics/CerenkovPhys')
0119 ph.MaxNumPhotonsPerStep = 10
0120 ph.MaxBetaChangePerStep = 10.0
0121 ph.TrackSecondariesFirst = True
0122 ph.VerboseLevel = 2
0123 ph.enableUI()
0124 phys.adopt(ph)
0125
0126 phys.dump()
0127
0128 geant4.execute()
0129
0130
0131 if __name__ == "__main__":
0132 run()