Adding custom arguments to k4run
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
Behind the scenes parser is just a normal instance of pythons argparse.ArgumentParser
, please refer to its documentation for usage details. The only important thing to keep in mind is to always use parse_known_args()
instead of parse_args()
so that the normal k4run
arguments keep working.