From ded38bc9c56f084efa31c5bea836ba25098da5d9 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Wed, 8 Jun 2022 13:47:14 +0200 Subject: [PATCH] DDSim: add possibility to load individual XML files The XML files need to follow the structure where at the end is a closer file. compactFile takes multiple arguments, or multiple instances of compactFile or both. ddsim --compactFile $DD4hep/examples/CLICSiD/compact/SiD_multiple_inputs.xml $DD4hep/examples/CLICSiD/compact/SiD_detectors_1.xml --compactFile $DD4hep/examples/CLICSiD/compact/SiD_detectors_2.xml $DD4hep/examples/CLICSiD/compact/SiD_close.xml --runType shell --- DDG4/python/DDSim/DD4hepSimulation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index d9b529d63..03c1de2d4 100644 --- a/DDG4/python/DDSim/DD4hepSimulation.py +++ b/DDG4/python/DDSim/DD4hepSimulation.py @@ -63,7 +63,7 @@ class DD4hepSimulation(object): def __init__(self): self.steeringFile = None - self.compactFile = "" + self.compactFile = [] self.inputFiles = [] self.outputFile = "dummyOutput.slcio" self.runType = "batch" @@ -145,8 +145,8 @@ class DD4hepSimulation(object): if self._argv is None: self._argv = list(argv) if argv else list(sys.argv) - parser.add_argument("--compactFile", action="store", default=self.compactFile, - help="The compact XML file") + parser.add_argument("--compactFile", nargs='+', action="extend", default=self.compactFile, type=str, + help="The compact XML file, or multiple compact files, if the last one is the closer.") parser.add_argument("--runType", action="store", choices=("batch", "vis", "run", "shell"), default=self.runType, help="The type of action to do in this invocation" # Note: implicit string concatenation @@ -301,7 +301,8 @@ class DD4hepSimulation(object): kernel = DDG4.Kernel() dd4hep.setPrintLevel(self.printLevel) - kernel.loadGeometry(str("file:" + self.compactFile)) + for compactFile in self.compactFile: + kernel.loadGeometry(str("file:" + compactFile)) detectorDescription = kernel.detectorDescription() DDG4.importConstants(detectorDescription) -- GitLab