Rebin to variable-size bins, keeping the same area?

Hi,

I have a histogram of pT spectrum. I want to rebin it using variable-size bins

TH1F* h = new TH1F("h", "h", 100, 0, 500); Double_t xbins[14] = {160,170,180,190,200,220,240,260,280,300,340,380,420,500}; TH1F* h1 = (TH1F*) h->Rebin(13, "h1", xbins);

But what happens is, the bins of larger width will have larger areas. How can I rebin them so that, when I group 2 bins together, the content of the new bin is the sum of both bins divided by 2?

Thanks much,
Jia Fu

Hi,

You might want to scale the histogram with the bin width (i.e dividing each content by its bin width). You can do this by calling

h1->Scale(1,"width");

Lorenzo

Thanks Lorenzo, that’s exactly what I’m looking for.