diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index da83bd6a847c7aa83b6226492dc964595b9bd75c..193688d12f91de3ce0828ff314c22690d0053376 100644 --- a/DDG4/python/DDSim/DD4hepSimulation.py +++ b/DDG4/python/DDSim/DD4hepSimulation.py @@ -17,6 +17,7 @@ from DDSim.Helper.HepMC3 import HepMC3 from DDSim.Helper.GuineaPig import GuineaPig from DDSim.Helper.Physics import Physics from DDSim.Helper.Filter import Filter +from DDSim.Helper.Geometry import Geometry from DDSim.Helper.Random import Random from DDSim.Helper.Action import Action from DDSim.Helper.Output import Output, outputLevel, outputLevelType @@ -85,6 +86,7 @@ class DD4hepSimulation(object): self.hepmc3 = HepMC3() self.meta = Meta() + self.geometry = Geometry() self.filter = Filter() self.physics = Physics() @@ -324,8 +326,10 @@ class DD4hepSimulation(object): # setup the magnetic field: self.__setMagneticFieldOptions(simple) - # ---------------------------------------------------------------------------------- + # configure geometry creation + self.geometry.constructGeometry(kernel, geant4) + # ---------------------------------------------------------------------------------- # Configure Run actions run1 = DDG4.RunAction(kernel, 'Geant4TestRunAction/RunInit') kernel.registerGlobalAction(run1) diff --git a/DDG4/python/DDSim/Helper/Geometry.py b/DDG4/python/DDSim/Helper/Geometry.py new file mode 100644 index 0000000000000000000000000000000000000000..608c98f02ef67db062925d85779a1bd3b89c24e6 --- /dev/null +++ b/DDG4/python/DDSim/Helper/Geometry.py @@ -0,0 +1,65 @@ +"""Helper object for Geant4 Geometry conversion.""" + +from __future__ import absolute_import, unicode_literals + +from DDSim.Helper.ConfigHelper import ConfigHelper + + +class Geometry(ConfigHelper): + """Configuration for the Detector Construction.""" + + def __init__(self): + super(Geometry, self).__init__() + + self._enableDebugMaterials_EXTRA = {"help": "Print Debug information about Materials"} + self.enableDebugMaterials = False + self._enableDebugElements_EXTRA = {"help": "Print Debug information about Elements"} + self.enableDebugElements = False + self._enableDebugVolumes_EXTRA = {"help": "Print Debug information about Volumes"} + self.enableDebugVolumes = False + self._enableDebugShapes_EXTRA = {"help": "Print Debug information about Shapes"} + self.enableDebugShapes = False + self._enableDebugPlacements_EXTRA = {"help": "Print Debug information about Placements"} + self.enableDebugPlacements = False + self._enableDebugReflections_EXTRA = {"help": "Print Debug information about Reflections"} + self.enableDebugReflections = False + self._enableDebugRegions_EXTRA = {"help": "Print Debug information about Regions"} + self.enableDebugRegions = False + self._enableDebugSurfaces_EXTRA = {"help": "Print Debug information about Surfaces"} + self.enableDebugSurfaces = False + self._dumpHierachy_EXTRA = {"help": "If larger than 0, the depth up to which detector hierarchy is dumped"} + self.dumpHierarchy = 0 + + # unused + self.printPlacements = False + self.printSensitives = False + # FIXME: get this via output.geoInfoPrintLevel!!! + self.geoInfoPrintLevel = 7 + + self._dumpDGDML_EXTRA = {"help": "If not empty, filename to dump the Geometry as GDML"} + self.dumpGDML = "" + + def constructGeometry(self, kernel, geant4, numberOfThreads=1): + """Construct Geant4 geometry.""" + from DDG4 import DetectorConstruction + + seq, act = geant4.addDetectorConstruction('Geant4DetectorGeometryConstruction/ConstructGeo') + act.DebugMaterials = self.enableDebugMaterials + act.DebugElements = self.enableDebugElements + act.DebugVolumes = self.enableDebugVolumes + act.DebugShapes = self.enableDebugShapes + act.DebugPlacements = self.enableDebugPlacements + act.DebugReflections = self.enableDebugReflections + act.DebugRegions = self.enableDebugRegions + act.DebugSurfaces = self.enableDebugSurfaces + act.PrintPlacements = self.printPlacements + act.PrintSensitives = self.printSensitives + act.GeoInfoPrintLevel = self.geoInfoPrintLevel + act.DumpHierarchy = self.dumpHierarchy + act.DumpGDML = self.dumpGDML + + + # Apply sensitive detectors + sensitives = DetectorConstruction(kernel, str('Geant4DetectorSensitivesConstruction/ConstructSD')) + sensitives.enableUI() + seq.adopt(sensitives)