Skip to content

Commit

Permalink
john arc results
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed May 31, 2024
1 parent 03f51be commit 6a433c7
Show file tree
Hide file tree
Showing 8 changed files with 541 additions and 203 deletions.
70 changes: 66 additions & 4 deletions paper/latex_tables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import yaml\n",
"import json\n",
"import numpy as np\n",
"from copy import deepcopy"
"import pandas as pd\n",
"from copy import deepcopy\n",
"from pathlib import Path"
]
},
{
Expand Down Expand Up @@ -343,12 +345,72 @@
" f.writelines(lines)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Lund plane SFs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Nonresonant"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": []
"source": [
"templates_dir = Path(\"../src/HHbbVV/postprocessing/templates/24Apr26NonresBDT995AllSigs\")\n",
"dfs = {\n",
" \"ggF\": pd.read_csv(templates_dir / \"lpsfs_passggf.csv\").to_numpy(),\n",
" \"VBF\": pd.read_csv(templates_dir / \"lpsfs_passvbf.csv\").to_numpy(),\n",
"}\n",
"\n",
"sig_map = {\n",
" \"HHbbVV\": r\"SM ggF \\HH\",\n",
" \"VBFHHbbVV\": r\"SM VBF \\HH\",\n",
" \"qqHH_CV_1_C2V_0_kl_1_HHbbVV\": r\"VBF \\HH ($\\kapvv = 0$)\",\n",
" \"qqHH_CV_1_C2V_2_kl_1_HHbbVV\": r\"VBF \\HH ($\\kapvv = 2$)\",\n",
"}\n",
"\n",
"df = dfs[\"ggF\"]\n",
"\n",
"lines = []\n",
"\n",
"for j, (region, df) in enumerate(dfs.items()):\n",
" sigs = df[:, 0]\n",
" for i, (sig, siglabel) in enumerate(sig_map.items()):\n",
" if i == 0:\n",
" region_label = rf\"\\multirow{{{len(sig_map)}}}{{*}}{{{region}}}\"\n",
" else:\n",
" region_label = \"\"\n",
"\n",
" line = [region_label, siglabel]\n",
" sigidx = np.where(sigs == sig)[0][0]\n",
" row = df[sigidx, 1:]\n",
"\n",
" sf = row[0].split(\" ± \")\n",
" line.append(rf\"${sf[0]} \\pm {sf[1]}$\")\n",
"\n",
" for i in range(1, len(row)):\n",
" line.append(f\"{row[i]:.2f}\")\n",
"\n",
" lines.append(\" & \".join(line) + r\" \\\\\" + \"\\n\")\n",
"\n",
" if j != len(dfs) - 1:\n",
" lines.append(r\"\\hline\" + \"\\n\")\n",
"\n",
"# remove trailing \"\\\\\" and \"\\n\"\n",
"lines[-1] = lines[-1][:-4]\n",
"\n",
"with Path(\"tables/nonres_lpsfs.tex\").open(\"w\") as f:\n",
" f.writelines(lines)"
]
}
],
"metadata": {
Expand Down
259 changes: 259 additions & 0 deletions paper/limit_plots.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
{
"cells": [
{
"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": [
"import matplotlib.pyplot as plt\n",
"import matplotlib.patches as patches\n",
"import mplhep as hep\n",
"\n",
"# Apply the CMS style\n",
"plt.style.use(hep.style.CMS)\n",
"\n",
"# Define the observed and expected data for the first set (from the first PDF)\n",
"observed_value_1 = 142\n",
"expected_median_1 = 69\n",
"expected_68_low_1, expected_68_high_1 = 50, 80 # 68% confidence interval\n",
"expected_95_low_1, expected_95_high_1 = 40, 100 # 95% confidence interval\n",
"\n",
"# Define the observed and expected data for the second set (from the second PDF)\n",
"observed_value_2 = 1.1\n",
"expected_median_2 = 0.9\n",
"expected_68_low_2, expected_68_high_2 = 0.7, 1.1 # 68% confidence interval\n",
"expected_95_low_2, expected_95_high_2 = 0.5, 1.3 # 95% confidence interval\n",
"\n",
"# Create the figure with custom dimensions\n",
"fig, ax = plt.subplots(figsize=(10, 6)) # Adjust the dimensions as needed\n",
"\n",
"# Plot for the first set\n",
"# Add rectangles for the confidence intervals\n",
"rect_95_1 = patches.Rectangle(\n",
" (expected_95_low_1, 0.7),\n",
" expected_95_high_1 - expected_95_low_1,\n",
" 0.2,\n",
" linewidth=0,\n",
" edgecolor=\"none\",\n",
" facecolor=\"yellow\",\n",
" alpha=0.5,\n",
")\n",
"ax.add_patch(rect_95_1)\n",
"rect_68_1 = patches.Rectangle(\n",
" (expected_68_low_1, 0.7),\n",
" expected_68_high_1 - expected_68_low_1,\n",
" 0.2,\n",
" linewidth=0,\n",
" edgecolor=\"none\",\n",
" facecolor=\"green\",\n",
" alpha=0.5,\n",
")\n",
"ax.add_patch(rect_68_1)\n",
"ax.plot([expected_median_1, expected_median_1], [0.7, 0.9], \"k--\")\n",
"ax.plot([observed_value_1, observed_value_1], [0.7, 0.9], \"k-\", linewidth=2)\n",
"\n",
"# Plot for the second set\n",
"# Add rectangles for the confidence intervals\n",
"rect_95_2 = patches.Rectangle(\n",
" (expected_95_low_2, 0.4),\n",
" expected_95_high_2 - expected_95_low_2,\n",
" 0.2,\n",
" linewidth=0,\n",
" edgecolor=\"none\",\n",
" facecolor=\"yellow\",\n",
" alpha=0.5,\n",
")\n",
"ax.add_patch(rect_95_2)\n",
"rect_68_2 = patches.Rectangle(\n",
" (expected_68_low_2, 0.4),\n",
" expected_68_high_2 - expected_68_low_2,\n",
" 0.2,\n",
" linewidth=0,\n",
" edgecolor=\"none\",\n",
" facecolor=\"green\",\n",
" alpha=0.5,\n",
")\n",
"ax.add_patch(rect_68_2)\n",
"ax.plot([expected_median_2, expected_median_2], [0.4, 0.6], \"k--\")\n",
"ax.plot([observed_value_2, observed_value_2], [0.4, 0.6], \"k-\", linewidth=2)\n",
"\n",
"# Set the x and y axis labels\n",
"ax.set_xlabel(r\"95% CL limit on $\\sigma(pp \\rightarrow HH) / \\sigma$\")\n",
"ax.set_yticks([0.8, 0.5])\n",
"ax.set_yticklabels(\n",
" [\n",
" r\"$\\kappa_{\\lambda} = 1, \\kappa_{t} = 2, \\kappa_{V} = 1$\",\n",
" r\"$\\kappa_{\\lambda} = 1, \\kappa_{t} = 1, \\kappa_{V} = 0$\",\n",
" ]\n",
")\n",
"\n",
"# Set the title\n",
"ax.set_title(\"CMS Work in Progress\")\n",
"\n",
"# Set x-axis to logarithmic scale\n",
"ax.set_xscale(\"log\")\n",
"\n",
"# Add a legend in the top right without the limit values\n",
"legend_elements = [\n",
" patches.Patch(color=\"green\", alpha=0.5, label=\"68% expected\"),\n",
" patches.Patch(color=\"yellow\", alpha=0.5, label=\"95% expected\"),\n",
" plt.Line2D([0], [0], color=\"k\", linestyle=\"--\", label=\"Median expected\"),\n",
" plt.Line2D([0], [0], color=\"k\", linewidth=2, label=\"Observed\"),\n",
"]\n",
"ax.legend(handles=legend_elements, loc=\"upper right\")\n",
"\n",
"# Set x-axis limits\n",
"ax.set_xlim(0.1, 200)\n",
"\n",
"# Use scientific notation for the x-axis\n",
"ax.xaxis.set_major_formatter(plt.ScalarFormatter(useMathText=True))\n",
"ax.ticklabel_format(style=\"sci\", axis=\"x\", scilimits=(0, 0))\n",
"\n",
"# Show grid\n",
"ax.grid(True, axis=\"x\")\n",
"\n",
"# Apply CMS label with `mplhep`\n",
"hep.cms.label(ax=ax, data=True, lumi=138, com=13)\n",
"\n",
"# Adjust layout\n",
"plt.tight_layout()\n",
"\n",
"# Show the plot\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import matplotlib.patches as patches\n",
"\n",
"# Define the observed and expected data\n",
"observed_value = 142\n",
"expected_median = 69\n",
"expected_68_low, expected_68_high = 50, 80 # 68% confidence interval\n",
"expected_95_low, expected_95_high = 40, 100 # 95% confidence interval\n",
"\n",
"# Create the plot with custom dimensions\n",
"fig, ax = plt.subplots(figsize=(8, 2)) # Adjust the dimensions as needed\n",
"\n",
"# Add rectangles for the confidence intervals\n",
"# 95% confidence interval\n",
"rect_95 = patches.Rectangle(\n",
" (expected_95_low, -0.1),\n",
" expected_95_high - expected_95_low,\n",
" 0.2,\n",
" linewidth=0,\n",
" edgecolor=\"none\",\n",
" facecolor=\"yellow\",\n",
" alpha=0.5,\n",
" label=\"95% expected\",\n",
")\n",
"ax.add_patch(rect_95)\n",
"\n",
"# 68% confidence interval\n",
"rect_68 = patches.Rectangle(\n",
" (expected_68_low, -0.1),\n",
" expected_68_high - expected_68_low,\n",
" 0.2,\n",
" linewidth=0,\n",
" edgecolor=\"none\",\n",
" facecolor=\"green\",\n",
" alpha=0.5,\n",
" label=\"68% expected\",\n",
")\n",
"ax.add_patch(rect_68)\n",
"\n",
"# Plot the expected median line\n",
"ax.plot([expected_median, expected_median], [-0.1, 0.1], \"k--\", label=\"Median expected: 69\")\n",
"\n",
"# Plot the observed value as a solid black line\n",
"ax.plot([observed_value, observed_value], [-0.1, 0.1], \"k-\", linewidth=2, label=\"Observed: 142\")\n",
"\n",
"# Set the x and y axis labels\n",
"ax.set_xlabel(r\"95% CL limit on $\\sigma(pp \\rightarrow HH) / \\sigma$\")\n",
"ax.set_yticks([]) # Remove y-axis ticks\n",
"\n",
"# Set the title\n",
"ax.set_title(\"CMS Work in Progress\")\n",
"\n",
"# Add a legend\n",
"ax.legend()\n",
"\n",
"# Set x-axis limits\n",
"ax.set_xlim(0, 150) # Adjust based on the range of your data\n",
"ax.set_ylim(-0.2, 0.3) # Adjust y-axis to provide space for the kappa values\n",
"\n",
"# Use scientific notation for the x-axis\n",
"ax.xaxis.set_major_formatter(plt.ScalarFormatter(useMathText=True))\n",
"ax.ticklabel_format(style=\"sci\", axis=\"x\", scilimits=(0, 0))\n",
"\n",
"# Add kappa values above the observed limit within the figure box\n",
"kappa_values = r\"$\\kappa_{\\lambda} = 1, \\kappa_{t} = 2, \\kappa_{V} = 1$\"\n",
"plt.text(\n",
" observed_value,\n",
" 0.2,\n",
" kappa_values,\n",
" fontsize=12,\n",
" horizontalalignment=\"center\",\n",
" verticalalignment=\"bottom\",\n",
")\n",
"\n",
"# Show grid\n",
"ax.grid(True, axis=\"x\")\n",
"\n",
"# Show the plot\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "python310",
"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.11"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
9 changes: 9 additions & 0 deletions paper/tables/nonres_lpsfs.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\multirow{4}{*}{ggF} & SM ggF \HH & $1.05 \pm 0.24$ & 0.16 & 0.05 & 0.00 & 0.16 \\
& SM VBF \HH & $1.17 \pm 0.45$ & 0.35 & 0.05 & 0.00 & 0.16 \\
& VBF \HH ($\kapvv = 0$) & $1.09 \pm 0.18$ & 0.02 & 0.04 & 0.01 & 0.15 \\
& VBF \HH ($\kapvv = 2$) & $1.10 \pm 0.18$ & 0.02 & 0.05 & 0.01 & 0.15 \\
\midrule
\multirow{4}{*}{VBF} & SM ggF \HH & $0.95 \pm 0.28$ & 0.26 & 0.08 & 0.01 & 0.12 \\
& SM VBF \HH & $1.08 \pm 0.46$ & 0.38 & 0.05 & 0.01 & 0.19 \\
& VBF \HH ($\kapvv = 0$) & $0.93 \pm 0.27$ & 0.16 & 0.06 & 0.02 & 0.23 \\
& VBF \HH ($\kapvv = 2$) & $0.94 \pm 0.27$ & 0.16 & 0.05 & 0.02 & 0.23
Loading

0 comments on commit 6a433c7

Please sign in to comment.