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.

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.

1 Like