Several integrals over one p.d.f

Dear ROOT experts,

I’m experiencing difficulties in using the createIntegral() function to integrate a custom p.d.f.

The p.d.f. is composed of a background and several peaks. The components are linked by scale factors a, b, c, … and the fit determines which part contributes how much to the data. This works fine.

In the end, I want to integrate the whole function and then set the scale factors consecutively to zero to isolate a single peak or the background and integrate that to determine the ratio of events in each peak.

And here the problems start: Obviously createIntegral() does not work as I think it does. I put together a minimal example with a RooGenericPdf and a toy formula that has no physical meaning. In this example, the integral is always the same although I change a and b between the calls to createIntegral().

What am I doing wrong?

Thanks in advance for your help,

problemDemo.C (1.04 KB)


Your macro is not correct (a part from several compilation errors).
In RooFit the three integral functions share the same variables (RooRealVar objects), so when you evaluate them they all have the same values.
Attached is a version that works.
If in your complicated case, after these changes, still it does not work, it could be a problem with caching of the integrals. In that case, please submit a working example so I can investigate it

Best Regards

LorenzoproblemDemo.C (1.05 KB)