Skip to content

Writing TTree in ROOT file inside a loop #815

Answered by jpivarski
a-akram asked this question in Q&A
Discussion options

You must be logged in to vote

I answered this on Gitter, but I should copy our conversation here so that it's useful to others in the future.

Jim:

Hi @a-akram! What's happening here is that Uproot follows ROOT's way of adding same-name objects to a directory: it gives each one a different "cycle number" to distinguish them. If root_file were a Python dict, each df would overwrite the previous one, but ROOT keeps them all, and the cycle number is like a version number.

But I think it's likely that you want to combine all of the dfs into one big TTree. In that case, use assignment (what you have above) to get the first one in, which defines the Tree, and all subsequent dfs can fill the TTree using uproot.WritableTree.ex…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Moelf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants