Rebin a variable bin-width histogram.
This tutorial illustrates how to:
- create a variable bin-width histogram with a binning such that the population per bin is about the same.
- rebin a variable bin-width histogram into another one.
void rebin() {
TH1F *h =
new TH1F(
"h",
"test rebin",100,-3,3);
for (
Int_t i=1;i<=100;i++) {
if (y <=0) continue;
xbins[k] = xmin +j*dx;
k++;
}
}
TH1F *hnew =
new TH1F(
"hnew",
"rebinned",k,xbins);
for (
Int_t j=0;j<k;j+=2) {
xbins2[kk] = xbins[j];
kk++;
}
xbins2[kk] = xbins[k];
}
- Author
- Rene Brun
Definition in file rebin.C.