Re: Overflow bin with Rebin

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 25 Jan 2006 09:27:34 +0100 (MET)


Hi Jeff,

Effectively, overflows were lost during the call to TH1::Rebin. I have now fixed the problem in CVS.
The same problem is also in TH2::Rebin2D and it will also be fixed soon.

Thanks for the message.

Rene Brun

On
Tue, 24
Jan 2006, Jeff Hartnell wrote:

> Hi,
> I've noticed that the overflow bin disappears when you Rebin a histogram (see
> example macro pasted below). Consequently the overflow value in the stats box
> is zero. Is there a legitimate reason for this?
>
> I'm using ROOT 5.08/00 on SUSE linux 10.
>
> Thanks,
> Jeff.
>
>
> void rebin()
> {
>
> gROOT->Reset();
> //turn off the stats box printing
> gStyle->SetOptStat(1111111);
> //gStyle->SetOptStat(0);
> gStyle->SetOptFit(11111);
> gStyle->SetPalette(1);
> gStyle->SetTitleFontSize(0.06);
> gStyle->SetTitleFillColor(0);
> gStyle->SetTitleBorderSize(0);
> gStyle->SetFrameBorderMode(0);
> gStyle->SetStatColor(0);
>
> gStyle->SetStatW(0.3);
> gStyle->SetStatH(0.2);
>
> TH1F* htest=new TH1F("htest","htest",440,-1.1,1.1);
>
> //entries in range
> htest->Fill(0.1);
> htest->Fill(0.3);
> htest->Fill(-0.5);
> htest->Fill(-0.7);
>
> //underflow entries
> htest->Fill(-2);
> htest->Fill(-3);
>
> //overflow entries
> htest->Fill(5);
> htest->Fill(6);
> htest->Fill(100);
>
> cout<<endl<<"Before rebin:"<<endl;
> cout<<"underflow="<<htest->GetBinContent(0)<<endl;
> Int_t n=htest->GetNbinsX();
> cout<<"n bins="<<n<<endl;
> cout<<"overflow="<<htest->GetBinContent(n+1)<<endl;
>
> TCanvas* c=new TCanvas("c","c",
> 0,0,1000,1150);
> c->SetFillColor(0);
> c->Divide(1,2);
> c->cd(1);
> htest->DrawClone();
>
> Int_t rebin=2;
> htest->Rebin(rebin);
>
> cout<<endl<<"After rebin:"<<endl;
> cout<<"underflow="<<htest->GetBinContent(0)<<endl;
> Int_t n2=htest->GetNbinsX();
> cout<<"n2="<<n2<<endl;
> cout<<"overflow (with n2)="<<htest->GetBinContent(n2+1)<<endl;
> cout<<"other (with n2)="<<htest->GetBinContent(n2+2)<<endl;
> cout<<"other (with n2)="<<htest->GetBinContent(n2-1)<<endl;
>
> //try with old number of bins:
> cout<<"overflow (with n)="<<htest->GetBinContent(n+1)<<endl;
> cout<<"other (with n)="<<htest->GetBinContent(n+2)<<endl;
> cout<<"other (with n)="<<htest->GetBinContent(n-1)<<endl;
>
> c->cd(2);
> htest->Draw();
> }
>
Received on Wed Jan 25 2006 - 09:27:45 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET