-
|
Dear All, I am trying to write a root file inside a for-loop in Python. I have a Everything runs perfectly. But when I read the Am I missing something? Is everything all right? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
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 But I think it's likely that you want to combine all of the In writing these scripts, I end up creating a Adeel: Thanks for clarification. It not clear to me how to apply the extend() here. In above code example, is the statement (later) Thanks it perfectly worked. I have another question. Is there a way to store TClonesArray? Jim: There is not a way to write the Python data as a specified ROOT/C++ type, such as TClonesArray. Sorry! (Each different ROOT/C++ type is a different serialization format, so it would essentially be a new project for each one. TClonesArray has a particularly odd serialization, as seen in the code that reads TClonesArray.) |
Beta Was this translation helpful? Give feedback.
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_filewere a Python dict, eachdfwould 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 subsequentdfs can fill the TTree using uproot.WritableTree.ex…