{ "cells": [ { "cell_type": "markdown", "id": "b6d991ed", "metadata": {}, "source": [ "# pdf010_CrystalBall\n", "Example of CrystalBall Function and its distribution (pdf and cdf)\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, May 19, 2026 at 08:26 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "66ffdf8d", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:53.406062Z", "iopub.status.busy": "2026-05-19T20:26:53.405951Z", "iopub.status.idle": "2026-05-19T20:26:53.750436Z", "shell.execute_reply": "2026-05-19T20:26:53.749818Z" } }, "outputs": [], "source": [ "auto c1 = new TCanvas();\n", "c1->Divide(1,3);" ] }, { "cell_type": "markdown", "id": "0feb18a9", "metadata": {}, "source": [ "crystal ball function" ] }, { "cell_type": "code", "execution_count": 2, "id": "3cdda9c8", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:53.760474Z", "iopub.status.busy": "2026-05-19T20:26:53.760339Z", "iopub.status.idle": "2026-05-19T20:26:53.967250Z", "shell.execute_reply": "2026-05-19T20:26:53.966689Z" } }, "outputs": [], "source": [ "c1->cd(1);\n", "\n", "auto f1 = new TF1(\"f1\",\"crystalball\",-5,5);\n", "f1->SetParameters(1, 0, 1, 2, 0.5);\n", "f1->SetLineColor(kRed);\n", "f1->Draw();" ] }, { "cell_type": "markdown", "id": "aac4be56", "metadata": {}, "source": [ "use directly the functionin ROOT::MATH note that the parameters definition is different is (alpha, n sigma, mu)" ] }, { "cell_type": "code", "execution_count": 3, "id": "4300e7d9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:53.969327Z", "iopub.status.busy": "2026-05-19T20:26:53.969210Z", "iopub.status.idle": "2026-05-19T20:26:54.176069Z", "shell.execute_reply": "2026-05-19T20:26:54.175424Z" } }, "outputs": [], "source": [ "auto f2 = new TF1(\"f2\",\"ROOT::Math::crystalball_function(x, 2, 1, 1, 0)\",-5,5);\n", "f2->SetLineColor(kGreen);\n", "f2->Draw(\"same\");\n", "auto f3 = new TF1(\"f3\",\"ROOT::Math::crystalball_function(x, 2, 2, 1, 0)\",-5,5);\n", "f3->SetLineColor(kBlue);\n", "f3->Draw(\"same\");\n", "\n", "auto legend = new TLegend(0.7,0.6,0.9,1.);\n", "legend->AddEntry(f1,\"N=0.5 alpha=2\",\"L\");\n", "legend->AddEntry(f2,\"N=1 alpha=2\",\"L\");\n", "legend->AddEntry(f3,\"N=2 alpha=2\",\"L\");\n", "legend->Draw();\n", "\n", "c1->cd(2);\n", "auto pdf1 = new TF1(\"pdf\",\"crystalballn\",-5,5);\n", "pdf1->SetParameters(2, 0, 1, 2, 3);\n", "pdf1->Draw();\n", "auto pdf2 = new TF1(\"pdf\",\"ROOT::Math::crystalball_pdf(x, 3, 1.01, 1, 0)\",-5,5);\n", "pdf2->SetLineColor(kBlue);\n", "pdf2->Draw(\"same\");\n", "auto pdf3 = new TF1(\"pdf\",\"ROOT::Math::crystalball_pdf(x, 2, 2, 1, 0)\",-5,5);\n", "pdf3->SetLineColor(kGreen);\n", "pdf3->Draw(\"same\");\n", "\n", "legend = new TLegend(0.7,0.6,0.9,1.);\n", "legend->AddEntry(pdf1,\"N=3 alpha=2\",\"L\");\n", "legend->AddEntry(pdf2,\"N=1.01 alpha=3\",\"L\");\n", "legend->AddEntry(pdf3,\"N=2 alpha=3\",\"L\");\n", "legend->Draw();\n", "\n", "c1->cd(3);\n", "auto cdf = new TF1(\"cdf\",\"ROOT::Math::crystalball_cdf(x, 1.2, 2, 1, 0)\",-5,5);\n", "auto cdfc = new TF1(\"cdfc\",\"ROOT::Math::crystalball_cdf_c(x, 1.2, 2, 1, 0)\",-5,5);\n", "cdf->SetLineColor(kRed-3);\n", "cdf->SetMinimum(0.);\n", "cdf->SetMaximum(1.);\n", "cdf->Draw();\n", "cdfc->SetLineColor(kMagenta);\n", "cdfc->Draw(\"Same\");\n", "\n", "legend = new TLegend(0.7,0.7,0.9,1.);\n", "legend->AddEntry(cdf,\"N=1.2 alpha=2\",\"L\");\n", "legend->AddEntry(cdfc,\"N=1.2 alpha=2\",\"L\");\n", "legend->Draw();" ] }, { "cell_type": "markdown", "id": "fd54852e", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 4, "id": "b6e2d21b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:26:54.177952Z", "iopub.status.busy": "2026-05-19T20:26:54.177835Z", "iopub.status.idle": "2026-05-19T20:26:54.491533Z", "shell.execute_reply": "2026-05-19T20:26:54.490924Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "