3 from __future__
import absolute_import, unicode_literals
8 from DDG4
import OutputLevel
as Output
9 from g4units
import keV, GeV, mm, ns, MeV
12 logging.basicConfig(format=
'%(levelname)s: %(message)s', level=logging.INFO)
13 logger = logging.getLogger(__name__)
16 dd4hep simulation example setup using the python configuration
26 description = kernel.detectorDescription()
27 install_dir = os.environ[
'DD4hepINSTALL']
29 kernel.loadGeometry(str(
"file:" +
"GenericRICH_example.xml"))
32 geant4 =
DDG4.Geant4(kernel, tracker=
'Geant4TrackerCombineAction')
33 geant4.printDetectors()
35 logger.info(
"# Configure UI")
36 geant4.setupUI(
'tcsh',vis=
True,macro=
'macro/vis.mac')
38 logger.info(
"# Configure G4 magnetic field tracking")
39 geant4.setupTrackingField()
41 logger.info(
"# Setup random generator")
47 logger.info(
"# Configure Run actions")
49 run1.Property_int = 12345
50 run1.Property_double = -5e15 * keV
51 run1.Property_string =
'Startrun: Hello_2'
52 logger.info(
"%s %s %s", run1.Property_string, str(run1.Property_double), str(run1.Property_int))
54 kernel.registerGlobalAction(run1)
55 kernel.runAction().adopt(run1)
57 logger.info(
"# Configure Event actions")
59 prt.OutputLevel = Output.INFO
61 kernel.eventAction().adopt(prt)
69 geant4.setupROOTOutput(
'RootOutput',
'derp_' + time.strftime(
'%Y-%m-%d_%H-%M'))
72 kernel.generatorAction().adopt(gen)
75 gen.Uses =
'G4GeneralParticleSource'
76 gen.OutputLevel = Output.INFO
79 kernel.generatorAction().adopt(gen)
140 logger.info(
"# Setup global filters fur use in sensitive detectors")
142 f2 =
DDG4.Filter(kernel,
'ParticleRejectFilter/OpticalPhotonRejector')
143 f2.particle =
'opticalphoton'
144 f3 =
DDG4.Filter(kernel,
'ParticleSelectFilter/OpticalPhotonSelector')
145 f3.particle =
'opticalphoton'
150 kernel.registerGlobalFilter(f2)
151 kernel.registerGlobalFilter(f3)
154 logger.info(
"# First the PID detectors")
155 seq, act = geant4.setupDetector(
'ForwardRICH',
'PhotoMultiplierSDAction')
181 logger.info(
"# Now build the physics list:")
182 phys = geant4.setupPhysics(
'QGSP_BERT')
183 geant4.addPhysics(str(
'Geant4PhysicsList/Myphysics'))
185 ph =
DDG4.PhysicsList(kernel,
'Geant4OpticalPhotonPhysics/OpticalPhotonPhys')
191 ph.MaxNumPhotonsPerStep = 10
192 ph.MaxBetaChangePerStep = 10.0
193 ph.TrackSecondariesFirst =
True
204 rg = geant4.addPhysics(
'Geant4DefaultRangeCut/GlobalRangeCut')
205 rg.RangeCut = 0.7 * mm
227 if __name__ ==
"__main__":