Different behaviour of multi-range fit in RooAddPdf and RooProdPdf
Check duplicate issues.
- [ ] Checked for duplicates
Description
When I use RooFit to do multi-range fit, different behaviour in RooAddPdf and RooProdPdf (with the same pdf) is got. When make workspace, people usually add some constrain pdfs to RooAddPdf to form RooProdPdf. However, the fit result is different, even if I just add the RooAddPdf into the RooProdPdf without changing the pdf form.
This different behaviour exists in ROOT v6.28/00, and still exists in ROOT v6.32/02. However, in ROOT v6.26/08, the fit results of RooAddPdf and RooProdPdf are the same, which is expected.
I make a reproducer script, in which RooAddpdf and RooProdPdf have the same pdf.
In ROOT v6.26/08, RooAddpdf and RooProdPdf fit give the same Nbkg, which is expected.
In ROOT v6.32/02, it gives different Nbkg.
Reproducer
#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 RooFitMacroA()
{
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 unzip and run as "root RooFitMacroA.cpp"
ROOT version
on lxplus ROOT v6.26.04-x86_64-centos7-gcc11-opt - no observed (same result) ROOT v6.26.08-x86_64-centos7-gcc11-opt - no observed (same result) ROOT v6.28.00-x86_64-centos7-gcc11-opt - observed (different result) ROOT v6.32.02-x86_64-el9-gcc13-opt - observed (different result)
Installation method
on lxplus, 'setupATLAS', lsetup "root ..."
Operating system
Linux centos7 and EL9
Additional context
No response
Hello,
To explain the context, in workspace we usually use RooProdPdf to attach systematics constraint pdf to the S+B RooAddPdf. So the different behaviors between RooAddPdf and RooProdPdf will cause issue when running blind fit with signal region vetoed. It would be good to have RooProdPdf return to 6.26 behavior.
Best,
Hongtao
Hello!
Just to provide more details about this topic. If I change the
Range("LEFT,RIGHT")
in "fitTo" to
Range("BLIND")
It will give something confusing
And if I add a signal to it
Please remind me if I make any mistake.
Best regards, Yanqi
Hello @guitargeek ,
Is there any news on a potential fix for this issue? It is affecting analyses that want to do blinded fits.
Cheers, Alkaid