# How to make use (function A) - (function B) ? (one RooAbsReal *A minus another RooAbsReal *B)?

Hi all,
I have a question about the RooAbsReal .
I use the un-binned maximum likelihood fit, and background contributes to the likelihood values is subtracted
with the likelihood value of background events.
Then I use the RooFormulaVar, and fit. But the fit doesn’t go on. The result is just the primary value.
And then I found the return of RooFormulaVar is a varible, not a funtion.
So how can I make two functions minus in Roofit?
How can I use the likelihood minus, and then fit in the Roofit?

``````    RooAbsReal *nll_data = sum.createNLL(data);
RooAbsReal *nll_bg = sum.createNLL(bg);
RooFormulaVar nll_minus("nll_bg_minus","","nll_data-nll_bg",RooArgSet(*nll_data,*nll_bg));
RooMinimizer min(nll_minus);
min.fit("l");    ``````

HI,

What you are doing is correct mathematically (i.e. subtracting the log-likelihood), but I am not sure this is correct from the statistical point of view. For subtracting the background, it is better to to fit with a model describing the signal and the background as two separated component on a data set which contains both.
Have you instead removed events from the data ?

Best Regards

Lorenzo

Hi,
I didn’t remove the events. Inside, data is all my events selected(including the signal parts and background), and bg is the background events, sum is the PDF constructed by the signal MC shape.
the use PDF to construct the log-likelihood function, and subtract the log-likelihood of background from data.

I know it is better to to fit with a model describing the signal and the background as two separated component on a data set which contains both. However, the background events are very few, just 7 events, thus I want to subtract the log-likelihood of background.

How can I make it come true technically?

Hi,

The likelihood function is constructed from the product of the probability density function at each data point.
So if your data include both signal and background you have a probability ps(x) that the data point is signal and a probability pb(x) that the data is background. The likelihood for a data point x is then L(x) = ps(x) + pb(x).
You then build the likelihood for all the data points as the product of the single likelihood.
For fitting one then maximise the log-likelihood function, which is the sum of the log-likelihood for each data point.
So, it does not make sense to subtract log-likelihood values.

Lorenzo

Hi,

Image I know the signal events, and the PDF ps(x) for signal events, so maximise the log-likelihood function L(x) just include the signal events, maximize ∑lnL(x)(i=1 to Nsig,Nsig is the signal events), and then
use the sideband events to estimate the background. Here I subtract the log-likelihood value, just because the background events are very few. And, below, the L(x) is constructed with the signal PDF components.

∑lnL(x)(i=1 to Nsig) + ∑lnL(x)(i=1 to Nbg) - ∑lnL(x)(i=1 to Nsideband)
= ∑lnL(x)(i=1 to Ndata) - ∑lnL(x)(i=1 to Nsideband)

So how can I realize it in Roofit techcally?

What you have done in RooFit before is correct!
However it will not work because it does not make sense statistically as I have tried explaining to you. I would contact a statistical expert of your experiment.

Best Regards

Lorenzo

Yes， yes, I know the statistical mind. But I want to realize it technically.?

Best Regards