17 from argparse
import ArgumentParser
20 if __name__ ==
'__main__':
21 parser = ArgumentParser(description=
"Helper script to convert a root file into an input file needed for HLT ZMQ tests.")
22 parser.add_argument(
"input_file", help=
"Input file name")
23 parser.add_argument(
"output_file", help=
"Output file name")
24 parser.add_argument(
"--number", help=
"How many events should be converted (default 10)", default=10, type=int)
25 parser.add_argument(
"--expressreco", help=
"Convert to express reco format, instead of HLT", action=
"store_true")
27 args = parser.parse_args()
28 input_file = args.input_file
29 output_file = args.output_file
31 basf2.conditions.override_globaltags([])
34 branchNames = HLT_INPUT_OBJECTS
36 branchNames = EXPRESSRECO_INPUT_OBJECTS
38 extension = os.path.splitext(input_file)[-1]
39 if extension ==
".root":
40 path.add_module(
"RootInput", inputFileName=input_file, branchNames=branchNames)
42 raise AttributeError(f
"Do not understand file format of {input_file}")
44 if not args.expressreco:
45 path.add_module(
"Root2Raw", outputFileName=output_file +
".raw")
46 path.add_module(
"SeqRootOutput", outputFileName=output_file +
".sroot")
47 path.add_module(
"RootOutput", outputFileName=output_file +
".root")