Skip to content

Commit 1ddd5f2

Browse files
retegaede
authored andcommitted
argv parameter added in parseOptions(), allowing user python scripts to supply custom argument list
1 parent fd04131 commit 1ddd5f2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

DDSim/DDSim/DD4hepSimulation.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def __init__(self):
8989
self.filter = Filter()
9090
self.physics = Physics()
9191

92+
self._argv = None
93+
9294
### use TCSH geant UI instead of QT
9395
os.environ['G4UI_USE_TCSH'] = "1"
9496

@@ -108,16 +110,20 @@ def readSteeringFile(self):
108110
self.__dict__ = obj.__dict__
109111
self.steeringFile = os.path.abspath(sFileTemp)
110112

111-
def parseOptions(self):
113+
def parseOptions(self, argv=None):
112114
"""parse the command line options"""
115+
116+
if argv is None:
117+
self._argv = list(sys.argv)
118+
113119
parser = argparse.ArgumentParser("Running DD4hep Simulations:",
114120
formatter_class=argparse.RawTextHelpFormatter)
115121

116122
parser.add_argument("--steeringFile", "-S", action="store", default=self.steeringFile,
117123
help="Steering file to change default behaviour")
118124

119125
#first we parse just the steering file, but only if we don't want to see the help message
120-
if not any( opt in sys.argv for opt in ('-h','--help')):
126+
if not any( opt in self._argv for opt in ('-h','--help')):
121127
parsed, _unknown = parser.parse_known_args()
122128
self.steeringFile = parsed.steeringFile
123129
self.readSteeringFile()
@@ -603,8 +609,8 @@ def __addParametersToRunHeader( self ):
603609
runHeader["MacroFileContent"] = mFile.read()
604610

605611
### add command line
606-
if sys.argv:
607-
runHeader["CommandLine"] = " ".join(sys.argv)
612+
if self._argv:
613+
runHeader["CommandLine"] = " ".join(self._argv)
608614

609615
### add current working directory (where we call from)
610616
runHeader["WorkingDirectory"] = os.getcwd()

0 commit comments

Comments
 (0)