Use of RooSimultaneous pdf with "MustBeExtended" and "CanNotBeExtended" pdfs

Hello,
I would like to build a model of this type:

// Model : two categories :
// category A : L = P(n1 | mu x s1 x f1+ alpha x b1) x P(n2 | mu x s1 * (1-f1) + b1) --> obviously cannot be extended (this is the extended term…)
// category B : pdf = mu * s2 * Gaus(myy,mH,smyy) + b2 * Exp(-0.8 x (myy-100)/60) --> must be extended
// Floating parameters : mu, a0, b1, b2
// Observables : n1, n2, myy (x nEvents), cat

where P is a Poisson. I tried to fit this to a background-only Asimov dataset (mu = 0). The result depends on the “initial state” of the category. It is wrong if the initial state is A, and correct if it is B (although many error messages are printed, saying that A does not support extended maximum likelihood, to which I agree of course).
Maybe this behavior is expected (although not nice), as I see in the “extendMode()” implementation of RooSimultaneous the comment “/// WVE NEEDS FIX”. In fact, in this method, I do not see where one iterates of the various pdfs, as _indexCat.label() never changes… In my case, I think one should find : allCanExtend = false, anyMustExtend = true. But as it is, if the initial label is A, one finds allCanExtend = false, anyMustExtend = false, and I guess B is not extended, and the results are wrong. If the initial state is B, one finds allCanExtend = true, anyMustExtend = true, which is still not true, but fine for the fit as B will be extended (and A won’t as it can’t, but this will trigger (harmeless ?) error messages).

Am I right ? If yes, could the “extendMode()” implementation of RooSimultaneous be fixed ?
I attached a macro for illustration. I did:

root [0] .L testWSsimul.C+
root [1] go()

The 2 first combined fits are identical, and return wrong results. The last one, where the initial state of the category is set to the one using a “MustBeExtended” pdf returns results that seem more plausible.

Best,

Jean-BaptistetestWSsimul.C (11.1 KB)

perhaps @moneta could help you here? (thank you @moneta in advance)

Hi,
Thank you for reporting this. It seems to be a bug and probably in the code you have indicated.
It is clear in the second case (the correct one), you get this message that is missing in the first combined fit:

[#1] INFO:Minization -- p.d.f. provides expected number of events, including extended term in likelihood.

I will investigate if it can be easily fixed. I have opened for the time being a github issue

Cheers

Lorenzo

The problem is that if the category saved in the SimPdf is not extended, the simultaneous pdf is due to the bug (issue #6894) tagged as non extended and the fit will not contain the extended term in the likelihood for the second category.
A simple workaround until the bug is fixed, is to force the fit to be extended, by adding the fit option
RooFit::Extended(true)

I have checked in your example and by doing this the results of the combined fit are correct whatever the initial state is

Lorenzo

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