{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Systematic uncertainties" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import seaborn as sns\n", "\n", "from freeforestml import Variable, Process, Cut, hist, SystStack, DataStack, \\\n", " McStack, TruthStack\n", "from freeforestml import toydata, example_style\n", "example_style()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = toydata.get()\n", "df = df.compute()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = df.assign(variation=\"NOMINAL\")\n", "\n", "df_up = df.assign(higgs_m=df.higgs_m + 1 * df.jet_1_eta.abs(),\n", " variation=\"1up\")\n", "\n", "df_down = df.assign(higgs_m=df.higgs_m - 1 * df.jet_2_eta.abs(),\n", " variation=\"1down\")\n", "\n", "df = pd.concat([df, df_up, df_down], sort=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p_ztt = Process(r\"$Z\\rightarrow\\tau\\tau$\", range=(0, 0))\n", "p_sig = Process(r\"Signal\", range=(1, 1))\n", "\n", "p_bkg_up = Process(r\"Up\", lambda d: d.variation == \"1up\")\n", "p_bkg_down = Process(r\"Down\", lambda d: d.variation == \"1down\")\n", "p_ztt_nom = Process(r\"$Z\\rightarrow\\tau\\tau$\", lambda d: (d.variation == \"NOMINAL\") & (d.fpid == 0))\n", "p_sig_nom = Process(r\"Signal\", lambda d: (d.variation == \"NOMINAL\") & (d.fpid == 1))\n", "\n", "p_asimov = Process(r\"Asimov\", selection=lambda d: (d.fpid >= 0) & (d.variation == \"NOMINAL\"))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "c_nominal = Cut(lambda d: d.variation == \"NOMINAL\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "colors = [\"windows blue\", \"amber\", \"greyish\", \"faded green\", \"dusty purple\"]\n", "\n", "s_bkg = McStack(p_ztt, p_sig, palette=sns.xkcd_palette(colors))\n", "\n", "s_bkg_up = TruthStack(p_bkg_up,\n", " histtype=\"step\",\n", " color='k',\n", " palette=sns.xkcd_palette(colors))\n", "\n", "s_bkg_down = TruthStack(p_bkg_down,\n", " histtype=\"step\",\n", " color='k',\n", " linestyle='--',\n", " palette=sns.xkcd_palette(colors))\n", "\n", "s_bkg_nom = McStack(p_ztt_nom, p_sig_nom, palette=sns.xkcd_palette(colors))\n", "\n", "s_bkg_syst = SystStack(p_ztt, p_sig, palette=sns.xkcd_palette(colors))\n", "\n", "s_data = DataStack(p_asimov)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v_higgs_m = Variable(r\"$m^H$\", \"higgs_m\", \"GeV\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot nominal" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hist(c_nominal(df), v_higgs_m, 20, [s_bkg, s_data], range=(0, 200), selection=None,\n", " weight=\"weight\", ratio_label=\"Data / SM\", ratio_range=(0.1, 1.9))\n", "None" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Envelop" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hist(df, v_higgs_m, 20, [s_bkg_nom, s_bkg_up, s_bkg_down], range=(0, 200), selection=None,\n", " weight=\"weight\", ratio_label=\"Up / Down\", ratio_range=(0.1, 1.9))\n", "None" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Full band" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hist(df, v_higgs_m, 20, [s_bkg_syst, s_data], range=(0, 200), selection=None,\n", " weight=\"weight\", ratio_label=\"Data / SM\", ratio_range=(0.1, 1.9))\n", "None" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.9.2" } }, "nbformat": 4, "nbformat_minor": 2 }