From a194854542da520e1a37d067a9c9d25eae1526bb Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Thu, 9 Mar 2023 11:31:41 +0100
Subject: [PATCH] DDSim.Geometry: add output level configuration

---
 DDG4/python/DDSim/DD4hepSimulation.py |  2 +-
 DDG4/python/DDSim/Helper/Geometry.py  |  7 ++-----
 DDG4/python/DDSim/Helper/Output.py    | 12 ++++++++++++
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py
index 052051611..5a541e6c5 100644
--- a/DDG4/python/DDSim/DD4hepSimulation.py
+++ b/DDG4/python/DDSim/DD4hepSimulation.py
@@ -328,7 +328,7 @@ class DD4hepSimulation(object):
     self.__setMagneticFieldOptions(geant4)
 
     # configure geometry creation
-    self.geometry.constructGeometry(kernel, geant4)
+    self.geometry.constructGeometry(kernel, geant4, self.output.geometry)
 
     # ----------------------------------------------------------------------------------
     # Configure Run actions
diff --git a/DDG4/python/DDSim/Helper/Geometry.py b/DDG4/python/DDSim/Helper/Geometry.py
index 608c98f02..127437c48 100644
--- a/DDG4/python/DDSim/Helper/Geometry.py
+++ b/DDG4/python/DDSim/Helper/Geometry.py
@@ -33,13 +33,11 @@ class Geometry(ConfigHelper):
     # 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):
+  def constructGeometry(self, kernel, geant4, geoPrintLevel=2, numberOfThreads=1):
     """Construct Geant4 geometry."""
     from DDG4 import DetectorConstruction
 
@@ -54,11 +52,10 @@ class Geometry(ConfigHelper):
     act.DebugSurfaces = self.enableDebugSurfaces
     act.PrintPlacements = self.printPlacements
     act.PrintSensitives = self.printSensitives
-    act.GeoInfoPrintLevel = self.geoInfoPrintLevel
+    act.GeoInfoPrintLevel = geoPrintLevel
     act.DumpHierarchy = self.dumpHierarchy
     act.DumpGDML = self.dumpGDML
 
-
     # Apply sensitive detectors
     sensitives = DetectorConstruction(kernel, str('Geant4DetectorSensitivesConstruction/ConstructSD'))
     sensitives.enableUI()
diff --git a/DDG4/python/DDSim/Helper/Output.py b/DDG4/python/DDSim/Helper/Output.py
index bb7916aca..3c795fac3 100644
--- a/DDG4/python/DDSim/Helper/Output.py
+++ b/DDG4/python/DDSim/Helper/Output.py
@@ -51,6 +51,9 @@ class Output(ConfigHelper):
     self._random_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
     self._random = outputLevel('FATAL')
 
+    self._geometry_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
+    self._geometry = outputLevel('DEBUG')
+
   @property
   def inputStage(self):
     """Output level for input sources"""
@@ -86,3 +89,12 @@ class Output(ConfigHelper):
   @random.setter
   def random(self, level):
     self._random = outputLevel(level)
+
+  @property
+  def geometry(self):
+    """Output level for geometry."""
+    return self._geometry
+
+  @geometry.setter
+  def geometry(self, level):
+    self._geometry = outputLevel(level)
-- 
GitLab