Rebin the 2D histogram H.
Use NAME for the new histogram.
Group together GX bins in x and GY bins in y.
Definition at line 14 of file rebin2.py.
14 def rebin2 (h, name, gx=1, gy=1):
15 """Rebin the 2D histogram H.
16 Use NAME for the new histogram.
17 Group together GX bins in x and GY bins in y.
19 old_nx = h.GetNbinsX()
20 old_ny = h.GetNbinsY()
23 hnew = ROOT.TH2F (name,
26 h.GetXaxis().GetXmin(),
27 h.GetXaxis().GetXmax(),
29 h.GetYaxis().GetXmin(),
30 h.GetYaxis().GetXmax())
31 for ix
in range(0, new_nx):
32 for iy
in range(0, new_ny):
34 for iix
in range(0, gx):
35 for iiy
in range(0, gy):
36 sum += h.GetBinContent(ix*gx+iix+1, iy*gy+iiy+1)
37 hnew.SetBinContent(ix+1, iy+1, sum)