Test Non Central

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.

In [1]:
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace RooFit;
In [2]:
RooWorkspace w("w");

K <2, must use sum

In [3]:

Kk > 2 can use bessel

In [4]:

Kk > 2, force sum

In [5]:
((RooNonCentralChiSquare *)w.pdf("nccc"))->SetForceSum(true);

A normal "central" chi-square for comparison when lambda->0

In [6]:

W.var("kk")->setval(4.); // test a large kk

In [7]:
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));
[#1] INFO:InputArguments -- RooNonCentralChiSquare sum being forced
[#0] WARNING:Eval -- RooNonCentralChiSquare did not converge: for x=36 k=2.01, lambda=5 fractional error = 0.00108172
 either adjust tolerance with SetErrorTolerance(tol) or max_iter with SetMaxIter(max_it)
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

Draw all canvases

In [8]:
%jsroot on