77 parser = argparse.ArgumentParser(description=
"NTUPLE PHYSVAL Histogram Post-processing Tool")
78 parser.add_argument(
"files", nargs=
"*", help=
"Input ROOT file and optionally output file name")
79 parser.add_argument(
"--domain", type=str, help=
"Specific domain to process (e.g., Electron, Photon, BTag)")
80 parser.add_argument(
"--crash_on_error", action=
"store_true", help=
"Crash on first error instead of just warning")
81 args = parser.parse_args()
83 physvalPostProcessingTools.crash_on_error = args.crash_on_error
85 if len(args.files) == 1:
86 input_file = args.files[0]
87 output_file = os.path.splitext(input_file)[0] +
"_after_post_process.root"
88 elif len(args.files) == 2:
89 input_file, output_file = args.files
91 logging.error(
"You must provide 1 or 2 positional arguments: <input_file> [output_file]")
94 config_manager = ConfigManager()
95 config_manager.add_configuration(
"Electron", electron_config)
96 config_manager.add_configuration(
"Photon", photon_config)
97 config_manager.add_configuration(
"BTag", btag_config)
99 logging.info(f
"Input: {input_file}")
100 logging.info(f
"Output: {output_file}")
106 logging.info(
"Post Processing started...")
108 process_domain(root_file, config_manager.get_config(args.domain), args.domain)
110 for domain, domain_config
in config_manager.get_all_configs():
115 logging.info(f
"Postprocessing complete. Output saved to: {output_file}")
116 except Exception
as e:
117 logging.error(f
"Failed to close ROOT file: {e}")