# Normalization in Conditional, Product PDF Fit

Hi,
In RooFit, I’ve created a composite, conditional PDF, and I’m having some trouble extracting some of the parameters after I use it to do a fit. The PDF is a RooProdPdf of 1.) a RooAddPdf of 3 RooGaussians and 2.) a conditional RooGaussian. I would like my fit to return the coefficients of the RooAddPdf, but the fit seems insensitive to these parameters. In particular, HESSE to fails with the following output:

``````MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
MINUIT WARNING IN HESSE
============== Second derivative enters zero, param 2
MINUIT WARNING IN HESSE
============== Second derivative zero for parameter2
MNHESS FAILS AND WILL RETURN DIAGONAL MATRIX. ``````

The larger story is that I’m trying to use RooFit to take an input PDF, which is a function of energy, and smear it with an energy-resolution that is also a function of energy. So for example if my input PDF is a sum of 3 delta functions at different energies, E1, E2, E3, I would like my procedure to return a sum of 3 gaussians centered on E1, E2, E3, with widths sig(E=E1), sig(E=E2), sig(E=E3), where sig(E) is my energy-dependant resolution.
To achieve this in my script, I set up a RooGaussian over E with mean EP and width sig(EP), where EP is a dummy variable, since I need a Gaussian that is normalized at any given energy, E. This is the conditional PDF that then goes into the product with my input PDF of 3 narrow gaussians. Then I make by hand a RooDataSet with columns for E and EP, where EP takes one of 3 values, as in a sum of 3 delta functions, and E is sampled from a gaussian about one of those 3 values, each gaussian having a width according to my function sig(E).

When I plot the resulting fitted, “smeared” PDF, it matches the data set, but the values returned for the fractional normalization of each gaussian seem arbitrary and are clearly not the fractions shown in the plot or in the data; see the lower left plot in the attached image. I’ve checked that the fractional components are indeed parameters of the smear PDF, so it’s not clear to me why the fit should be insensitive to them.
I’ve attached a running version of my code, and could use any comments on the problem or my procedure in general.

– Simon

resSmearTest6_3_A_post.C (4.65 KB)

Hi Simon,

I had a quick look at your macro and I spotted one problem which may cause your problems

// F( EP ) x G ( E | EP )
RooProdPdf smear(“smear”,“smear”, RooArgSet(gm, model) );

The issue is that that line of code doesn’t do what the comment suggests. To
make a product F(X|Y)*G(Y) one should write

RooProdPdf prod(“prod”,“prod”,G,Conditional(F,x)) ;

(Note that you write the non-conditional observable in the conditional argument.)

Wouter

Hi, Wouter,
Thanks for the reply. I believe you have put your finger on the problem. I changed the code from

``````// F( EP ) x G ( E | EP )
RooProdPdf smear("smear","smear", RooArgSet(gm, model) );``````

to

``RooProdPdf smear("smear","smear",model,Conditional(gm, E));``

This by itself did not make the signal fractions get fit, but it did fix the 2-D plot of the smeared PDF (in the lower right of the attached canvas) to showing 2-D Gaussians with the right widths.
I did recall, though, that a RooProdPdf with a conditional flag gets promoted to a full PDF, so I also changed the fit command to reflect this:

``````//  smear.fitTo(*fakeDataEEP, ConditionalObservables(RooArgList(EP)), NumCPU(2));  //Does not work
smear.fitTo(*fakeDataEEP, NumCPU(2));``````

Now the signal fractions are returned correctly, as indicated in the new attached plot.
resSmearTest6_3_A_post2.1.C (5.15 KB)