I have a fit to the signal region using zfit and fitting with an ExtendedUnbinnedNLL
. My models are a signal and a background PDF.
How can I obtain the sWeights for background subtraction?
I had a look already at hepstats, they seem to provide many high-level tools. However, it was not clear to me how to use them.
The best way is to directly use the compute_sweights
function provided by hepstats. Assuming you have your models signal
and background
, both fit extended to data, that would read as
from hepstats.splot import compute_sweights
sweights = compute_sweights(zfit.pdf.SumPDF([signal, background]), data)
bkg_sweights = sweights[Nbkg]
sig_sweights = sweights[Nsig]