Hi.
I am trying to read root files and extract out information out of histograms and trees (such as mean of multiple histograms) to plot. I am not experienced with root, and I was testing a simple exercise to draw one of the histograms using the following:
Thanks for the reply. I’m still very new to this and don’t understand what is going on. Trying your first suggested method I get a ReferenceError: attempt to access a null pointer. While your second method gives me an AttributeError: TFile object has no attribute ‘histogram.’
I think I understand the second error as file is a variable for the root file instead of the histograms within (though I may be wrong). However I do not understand the ReferenceError.
There are 1D histograms in the file I am looking into. More specifically to what I am trying to do, I want to get into each of the histograms and extract the mean values out of each one.
myHistList = ["Eabs0", "Eabs1", ...] # Here the list of histogram names
file = ROOT.TFile(‘filename.root’)
for hName in myHistList:
hist = file.Get(hName)
print hist.GetMean()