Reading histograms with attached fit functions #744
-
Dear experts, Newcomer’s question. I’m using more and more uproot for histogram post-processing but, sometime, I have some issue to get histograms from root files. I put a MWE here and a root file as sample: #!/usr/bin/env python
import uproot
def main():
file = uproot.open('scripts/output.root')
print(file.classnames()) # Show 2 TH1D in file
h1neutron_amp = file['h1neutron_amp;1'] # Get first hist
print(h1neutron_amp.values()) # Work fine
h1neutron_rate = file['h1neutron_rate;1'] # Traceback here
print(h1neutron_rate.values())
if __name__ == '__main__':
main() The file contains two TH1D, I can get the ‘h1neutron_amp’ without problem. But when I try to get the other one, I get this traceback:
Unfortunately, the traceback is a too cryptic for my understanding. Do you have an idea on where this error may come from, please? Thanks for your help. OS: Ubuntu 20.04 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
This is an unimplemented part of ROOT serialization. (That's why the error type is |
Beta Was this translation helpful? Give feedback.
-
btw how old is this file, it seems to be made with a relatively old ROOT version |
Beta Was this translation helpful? Give feedback.
-
My other example of a file with non-memberwise (In retrospect, I should have asked you to test on the git branch before merging it, because we could have adapted to any surprises that you encounter. But, oh well, at least it will be easier for you to test. Just |
Beta Was this translation helpful? Give feedback.
My other example of a file with non-memberwise
std::map
serialization (#556) is also a histogram, and thestd::map
is the parameterization of a TFormula, which is a fit function (TF1) attached to the histogram. Your stack trace also shows that it failed while deserializingfFunctions
, so I'm going to guess that it's the same thing. I've released a fix in Uproot 4.3.6. Try upgrading and seeing if it fixes the problem.(In retrospect, I should have asked you to test on the git branch before merging it, because we could have adapted to any surprises that you encounter. But, oh well, at least it will be easier for you to test. Just
pip install -U uproot
and try again. If it doesn't work, then…