Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDSim UI config #1142

Merged
merged 5 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/scripts/runPythonChecks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} +
3 changes: 1 addition & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} +
10 changes: 5 additions & 5 deletions DDG4/include/DDG4/Geant4UIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> m_postRunCommands;
/// Property: Array of commands to be chained
std::vector<std::string> m_macros;
Expand Down
19 changes: 14 additions & 5 deletions DDG4/python/DDSim/DD4hepSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -99,6 +100,7 @@ def __init__(self):
self.geometry = Geometry()
self.filter = Filter()
self.physics = Physics()
self.ui = UI()

self._argv = None

Expand Down Expand Up @@ -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

# -----------------------------------------------------------------------------------
Expand Down
76 changes: 76 additions & 0 deletions DDG4/python/DDSim/Helper/UI.py
Original file line number Diff line number Diff line change
@@ -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)