{
"cells": [
{
"cell_type": "markdown",
"id": "d47b59de",
"metadata": {},
"source": [
"# StandardTestStatDistributionDemo\n",
"StandardTestStatDistributionDemo.C\n",
"\n",
"This simple script plots the sampling distribution of the profile likelihood\n",
"ratio test statistic based on the input Model File. To do this one needs to\n",
"specify the value of the parameter of interest that will be used for evaluating\n",
"the test statistic and the value of the parameters used for generating the toy data.\n",
"In this case, it uses the upper-limit estimated from the ProfileLikleihoodCalculator,\n",
"which assumes the asymptotic chi-square distribution for -2 log profile likelihood ratio.\n",
"Thus, the script is handy for checking to see if the asymptotic approximations are valid.\n",
"To aid, that comparison, the script overlays a chi-square distribution as well.\n",
"The most common parameter of interest is a parameter proportional to the signal rate,\n",
"and often that has a lower-limit of 0, which breaks the standard chi-square distribution.\n",
"Thus the script allows the parameter to be negative so that the overlay chi-square is\n",
"the correct asymptotic distribution.\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Kyle Cranmer \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:36 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c045ad53",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:36.442310Z",
"iopub.status.busy": "2026-05-19T20:36:36.442176Z",
"iopub.status.idle": "2026-05-19T20:36:36.459105Z",
"shell.execute_reply": "2026-05-19T20:36:36.458490Z"
}
},
"outputs": [],
"source": [
"%%cpp -d\n",
"#include \"TFile.h\"\n",
"#include \"TROOT.h\"\n",
"#include \"TH1F.h\"\n",
"#include \"TCanvas.h\"\n",
"#include \"TSystem.h\"\n",
"#include \"TF1.h\"\n",
"#include \"TSystem.h\"\n",
"\n",
"#include \"RooWorkspace.h\"\n",
"#include \"RooAbsData.h\"\n",
"\n",
"#include \"RooStats/ModelConfig.h\"\n",
"#include \"RooStats/FeldmanCousins.h\"\n",
"#include \"RooStats/ToyMCSampler.h\"\n",
"#include \"RooStats/PointSetInterval.h\"\n",
"#include \"RooStats/ConfidenceBelt.h\"\n",
"\n",
"#include \"RooStats/ProfileLikelihoodCalculator.h\"\n",
"#include \"RooStats/LikelihoodInterval.h\"\n",
"#include \"RooStats/ProfileLikelihoodTestStat.h\"\n",
"#include \"RooStats/SamplingDistribution.h\"\n",
"#include \"RooStats/SamplingDistPlot.h\"\n",
"\n",
"using namespace RooFit;\n",
"using namespace RooStats;"
]
},
{
"cell_type": "markdown",
"id": "b16a96f5",
"metadata": {},
"source": [
" Arguments are defined. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "5c9605eb",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:36.461191Z",
"iopub.status.busy": "2026-05-19T20:36:36.461071Z",
"iopub.status.idle": "2026-05-19T20:36:36.798049Z",
"shell.execute_reply": "2026-05-19T20:36:36.791573Z"
}
},
"outputs": [],
"source": [
"const char *infile = \"\";\n",
"const char *workspaceName = \"combined\";\n",
"const char *modelConfigName = \"ModelConfig\";\n",
"const char *dataName = \"obsData\";"
]
},
{
"cell_type": "markdown",
"id": "57d128b0",
"metadata": {},
"source": [
"the number of toy MC used to generate the distribution"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8da5e4d5",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:36.800412Z",
"iopub.status.busy": "2026-05-19T20:36:36.800284Z",
"iopub.status.idle": "2026-05-19T20:36:37.009670Z",
"shell.execute_reply": "2026-05-19T20:36:37.008984Z"
}
},
"outputs": [],
"source": [
"int nToyMC = 1000;"
]
},
{
"cell_type": "markdown",
"id": "f00d0f70",
"metadata": {},
"source": [
"The parameter below is needed for asymptotic distribution to be chi-square,\n",
"but set to false if your model is not numerically stable if mu<0"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b6e3d362",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:37.011283Z",
"iopub.status.busy": "2026-05-19T20:36:37.011168Z",
"iopub.status.idle": "2026-05-19T20:36:37.220312Z",
"shell.execute_reply": "2026-05-19T20:36:37.219701Z"
}
},
"outputs": [],
"source": [
"bool allowNegativeMu = true;"
]
},
{
"cell_type": "markdown",
"id": "4fd9e233",
"metadata": {},
"source": [
"-------------------------------------------------------\n",
"First part is just to access a user-defined file\n",
"or create the standard example file if it doesn't exist"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "7154b67d",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:37.222248Z",
"iopub.status.busy": "2026-05-19T20:36:37.222124Z",
"iopub.status.idle": "2026-05-19T20:36:37.431944Z",
"shell.execute_reply": "2026-05-19T20:36:37.431240Z"
}
},
"outputs": [],
"source": [
"const char *filename = \"\";\n",
"if (!strcmp(infile, \"\")) {\n",
" filename = \"results/example_combined_GaussExample_model.root\";\n",
" bool fileExist = !gSystem->AccessPathName(filename); // note opposite return code\n",
" // if file does not exists generate with histfactory\n",
" if (!fileExist) {\n",
" // Normally this would be run on the command line\n",
" cout << \"will run standard hist2workspace example\" << endl;\n",
" gROOT->ProcessLine(\".! prepareHistFactory .\");\n",
" gROOT->ProcessLine(\".! hist2workspace config/example.xml\");\n",
" cout << \"\\n\\n---------------------\" << endl;\n",
" cout << \"Done creating example input\" << endl;\n",
" cout << \"---------------------\\n\\n\" << endl;\n",
" }\n",
"\n",
"} else\n",
" filename = infile;"
]
},
{
"cell_type": "markdown",
"id": "3015cf0d",
"metadata": {},
"source": [
"Try to open the file"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "325ff40b",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:37.434225Z",
"iopub.status.busy": "2026-05-19T20:36:37.434108Z",
"iopub.status.idle": "2026-05-19T20:36:37.767437Z",
"shell.execute_reply": "2026-05-19T20:36:37.766662Z"
}
},
"outputs": [],
"source": [
"TFile *file = TFile::Open(filename);"
]
},
{
"cell_type": "markdown",
"id": "48807178",
"metadata": {},
"source": [
"if input file was specified but not found, quit"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "4ecc56d1",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:37.783038Z",
"iopub.status.busy": "2026-05-19T20:36:37.782895Z",
"iopub.status.idle": "2026-05-19T20:36:37.996672Z",
"shell.execute_reply": "2026-05-19T20:36:37.988664Z"
}
},
"outputs": [],
"source": [
"if (!file) {\n",
" cout << \"StandardRooStatsDemoMacro: Input file \" << filename << \" is not found\" << endl;\n",
" return;\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "958a74c2",
"metadata": {},
"source": [
"-------------------------------------------------------\n",
"Now get the data and workspace"
]
},
{
"cell_type": "markdown",
"id": "27e4be6c",
"metadata": {},
"source": [
"get the workspace out of the file"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "5807904e",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:38.022844Z",
"iopub.status.busy": "2026-05-19T20:36:38.022664Z",
"iopub.status.idle": "2026-05-19T20:36:38.376555Z",
"shell.execute_reply": "2026-05-19T20:36:38.375946Z"
}
},
"outputs": [],
"source": [
"RooWorkspace *w = (RooWorkspace *)file->Get(workspaceName);\n",
"if (!w) {\n",
" cout << \"workspace not found\" << endl;\n",
" return;\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "d2c4c4bb",
"metadata": {},
"source": [
"get the modelConfig out of the file"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a3402588",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:38.378148Z",
"iopub.status.busy": "2026-05-19T20:36:38.378022Z",
"iopub.status.idle": "2026-05-19T20:36:38.589251Z",
"shell.execute_reply": "2026-05-19T20:36:38.588825Z"
}
},
"outputs": [],
"source": [
"ModelConfig *mc = (ModelConfig *)w->obj(modelConfigName);"
]
},
{
"cell_type": "markdown",
"id": "5b43fe84",
"metadata": {},
"source": [
"get the modelConfig out of the file"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "401b648c",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:38.595378Z",
"iopub.status.busy": "2026-05-19T20:36:38.595254Z",
"iopub.status.idle": "2026-05-19T20:36:38.804762Z",
"shell.execute_reply": "2026-05-19T20:36:38.804330Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_78:2:2: warning: 'data' shadows a declaration with the same name in the 'std' namespace; use '::data' to reference this declaration\n",
" RooAbsData *data = w->data(dataName);\n",
" ^\n"
]
}
],
"source": [
"RooAbsData *data = w->data(dataName);"
]
},
{
"cell_type": "markdown",
"id": "5c230c98",
"metadata": {},
"source": [
"make sure ingredients are found"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "15b459ec",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:38.814329Z",
"iopub.status.busy": "2026-05-19T20:36:38.814197Z",
"iopub.status.idle": "2026-05-19T20:36:39.025304Z",
"shell.execute_reply": "2026-05-19T20:36:39.024729Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_79:2:7: error: reference to 'data' is ambiguous\n",
" if (!data || !mc) {\n",
" ^\n",
"input_line_78:2:14: note: candidate found by name lookup is 'data'\n",
" RooAbsData *data = w->data(dataName);\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n"
]
}
],
"source": [
"if (!data || !mc) {\n",
" w->Print();\n",
" cout << \"data or ModelConfig was not found\" << endl;\n",
" return;\n",
"}\n",
"\n",
"mc->Print();"
]
},
{
"cell_type": "markdown",
"id": "2e10d443",
"metadata": {},
"source": [
"-------------------------------------------------------\n",
"Now find the upper limit based on the asymptotic results"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "5063030c",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:39.027137Z",
"iopub.status.busy": "2026-05-19T20:36:39.027015Z",
"iopub.status.idle": "2026-05-19T20:36:39.249844Z",
"shell.execute_reply": "2026-05-19T20:36:39.249435Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_80:3:34: error: reference to 'data' is ambiguous\n",
"ProfileLikelihoodCalculator plc(*data, *mc);\n",
" ^\n",
"input_line_78:2:14: note: candidate found by name lookup is 'data'\n",
" RooAbsData *data = w->data(dataName);\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n"
]
}
],
"source": [
"RooRealVar *firstPOI = (RooRealVar *)mc->GetParametersOfInterest()->first();\n",
"ProfileLikelihoodCalculator plc(*data, *mc);\n",
"LikelihoodInterval *interval = plc.GetInterval();\n",
"double plcUpperLimit = interval->UpperLimit(*firstPOI);\n",
"delete interval;\n",
"cout << \"\\n\\n--------------------------------------\" << endl;\n",
"cout << \"Will generate sampling distribution at \" << firstPOI->GetName() << \" = \" << plcUpperLimit << endl;\n",
"int nPOI = mc->GetParametersOfInterest()->getSize();\n",
"if (nPOI > 1) {\n",
" cout << \"not sure what to do with other parameters of interest, but here are their values\" << endl;\n",
" mc->GetParametersOfInterest()->Print(\"v\");\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "6cf184c7",
"metadata": {},
"source": [
"-------------------------------------------------------\n",
"create the test stat sampler"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "5e18d0a3",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:39.266316Z",
"iopub.status.busy": "2026-05-19T20:36:39.266180Z",
"iopub.status.idle": "2026-05-19T20:36:39.476845Z",
"shell.execute_reply": "2026-05-19T20:36:39.476467Z"
}
},
"outputs": [],
"source": [
"ProfileLikelihoodTestStat ts(*mc->GetPdf());"
]
},
{
"cell_type": "markdown",
"id": "3dda659a",
"metadata": {},
"source": [
"to avoid effects from boundary and simplify asymptotic comparison, set min=-max"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "ae6772f7",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:39.485403Z",
"iopub.status.busy": "2026-05-19T20:36:39.485282Z",
"iopub.status.idle": "2026-05-19T20:36:39.725146Z",
"shell.execute_reply": "2026-05-19T20:36:39.724678Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_83:2:3: error: use of undeclared identifier 'firstPOI'\n",
" (firstPOI->setMin(-1 * firstPOI->getMax()))\n",
" ^\n",
"input_line_83:2:25: error: use of undeclared identifier 'firstPOI'\n",
" (firstPOI->setMin(-1 * firstPOI->getMax()))\n",
" ^\n",
"Error in : Error evaluating expression (firstPOI->setMin(-1 * firstPOI->getMax()))\n",
"Execution of your code was aborted.\n"
]
}
],
"source": [
"if (allowNegativeMu)\n",
" firstPOI->setMin(-1 * firstPOI->getMax());"
]
},
{
"cell_type": "markdown",
"id": "fe8a0570",
"metadata": {},
"source": [
"temporary RooArgSet"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "4a580e08",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:39.729386Z",
"iopub.status.busy": "2026-05-19T20:36:39.729255Z",
"iopub.status.idle": "2026-05-19T20:36:39.939666Z",
"shell.execute_reply": "2026-05-19T20:36:39.938620Z"
}
},
"outputs": [],
"source": [
"RooArgSet poi;\n",
"poi.add(*mc->GetParametersOfInterest());"
]
},
{
"cell_type": "markdown",
"id": "26282f13",
"metadata": {},
"source": [
"create and configure the ToyMCSampler"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "4fc2d3a7",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:39.941485Z",
"iopub.status.busy": "2026-05-19T20:36:39.941348Z",
"iopub.status.idle": "2026-05-19T20:36:40.177221Z",
"shell.execute_reply": "2026-05-19T20:36:40.176665Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_85:6:40: error: reference to 'data' is ambiguous\n",
"if (!mc->GetPdf()->canBeExtended() && (data->numEntries() == 1)) {\n",
" ^\n",
"input_line_78:2:14: note: candidate found by name lookup is 'data'\n",
" RooAbsData *data = w->data(dataName);\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n",
"input_line_85:6:40: error: unknown type name 'data'\n",
"if (!mc->GetPdf()->canBeExtended() && (data->numEntries() == 1)) {\n",
" ^\n",
"input_line_85:6:44: error: expected ')'\n",
"if (!mc->GetPdf()->canBeExtended() && (data->numEntries() == 1)) {\n",
" ^\n",
"input_line_85:6:39: note: to match this '('\n",
"if (!mc->GetPdf()->canBeExtended() && (data->numEntries() == 1)) {\n",
" ^\n",
"input_line_85:10:1: error: use of undeclared identifier 'firstPOI'\n",
"firstPOI->setVal(plcUpperLimit); // set POI value for generation\n",
"^\n",
"input_line_85:10:18: error: use of undeclared identifier 'plcUpperLimit'\n",
"firstPOI->setVal(plcUpperLimit); // set POI value for generation\n",
" ^\n",
"input_line_85:13:1: error: use of undeclared identifier 'firstPOI'\n",
"firstPOI->setVal(plcUpperLimit);\n",
"^\n",
"input_line_85:13:18: error: use of undeclared identifier 'plcUpperLimit'\n",
"firstPOI->setVal(plcUpperLimit);\n",
" ^\n",
"input_line_85:23:49: error: use of undeclared identifier 'plcUpperLimit'\n",
" Form(\"f(-log #lambda(#mu=%.2f) | #mu=%.2f)\", plcUpperLimit, plcUpperLimit));\n",
" ^\n",
"input_line_85:23:64: error: use of undeclared identifier 'plcUpperLimit'\n",
" Form(\"f(-log #lambda(#mu=%.2f) | #mu=%.2f)\", plcUpperLimit, plcUpperLimit));\n",
" ^\n",
"input_line_85:24:50: error: use of undeclared identifier 'plcUpperLimit'\n",
"plot.SetAxisTitle(Form(\"-log #lambda(#mu=%.2f)\", plcUpperLimit));\n",
" ^\n",
"input_line_85:32:70: error: use of undeclared identifier 'nPOI'\n",
"TF1 *f = new TF1(\"f\", Form(\"2*ROOT::Math::chisquared_pdf(2*x,%d,0)\", nPOI), min, max);\n",
" ^\n",
"input_line_85:29:1: warning: 'min' shadows a declaration with the same name in the 'std' namespace; use '::min' to reference this declaration\n",
"double min = plot.GetTH1F(sampDist)->GetXaxis()->GetXmin();\n",
"^\n",
"input_line_85:30:1: warning: 'max' shadows a declaration with the same name in the 'std' namespace; use '::max' to reference this declaration\n",
"double max = plot.GetTH1F(sampDist)->GetXaxis()->GetXmax();\n",
"^\n"
]
}
],
"source": [
"ToyMCSampler sampler(ts, nToyMC);\n",
"sampler.SetPdf(*mc->GetPdf());\n",
"sampler.SetObservables(*mc->GetObservables());\n",
"sampler.SetGlobalObservables(*mc->GetGlobalObservables());\n",
"if (!mc->GetPdf()->canBeExtended() && (data->numEntries() == 1)) {\n",
" cout << \"tell it to use 1 event\" << endl;\n",
" sampler.SetNEventsPerToy(1);\n",
"}\n",
"firstPOI->setVal(plcUpperLimit); // set POI value for generation\n",
"sampler.SetParametersForTestStat(*mc->GetParametersOfInterest()); // set POI value for evaluation\n",
"\n",
"firstPOI->setVal(plcUpperLimit);\n",
"RooArgSet allParameters;\n",
"allParameters.add(*mc->GetParametersOfInterest());\n",
"allParameters.add(*mc->GetNuisanceParameters());\n",
"allParameters.Print(\"v\");\n",
"\n",
"SamplingDistribution *sampDist = sampler.GetSamplingDistribution(allParameters);\n",
"SamplingDistPlot plot;\n",
"plot.AddSamplingDistribution(sampDist);\n",
"plot.GetTH1F(sampDist)->GetYaxis()->SetTitle(\n",
" Form(\"f(-log #lambda(#mu=%.2f) | #mu=%.2f)\", plcUpperLimit, plcUpperLimit));\n",
"plot.SetAxisTitle(Form(\"-log #lambda(#mu=%.2f)\", plcUpperLimit));\n",
"\n",
"TCanvas *c1 = new TCanvas(\"c1\");\n",
"c1->SetLogy();\n",
"plot.Draw();\n",
"double min = plot.GetTH1F(sampDist)->GetXaxis()->GetXmin();\n",
"double max = plot.GetTH1F(sampDist)->GetXaxis()->GetXmax();\n",
"\n",
"TF1 *f = new TF1(\"f\", Form(\"2*ROOT::Math::chisquared_pdf(2*x,%d,0)\", nPOI), min, max);\n",
"f->Draw(\"same\");\n",
"c1->SaveAs(\"standard_test_stat_distribution.pdf\");"
]
},
{
"cell_type": "markdown",
"id": "f59d2440",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "1dceffd3",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:36:40.178797Z",
"iopub.status.busy": "2026-05-19T20:36:40.178674Z",
"iopub.status.idle": "2026-05-19T20:36:40.388388Z",
"shell.execute_reply": "2026-05-19T20:36:40.387439Z"
}
},
"outputs": [],
"source": [
"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
}