RooFit:Why I cant display the stat box on the canvas?

Dear experts,
I want to know that why I cant show the stat box on canvas?

    model.fitTo(data);
    RooPlot *frame = x.frame();
    data.plotOn(frame,RooFit::DataError(RooAbsData::None), RooFit::DrawOption("None"));
    model.plotOn(frame);
    gStyle->SetOptStat("emr");
    gStyle->SetOptFit(1111);
    frame->Draw();
    hsum->SetStats(1);
    gaus1->SetLineColor(kRed);
    gaus1->Draw("same");
    gaus2->SetLineColor(kBlue);
    gaus2->Draw("same");
    bg->SetLineColor(kGreen);
    bg->Draw("same");
    hsum->SetLineColor(kViolet);
    hsum->Draw("same");
    c->SaveAs("RooFit.png");
}

Hello,

Thanks for the post and welcome to the ROOT Community!

I would propose to have a look to this tutorial that shows how to decorate a RooFit plot.

Don’t hesitate to come back with questions if that’s not enough to unblock you!

Cheers,
Danilo

1 Like

Thank you very much.
I read his tutorial and know that seems I have to use .statOn and .paramOn to do something like SetOptStat and SetOptFit can do.
But It seems that in RooFit I can’t use the code like SetOptFit(1111) to display the stat like chisquare/ndf and so on (ps:the .statOn can induct the parameter like “What(“nemr”)”,but .paramOn cant induct “What(1111)” .
So Do I have to calculate the Statistics by myself and put them on the canvas in text?

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