ROOT TArrayD from TAxis->GetXbins() cannot be fed back as histogram argument

I’m trying to use the array of xbins from a histogram to initialize a new histogram. I don’t understand why this doesn’t work

[code]#!/usr/bin/python

from ROOT import *
h = TH1D(“hhh”,"",2, 0, 1)
xarr = h.GetXaxis().GetXbins()
foo = TH1D(“foo”,"",2, xarr)[/code]

It doesn’t understand xarr (“could not convert argument”)

Your “h” histogram is a “fix bin size” one, so “h->GetXaxis()->GetXbins()->GetSize()” is 0.
Try: foo = TH1D("foo", "", h.GetXaxis().GetNbins(), h.GetXaxis().GetXmin(), h.GetXaxis().GetXmax()) or maybe better (works for fix and variable bin size histograms): foo = h.Clone("foo") foo.Reset("M")