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