{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Blinding" ] }, { "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, McStack, DataStack, Stack, \\\n", " RangeBlindingStrategy\n", "from freeforestml import toydata, example_style\n", "example_style()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = toydata.get()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Setup processes:" ] }, { "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_asimov = Process(r\"Asimov\", selection=lambda d: d.fpid >= 0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Setup up stacks:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "colors = [\"windows blue\", \"amber\", \"greyish\", \"faded green\", \"dusty purple\"]\n", "s_mc = McStack(p_ztt, p_sig, palette=sns.xkcd_palette(colors))\n", "s_data = DataStack(p_asimov)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the blinding strategy for a variables:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "b_higgs_m = RangeBlindingStrategy(99, 150)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The the blinding strategy to the variable definition." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v_higgs_m = Variable(r\"$m^H$\", \"higgs_m\", \"GeV\", blinding=b_higgs_m)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plotting" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Stacks passed to `blind` argument will be blinded according to blind strategy of variable `v_higgs_m`. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Blind data stack" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hist(df, v_higgs_m, 20, [s_mc, s_data], range=(0, 200),\n", " weight=\"weight\", ratio_label=\"Data / SM\", blind=[s_data], diff=True)\n", "None" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Blind MC stack" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hist(df, v_higgs_m, 20, [s_mc, s_data], range=(0, 200),\n", " weight=\"weight\", ratio_label=\"Data / SM\", blind=[s_mc])\n", "None" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Blind both stacks\n", "`blind` argument can be a single stack or a list of stacks." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hist(df, v_higgs_m, 20, [s_mc, s_data], range=(0, 200),\n", " weight=\"weight\", ratio_label=\"Data / SM\", blind=[s_mc, s_data])\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 }