Merging two RooPlots to plot the sum total

Dear experts,

I wish to add the contents of two RooPlots together (from two categories of my simultaneous fit), in order to plot the total. I know that RooPlot used to have a merge() method for exactly this purpose, but it no longer appears in the class definition. Is there an alternative that I can use?

When you call plotOn(), you can use the OR of multiple categories and it will plot the merger of the two data categories. So:

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

works well. But I am unsure how to plot the PDF. The Slice() argument for plotOn() requires an explicit category index I think, so you can’t pass it the OR of several categories.


Hi Donal,
Our RooFit expert (@StephanH) is currently on the road. Once he is back he will reply! If you did not receive an answer within 10 days please ping him here!

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

Hi Donal,

I’m not aware of a merge() method. I had a quick look, and it’s indeed not there. Can you tell me a ROOT version in which this should have existed? I checked 5.20 and 6.10, but they both didn’t have it. Could it be something else that was supporting a merge?

One way to get what you want is to create histograms from each category:

  1. Set the category to state A.
  2. Create a histogram
  3. Set to state B, create second histogram.
  4. Add them.

To be able to add the histograms, they need to have the same bins. I assume that the binning will automatically follow whatever the default binning of the observable is, for which you request the histogram. As you see in the documentation, you can also request a custom binning.