diff --git a/.github/scripts/runPythonChecks.sh b/.github/scripts/runPythonChecks.sh index 850597d50..4e228e24d 100755 --- a/.github/scripts/runPythonChecks.sh +++ b/.github/scripts/runPythonChecks.sh @@ -3,8 +3,5 @@ source /cvmfs/sft.cern.ch/lcg/views/${VIEW}/setup.sh cd /Package -echo "RUNNING PYLINT PY3K CHECK" && \ -find . -name "*.py" -and -not -name 'ddsix.py' -exec pylint --rcfile=.github/scripts/DD4hep.pylint.py3k.rc --py3k --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" {} + && \ -echo "" && \ echo "RUNNING FLAKE8 CHECK" && \ find . -name "*.py" -and -not -name 'ddsix.py' -exec flake8 {} + diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 842040d54..dc1475473 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -82,8 +82,7 @@ jobs: strategy: fail-fast: false matrix: - view-path: ["/cvmfs/sw.hsf.org/key4hep/", - "/cvmfs/sw-nightlies.hsf.org/key4hep/"] + view-path: ["/cvmfs/sw-nightlies.hsf.org/key4hep/"] steps: - uses: actions/checkout@v3 - uses: cvmfs-contrib/github-action-cvmfs@v3 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e6e622fde..eb6016e07 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -15,8 +15,5 @@ jobs: with: release-platform: ${{ matrix.LCG }} run: | - echo "RUNNING PYLINT PY3K CHECK" - find . -name "*.py" -and -not -name 'ddsix.py' -exec pylint --rcfile=.github/scripts/DD4hep.pylint.py3k.rc --py3k --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" {} + - echo "" echo "RUNNING FLAKE8 CHECK" find . -name "*.py" -and -not -name 'ddsix.py' -exec flake8 {} + diff --git a/DDG4/include/DDG4/Geant4UIManager.h b/DDG4/include/DDG4/Geant4UIManager.h index b696a7cde..2bcfa4e2f 100644 --- a/DDG4/include/DDG4/Geant4UIManager.h +++ b/DDG4/include/DDG4/Geant4UIManager.h @@ -58,15 +58,15 @@ namespace dd4hep { std::string m_uiSetup; /// Property: Name of the visualization macro file std::string m_visSetup; - /// Property: Array of macro files to be chained and executed when the Geant4Kernel gets configured + /// Property: List of commands to be executed when the Geant4Kernel gets configured std::vector m_configureCommands; - /// Property: Array of macro files to be chained and executed when the Geant4Kernel gets initialized + /// Property: List of commands to be executed when the Geant4Kernel gets initialized std::vector m_initializeCommands; - /// Property: Array of macro files to be chained and executed when the Geant4Kernel gets terminated + /// Property: List of commands to be executed when the Geant4Kernel gets terminated std::vector m_terminateCommands; - /// Property: Array of macro files to be chained and executed BEFORE running + /// Property: List of commands to be executed BEFORE running std::vector m_preRunCommands; - /// Property: Array of macro files to be chained and executed AFTER running + /// Property: List of commands to be executed AFTER running std::vector m_postRunCommands; /// Property: Array of commands to be chained std::vector m_macros; diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index 9b8708edf..8c25b442a 100644 --- a/DDG4/python/DDSim/DD4hepSimulation.py +++ b/DDG4/python/DDSim/DD4hepSimulation.py @@ -28,6 +28,7 @@ from DDSim.Helper.MagneticField import MagneticField from DDSim.Helper.ParticleHandler import ParticleHandler from DDSim.Helper.Gun import Gun +from DDSim.Helper.UI import UI import argparse import ddsix as six import logging @@ -99,6 +100,7 @@ def __init__(self): self.geometry = Geometry() self.filter = Filter() self.physics = Physics() + self.ui = UI() self._argv = None @@ -317,19 +319,26 @@ def run(self): geant4.printDetectors() if self.runType == "vis": - geant4.setupUI(typ="tcsh", vis=True, macro=self.macroFile) + uiaction = geant4.setupUI(typ="tcsh", vis=True, macro=self.macroFile) elif self.runType == "qt": - geant4.setupUI(typ="qt", vis=True, macro=self.macroFile) + uiaction = geant4.setupUI(typ="qt", vis=True, macro=self.macroFile) elif self.runType == "run": - geant4.setupUI(typ="tcsh", vis=False, macro=self.macroFile, ui=False) + uiaction = geant4.setupUI(typ="tcsh", vis=False, macro=self.macroFile, ui=False) elif self.runType == "shell": - geant4.setupUI(typ="tcsh", vis=False, macro=None, ui=True) + uiaction = geant4.setupUI(typ="tcsh", vis=False, macro=None, ui=True) elif self.runType == "batch": - geant4.setupUI(typ="tcsh", vis=False, macro=None, ui=False) + uiaction = geant4.setupUI(typ="tcsh", vis=False, macro=None, ui=False) else: logger.error("unknown runType") exit(1) + # User Configuration for the Geant4Phases + uiaction.ConfigureCommands = self.ui._commandsConfigure + uiaction.InitializeCommands = self.ui._commandsInitialize + uiaction.PostRunCommands = self.ui._commandsPostRun + uiaction.PreRunCommands = self.ui._commandsPreRun + uiaction.TerminateCommands = self.ui._commandsTerminate + kernel.NumEvents = self.numberOfEvents # ----------------------------------------------------------------------------------- diff --git a/DDG4/python/DDSim/Helper/UI.py b/DDG4/python/DDSim/Helper/UI.py new file mode 100644 index 000000000..053cb84f3 --- /dev/null +++ b/DDG4/python/DDSim/Helper/UI.py @@ -0,0 +1,76 @@ +"""Helper object for configuration of Geant4 commands to run during different phases.""" + +from DDSim.Helper.ConfigHelper import ConfigHelper + + +class UI(ConfigHelper): + """Configuration for setting commands to run during different phases. + + In this section, one can configure commands that should be run during the different phases of the Geant4 execution. + + 1. Configuration + 2. Initialization + 3. Pre Run + 4. Post Run + 5. Terminate / Finalization + + For example, one can add + + >>> SIM.ui.commandsConfigure = ['/physics_lists/em/SyncRadiation true'] + + Further details should be taken from the Geant4 documentation. + """ + + def __init__(self): + super(UI, self).__init__() + + self._commandsConfigure = [] + self._commandsInitialize = [] + self._commandsPostRun = [] + self._commandsPreRun = [] + self._commandsTerminate = [] + + @property + def commandsConfigure(self): + """List of UI commands to run during the 'Configure' phase.""" + return self._commandsConfigure + + @commandsConfigure.setter + def commandsConfigure(self, val): + self._commandsConfigure = self.makeList(val) + + @property + def commandsInitialize(self): + """List of UI commands to run during the 'Initialize' phase.""" + return self._commandsInitialize + + @commandsInitialize.setter + def commandsInitialize(self, val): + self._commandsInitialize = self.makeList(val) + + @property + def commandsPostRun(self): + """List of UI commands to run during the 'PostRun' phase.""" + return self._commandsPostRun + + @commandsPostRun.setter + def commandsPostRun(self, val): + self._commandsPostRun = self.makeList(val) + + @property + def commandsPreRun(self): + """List of UI commands to run during the 'PreRun' phase.""" + return self._commandsPreRun + + @commandsPreRun.setter + def commandsPreRun(self, val): + self._commandsPreRun = self.makeList(val) + + @property + def commandsTerminate(self): + """List of UI commands to run during the 'Terminate' phase.""" + return self._commandsTerminate + + @commandsTerminate.setter + def commandsTerminate(self, val): + self._commandsTerminate = self.makeList(val)