Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TestNonCentral.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roostats
3 /// \notebook -js
4 ///
5 /// \macro_image
6 /// \macro_output
7 /// \macro_code
8 ///
9 /// \author Lorenzo Moneta
10 
11 using namespace RooFit;
12 void TestNonCentral()
13 {
14 
15  RooWorkspace w("w");
16  // k <2, must use sum
17  w.factory("NonCentralChiSquare::nc(x[0,50],k[1.99,0,5],lambda[5])");
18  // kk > 2 can use bessel
19  w.factory("NonCentralChiSquare::ncc(x,kk[2.01,0,5],lambda)");
20  // kk > 2, force sum
21  w.factory("NonCentralChiSquare::nccc(x,kk,lambda)");
22  ((RooNonCentralChiSquare *)w.pdf("nccc"))->SetForceSum(true);
23 
24  // a normal "central" chi-square for comparison when lambda->0
25  w.factory("ChiSquarePdf::cs(x,k)");
26 
27  // w.var("kk")->setVal(4.); // test a large kk
28 
29  RooDataSet *ncdata = w.pdf("nc")->generate(*w.var("x"), 100);
30  RooDataSet *csdata = w.pdf("cs")->generate(*w.var("x"), 100);
31  RooPlot *plot = w.var("x")->frame();
32  ncdata->plotOn(plot, MarkerColor(kRed));
33  csdata->plotOn(plot, MarkerColor(kBlue));
34  w.pdf("nc")->plotOn(plot, LineColor(kRed));
35  w.pdf("ncc")->plotOn(plot, LineColor(kGreen));
36  w.pdf("nccc")->plotOn(plot, LineColor(kYellow), LineStyle(kDashed));
37  w.pdf("cs")->plotOn(plot, LineColor(kBlue), LineStyle(kDotted));
38  plot->Draw();
39 }