Skip to content

[RF] Offset() option is ignored by the fitTo() function #20083

@dpiparo

Description

@dpiparo

Check duplicate issues.

  • Checked for duplicates

Description

(from https://root-forum.cern.ch/t/cannot-use-offset-with-rooabspdf-fitto/64293)
I’m trying to update my workflow from root v6.24/02 to 6.32/16, but it seems the Offset() option is ignored by the fitTo() function. This is quite important for me as I’m running an unbinned simultaneous fit where one category has orders of magnitude more events than the other, and I keep seeing MACHINE ACCURACY LIMITS FURTHER IMPROVEMENT if I don’t use it (together with the fact that the fit fails to find sensible results). I’ve attached a minimal example where Offset() is ignored, but it’s really nothing special. I have tried with both Offset(true) and Offset(“initial“).

Reproducer

using namespace RooFit;

void test_fit2()
{
   RooRealVar x("x", "x", 0., 200., "MeV");
   RooRealVar mean("mean", "mean", 100., 50., 150., "MeV");
   RooRealVar width("width", "width", 15., 1., 50., "MeV");

   RooGaussian sig_gauss("sig_gauss", "sig_gauss", x, mean, width);

   RooRealVar b("b", "b", -0.01, -1., 0., "");

   RooExponential bkg("bkg_pwrlaw_passed", "bkg_pwrlaw_passed", x, b);

   RooRealVar f("f", "f", 0.4, 0., 1., "");
   RooAddPdf model("model", "model", sig_gauss, bkg, f);

   std::unique_ptr<RooDataSet> dataset(model.generate(x, 1000000));

   mean.setVal(110.);
   width.setVal(20.);
   b.setVal(-0.001);
   f.setVal(0.5);

   model.fitTo(*dataset, Strategy(2), Minimizer("Minuit", "minimize"), Offset(true));

   TCanvas c("c", "c", 960, 720);

   std::unique_ptr<RooPlot> frame_passed(x.frame());
   dataset->plotOn(frame_passed.get());
   model.plotOn(frame_passed.get());
   frame_passed->Draw();

   c.SaveAs("./test2.pdf");

   return;
}

ROOT version

6.32

Installation method

all

Operating system

all

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions