Errors in histograms

Hi,

I have an input histogram in which certain errors were set for each individual bin contents.
When I feed this into RooFit, the errors are recalculated according to some Poisson (default) or SumW2 scheme, which obviously only takes into account the number of entries in the individual bins. Is it possible to turn off this feature so that the original
errors from the histogram are kept (and then used further on for the error propagation…)?

As an illustration:

testRooFit(){
    gSystem->Load("libRooFit");
    int N = 1000;
    double scale = 0.25;
    TH1F * horig = new TH1F("horig", "horig", 100, 0.0, 100.0);
    for(int i = 0; i < N; i++){
	horig->Fill(gRandom->Gaus(50.0, 10.0));
    }
    for(int i = 0; i < horig->GetNbinsX();i++){
	horig->SetBinError(i, horig->GetBinError(i)*scale);
    }

    TCanvas * c = new TCanvas("c", "c", 1);
    c->Divide(1,2);
    c->cd(1);
    horig->Draw();
    c->cd(2);
    RooRealVar x("x","x",0.0,100.0);
    RooDataHist data("data", "data", x, horig);
    RooPlot* frame = x.frame();
    data.plotOn(frame) ;
    frame->Draw();

}

Thanks,
Balint

Hi Balint,

If a TH1 has custom errors, those are automatically copied into the RooDataHist.
If you plot the RooDataHist with the SumW2 option

data.plotOn(frame,DataError(RooAbsData::SumW2) ; 

you will get back the original errors from the TH1.

Wouter

Hi Wouter,

I did it and I got the following error (Root 5.18/00, CINT 5.16.29, RooFit v2.31):

Error: Function SumW2) is not defined in $DataError(RooAbsData  testRooFit.C

It seems that CINT thinks that it is a function instead of a RooAbsData::ErrorType.
If I just log in to Cint and load the libRooFit then I am able - using tab completition - to
recover the function declaration and also the variable:

root [1] RooFit::DataError(
RooCmdArg DataError(RooAbsData::ErrorType)
root [1] RooAbsData::SumW2 

but why can’t it find it when I want to use it?

(BTW: when doing tab completition CINT is looking for these function declarations in the libRooFit.so or else? because I wanted to dig out the RooAbsData namespace but I couldn’t find it - yet - in my root source and include folders of roofit)

Thanks,
Balint

Hi Again,

If I do

data.plotOn(frame,RooAbsData::SumW2);

then there is no error from CINT but then there is no effect on the error bars again. So they are different when plotting with “TH1::Draw” from “data.plotOn”.

Cheers,
Balint

Hi,

You should first do

using namespace RooFit

because the function DataError() is defined in that namespace.

Wouter

Hi,

yes it works! Thanks.

Another related question: when not using the original errors from the input TH1, then
do I get it right that RooFit expects integer bin contents to calculate the statistical errors on the number of entries in the bins? Having non-integer bincontents RooFit tends to round the bincontents to integer values. Although sometimes one wants to normalize his/her TH1 to some floating point number.

So (perhaps it is only due to my misunderstanding but) is it possible to use RoofFit with non-integer bin contents too (and so force RooFit to no to calculate the errors but use the original ones)?
Or once I say “DataError(RooAbsValue::SumW2)” RooFit automatically won’t round the non-integer bin contents to integer ones?

Thanks for helping,
Balint