Histo norm

Hello,

I have a little problem with histograms:

Int_t main()
{
    gStyle->SetOptFit();
        
    TCanvas *c=new TCanvas();
    TH1F    *h=new TH1F("","",100,-1,1);

    for(Int_t i=0;i<10000;i++){
        
        h->Fill(gRandom->Gaus(0,0.1));
    }
        
    h->Scale(1.0/h->Integral());
    h->Fit("gaus");
    h->DrawCopy("e");

    delete h;
    return(0);
}

The problem is that chi2/ndf for normalized histogram is wrong
and the error bars are not scaled. Do I need to use some option or
its just a bug?

Dimitar.

Please read the documentation of TH1::Scale at:
root.cern.ch/root/htmldoc/TH1.html#TH1:Scale

You must add a call to TH1::Sumw2 before scaling your histogram if you want to have errors computed correctly as shown below

Rene

                   Int_t norm() 
                   { 
                       gStyle->SetOptFit(); 
                           
                       TCanvas *c=new TCanvas(); 
                       TH1F    *h=new TH1F("","",100,-1,1); 

                       h->Sumw2();
                       for(Int_t i=0;i<10000;i++){ 
                           
                           h->Fill(gRandom->Gaus(0,0.1)); 
                       } 
                           
                       h->Scale(1.0/h->Integral()); 
                       h->Fit("gaus"); 
                       h->DrawCopy("e"); 

                       delete h; 
                       return(0); 
                   }

Thanks.