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']
31 kernel.loadGeometry(str(
"file:" +
"HeavyGasCherenkov_example.xml"))
34 geant4 =
DDG4.Geant4(kernel, tracker=
'Geant4TrackerCombineAction')
35 geant4.printDetectors()
37 logger.info(
"# Configure UI")
38 geant4.setupUI(
'qt',vis=
True,macro=
'macro/vis.mac')
40 logger.info(
"# Configure G4 magnetic field tracking")
41 geant4.setupTrackingField()
43 logger.info(
"# Setup random generator")
49 logger.info(
"# Configure Run actions")
51 run1.Property_int = 12345
52 run1.Property_double = -5e15 * keV
53 run1.Property_string =
'Startrun: Hello_2'
54 logger.info(
"%s %s %s", run1.Property_string, str(run1.Property_double), str(run1.Property_int))
56 kernel.registerGlobalAction(run1)
57 kernel.runAction().adopt(run1)
59 logger.info(
"# Configure Event actions")
61 prt.OutputLevel = Output.INFO
63 kernel.eventAction().adopt(prt)
71 geant4.setupROOTOutput(
'RootOutput',
'derp_' + time.strftime(
'%Y-%m-%d_%H-%M'))
74 kernel.generatorAction().adopt(gen)
89 gen.Uses =
'G4GeneralParticleSource'
93 kernel.generatorAction().adopt(gen)
98 kernel.generatorAction().adopt(gen)
103 kernel.generatorAction().adopt(gen)
107 kernel.generatorAction().adopt(part)
109 part.SaveProcesses = [
'Decay']
110 part.MinimalKineticEnergy = 100 * MeV
173 logger.info(
"# Setup global filters fur use in sensitive detectors")
175 f2 =
DDG4.Filter(kernel,
'ParticleRejectFilter/OpticalPhotonRejector')
176 f2.particle =
'opticalphoton'
177 f3 =
DDG4.Filter(kernel,
'ParticleSelectFilter/OpticalPhotonSelector')
178 f3.particle =
'opticalphoton'
183 kernel.registerGlobalFilter(f2)
184 kernel.registerGlobalFilter(f3)
187 logger.info(
"# First the PID detectors")
188 seq, act = geant4.setupDetector(
'LightGasCherenkov',
'PhotoMultiplierSDAction')
214 logger.info(
"# Now build the physics list:")
215 phys = geant4.setupPhysics(
'QGSP_BERT')
216 geant4.addPhysics(str(
'Geant4PhysicsList/Myphysics'))
218 ph =
DDG4.PhysicsList(kernel,
'Geant4OpticalPhotonPhysics/OpticalPhotonPhys')
224 ph.MaxNumPhotonsPerStep = 10
225 ph.MaxBetaChangePerStep = 10.0
226 ph.TrackSecondariesFirst =
True
237 rg = geant4.addPhysics(
'Geant4DefaultRangeCut/GlobalRangeCut')
238 rg.RangeCut = 0.7 * mm
260 if __name__ ==
"__main__":