About normalization of RooAbsPdf in multi-range fit

Dear experts,

When I use RooFit to do blind fit, I constructed a RooAddPdf called ‘modelSB’ (RIGHT in following plots) in the form of [ nbkg * bkg_pdf + nsig * sig_pdf ] . And I add some constrains to form a RooProdPdf called ‘model’ (LEFT in following plots) using the former RooAddPdf. However, when I try to do blind fit, the nbkg is not the expected number in full range.

In ROOT v6.30, when I use range (0,40) and (60,100) to fit 5000 entries, I get nbkg ~ 5000 for RooAddPdf and nbkg ~ 4000 for RooProdPdf. My expectation is they both give ~ 5000 nbkg.

While in ROOT v6.24, both results are ~ 5000 nbkg.

What should I do if I want to get expected entry number in full range in new ROOT version, when do fit with RooProdPdf?

Thanks a lot!

Also I see a similar behaviour in roofit tutorial rf204b.

ROOT v6.24

ROOT v6.30

The middle plot N has changed.

Those code (XMLAnaWorkspaceBuilder) is written when ROOT is in old version, and this update (if properly) in ROOT change the behaviour in it.

Hi Yanqi,

Welcome to the ROOT Community!

This requires some knowledge of @jonas . In the meantime could you perhaps share a minimal reproducer?

Best,
Danilo

Hi Danilo,

Thanks for your reply.
This is a reproducer in C++ code. I have run it on lxplus. The system says that I can’t attach link to posts because I am a new user, so I just attach the code after the message.

Here the pdf construction lines are as follows, for which I expect they give the same fit result:
RooAddPdf pdfadd(“pdfadd”, “NBkg*background”, {model}, {Nbkg});
RooProdPdf pdfprod(“pdfprod”, “pdfprod”, RooArgSet(pdfadd));

In ROOT v6.24\06, the fit results are the same.

And in ROOT v6.30\02, it gives different Nbkg result.

Best regards,
Yanqi

#include "RooRealVar.h"
#include "RooExponential.h"
#include "RooGaussian.h"
#include "RooAddPdf.h"
#include "RooProdPdf.h"
#include "RooDataSet.h"
#include "RooPlot.h"
#include "RooExtendPdf.h"
#include "RooFitResult.h"
#include "TCanvas.h"

int RooFitMacro()
{

    using namespace RooFit;
    
    RooRealVar x("x", "x", 0, 100);
    RooRealVar alpha("alpha", "alpha", -0.04, -0.1, -0.0);
    RooExponential model("model", "Exponential model", x, alpha);
    
    // Define side band regions and full range

    x.setRange("LEFT", 0, 20);
    x.setRange("RIGHT", 60, 100);
    x.setRange("BLIND",20,60);
    x.setRange("FULL", 0, 100);
    std::unique_ptr<RooDataSet> data{model.generate(x, 10000)};
    
    RooRealVar Nsig("Nsig", "Number of signal events", 1000, 0, 2000);
    RooRealVar Nbkg("Nbkg", "Number of background events", 10000, 0, 20000);
    
    RooRealVar mean("mean", "Mean of signal model", 40.);
    RooRealVar width("width", "Width of signal model", 5.);
    RooGaussian sig("sig", "Signal model", x, mean, width);
    
    // RooAddPdf pdfadd("pdfadd", "NSig*signal + NBkg*background", {sig, model}, {Nsig, Nbkg});
    RooAddPdf pdfadd("pdfadd", "NBkg*background", {model}, {Nbkg});
    RooProdPdf pdfprod("pdfprod", "pdfprod", RooArgSet(pdfadd));
    
    pdfadd.Print();
    pdfprod.Print();

    TCanvas* c = new TCanvas("c", "c", 1400, 1000);
    c->Divide(2,2);

    c->cd(1);
    RooPlot* frame1 = x.frame();
    pdfadd.plotOn(frame1);
    pdfadd.paramOn(frame1,Label("RooAddPdf"));
    frame1->Draw();

    c->cd(2);
    RooPlot* frame2 = x.frame();
    pdfprod.plotOn(frame2);
    pdfprod.paramOn(frame2,Label("RooProdPdf"));
    frame2->Draw();

    c->cd(3);
    RooPlot* frame3 = x.frame();
    RooFitResult* status3 = pdfadd.fitTo(*data,Range("LEFT,RIGHT"),Save());
    status3->Print();
    data->plotOn(frame3);
    pdfadd.plotOn(frame3);
    pdfadd.paramOn(frame3,Label("RooAddPdf_fitted"));
    frame3->Draw();

    c->cd(4);
    RooPlot* frame4 = x.frame();
    RooFitResult* status4 = pdfprod.fitTo(*data,Range("LEFT,RIGHT"),Save());
    status4->Print();
    data->plotOn(frame4);
    pdfprod.plotOn(frame4);
    pdfprod.paramOn(frame4,Label("RooProdPdf_fitted"));
    frame4->Draw();

    c->Draw();
    c->SaveAs("RooFitMacro.png");

    pdfadd.Print();
    status3->Print();
    pdfprod.Print();
    status4->Print();

    return 0;
}

Just to give a more detailed information about the change. I tested different ROOT versions. And the change is not found in v6_26/08 and exists from v6_28/00.

I just moved this topic to Git issue, which may be more proper to place the topic.