Mean function of a Gaussian depending on the range in Roofit

Dear Expert,

I tried to do a 2D fit (m and errm) using a Signal Gaussian function in which variation of the mean depends on the range of the errm.
For example: in range a to b of errm (errm1): variation of mean = poly1
in range b to c of errm (errm2): variation of mean = poly2
in range c to d of errm (errm3): variation of mean = poly1
and variation of std Dev also depends on errm but same for the whole range of errm.

Here is the code that I am using: (648.2 KB)

Please help me to add the mean function which changes depending on the range of the errm.


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!


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.

Hi @jonas,

Thanks a lot for your answer. it’s very helpful to me.
Yes, I am trying to improve my model.


Hii @jonas,

Just want to ask one thing, this is not showing the status and error matrix from MIGRAD and HISSE.
Is this because the fitting is not good?


Hi @chanchal, I made the fit less vebose by adding the PrintLevel(-3) parameter to the calls to fitTo.

But you can see when the RooFitResults are printed that the minimization and and hesse procedures finished without error (status 0):

  RooFitResult: minimized FCN value: -122725, estimated distance to minimum: 0.000357068
                covariance matrix quality: Full, accurate covariance matrix
                Status : MINIMIZE=0 HESSE=0

Hii @jonas,

ok, Thanks a lot.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.