Skip to content

[RF] Crash when RooSimultaneous does not contain a pdf for each value of the index category #10473

@elusian

Description

@elusian
  • Checked for duplicates

Describe the bug

I have a dataset with a category, and a RooSimultaneous pdf. The sim pdf does not contain a pdf for each value of the category, because some values are to be ignored in that stage of the fit.
In ROOT 6.26 this segfaults, either in prepareSimultaneousModelForBatchMode (when batchmode is on) or in RooAbsData::split (when batchmode is off).
The issue in both functions is that they iterate over the values of the index category, and assume that each value has a corresponding pdf inside the RooSimultaneous.

Expected behavior

No crash, the sim pdf fits the pdfs for the index it contains and ignores the rest. This used to work in ROOT 6.24 and earlier.

To Reproduce

void test_roosimcrash() {
    RooRealVar x("x", "", 0, 1);
    RooRealVar rnd("rnd", "", 0, 1);
    RooThresholdCategory catThr("cat", "", rnd, "v2", 2);
    catThr.addThreshold(1./3, "v0", 0);
    catThr.addThreshold(2./3, "v1", 1);
    
    RooRealVar m("m", "", 0.5, 0, 1);
    RooGaussian g("g", "", x, m, RooFit::RooConst(0.1));
    RooUniform rndPdf("rndPdf", "", rnd);
    RooProdPdf pdf("pdf", "", RooArgSet(g, rndPdf));
    
    auto ds = pdf.generate(RooArgSet(x, rnd), RooFit::Name("ds"), RooFit::NumEvents(100));
    auto cat = dynamic_cast<RooCategory*>(ds->addColumn(catThr));
    
    RooSimultaneous sim("sim", "", *cat);
    sim.addPdf(g, "v0");
    sim.addPdf(g, "v1");
    
    sim.fitTo(*ds, RooFit::Save(true))->Print("V");
}

Setup

Centos7
Broken in 6.26 from LCG dev4
Works in 6.24.06 from LCG_101

Additional context

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions