10def find_histo(root_file, path, should_delete=False):
11 obj = root_file.Get(path)
12 if not obj:
13 if crash_on_error:
14 raise RuntimeError(f"Object not found at path: {path}")
15 else:
16 logging.warning(f"Object not found at path: {path}")
17 return None
18 if should_delete:
19
20 path_parts = path.strip(
"/").
split(
"/")
21 *dirs, name = path_parts
22 current_dir = root_file
23 for d in dirs:
24 current_dir = current_dir.Get(d)
25 if not current_dir:
26 if crash_on_error:
27 raise RuntimeError(f"Directory '{d}' not found in path '{'/'.join(dirs)}' for deletion.")
28 else:
29 logging.warning(f"Directory '{d}' not found in path '{'/'.join(dirs)}' for deletion.")
30 return None
31
32 current_dir.Delete(f"{name};*")
33 return None
34 return obj
35