Dear all,
I am having a very hard time to find the correct way of fitting the sideband of a distribution with a straight line.
I have found countless bugs, the last one if the bug concerning RooProdPdf therefore I am wondering if you have a good solution for my problem.
After many attempts I am now running this code which I though it was working but I see now that it print different result for the fit if someone if excluding or not the data in RooDataSet in the central window. This of course should not affect the fit which is performed only in the sideband. Have you got any idea or where I am hitting a bug? Thanks
{
double minL = 4829.24;
double MAXL = 4887.06;
double minR = 5060.54;
double MAXR = 5118.36;
RooRealVar *mHNL = new RooRealVar("Lambda0_M","m_{HNL}",minL,MAXR,"MeV/c^{2}");
mHNL->setRange("R",minL,MAXR) ;
mHNL->setRange("R1",minL,MAXL) ;
mHNL->setRange("R2",minR,MAXR) ;
RooRealVar leftEdge ("lE","lE",minL);
RooRealVar rightEdge ("rE","rE",MAXL);
RooRealVar leftEdge1 ("lE1","lE1",minR);
RooRealVar rightEdge1("rE1","rE1",MAXR);
RooGenericPdf stepFuncPDF("stepFuncPDF", "stepFuncPDF",
"((@0 >= @1) && (@0 < @2)) || ((@0 >= @3) && (@0 < @4))",
RooArgList(*mHNL,leftEdge,rightEdge,leftEdge1,rightEdge1));
RooRealVar *a0 = new RooRealVar("a0", "coefficient of x^1 term",-1.,1.);
RooChebychev *p0 = new RooChebychev("p0","p0",*mHNL,RooArgSet(*a0));
RooProdPdf *pp = new RooProdPdf("pp","pp",RooArgSet(stepFuncPDF,*p0));
RooDataSet* mHNL_dataset = pp->generate(*mHNL,100) ;
// --- Fit
RooFitResult* fitep0 = pp->fitTo(*mHNL_dataset,RooFit::Optimize(1),RooFit::Range("R1,R2"),RooFit::Save());
cout<<" +++ Fit results +++ "<<endl;
fitep0->Print();
cout<<"Fit status= "<<fitep0->status()<<"; covQual= "<<fitep0->covQual()<<endl;
// --- Plot
RooPlot* frame = mHNL->frame() ;
mHNL_dataset->plotOn(frame, RooFit::DrawOption("Zp")) ;
pp->plotOn(frame);
frame->Draw();
}