Skip to content

[RF] Regression in ranged fits with RooSimultaneous due to new likelihood evaluation #18718

@guitargeek

Description

@guitargeek

Description

As we learned from a user report on the forum, ranged fits with RooSimultaneous are currently broken with the RooFit::EvalBackend("cpu"):
https://root-forum.cern.ch/t/problems-fitting-simultaneous-pdf-fit-in-subranges/63537

It only works with RooFit::EvalBackend("legacy").

@will-cern, I think this is also the issue that you faced some time ago, and now we have a simple reproducer so I think I can fix it soon.

Reproducer

using namespace RooFit;

const double nBkgA_nom = 9000;
const double nBkgB_nom = 10000;

RooRealVar x("x", "Observable", 100, 150);
x.setRange("fullRange", 100, 150);
x.setRange("fitRange", 100, 130);

// For SplitRange() support
x.setRange("fullRange_RunA", 100, 150);
x.setRange("fitRange_RunA", 100, 130);
x.setRange("fullRange_RunB", 100, 150);
x.setRange("fitRange_RunB", 100, 130);

RooRealVar nBkgA("nBkgA", "", nBkgA_nom, 0.8 * nBkgA_nom, 1.2 * nBkgA_nom);
RooRealVar nBkgB("nBkgB", "", nBkgB_nom, 0.8 * nBkgB_nom, 1.2 * nBkgB_nom);

RooExponential expA("expA", "", x, RooConst(-0.06));
RooAddPdf modelA("modelA", "", {expA}, {nBkgA});

RooExponential expB("expB", "", x, RooConst(-0.09));
RooAddPdf modelB("modelB", "", {expB}, {nBkgB});

RooCategory runCat("runCat", "", {{"RunA", 0}, {"RunB", 1}});

RooSimultaneous simPdf("simPdf", "", {{"RunA", &modelA}, {"RunB", &modelB}}, runCat);

std::unique_ptr<RooDataSet> combData{simPdf.generate(RooArgSet(x, runCat), Extended())};

using Res = std::unique_ptr<RooFitResult>;
Res fitResult{simPdf.fitTo(*combData, Save(), Range("fitRange"),
                           // SumCoefRange("fullRange"), // doesn't help...
                           // SplitRange(), // also doesn't help...
                           EvalBackend("cpu") // works only with the "legacy" backend
                           )};
fitResult->Print("v");

The output is:

    Floating Parameter  InitialValue    FinalValue +/-  Error     GblCorr.
  --------------------  ------------  --------------------------  --------
                 nBkgA    9.0000e+03    7.2000e+03 +/-  2.05e-02  <none>
                 nBkgB    1.0000e+04    8.0000e+03 +/-  6.79e-04  <none>

Looks like there is not even a fit happening, but the parameters are set to some constant values.

With EvalBackend("legacy"), the output is correct:

    Floating Parameter  InitialValue    FinalValue +/-  Error     GblCorr.
  --------------------  ------------  --------------------------  --------
                 nBkgA    9.0000e+03    8.9486e+03 +/-  1.01e+02  <none>
                 nBkgB    1.0000e+04    1.0103e+04 +/-  1.03e+02  <none>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions