with categories, it maybe doesn’t make sense to project. You can do it technically, I guess, but how do you want to combine the categories? Do you just want to sum them? This only works if it’s the same observable in each category. If it’s the same observable, though, why are they in different categories?
Note also that signal and background should in general not be different categories. They should be components of a sum, i.e.
RooAddPdf("name", "title", RooArgSet(sig, bkg), RooArgSet(f_sig, f_bkg)) or similar. You can have a sum like this in each category, though.
rf501 again. They have a signal+background model (
gx + px), but both components are present in the category
Let’s assume, now, that signal and background are in the right place everywhere, and that the different category states all share the same observable, so we can just sum them. You have two options:
1. Sum the plotted curves
You can project out each component of the simultaneous, and add it to an existing curve. That would roughly look like:
// We are projecting out the `physics` component, and give its curve a name so we can reference it later:
pdf.plotOn(frame, Slice(sample, "physics"), ProjWData(sample, combData), RooFit::Name("cat1Curve1"));
// Now get the second component, and add it to the existing curve:
pdf.plotOn(frame, Slice(sample, "control"), ProjWData(sample, combData), RooFit::AddTo("cat1Curve1"), RooFit::Name("cat1Curve2"));
If you don’t want to see each intermediate curve, make it
The reason you need the
ProjWData, the data-weighted projection, is that RooFit has to read off from the data how many events should be in each category. Otherwise, it wouldn’t be clear how “high” each component has to be.
2. Create a PDF that sums the components for you
Use e.g. a RooAddPdf for each category you want to sum over (again, this requires that they share the same observable).
RooAddPdf(..., ..., RooArgSet(modelCat1, modelCat2, modelCat3, modelCat4, ...),
RooArgSet(n_cat1, n_cat2, ...));
This PDF will share all the parameters etc. with the Simultaneous PDF that you use for fitting, so if you fit the simultaneous to data, this one will automagically follow each change of parameters. What you need, though, is to find out the proper scale factors
n_cat1, ..., . Those you get from the data directly:
RooRealVar n_cat1("n_cat1", "Number of events in first category", data.sumEntries("sample==sample::cat1"));
RooRealVar n_cat2("n_cat2", "Number of events in second category", data.sumEntries("sample==sample::cat2"));
sample with the proper name of your category object.
You have to set up those coefficients only once, and they can stay fixed after that, because the amount of data events in each category doesn’t change.