Skip to content

[RF] Cannot generate nested RooSimultaneous from prototype category data #12020

@elusian

Description

@elusian
  • Checked for duplicates

Describe the bug

RooSimultaneous has a feature where if the internal pdfs are themselves RooSimulteneous, the pdf is flattened in a single level RooSimulteneous with a RooSuperCategory as index.
When generating such a pdf from prototype data, the prototype needs to contain all the subcategories of the super-category, and it does so by checking the super-category servers.
However, recently RooSuperCategory was changed to contain a RooMultiCategory internally, and the only reported direct server is the internal multi-category. This leads to a wrong generation (the prototype data is ignored, the gen context refers to the current labels)

Expected behavior

Proto data works even with nested RooSimultaneous

To Reproduce

import ROOT

x = ROOT.RooRealVar('x', '', 0, 1)

c1 = ROOT.RooCategory('c1', '', {'c11': 0})
c2 = ROOT.RooCategory('c2', '', {'c21': 0})

u = ROOT.RooUniform('u', '', x)
s1 = ROOT.RooSimultaneous('s1', '', {'c11': u}, c1)
s2 = ROOT.RooSimultaneous('s2', '', {'c21': s1}, c2)

proto = ROOT.RooDataSet('proto', '', {c1, c2})
for i in range(100):
    proto.add({c1, c2})

proto.table(c1).Print("V")
proto.table(c2).Print("V")

ROOT.RooMsgService.instance().addStream(ROOT.RooFit.INFO)

# correct
context = s1.genContext(ROOT.RooArgSet(x), proto, ROOT.nullptr, True)
print(context.ClassName())
context.Print()

# not a RooSimGenContext
context = s2.genContext(ROOT.RooArgSet(x), proto, ROOT.nullptr, True)
print(context.ClassName())
context.Print()

# internal super-cat
print(s2.indexCat().GetName(), s2.indexCat().ClassName())

# the server is the internal multi-cat
print([cat.GetName() for cat in s2.indexCat().servers()])

Setup

Head of ROOT 6.26 from LCG dev4

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions