Hi,
I’m trying to perform a simultaneous fit over different energy ranges; I know about the Range() and SplitRange() functions to be used with fitTo(), but I can’t seem to make them work. Here’s an example of what I’ve been trying to do.
I read data from a TChain, store it into two RooDatasets, with a different cut and merge them into a combined dataset
TChain* chain = new TChain(...);
chain->Add(...);
RooRealVar Energy("Energy", "Event Energy", 1000, 0, 2000, "keV");
RooRealVar Channel("Channel", "Channel", 1, 0, 10);
RooDataSet ds1("ds1", "ds1", RooArgSet(Energy, Channel), Import(*chain), Cut("Channel==1"));
RooDataSet ds2("ds2", "ds2", RooArgSet(Energy, Channel), Import(*chain), Cut("Channel==2"));
RooCategory cat("cat", "cat");
cat.defineType("cat1");
cat.defineType("cat2);
RooDataSet combData("combData", "Combined data", Energy, Index(cat), Import("cat1", ds1), Import("cat2", ds2));
The fit model is a simple RooGaussian (Gauss1/2 in the following lines) over a flat background (0th order RooPolynomial, Poly1/2).
RooAddPdf Model1("Model1", "Model1", RooArgList(Poly1, Gauss1), RooArgList(nBackground1, nGauss1));
RooAddPdf Model2("Model2", "Model2", RooArgList(Poly2, Gauss2), RooArgList(nBackground2, nGauss2));
Finally, I create a RooSimultaneous object, define energy ranges for the two categories and perform the fit:
RooSimultaneous simPdf("simPdf", "simPdf", cat);
simPdf.add(Model1, "cat1");
simPdf.add(Model2, "cat2");
Energy.setRange("range_cat1", eMin1, eMax1);
Energy.setRange("range_cat2", eMin2, eMax2);
simPdf.fitTo(combData, Extended(kTRUE), Range("range"), SplitRange(kTRUE));
In the end the fit converges without error messages, but it’s clearly wrong. My impression is that the range requirements are being ignored and empty bins outside of the desired range are strongly influencing the fit.
What am I doing wrong?
Thanks,
Stefano