'manually' extended likelihood fits

Hi all,

I’m trying to perform an extended likelihood fit with RooFit, in which I manually add the Poisson term to the likelihood. (Eventually I’d like to better control this term.) For only one fit component, I managed to reproduce the result obtained by the builtin Extended() mechanism. But for two components it fails. Does anybody have an idea why?

The attached code runs standalone in pyroot and demonstrates both examples.

understandExtended.py (2.77 KB)

Found it. The product of two Possonians is of course not what I want. The correct code is

w2.factory("RooGaussian::sig(mass[0,-10,10], mean[0,-5,5], width[1,-5,5])")
w2.factory("Exponential::bkg(mass, a1[0.])")
w2.factory("SUM:modelTimesYields(Nsig[1000,500,1500] * sig, Nbkg[500,250,750] * bkg)")
w2.factory("expr::N('Nsig+Nbkg', Nsig, Nbkg)")
w2.factory("RooPoisson::PoissonN(NExp[1500],  N)")
w2.factory("PROD:modelTimesYieldsTimesPoissons(modelTimesYields, PoissonN)")

Sorry for the noise.