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
25 os.environ[
'G4UI_USE_TCSH'] =
"1"
27 description = kernel.detectorDescription()
28 install_dir = os.environ[
'DD4hepINSTALL']
30 kernel.loadGeometry(str(
"file:" +
"eic_beamline_example.xml"))
33 geant4 =
DDG4.Geant4(kernel, tracker=
'Geant4TrackerCombineAction')
34 geant4.printDetectors()
36 logger.info(
"# Configure UI")
37 geant4.setupUI(
'tcsh',vis=
True,macro=
'macro/vis.mac')
39 logger.info(
"# Configure G4 magnetic field tracking")
40 geant4.setupTrackingField()
42 logger.info(
"# Setup random generator")
48 logger.info(
"# Configure Run actions")
50 run1.Property_int = 12345
51 run1.Property_double = -5e15 * keV
52 run1.Property_string =
'Startrun: Hello_2'
53 logger.info(
"%s %s %s", run1.Property_string, str(run1.Property_double), str(run1.Property_int))
55 kernel.registerGlobalAction(run1)
56 kernel.runAction().adopt(run1)
58 logger.info(
"# Configure Event actions")
60 prt.OutputLevel = Output.INFO
62 kernel.eventAction().adopt(prt)
70 geant4.setupROOTOutput(
'RootOutput',
'derp_' + time.strftime(
'%Y-%m-%d_%H-%M'))
73 kernel.generatorAction().adopt(gen)
76 gen.Uses =
'G4GeneralParticleSource'
77 gen.OutputLevel = Output.INFO
80 kernel.generatorAction().adopt(gen)
182 logger.info(
"# Now build the physics list:")
183 phys = geant4.setupPhysics(
'QGSP_BERT')
184 geant4.addPhysics(str(
'Geant4PhysicsList/Myphysics'))
205 rg = geant4.addPhysics(
'Geant4DefaultRangeCut/GlobalRangeCut')
206 rg.RangeCut = 0.7 * mm
228 if __name__ ==
"__main__":