55 Rebin 2D histogram. This is dog slow. 57 xaxis = hist.GetXaxis()
58 nbinsx = hist.GetNbinsX()
59 yaxis = hist.GetYaxis()
60 nbinsy = hist.GetNbinsY()
62 h = ROOT.TH2F(hist.GetName(), hist.GetTitle(),
63 int(round(nbinsx/xrebin)), xaxis.GetBinLowEdge(1), xaxis.GetBinUpEdge(nbinsx),
64 int(round(nbinsy/yrebin)), yaxis.GetBinLowEdge(1), yaxis.GetBinUpEdge(nbinsy))
66 xaxis_new = h.GetXaxis()
67 yaxis_new = h.GetYaxis()
69 for ixbin
in range(hist.GetNbinsX()):
70 x = xaxis.GetBinCenter(ixbin+1)
71 ix = xaxis_new.FindBin(x)
73 for iybin
in range(hist.GetNbinsY()):
74 y = yaxis.GetBinCenter(iybin+1)
75 iy = yaxis_new.FindBin(y)
76 val = hist.GetBinContent(ixbin+1, iybin+1)
77 ibin = h.GetBin(ix,iy)
78 h.AddBinContent(ibin, val)
81
def resize_hist2f(hist, xrebin, yrebin)