Skip to content

Commit

Permalink
Merge pull request #67 from rkansal47/unblinding
Browse files Browse the repository at this point in the history
QCD TF Plots
  • Loading branch information
rkansal47 authored May 31, 2024
2 parents 013ad1a + f6607a2 commit 03f51be
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 deletions src/HHbbVV/postprocessing/PlotFits.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"k2v0sig = False\n",
"unblinded = True\n",
"\n",
"plot_dir = MAIN_DIR / f\"plots/PostFit/24Apr26NonresBDT995\"\n",
"plot_dir = MAIN_DIR / f\"plots/PostFit/24May30QCDTF\"\n",
"# plot_dir = (\n",
"# MAIN_DIR\n",
"# / \"plots/PostFit/24Apr9ggFScan/nTF1/ggf_txbb_MP_ggf_bdt_0.9965_vbf_txbb_HP_vbf_bdt_0.999_lepton_veto_Hbb\"\n",
Expand Down Expand Up @@ -237,7 +237,7 @@
" \"bg_keys\": bg_keys,\n",
" \"bg_err\": bgerrs[shape][region],\n",
" \"sig_scale_dict\": sig_scale_dict if pass_region else None,\n",
" \"show\": True,\n",
" \"show\": False,\n",
" \"year\": \"all\",\n",
" \"ylim\": ylims[region],\n",
" \"title\": f\"{shape_label} {region_label} Region{title_label}\",\n",
Expand All @@ -249,6 +249,61 @@
" # break\n",
" # break"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.ticker as mticker\n",
"import mplhep as hep\n",
"\n",
"plt.style.use(hep.style.CMS)\n",
"hep.style.use(\"CMS\")\n",
"formatter = mticker.ScalarFormatter(useMathText=True)\n",
"formatter.set_powerlimits((-3, 3))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ylims = {\"passggf\": 1e-4, \"passvbf\": 1e-5}\n",
"tfs = {}\n",
"\n",
"for region, region_label in selection_regions.items():\n",
" if region == \"fail\":\n",
" continue\n",
"\n",
" tf = hists[\"postfit\"][region][\"QCD\", ...] / hists[\"postfit\"][\"fail\"][\"QCD\", ...]\n",
" tfs[region] = tf\n",
"\n",
" hep.histplot(tf)\n",
" plt.title(f\"{region_label} Region\")\n",
" plt.ylabel(\"QCD Transfer Factor\")\n",
" plt.xlim([50, 250])\n",
" plt.ylim([0, ylims[region]])\n",
" plt.ticklabel_format(style=\"sci\", axis=\"y\", scilimits=(0, 0))\n",
" plt.savefig(f\"{plot_dir}/{region}_QCDTF.pdf\", bbox_inches=\"tight\")\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tf = tfs[\"passvbf\"]\n",
"slope = (tf.view()[-1] - tf.view()[0]) / (245 - 55)\n",
"yint = tf.view()[0] - slope * 55\n",
"print(slope, yint)"
]
}
],
"metadata": {
Expand Down

0 comments on commit 03f51be

Please sign in to comment.