It is possible to extend k4run
with custom arguments from a steering file
using k4FWCore.parseArgs
.
Example:
from k4FWCore.parseArgs import parser
parser.add_argument("--trackingOnly", action="store_true", help="Run only track reconstruction", default=False)
my_opts = parser.parse_known_args()[0]
# later
if my_opts.trackingOnly:
# only run track reconstruction
The example steering file can then be executed as follows:
k4run example_steering_file.py --trackingOnly --some-other-args
Behind the scenes parser
is just a normal instance of python's
argparse.ArgumentParser
,
please refer to its documentation for usage details. Use parse_known_args()
instead of parse_args()
so that the normal k4run
arguments keep working. The
[0]
is necessary because the added arguments will be in the first element of
the tuple returned from parse_known_args
.