[RooFit] Failed to create NLL for simultaneous pdfs with multiple range names

Since ROOT 6.26/00, there is a new type checking on the observables type that requires the observable to be an instance of RooAbsRealLValue when creating NLL with multiple ranges and that RooFit tries to check for range overlaps(ROOT: roofit/roofitcore/src/RooHelpers.cxx Source File).

This throws an error for simultaneous pdfs because when pdf.getObservables(data) is invoked, the observable set will contain the index cat variable which is of type RooCategory.

Reproducer:

// Define categories
RooCategory index_cat("indexCat", "indexCat");
index_cat.defineType("cat_1");
index_cat.defineType("cat_2");

// Observable 
RooRealVar x_cat_1("x_cat_1", "x_cat_1", 105, 150);
x_cat_1.setRange("sideband_lo_cat_1", 105, 120);
x_cat_1.setRange("sideband_hi_cat_1", 130, 150);
x_cat_1.setBins(55);

// Signal
RooRealVar mean_cat_1("mean_cat_1", "", 125.3, 120, 130);
RooRealVar sigma_cat_1("sigma_cat_1", "", 1.5, 0, 5);
RooGaussian pdf_sig_cat_1("pdf_sig_cat_1", "", x_cat_1, mean_cat_1, sigma_cat_1);
RooRealVar yield_sig_cat_1("yield_sig_cat_1", "", 100, 0, 200);

// Background
RooRealVar bkg_p0_cat_1("bkg_p0_cat_1", "", -1/125.6);  //, 30, 50);
RooExponential pdf_bkg_cat_1("pdf_bkg_cat_1", "", x_cat_1, bkg_p0_cat_1);
RooRealVar yield_bkg_cat_1("yield_bkg_cat_1", "", 1000, 0, 2000);

RooArgSet yields_cat_1;
yields_cat_1.add(yield_sig_cat_1);
yields_cat_1.add(yield_bkg_cat_1);
RooArgSet pdfs_cat_1;
pdfs_cat_1.add(pdf_sig_cat_1);
pdfs_cat_1.add(pdf_bkg_cat_1);

RooAddPdf pdf_cat_1("pdf_cat_1", "", pdfs_cat_1, yields_cat_1);

// Observable 
RooRealVar x_cat_2("x_cat_2", "x_cat_2", 105, 150);
x_cat_2.setRange("sideband_lo_cat_2", 105, 120);
x_cat_2.setRange("sideband_hi_cat_2", 130, 150);
x_cat_2.setBins(55);

// Signal
RooRealVar mean_cat_2("mean_cat_2", "", 125.8, 120, 130);
RooRealVar sigma_cat_2("sigma_cat_2", "", 1.3, 0, 5);
RooGaussian pdf_sig_cat_2("pdf_sig_cat_2", "", x_cat_2, mean_cat_2, sigma_cat_2);
RooRealVar yield_sig_cat_2("yield_sig_cat_2", "", 230, 0, 200);

// Background
RooRealVar bkg_p0_cat_2("bkg_p0_cat_2", "", -1/125.5);  //, 30, 50);
RooExponential pdf_bkg_cat_2("pdf_bkg_cat_2", "", x_cat_2, bkg_p0_cat_2);
RooRealVar yield_bkg_cat_2("yield_bkg_cat_2", "", 1700, 0, 2000);

RooArgSet yields_cat_2;
yields_cat_2.add(yield_sig_cat_2);
yields_cat_2.add(yield_bkg_cat_2);
RooArgSet pdfs_cat_2;
pdfs_cat_2.add(pdf_sig_cat_2);
pdfs_cat_2.add(pdf_bkg_cat_2);

RooAddPdf pdf_cat_2("pdf_cat_2", "", pdfs_cat_2, yields_cat_2);

// Create combined pdf
RooSimultaneous simPdf("simPdf", "", index_cat);
simPdf.addPdf(pdf_cat_1, "cat_1");
simPdf.addPdf(pdf_cat_2, "cat_2");

// Generate datasets
std::map<std::string, RooDataSet*> dataset_map{};
dataset_map["cat_1"] = pdf_cat_1.generate(RooArgSet(x_cat_1), 11000);
dataset_map["cat_2"] = pdf_cat_2.generate(RooArgSet(x_cat_2), 11000);
RooDataSet combData("combData", "", RooArgSet(x_cat_1, x_cat_2),
                    RooFit::Index(index_cat),
                    RooFit::Import(dataset_map));

auto nll = simPdf.createNLL(combData, RooFit::Range("range_1,range_2"), RooFit::SplitRange())

This gives:

Error in <TRint::HandleTermInput()>: std::logic_error caught: Classes that represent observables are expected to inherit from RooAbsRealLValue!

The same code does not throw an error for ROOT 6.22/xx, 6.24/06, …

I think @moneta can help you.

Hi @AlkaidCheng,

thank you very much for reporting this problem!

This needs to be fixed of course, categories need to be just ignored in the overlap check.

I have created a PR to fix this, and this fix will also end up in the 6.26 patch release that will be released in the next week or so.

Cheers and thanks again,
Jonas

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