Hi all
I’m fitting a template, which will be later used as a fixed shape in a fit with a different range.
Since the template uses a RooAddPdf, it is my understanding that I should use RooAddPdf::fixCoefRange, or the shape will be different when used in the main fit (it is, I tried).
However, I’m not sure I understand exactly that method: it says that it ties the coefficient normalization to a specific named range instead of the fit range, but even if I set the normalization range to the fit range the fit appears different.
void test() {
using namespace RooFit;
RooRealVar x("x", "", 0, 2);
RooRealVar c1("c1", "", 0.5, 0, 10);
RooRealVar c2("c2", "", 2, 0, 10);
RooExponential exp1("exp1", "", x, c1);
RooExponential exp2("exp2", "", x, c2);
RooRealVar frac("frac", "", 0.15, 0, 1);
RooAddPdf model("model", "", RooArgList(exp1, exp2), frac);
auto data = model.generate(x, 100000);
x.setRange("norm", 0, 2);
model.fixCoefRange("norm");
model.fitTo(*data, Save(true), PrintLevel(-1))->Print("V");
auto frame = x.frame();
data->plotOn(frame);
model.plotOn(frame);
frame->Draw();
}
Am I misunderstanding something? What is the correct way to export the model so that it will not change when using a different range?
Thank you in advance.
Enrico