{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "fb90c5b0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Welcome to JupyROOT 6.26/10\n" ] } ], "source": [ "import ROOT\n", "import numpy as np" ] }, { "cell_type": "markdown", "id": "68a9f689", "metadata": {}, "source": [ "## First some code to create the data in NumPy" ] }, { "cell_type": "code", "execution_count": 2, "id": "099a780d", "metadata": {}, "outputs": [], "source": [ "b0_mass = 5279.66#same value as particle package.literals" ] }, { "cell_type": "code", "execution_count": 3, "id": "0de94c08", "metadata": {}, "outputs": [], "source": [ "rand = 0" ] }, { "cell_type": "markdown", "id": "977741b3", "metadata": {}, "source": [ "## Here, the actual reproducer code starts:" ] }, { "cell_type": "code", "execution_count": 4, "id": "3ffa0fe8", "metadata": {}, "outputs": [], "source": [ "npsigmass=np.loadtxt('data.txt')\n", "mass = ROOT.RooRealVar(\"mass\", \"mass\", 4.6, 6.)\n", "signal_mass = ROOT.RooDataSet.from_numpy(data={\"mass\": npsigmass}, variables=[mass])" ] }, { "cell_type": "code", "execution_count": 5, "id": "ea498895", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[5.55474178 5.41846397 5.30449934 ... 5.28286643 5.39792737 5.43371422]\n" ] } ], "source": [ "print(npsigmass)" ] }, { "cell_type": "code", "execution_count": 9, "id": "af72bede", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[#0] WARNING:InputArguments -- The parameter 'nR_2' with range [0, 200] of the RooCrystalBall 'CBR_2' exceeds the safe range of (0, inf). Advise to limit its range.\n", "[#0] WARNING:InputArguments -- The parameter 'nL_2' with range [0, 200] of the RooCrystalBall 'CBL_2' exceeds the safe range of (0, inf). Advise to limit its range.\n", "[#0] WARNING:InputArguments -- The parameter 'sigmaG_2' with range [0, 1] of the RooGaussian 'gau_2' exceeds the safe range of (0, inf). Advise to limit its range.\n" ] } ], "source": [ "low1=5.26\n", "high1=5.3\n", "low = 4.6\n", "high = 6\n", "\n", "rand+=1\n", "\n", "#signal fit\n", "#crystal ball parameters\n", "mu=ROOT.RooRealVar(f\"mu_{rand}\", f\"mu_{rand}\", b0_mass/1000., low, high)\n", "sigma = ROOT.RooRealVar(f\"sigma_{rand}\", f\"sigma_{rand}\", 0.04, 0.025, 0.2)\n", "alphaL = ROOT.RooRealVar(f\"alphaL_{rand}\", f\"alphaL_{rand}\", 0.2, 0., 5.)\n", "nL = ROOT.RooRealVar(f\"nL_{rand}\", f\"nL_{rand}\", 10., 0., 200.)\n", "alphaR = ROOT.RooRealVar(f\"alphaR_{rand}\", f\"alphaR_{rand}\", -0.2, -5., 0.)\n", "nR = ROOT.RooRealVar(f\"nR_{rand}\", f\"nR_{rand}\", 10., 0., 200.)\n", "# Core gaussian parameters\n", "muG = ROOT.RooRealVar(f\"muG_{rand}\", f\"muG_{rand}\", b0_mass/1000., low1, high1)\n", "sigmaG = ROOT.RooRealVar(f\"sigmaG_{rand}\", f\"sigmaG_{rand}\", 0.015, 0., 1)\n", "# Fractions\n", "frac = ROOT.RooRealVar(f\"frac_{rand}\", f\"frac_{rand}\", 0.5, 0., 1.)\n", "frac_CB = ROOT.RooRealVar(f\"frac_CB_{rand}\", f\"frac_CB_{rand}\", 0.5, 0., 1.)\n", "# Yield\n", "#nsig=ROOT.RooRealVar(\"nSig\",\"nSig\",data[f\"sig_{smearing}\"][f\"sel_plot_true_number\"],0.,50000.)\n", "CBR = ROOT.RooCrystalBall(f\"CBR_{rand}\",f\"CBR_{rand}\",mass,mu,sigma,alphaR, nR, doubleSided=False)\n", "CBL = ROOT.RooCrystalBall(f\"CBL_{rand}\",f\"CBL_{rand}\",mass,mu,sigma,alphaL, nL, doubleSided=False)\n", "Gau = ROOT.RooGaussian(f\"gau_{rand}\",f\"gau_{rand}\",mass,muG,sigmaG)\n", "sig_a = ROOT.RooAddPdf( f\"sig_a_{rand}\",f\"sig_a_{rand}\",CBL,CBR,frac_CB)\n", "sig_fit= ROOT.RooAddPdf( f\"sig_fit_{rand}\",f\"sig_fit_{rand}\",sig_a, Gau,frac)" ] }, { "cell_type": "code", "execution_count": null, "id": "b33a08ed", "metadata": {}, "outputs": [], "source": [ "sig_fit.fitTo(signal_mass)\n", "c22=ROOT.TCanvas()\n", "Mframe = mass.frame()\n", "signal_mass.plotOn(Mframe)\n", "sig_fit.plotOn(Mframe)\n", "Mframe.Draw()\n", "c22.Draw('mass')" ] }, { "cell_type": "code", "execution_count": null, "id": "01e49335", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "9d96848b", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "FCC_XGBoost_env", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.8" }, "vscode": { "interpreter": { "hash": "3a5ef2f09598269b7daeb2c83fde27c1c26585342c31db4c787eb66d03c07c97" } } }, "nbformat": 4, "nbformat_minor": 5 }