CrystalBall擬合(Roofit)
using namespace RooFit;???? 啟用roofit
void roofitwithcrystalball()?? 注意文件名
{
RooRealVar x("x", "x", -20, 20);
RooRealVar mean("mean", "mean", 5, -0.1, 0.1);
RooRealVar sigma("sigma", "sigma", 2, 1.5, 2.5);
RooRealVar alpha("alpha", "alpha", 1, 0.9, 1.1);
RooRealVar nin("nin", "nin", 3, 2.5, 3.5);??? 定義5個(gè)變量
RooCrystalBall f1("f1", "f1",x, alpha, nin, sigma, mean);?? 函數(shù)形式
RooPlot * p1 = x.frame(Title("oringinal"));????? ?
RooPlot * p2 = x.frame(Title("Fitted"));
RooPlot * p3 = x.frame(Title("oringinal scatter"));????? 定義3個(gè)框架
RooDataSet * data1 = f1.generate(x, 10000);???? 產(chǎn)生數(shù)據(jù) ?
f1.plotOn(p1);
data1->plotOn(p2);
f1.plotOn(p2);
f1.fitTo(*data1);???????????? 擬合數(shù)據(jù)導(dǎo)入進(jìn)行對(duì)比
data1->plotOn(p3);
mean.Print();
sigma.Print();
alpha.Print();
nin.Print();???? 輸出參數(shù)
TCanvas * c1 = new TCanvas("c1","c1");???? ?
c1->Divide(1,3);
c1->cd(1);
p1->Draw();
c1->cd(2);
p2->Draw();
c1->cd(3);
p3->Draw();??? ?
}