Hi @chanchal!

Thanks for providing all the necessary code and data together with your question.

I don’t think what you attempted with the various `errm1`

, `errm2, and `

errm3` variables is the right approach. It’s better to create a RooFormulaVar for the mean in which you discriminate between your resolution bins.

```
// mean: Create function f(y) = a0 + a1*y (errm range: 0,0.0041)
RooRealVar p00("p00", "p00", 1.34010e-01, -1, 1); // 1.34010e-01
RooRealVar p01("p01", "p01", -2.72535e-01, -1, 1); // -2.72535e-01
mus.emplace_back("mu0", "mean0", errm, RooArgSet(p00, p01));
// mean: Create function f(y) = a0 + a1*y + a2*y^2
// (errm range: 0.0041,0.0055)
RooRealVar p10("p10", "p10", 9.22697e-02, -0.2, 0.2); // 9.22697e-02
RooRealVar p11("p11", "p11", 1.68039e+01, -1, 1); // 1.68039e+01
RooRealVar p12("p12", "p12", -1.68719e+03, -0.1, 0.1); // -1.68719e+03
mus.emplace_back("mu1", "mean1", errm, RooArgSet(p10, p11, p12));
// mean: Create function f(y) = a0 + a1*y + a2*y^2
// (errm range: 0.0055,0.015)
RooRealVar p20("p20", "p20", 1.31621e-01, -1, 1); // 1.31621e-01
RooRealVar p21("p21", "p21", 3.81109e-01, -1, 1); // 3.81109e-01
mus.emplace_back("mu2", "mean2", errm, RooArgSet(p20, p21));
RooFormulaVar mu("mu",
"pi0_errm < 0.0041 ? mu0 : (pi0_errm < 0.0055 ? mu1 : mu2)",
RooArgList(errm, mus[0], mus[1], mus[2]));
```

Then, I would still use the RooFit range feature to do the fit in your three independent resolution ranges, such that the fit is not overcomplicated by assuming correlations between parameters where there aren’t any.

I have attached a modified version of your script where this is implemented:

unbinned_Kpipi0_RS_2D_fit_updated_v2.C (9.3 KB)

The fit is not really good, I suppose the single Gaussians are not good enough as a model. But at least you have now a starting point from which you can improve your model.

By the way, I have reused the same self-normalized Gaussian class I already wrote to answer your previous question about avoiding numerical integrals.

I hope this helps you with your work, please let me know if something is unclear or you have further questions!

Cheers,

Jonas

PS: if your model for the individual resolution regions becomes more complicated, you might need to do the the combination with the RooFormulaVar at the level of the final models, and not for the `mu`

parameter.