Saving histogram data as a map or vector pair

What would be the easiest way to save the contents of a histogram as a map or vector pair of bin centers and values? I would like to have something similar to the result of Print('range"), where the bin centers and histogram values are nicely paired up, but as an easily usable cpp item.
I am using root 6.20/06, on lxplus.
Thanks!

Just loop over the bins (1 to nbins, or whatever range) and use GetXaxis()->GetBinCenter and GetBinContent for x and y, saving them in vectors.
https://root.cern/doc/master/classTH1.html#a0ee88e02b75d885985097dcde0a9eaa1

1 Like