This is a clear case of categories and a simultaneous PDF!
- Create categories for the different cases. Make one category for the switch between model A and B, and a second one for the switch between Fbkg[123].
See a tutorial about categories here. - Add the category labels to the dataset. rf405 shows how to convert real-valued variables to category numbers. Use this to create the category states from y and from m.
- Create a RooSuperCategory that gives each state of the combination {yState, mState} a unique label. rf406 shows how to do this.
- Create a RooSimultaneous with the 6 different states. rf501 shows how to do this. The category that tells the simultaneous what to do is the supercategory that does the
yState * mState
combination.
For each of the 6 states, explicitly write down the model you want, i.e., use modelA with Fbkg1 or modelB with Fbkg2, … . RooFit will know how to properly integrate each one of them, and then they will be combined by the simultaneous PDF.
This would roughly look like:
RooSimultaneous fullModel(..., ..., theSuperCat);
yCat.setLabel("A");
mCat.setIndex(1);
fullModel.addPdf(theA1Pdf, theSuperCat.getLabel());
yCat.setLabel("B");
mCat.setIndex(1);
fullModel.addPdf(theB1Pdf, theSuperCat.getLabel());
yCat.setLabel("A");
mCat.setIndex(2);
fullModel.addPdf(theA2Pdf, theSuperCat.getLabel());