Fit on two (or more) DataHist simultaneously

Hello. Here is a question about fitting on multiple DataHist simultaneously.
For instance, if I have two pdf (“sig” and “bkg”), and I use these two pdf to fit on a DataHist:

RooAddPdf pdf_tot(“pdf_tot”,“pdf_tot”,RooArgList(pdf_sig,pdf_bkg), RooArgList(Nsig,Nbkg));
RooFitResult* result = pdf_tot.fitTo(datahist);

where Nsig and Nbkg are the fitted yields of the two categories, and datahist is the RooDataHist to be fitted.

If I have two DataHists (labelled by “A” and “B”) to be fitted, then I need to prepare pdf for them separated:

RooAddPdf pdf_tot_A(“pdf_tot_A”,“pdf_tot_A”,RooArgList(pdf_sig_A,pdf_bkg_A), RooArgList(Nsig_A,Nbkg_A));
RooAddPdf pdf_tot_B(“pdf_tot_B”,“pdf_tot_B”,RooArgList(pdf_sig_B,pdf_bkg_B), RooArgList(Nsig_B,Nbkg_B));

RooFitResult* result_A = pdf_tot.fitTo(datahist_A);
RooFitResult* result_B = pdf_tot.fitTo(datahist_B);

In this case, there are actually two independent fits on datahist_A and datahist_B.

I am wondering if I can make these two fits into a single fit, while constraining Nsig_A = Nsig_B and Nbkg_A = Nbkg_B?
Just like performing two fits on two Datahists simultaneously? So there will be only one sets of number of yields.

Making a two-dimensional fit is one way, but in my case, the statistics of the histogram is not enough, so I prefer fitting on 1D fit.

Thank you.

Hi @ytlai,
and welcome to the ROOT forum.
This is a question for @moneta, let’s ping him :smile:



You should be able to to a combined fir using the RooSimultaneous pdf class. See as example the tutorial:


1 Like

@moneta Thank you. Yes, RooSimultaneous is the function that I am looking for.

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