diff --git a/DDSim/DD4hepSimulation.py b/DDSim/DD4hepSimulation.py index b5ea32b8c6cee25265165aee6a9a27a348251f82..5f267174a4c2c617c5ada0df8443618d01a1e340 100644 --- a/DDSim/DD4hepSimulation.py +++ b/DDSim/DD4hepSimulation.py @@ -89,6 +89,8 @@ class DD4hepSimulation(object): self.filter = Filter() self.physics = Physics() + self._argv = None + ### use TCSH geant UI instead of QT os.environ['G4UI_USE_TCSH'] = "1" @@ -108,8 +110,12 @@ class DD4hepSimulation(object): self.__dict__ = obj.__dict__ self.steeringFile = os.path.abspath(sFileTemp) - def parseOptions(self): + def parseOptions(self, argv=None): """parse the command line options""" + + if argv is None: + self._argv = list(sys.argv) + parser = argparse.ArgumentParser("Running DD4hep Simulations:", formatter_class=argparse.RawTextHelpFormatter) @@ -117,7 +123,7 @@ class DD4hepSimulation(object): help="Steering file to change default behaviour") #first we parse just the steering file, but only if we don't want to see the help message - if not any( opt in sys.argv for opt in ('-h','--help')): + if not any( opt in self._argv for opt in ('-h','--help')): parsed, _unknown = parser.parse_known_args() self.steeringFile = parsed.steeringFile self.readSteeringFile() @@ -603,8 +609,8 @@ class DD4hepSimulation(object): runHeader["MacroFileContent"] = mFile.read() ### add command line - if sys.argv: - runHeader["CommandLine"] = " ".join(sys.argv) + if self._argv: + runHeader["CommandLine"] = " ".join(self._argv) ### add current working directory (where we call from) runHeader["WorkingDirectory"] = os.getcwd()