No of signal and bkg events in signal region

Dear Expert,

I tried to check the signal and background events in the signal region by using post.

  Double_t Nsig = n_sig.getVal();
    Double_t NsigError = n_sig.getPropagatedError(*fitresult);
    std::cout << "N_sig = " << Nsig << std::endl;
    std::cout << "N_sigError = " << NsigError << std::endl;

    Double_t Nbkg = n_bkg.getVal();
    Double_t NbkgError = n_bkg.getPropagatedError(*fitresult);
    std::cout << "N_bkg = " << Nbkg << std::endl;
    std::cout << "N_bkgError = " << NbkgError << std::endl;

    Double_t Ntot = Nsig + Nbkg;
    Double_t NtotError = sqrt(pow(NsigError,2) + pow(NbkgError,2));
    std::cout << "N_total = " << Ntot << std::endl;
    std::cout << "N_totalError = " << NtotError << std::endl;

    
    deltaM.setRange("signalRange",0.1445,0.1465);
    RooAbsReal* i_sig = sgn.createIntegral(deltaM, NormSet(deltaM), RooFit::Range("signalRange"));
    RooAbsReal* i_bkg = bkg.createIntegral(deltaM, NormSet(deltaM), RooFit::Range("signalRange"));

    double NsigSigWin, dNsigSigWin; std::tie(NsigSigWin, dNsigSigWin) = getIntegral(*i_sig, Nsig, NsigError);
    double NbkgSigWin, dNbkgSigWin; std::tie(NbkgSigWin, dNbkgSigWin) = getIntegral(*i_bkg, Nbkg, NbkgError);
    std::cout << Form("Nsig in signal region = %f +- %f\n", NsigSigWin, dNsigSigWin);
    std::cout << Form("Nbkg in signal region = %f +- %f\n", NbkgSigWin, dNbkgSigWin);

but its gives error below:

Here is the attached file that I am using:
fitting_script.C (6.9 KB)
input_file.root (112.9 KB)
myRooJohnsonSU.cpp (1.9 KB)
myRooJohnsonSU.h (1.1 KB)
myRooPolBG.cpp (1.8 KB)
myRooPolBG.h (929 Bytes)

Can you please help me to sort it out?

Reagrds
Chanchal

Hi @chanchal, thanks for asking!

You forgot to copy-paste and adapt the getIntegral function from the forum thread you linked into your file:

auto getIntegral = [&](RooAbsReal& integral, double norm, double normErr) {

   double val = norm * integral.getVal();
   double err = std::sqrt(
                std::pow(norm * integral.getPropagatedError(*fitresult, deltaM), 2)
                +
                std::pow(normErr * integral.getVal(), 2)
                );

   return std::make_pair(val, err);
};

Note that this method assumes that the normalization and shape parameters are not correlated, which is not the case for your fit as I saw when looking at the covariance matrix of your fit result. The alpha parameter is correlated a bit with n_bkg.

To also consider the correlation, you can create new RooFit objects that represent the yield in the signal region and evaluate them:

RooProduct n_sig_sigwin{"n_sig_sigwin", "n_sig_sigwin", {*i_sig, n_sig}};
double NsigSigWin = n_sig_sigwin.getVal();
double dNsigSigWin = n_sig_sigwin.getPropagatedError(*fitresult, deltaM);

RooProduct n_bkg_sigwin{"n_bkg_sigwin", "n_bkg_sigwin", {*i_bkg, n_bkg}};
double NbkgSigWin = n_bkg_sigwin.getVal();
double dNbkgSigWin = n_bkg_sigwin.getPropagatedError(*fitresult, deltaM);

std::cout << Form("Nsig in signal region = %f +- %f\n", NsigSigWin, dNsigSigWin);
std::cout << Form("Nbkg in signal region = %f +- %f\n", NbkgSigWin, dNbkgSigWin);

You are also making the same mistake when calculating N_total and it’s error. You are adding the uncertainties in quadrature, which is wrong because N_sig and N_bkg are correlated in the fit. Once again, you can create a new RooFit object and propagate the error:

RooAddition n_tot("N_{tot}", "n_{t}", {n_sig, n_bkg});
double Ntot = n_tot.getVal();
double NtotError = n_tot.getPropagatedError(*fitresult, deltaM);
std::cout << "N_total = " << Ntot << std::endl;
std::cout << "N_totalError = " << NtotError << std::endl;

Now, you will also see that N_totalError == sqrt(N_total) as expected.

I hope this helps!
Jonas

Thanks a lot, @jonas for this detailed explanation.
it’s working now.

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