5Inspect TTree branches to find which ones use TObjArray or other unsupported types.
7This helps identify branches that would prevent RNTuple conversion.
18 Inspect all branches in a TTree
and report their types.
21 input_file: Path to input ROOT file
22 tree_name: Name of the TTree to inspect
24 print(f"Inspecting TTree: {input_file}:{tree_name}")
28 with ROOT.TFile.Open(input_file,
"READ")
as f:
29 tree = f.Get(tree_name)
31 print(f
"ERROR: Tree '{tree_name}' not found")
34 branches = tree.GetListOfBranches()
35 print(f
"Found {branches.GetEntries()} branches\n")
37 problematic_branches = []
39 for i
in range(branches.GetEntries()):
40 branch = branches.At(i)
41 branch_name = branch.GetName()
42 class_name = branch.GetClassName()
44 is_problematic =
False
47 if "TObjArray" in class_name:
49 reason =
"TObjArray not supported in RNTuple"
50 elif "TClonesArray" in class_name:
52 reason =
"TClonesArray not supported in RNTuple"
53 elif class_name
and "TObject" in class_name
and "std::" not in class_name:
56 reason =
"Legacy ROOT container"
58 status =
"⚠️ PROBLEM" if is_problematic
else "✓ OK"
59 print(f
"{status:12} {branch_name:40} {class_name}")
62 problematic_branches.append((branch_name, class_name, reason))
67 if problematic_branches:
68 print(f
"\n❌ Found {len(problematic_branches)} problematic branch(es):\n")
69 for name, cls, reason
in problematic_branches:
71 print(f
" Type: {cls}")
72 print(f
" Issue: {reason}")
75 print(
"These branches prevent RNTuple conversion.")
76 print(
"Consider migrating to std::vector or other supported types.")
79 print(
"\n✓ All branches appear to be RNTuple-compatible!")
84 """Parse arguments and run the TTree branch inspection."""
85 parser = argparse.ArgumentParser(description=
"Inspect TTree branches for RNTuple compatibility")
86 parser.add_argument(
"-f",
"--input-file", required=
True, help=
"Input ROOT file")
91 help=
"Name of TTree to inspect (default: cbmsim)",
94 args = parser.parse_args()
97 return 0
if success
else 1
100if __name__ ==
"__main__":