RooSimPdfBuilder bug in ROOT 6.22.00

Dear experts,

it seems that theRooSimPdfBuilder is bugged in ROOT 6.22.00.

When trying to build a simultaneous pdf, each component pdf is build with the first defined state of a given RooCategory.
This is demonstrated in the python script:

import ROOT as R

x = R.RooRealVar('x', 'x', -10, 10)
mu = R.RooRealVar('mu', 'mu', 0)
sigma = R.RooRealVar('sigma', 'sigma', 1)

cat = R.RooCategory('cat', 'cat')
cat.defineType('one', 1)
cat.defineType('two', 2)

gaus = R.RooGaussian('gaus', 'gaus', x, mu, sigma)

builder = R.RooSimPdfBuilder(R.RooArgSet(gaus))
config = builder.createProtoBuildConfig()
config.setStringValue('physModels', 'gaus')
config.setStringValue('splitCats', 'cat')
config.setStringValue('gaus', 'cat : sigma')

sim_gaus = builder.buildPdf(config, R.RooArgSet(cat))

sim_gaus.printComponentTree()

The expected output is what e.g. ROOT 6.18.04 provides:

...
[#1] INFO:ObjectHandling -- RooSimPdfBuilder::buildPdf: Customizing physics model gaus for mode {one}
[#1] INFO:ObjectHandling -- RooSimPdfBuilder::buildPdf: Customizing physics model gaus for mode {two}
RooSimultaneous::simPdf[ indexCat=fitCat {one}=gaus_{one} {two}=gaus_{two} ] = 1
  RooSuperCategory::fitCat[ input=(cat) ] = {two}(idx = 1)

  RooGaussian::gaus_{one}[ x=x mean=mu sigma=sigma_one ] = 1
  RooGaussian::gaus_{two}[ x=x mean=mu sigma=sigma_two ] = 1
...

This is what I get with the newer version:

...
[#1] INFO:ObjectHandling -- RooSimPdfBuilder::buildPdf: Customizing physics model gaus for mode {one}
[#1] INFO:ObjectHandling -- RooSimPdfBuilder::buildPdf: Customizing physics model gaus for mode {two}
[#0] ERROR:InputArguments -- RooArgSet::checkForDup: ERROR argument with name gaus_{one} is already in this set
RooSimultaneous::simPdf[ indexCat=fitCat {one}=gaus_{one} {two}=gaus_{one} ] = 1
  RooSuperCategory::fitCat[ MultiCatProxy=fitCat_internalMultiCat ] = {one}(idx = 0)

    RooMultiCategory::fitCat_internalMultiCat[ input=(cat) ] = {one}(idx = 0)

  RooGaussian::gaus_{one}[ x=x mean=mu sigma=sigma_one ] = 1
  RooGaussian::gaus_{one}[ x=x mean=mu sigma=sigma_one ] = 1
...

As you can see the two component Gaussians are the same and there is an Error concerning a duplicate.

Thanks for your help!

Maybe @StephanH can take a look, and maybe confirm the bug, and then open a Jira issue if needed

Hello,

I’m looking into it. Could well be a bug.

It is, thanks for reporting. A fix is on the way:
https://sft.its.cern.ch/jira/browse/ROOT-10913

Hello,

it should be working since yesterday in the nightly builds of root:

Thank you for looking into this and fixing it on such short notice.
It is much appreciated!