{
"cells": [
{
"cell_type": "markdown",
"id": "850b4ca0",
"metadata": {},
"source": [
"# TestNonCentral\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Lorenzo Moneta \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, March 19, 2024 at 07:18 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "4bfecc5d",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:00.032064Z",
"iopub.status.busy": "2024-03-19T19:19:00.031688Z",
"iopub.status.idle": "2024-03-19T19:19:00.441643Z",
"shell.execute_reply": "2024-03-19T19:19:00.440325Z"
}
},
"outputs": [],
"source": [
"using namespace RooFit;"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "5d109896",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:00.446619Z",
"iopub.status.busy": "2024-03-19T19:19:00.446195Z",
"iopub.status.idle": "2024-03-19T19:19:00.659212Z",
"shell.execute_reply": "2024-03-19T19:19:00.658077Z"
}
},
"outputs": [],
"source": [
"RooWorkspace w(\"w\");"
]
},
{
"cell_type": "markdown",
"id": "cd658a60",
"metadata": {},
"source": [
"k <2, must use sum"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "79f2724e",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:00.663596Z",
"iopub.status.busy": "2024-03-19T19:19:00.663246Z",
"iopub.status.idle": "2024-03-19T19:19:01.105217Z",
"shell.execute_reply": "2024-03-19T19:19:01.103760Z"
}
},
"outputs": [],
"source": [
"w.factory(\"NonCentralChiSquare::nc(x[0,50],k[1.99,0,5],lambda[5])\");"
]
},
{
"cell_type": "markdown",
"id": "03274245",
"metadata": {},
"source": [
"kk > 2 can use bessel"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6ca0a128",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:01.114481Z",
"iopub.status.busy": "2024-03-19T19:19:01.114057Z",
"iopub.status.idle": "2024-03-19T19:19:01.328613Z",
"shell.execute_reply": "2024-03-19T19:19:01.327514Z"
}
},
"outputs": [],
"source": [
"w.factory(\"NonCentralChiSquare::ncc(x,kk[2.01,0,5],lambda)\");"
]
},
{
"cell_type": "markdown",
"id": "66e71325",
"metadata": {},
"source": [
"kk > 2, force sum"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "818b742b",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:01.333064Z",
"iopub.status.busy": "2024-03-19T19:19:01.332766Z",
"iopub.status.idle": "2024-03-19T19:19:01.543246Z",
"shell.execute_reply": "2024-03-19T19:19:01.542143Z"
}
},
"outputs": [],
"source": [
"w.factory(\"NonCentralChiSquare::nccc(x,kk,lambda)\");\n",
"((RooNonCentralChiSquare *)w.pdf(\"nccc\"))->SetForceSum(true);"
]
},
{
"cell_type": "markdown",
"id": "88d1d59d",
"metadata": {},
"source": [
"a normal \"central\" chi-square for comparison when lambda->0"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "73034d5a",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:01.549988Z",
"iopub.status.busy": "2024-03-19T19:19:01.549642Z",
"iopub.status.idle": "2024-03-19T19:19:01.759726Z",
"shell.execute_reply": "2024-03-19T19:19:01.758702Z"
}
},
"outputs": [],
"source": [
"w.factory(\"ChiSquarePdf::cs(x,k)\");"
]
},
{
"cell_type": "markdown",
"id": "4e5a86c6",
"metadata": {},
"source": [
"w.var(\"kk\")->setVal(4.); // test a large kk"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "33722ea7",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:01.764960Z",
"iopub.status.busy": "2024-03-19T19:19:01.764609Z",
"iopub.status.idle": "2024-03-19T19:19:02.240332Z",
"shell.execute_reply": "2024-03-19T19:19:02.238986Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[#1] INFO:InputArguments -- RooNonCentralChiSquare sum being forced\n",
"[#0] WARNING:Eval -- RooNonCentralChiSquare did not converge: for x=36 k=2.01, lambda=5 fractional error = 0.00108172\n",
" either adjust tolerance with SetErrorTolerance(tol) or max_iter with SetMaxIter(max_it)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Info in : created default TCanvas with name c1\n"
]
}
],
"source": [
"std::unique_ptr ncdata{w.pdf(\"nc\")->generate(*w.var(\"x\"), 100)};\n",
"std::unique_ptr csdata{w.pdf(\"cs\")->generate(*w.var(\"x\"), 100)};\n",
"RooPlot *plot = w.var(\"x\")->frame();\n",
"ncdata->plotOn(plot, MarkerColor(kRed));\n",
"csdata->plotOn(plot, MarkerColor(kBlue));\n",
"w.pdf(\"nc\")->plotOn(plot, LineColor(kRed));\n",
"w.pdf(\"ncc\")->plotOn(plot, LineColor(kGreen));\n",
"w.pdf(\"nccc\")->plotOn(plot, LineColor(kYellow), LineStyle(kDashed));\n",
"w.pdf(\"cs\")->plotOn(plot, LineColor(kBlue), LineStyle(kDotted));\n",
"plot->Draw();"
]
},
{
"cell_type": "markdown",
"id": "8be08e11",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "8bb0dd3e",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2024-03-19T19:19:02.250007Z",
"iopub.status.busy": "2024-03-19T19:19:02.249629Z",
"iopub.status.idle": "2024-03-19T19:19:02.728183Z",
"shell.execute_reply": "2024-03-19T19:19:02.726485Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%jsroot on\n",
"gROOT->GetListOfCanvases()->Draw()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ROOT C++",
"language": "c++",
"name": "root"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".C",
"mimetype": " text/x-c++src",
"name": "c++"
}
},
"nbformat": 4,
"nbformat_minor": 5
}