Bug in RooSimultaneous?


While using RooSimultaneous PDFs I have the problem that the extended terms are not computed correctly: the terms are computed based only on the expected number of events in one category state, not the total number in all categories.

I traced the problem to the following feature/bug :

  1. in RooNLLVar, the extended term is calculated as follows:


  1. This in turn internally calls RooAbsPdf::expectedEvents(_dataClone->get()), which in RooSimultaneous is implemented as follows:
  • if the index category of the RooSimultaneous is contained in nset = _dataClone->get(), the code returns the number of events for all category states
  • if not, it returns only the number of events in the current state.

This is the correct behavior if the index category of the RooSimultaneous is a simple category (RooCategory). However for composite categories this breaks down. In my case, the index category is a RooSuperCategory with a single RooCategory input (this is what is built by RooSimPdfBuilder). This supercategory is effectively the same as the input RooCategory, but it is not recognized as such in the test above. So roofit thinks the category is not in the nset --even though it is-- and returns the wrong number of events.

From the user-side I really don’t see a way around this: a RooDataSet can use only simple categories, so there seems no way to pass the RooSuperCategory in _dataClone->get(). I could probably rebuild the RooSimultaneous to use the simple category instead, but this will not work when more than 1 categories are needed (which will happen in the project I am working on).

I realize this is not a trivial problem to fix (or maybe even to understand), but I would really appreciate some guidance from developers on how to deal with this issue…

Thanks in advance,

  • Nicolas