This is taking a long time to run because of 1) numerical integration and 2) you forgot to add the
ProjWData(*dataxy) argument to your
ProjWData is trivial, but the numerical integration is a bit more specific. Since your Gaussian is conditional on sigma which depends on an observable from the data via some RooFormulaVar, RooFit will do a numeric integration for each event to normalize the Gaussian.
The problem with
RooGaussian in your application is that it doesn’t normalize itself to save computation time. But if the normalization factor is different for every event because it’s a conditional fit, this optimization is not meaningful anymore. What I would do is to implement a little self-normalized Gaussian class for this fit to avoid integrals altogether.
I implemented this in a modified version of your script, also adding the missing
ProjWData(*dataxy) in the plotting:
unbinned_2D_fit_Kpipi0_RS_pi0M_conv_new_histo_v2.C (6.2 KB)
I hope this helps! If you have any further questions, please let me know.