sPlot Roofit Error

Hello Experts and community,

I want to use a sPlot in RooFit and I get an error I can’t seem to tackle. The code is compiled but I call the sPlot in my macro I get:

[#0] ERROR:Eval -- SPlot Error: covariance matrix is singular; I can't invert it!

In this example I try to do a Gauss+Crystall Ball fit for Jpsi, and fit a functional form to the background.
So my Macro has the following form:

RooRealVar x("x", "m_{#mu#mu}",  vec_hist_signal.at(i_histogram)->GetXaxis()->GetXmin(), vec_hist_signal.at(i_histogram)->GetXaxis()->GetXmax(), "GeV");

//::: Let's fit MC first
   RooDataHist tempDataSet_MC("tempDataSet_MC", "", RooArgList(x), vec_hist_signal.at(i_histogram));

   //::: Crystall Ball and Gauss components
   RooRealVar mean("mean", "#mu", 3.1, 3.05, 3.15);
   RooRealVar sigma("sigma", "#sigma", 0.05, 0.0001, 0.5);
   RooRealVar alpha("a", "#alpha", 2, 0.5, 4);
   RooRealVar eta("e", "#eta", 10, 0, 100);
   RooCBShape tempCB_MC("tempCB_MC", "Crystal-Ball", x, mean, sigma, alpha, eta);

   RooRealVar sigma_gauss("sigma_gauss", "#sigma_{gauss}", 1, 0.05, 1);
   RooGaussian tempGauss_MC("tempGauss_MC", "Gauss", x, mean, sigma_gauss);

   RooRealVar sigma_add("sigma_add", "#sigma_{add}", 0.05, 0.0001, 0.5);
   RooRealVar alpha_add("a", "#alpha_{add}", 2, 0.5, 4);
   RooRealVar eta_add("e", "#eta_{add}", 10, 0, 100);
   RooCBShape tempCB_MC_add("tempCB_MC_add", "Crystal-Ball", x, mean, sigma_add, alpha_add, eta_add);

   RooRealVar frac_1("frac_1", "frac_1", 0.7, 0.6, 1.);

   signal_model = new RooAddPdf("tempModel_MC", "Crystal Ball + Gaussian", tempCB_MC, tempGauss_MC, frac_1);

    //::: Move on to data!
    double Estimated_Bkg_Yield = 0.5 * (vec_hist_data.at(i_histogram)->GetBinContent(1) + vec_hist_data.at(i_histogram)->GetBinContent(vec_hist_data.at(i_histogram)->GetNbinsX())) * vec_hist_data.at(i_histogram)->GetNbinsX();
    double Estimated_Sig_Yield = vec_hist_data.at(i_histogram)->Integral() - Estimated_Bkg_Yield;

    RooDataHist tempDataSet_Data("tempDataSet_Data", "", RooArgList(x), vec_hist_data.at(i_histogram));
    RooRealVar tempBkgYield("tempBkgYield", "Exponential Coefficient", Estimated_Bkg_Yield, 0, 10000000);
    RooRealVar tempSigYield("tempSigYield", "Signal Coefficient", Estimated_Sig_Yield, 0, 10000000);
    RooAbsPdf *background_pdf = nullptr;

    //::: In case we fit the background with an exponential p.d.f.
    RooRealVar t("t", "#tau", -1, -10, 0,"");
    background_pdf = new RooExponential("background_pdf", "Exponential", x, t);

    //::: The actual Fit
    RooAddPdf tempModel("tempModel", "Complete Model", RooArgList(*background_pdf, *signal_model), RooArgList(tempBkgYield, tempSigYield));

    background_pdf->fillHistogram(vec_hist_bkg.at(i_histogram), RooArgList(x), tempBkgYield.getVal()); 

    //***** sPlot************
    std::cout << "\n\n------------------------------------------\nThe dataset before creating sWeights:\n";

    // Now we use the SPlot class to add SWeights for the isolation variable to
    // our data set based on fitting the yields to the invariant mass variable
    RooStats::SPlot sData{"sData", "An SPlot", vec_roo_data_set.at(i_histogram), &tempModel, RooArgList(tempBkgYield, tempSigYield)}; //Is it Correct with &??????????// ASK EMILIEN

Thank you

Dear @dfakoudi ,

Maybe @moneta or @jonas may be able to help you.


1 Like

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