Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:21

0001 RooPlot* resolution_fit(TH1* histo)
0002 {
0003    TString title(histo->GetTitle());
0004    RooRealVar x("x","x",0);
0005    RooRealVar mean1("mean1","mean1",-100,100);
0006    RooRealVar mean2("mean2","mean2",-100,100);
0007    RooRealVar sigma1("sigma1","sigma1",0.001,100);
0008    RooRealVar sigma2("sigma2","sigma2",1,100);
0009    RooGaussian pdf1("gaus1","gaus1",x,mean1,sigma1);
0010    RooGaussian pdf2("gaus2","gaus2",x,mean2,sigma2);
0011    RooRealVar frac("frac","frac",0,1);
0012    RooAddPdf pdf("pdf","pdf",pdf1,pdf2,frac);
0013    RooDataHist data("data","data",x,histo);
0014    pdf.fitTo(data,RooFit::Minos(kFALSE));
0015    frame=x.frame();
0016    data.plotOn(frame);
0017    data.statOn(frame,What("N"));
0018    pdf.paramOn(frame,Format("NEA",AutoPrecision(2)));
0019    pdf.plotOn(frame);
0020    frame->SetTitle(title);
0021    frame->Draw();
0022    return frame;
0023 }
0024