Range of y axis for RooPlot always starts from 0

Dear ROOT experts,

I am a newbie to RooFit.

I tried to plot a distribution with dominant background. But the RooPlot is always starting from 0. I can barely see the detailed structure since the signal was overwhelmed without zooming in.

A mini code snippet to reproduce is

void test()
    RooRealVar x("x", "", -6, 6);
    RooRealVar x0("x0", "", 0);
    RooRealVar sigma("sigma", "", 1, 0.00001, 5);
    RooGaussian gaus("gaus", "", x, x0, sigma);
    RooRealVar a1("a1", "", 0.1);
    RooChebychev cb("cb", "", x, RooArgList(a1));
    RooRealVar nsig("nsig", "", 100);
    RooRealVar nbkg("nbkg", "", 50000);
    RooAddPdf sum("sum", "s+b", RooArgList(gaus, cb), RooArgList(nsig, nbkg));
    auto ds = sum.generate(x, 2000000);
    TCanvas* c = new TCanvas();
    auto frame = x.frame();

The platform is 1fedora 34 and ROOT version is 6.24.

Is this behavior expected? Does ROOT provide a way to automatically determine the range, like TH1::Draw? When I draw a histogram, it will automatically adjust the maximum and minimum of y axis.

Many thanks in advance!

Maybe @moneta can help

you need to use frame->SetMinimum(ymin) in this case.


So, it seems that starting from 0 is the default behavior. When I tried RooPlot->GetMinimum(), I always get 0. For a unbinned dataset, how could I find the minimum bin content in RooPlot and set the minimum as the bin content multiplied by some factor? I may be able to use createHistogram at first but is there a more direct way?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.