Pre-conditioning complex fit in RooFit


This is very likely a basic question, but I have not really found any clues on how to perform this efficiently with RooFit.

I have something like 40 datasamples to fit with 4 parameters each, plus 1 parameter correlated across all samples. Right now, I have fits failing when throwing toys because I am performing one simultaneous fit with 160+1 dimensions. I am not surprised with the results at all.

What I would like to be doing is to take the full model and pre-condition parts of it by performing (partial) fits of the each of the 40 datasets one at a time. Once the pre-conditioning is done, the chances for the global fit to converge should be, well, much larger.

Is there a straightforward way to do this in RooFit?



Tentatively answering my own question, the simplest thing I could come up with is along the lines of looping over categories, repeating calls like:


	RooCategory cat("cat","cat") ;
	cat.defineType("cat0") ;
	cat.defineType("cat1") ;

	RooSimultaneous model("model", "model", cat);
	model.addPdf(model0, "cat0");
	model.addPdf(model1, "cat1");

With a simple pol1+gaus model, where the pol1 functions are uncorrelated (but the gaus ones are not) and with two categories I compared:
[ul][li]Fitting model straight up, and[/li]
[li]Running the loop above plus a final simultaneous fit.[/li][/ul]
In this very simple example I see savings of 5 to 10% in Nfcn when using the loop.

So, taking pythonic as a template, is this the Roofitic way of doing this?