Author: Lorenzo Moneta
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Thursday, June 30, 2022 at 10:05 AM.
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace RooFit;
RooWorkspace w("w");
K <2, must use sum
w.factory("NonCentralChiSquare::nc(x[0,50],k[1.99,0,5],lambda[5])");
Kk > 2 can use bessel
w.factory("NonCentralChiSquare::ncc(x,kk[2.01,0,5],lambda)");
Kk > 2, force sum
w.factory("NonCentralChiSquare::nccc(x,kk,lambda)");
((RooNonCentralChiSquare *)w.pdf("nccc"))->SetForceSum(true);
A normal "central" chi-square for comparison when lambda->0
w.factory("ChiSquarePdf::cs(x,k)");
W.var("kk")->setval(4.); // test a large kk
RooDataSet *ncdata = w.pdf("nc")->generate(*w.var("x"), 100);
RooDataSet *csdata = w.pdf("cs")->generate(*w.var("x"), 100);
RooPlot *plot = w.var("x")->frame();
ncdata->plotOn(plot, MarkerColor(kRed));
csdata->plotOn(plot, MarkerColor(kBlue));
w.pdf("nc")->plotOn(plot, LineColor(kRed));
w.pdf("ncc")->plotOn(plot, LineColor(kGreen));
w.pdf("nccc")->plotOn(plot, LineColor(kYellow), LineStyle(kDashed));
w.pdf("cs")->plotOn(plot, LineColor(kBlue), LineStyle(kDotted));
plot->Draw();
Draw all canvases
%jsroot on
gROOT->GetListOfCanvases()->Draw()