Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:59

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