Skip to content

Commit

Permalink
update limits
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed Aug 26, 2023
1 parent b276749 commit ce368e6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,8 @@
"metadata": {},
"outputs": [],
"source": [
"def scatter2d(arr, title, name):\n",
" fig, ax = plt.subplots(figsize=(14, 12))\n",
" mappable = plt.scatter(\n",
" arr[:, 0],\n",
" arr[:, 1],\n",
" s=150,\n",
" c=arr[:, 2],\n",
" cmap=\"turbo\",\n",
" norm=matplotlib.colors.LogNorm(vmin=0.01, vmax=100),\n",
" )\n",
" plt.title(title)\n",
" plt.xlabel(r\"$m_X$ (GeV)\")\n",
" plt.ylabel(r\"$m_Y$ (GeV)\")\n",
" plt.colorbar(mappable)\n",
" plt.savefig(name, bbox_inches=\"tight\")"
"plot_dir = \"../../../../plots/XHY/Limits/23Aug24\"\n",
"_ = os.system(f\"mkdir -p {plot_dir}\")"
]
},
{
Expand All @@ -68,18 +55,15 @@
"metadata": {},
"outputs": [],
"source": [
"plot_dir = \"../../../plots/XHY/Limits/Apr14\"\n",
"_ = os.system(f\"mkdir -p {plot_dir}\")"
"cards_dir = \"/eos/uscms/store/user/rkansal/bbVV/cards/Apr11\"\n",
"samples = os.listdir(cards_dir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"cards_dir = \"/eos/uscms/store/user/rkansal/bbVV/cards/Apr11\"\n",
"samples = os.listdir(cards_dir)"
"Load / process limits"
]
},
{
Expand Down Expand Up @@ -107,25 +91,17 @@
" nums += 1\n",
"\n",
" if nums == 5:\n",
" break"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"limits[\"50.0\"]"
" break\n",
"\n",
"for key in limits:\n",
" limits[key] = np.array(limits[key])"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"len(limits[\"50.0\"])"
"Plot"
]
},
{
Expand All @@ -134,8 +110,21 @@
"metadata": {},
"outputs": [],
"source": [
"for key in limits:\n",
" limits[key] = np.array(limits[key])"
"def scatter2d(arr, title, name):\n",
" fig, ax = plt.subplots(figsize=(14, 12))\n",
" mappable = plt.scatter(\n",
" arr[:, 0],\n",
" arr[:, 1],\n",
" s=150,\n",
" c=arr[:, 2],\n",
" cmap=\"turbo\",\n",
" norm=matplotlib.colors.LogNorm(vmin=0.01, vmax=100),\n",
" )\n",
" plt.title(title)\n",
" plt.xlabel(r\"$m_X$ (GeV)\")\n",
" plt.ylabel(r\"$m_Y$ (GeV)\")\n",
" plt.colorbar(mappable)\n",
" plt.savefig(name, bbox_inches=\"tight\")"
]
},
{
Expand All @@ -144,10 +133,17 @@
"metadata": {},
"outputs": [],
"source": [
"interpolated = {}\n",
"\n",
"for key, val in limits.items():\n",
" interpolated[key] = interpolate.LinearNDInterpolator(val[:, :2], np.log(val[:, 2]))"
"def colormesh(xx, yy, lims, label, name):\n",
" fig, ax = plt.subplots(figsize=(12, 8))\n",
" _ = plt.pcolormesh(\n",
" xx, yy, lims, norm=matplotlib.colors.LogNorm(vmin=0.05, vmax=1e4), cmap=\"turbo\"\n",
" )\n",
" # plt.title(title)\n",
" plt.xlabel(r\"$m_X$ (GeV)\")\n",
" plt.ylabel(r\"$m_Y$ (GeV)\")\n",
" plt.colorbar(label=label)\n",
" hep.cms.label(\"Work in Progress\", data=True, lumi=\"138\", ax=ax)\n",
" plt.savefig(name, bbox_inches=\"tight\")"
]
},
{
Expand All @@ -168,37 +164,12 @@
"metadata": {},
"outputs": [],
"source": [
"interpolated = {}\n",
"grids = {}\n",
"\n",
"for key, interp in interpolated.items():\n",
" grids[key] = np.exp(interp(xx, yy))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"grids[key]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def colormesh(xx, yy, lims, title, name):\n",
" fig, ax = plt.subplots(figsize=(12, 8))\n",
" # _ = plt.pcolormesh(xx, yy, lims, norm=matplotlib.colors.LogNorm(vmin=0.01, vmax=100))\n",
" _ = plt.pcolormesh(xx, yy, lims, norm=matplotlib.colors.LogNorm(), cmap=\"turbo\")\n",
" # plt.title(title)\n",
" plt.xlabel(r\"$m_X$ (GeV)\")\n",
" plt.ylabel(r\"$m_Y$ (GeV)\")\n",
" plt.colorbar(label=\"Expected exclusion limits (fb)\")\n",
" plt.savefig(name, bbox_inches=\"tight\")\n",
" hep.cms.label(\"Work in Progress\", data=True, lumi=\"138.0\", ax=ax)"
"for key, val in limits.items():\n",
" interpolated[key] = interpolate.LinearNDInterpolator(val[:, :2], np.log(val[:, 2]))\n",
" grids[key] = np.exp(interpolated[key](xx, yy))"
]
},
{
Expand All @@ -207,8 +178,13 @@
"metadata": {},
"outputs": [],
"source": [
"key = \"50.0\"\n",
"colormesh(xx, yy, grids[key], f\"Expected {key}% Limits\", f\"{plot_dir}/mesh_{key}_turbo.pdf\")"
"for key, grid in grids.items():\n",
" label = (\n",
" f\"{key}% expected exclusion limits (fb)\"\n",
" if key != \"50.0\"\n",
" else f\"Median expected exclusion limits (fb)\"\n",
" )\n",
" colormesh(xx, yy, grid, label, f\"{plot_dir}/mesh_{key}_turbo.pdf\")"
]
},
{
Expand All @@ -221,36 +197,6 @@
"val = limits[key]\n",
"scatter2d(val, f\"Expected {key}% Limit\", f\"{plot_dir}/scatter_{key}.pdf\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"key = \"50.0\"\n",
"arr = limits[key]\n",
"plt.figure(figsize=(12, 8))\n",
"_ = plt.pcolormesh(xx, yy, grids[key], norm=matplotlib.colors.LogNorm(vmin=0.01, vmax=100))\n",
"plt.scatter(\n",
" arr[:, 0],\n",
" arr[:, 1],\n",
" s=150,\n",
" c=arr[:, 2],\n",
" # cmap=\"turbo\",\n",
" norm=matplotlib.colors.LogNorm(vmin=0.01, vmax=100),\n",
")\n",
"plt.xlabel(r\"$m_X$ (GeV)\")\n",
"plt.ylabel(r\"$m_Y$ (GeV)\")\n",
"plt.colorbar()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion src/HHbbVV/processors/corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def get_jmsr(
smearing = np.random.normal(size=mass.shape)
# scale to JMR nom, down, up (minimum at 0)
jmr_nom, jmr_down, jmr_up = [
(smearing * max(jmrValues[mkey][year][i] - 1, 0) + 1) for i in range(3)
((smearing * max(jmrValues[mkey][year][i] - 1, 0)) + 1) for i in range(3)
]
jms_nom, jms_down, jms_up = jmsValues[mkey][year]

Expand Down

0 comments on commit ce368e6

Please sign in to comment.