345 def __call__(self, root_file):
346 histo1 = find_histo(root_file, self.histo1)
347 histo2 = find_histo(root_file, self.histo2)
348 if not histo1 or not histo2:
349 if crash_on_error:
350 raise RuntimeError(f"Missing histograms: {self.histo1} or {self.histo2}")
351 else:
352 logging.error(f"Missing histograms: {self.histo1} or {self.histo2}")
353 return
354
355 path_parts = self.output.
strip(
"/").
split(
"/")
356 *dir_path, output_name = path_parts
357 directory_path = "/".join(dir_path)
358 summed = histo1.Clone(output_name)
359 summed.Add(histo2)
360 ensure_directory_exists(root_file, directory_path)
361 root_file.cd(directory_path)
362 summed.Write(output_name, ROOT.TObject.kOverwrite)
363 logging.info(f"Saved added histogram '{output_name}' in '{directory_path}'.")
364 if self.delete_inputs:
365
366 find_histo(root_file, self.histo1, should_delete=True)
367 find_histo(root_file, self.histo2, should_delete=True)
368
std::vector< std::string > split(const std::string &s, const std::string &t=":")