Extracting data from histogram

Hi everyone,
I’ve only recently started using root and I’m gradually learning the ropes.
I need to exract the actual data points from a 2-D histogram(not the number of entries,i.e getbin()).Meaning, I want the actual co-ordinates of the data ponts on the histogram. Is it possible to do that ? Any help would be welcome!

http://root.cern.ch/root/html/TH1.html#TH1:FindBin
http://root.cern.ch/root/html/TH1.html#TH1:GetBinContent
http://root.cern.ch/root/html/TH1.html#TH1:GetBinError

Thanks for the links Pepe. However, getbincontent simply returns the number of events in a bin, no? I needed the actual data points (coordinates of each of those events). Didn’t find any function to do that…is there any other way ?

For this you need the original data which were used for the histogram creation/filling.

Oh,ok. So the root file itslef isn’t enough?

I don’t know how you store the “original data”. They may reside in a root file, for example, in a TTree. I simply say that having the histogram is not enough for what you want to do now.

1 Like

Histograms are binned data set. Once data are binned the value you can get about a bin are the bin lower edge, the bin upper edge and the bin content. You can also get associated errors if there some. Bute the actual X Y (z) coordinates fo the points are lost. That’s why Pepe suggested you to go back to original data which may reside in a TTree. Also you might be happy with the information coming from the histogram (those I mentioned).

1 Like