Plotting two categories of simultaneous fit in a single plot

Dear Experts,

I am trying to plot two categories of simultaneous fit in a single plot. From Merging two RooPlots to plot the sum total,

data.plotOn(frame,RooFit.Cut("sample==sample::A || sample==sample::B"))

should work. But, I am getting an error as “Formula “sample==sample::A || sample==sample::B” is invalid !”
I am using Pyroofit with the root version of 6.24.

I also want to combine the simultaneous fit PDFs, but I don’t see any solution for this issue. Similar questions were asked earlier(RooSimultaneous plot sum of categories / labels, Merging two RooPlots to plot the sum total), but there is no clear answer. An example is desirable.


Dear @CS_p ,

It might be that the formula needs to be slightly adjusted (e.g. I don’t know what the meaning of sample::A should be in that context. Probably @jonas can help here.


Hi @jonas,

I would appreciate your comments on this issue. Here are more details on this,

I have two categories “mumu” and “ee” and the corresponding PDFs are “model_mumu” and “model_ee”. I perform 2-dimensional simultaneous fit on data sample names “combData” as

sample = ROOT.RooCategory("sample", "sample")

combData = ROOT.RooDataSet("combData","combined data",ROOT.RooArgSet(Mbc,deltaE),ROOT.RooFit.Index(sample),ROOT.RooFit.Import("mumu",roo_dataA1),ROOT.RooFit.Import("ee",roo_dataA3))

simPdf = ROOT.RooSimultaneous("simPdf", "simultaneous pdf", sample)

While plotting, I want to show combined data sample, with separate PDFs as well as combined PDF. The combined data sample can be plotted using,

 combData.plotOn(yframe,ROOT.RooFit.Cut("sample==sample::mumu || sample==sample::ee"))

The separate PDF as well as PDF components can be plotted using,


But, what I don’t understand is how to plot “mumu+ee” PDF as well as mumu+ee component PDFs. I tried something like,

simPdf.plotOn(yframe,ROOT.RooFit.Slice(sample,"mumu, ee"),ROOT.RooFit.ProjWData(sample,combData))

but it doesn’t help.


Dear @CS_p,

you question will be addressed by an updated version of the RooSimultaneous tutorial:

I hope this will help! Once the PR is merged, the updated tutorial will also appear on the website soon:


Dear @jonas,

Thank you very much for your response!

I solved the problem by removing the “ROOT.RooFit.Slice(sample,“xx”)” part. Below is how I am plotting now;


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