Skip to content

Commit c9d7be2

Browse files
billy000400Billy Lipre-commit-ci[bot]jmduarte
authored
GloParT option in PostProcessTT + updated BDT SF measurement (#246)
* init commit: adding glopart option * add: load tt sf * debug: typo * style: pre-commit fixes * dev: add location arg to include ucsd file prefix * feat: skip empty output parquet files * dev * style: pre-commit fixes * dev: use the previous TT txbbsf instead of the ones used in Postprocess.py * dev: include more samples * dev: comment out make_plot * style: pre-commit fixes * dev * style: pre-commit fixes * dev: add vbf plots, save the correction to a new file * style: pre-commit fixes * dev: save vbf corrections too * style: pre-commit fixes * update ttbar correction loading * add corrections * style: pre-commit fixes * clean up jsons * style: pre-commit fixes * updates * style: pre-commit fixes * updates for new bdt sfs * style: pre-commit fixes * df * style: pre-commit fixes * bdt bins * style: pre-commit fixes * adjust binning to reflect current ggF WP and more VBF stats * style: pre-commit fixes * update sfs * style: pre-commit fixes * Fix * update subtracted plots --------- Co-authored-by: Billy Li <li000400@umn.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Javier Duarte <jduarte@ucsd.edu>
1 parent 2618626 commit c9d7be2

17 files changed

Lines changed: 722 additions & 368 deletions

src/HH4b/boosted/correlations.ipynb

Lines changed: 60 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -27,7 +27,7 @@
2727
},
2828
{
2929
"cell_type": "code",
30-
"execution_count": 2,
30+
"execution_count": null,
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
@@ -38,7 +38,7 @@
3838
},
3939
{
4040
"cell_type": "code",
41-
"execution_count": 3,
41+
"execution_count": null,
4242
"metadata": {},
4343
"outputs": [],
4444
"source": [
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"cell_type": "code",
65-
"execution_count": 8,
65+
"execution_count": null,
6666
"metadata": {},
6767
"outputs": [],
6868
"source": [
@@ -174,7 +174,7 @@
174174
},
175175
{
176176
"cell_type": "code",
177-
"execution_count": 10,
177+
"execution_count": null,
178178
"metadata": {},
179179
"outputs": [],
180180
"source": [
@@ -462,23 +462,11 @@
462462
"metadata": {},
463463
"outputs": [],
464464
"source": [
465-
"year = \"2023BPix\"\n",
466-
"with open(f\"{package_path}/corrections/data/txbb_sfs/{year}/sf_txbbv11_Jun14.json\") as f:\n",
467-
" txbb_sf_old = json.load(f)\n",
468-
"with open(f\"{package_path}/corrections/data/txbb_sfs/{year}/sf_txbbv11_Jun26_freezeSFs.json\") as f:\n",
469-
" txbb_sf = json.load(f)\n",
470-
"with open(\n",
471-
" f\"{package_path}/corrections/data/txbb_sfs/{year}/sf_txbbv11_Jun27_freezeSFs_finerWPs.json\"\n",
472-
") as f:\n",
473-
" txbb_sf_fine = json.load(f)\n",
474-
"with open(\n",
475-
" f\"{package_path}/corrections/data/txbb_sfs/{year}/sf_txbbv11_Jun29_freezeSFs_zoomedInWPs.json\"\n",
476-
") as f:\n",
477-
" txbb_sf_zoom = json.load(f)\n",
465+
"year = \"2023\"\n",
478466
"with open(\n",
479-
" f\"{package_path}/corrections/data/txbb_sfs/{year}/sf_txbbv11_Jul3_freezeSFs_newPt.json\"\n",
467+
" f\"{package_path}/corrections/data/txbb_sfs/glopart-v2/{year}/sf_glopart-v2_freezeSFs_trial20241011.json\"\n",
480468
") as f:\n",
481-
" txbb_sf_new_pt = json.load(f)"
469+
" txbb_sf = json.load(f)"
482470
]
483471
},
484472
{
@@ -487,110 +475,45 @@
487475
"metadata": {},
488476
"outputs": [],
489477
"source": [
490-
"txbb_sf_new = {}\n",
491-
"\n",
492-
"ptbins = np.array([200, 250, 300, 400, 500, 100000])\n",
493-
"\n",
494-
"for i in range(len(ptbins) - 1):\n",
495-
" txbb_sf_new[f\"WP3_pt{ptbins[i]}to{ptbins[i+1]}\"] = txbb_sf_zoom[\n",
496-
" f\"WP2_pt{ptbins[i]}to{ptbins[i+1]}\"\n",
497-
" ]\n",
498-
" txbb_sf_new[f\"WP4_pt{ptbins[i]}to{ptbins[i+1]}\"] = txbb_sf_fine[\n",
499-
" f\"WP2_pt{ptbins[i]}to{ptbins[i+1]}\"\n",
500-
" ]\n",
501-
" txbb_sf_new[f\"WP5_pt{ptbins[i]}to{ptbins[i+1]}\"] = txbb_sf_fine[\n",
502-
" f\"WP3_pt{ptbins[i]}to{ptbins[i+1]}\"\n",
503-
" ]\n",
504-
" txbb_sf_new[f\"WP6_pt{ptbins[i]}to{ptbins[i+1]}\"] = txbb_sf_fine[\n",
505-
" f\"WP4_pt{ptbins[i]}to{ptbins[i+1]}\"\n",
506-
" ]\n",
507-
"\n",
508-
"ptbins_new = np.array([200, 400, 100000])\n",
509-
"\n",
510-
"for i in range(len(ptbins_new) - 1):\n",
511-
" txbb_sf_new[f\"WP1_pt{ptbins_new[i]}to{ptbins_new[i+1]}\"] = txbb_sf_new_pt[\n",
512-
" f\"WP1_pt{ptbins_new[i]}to{ptbins_new[i+1]}\"\n",
513-
" ]\n",
514-
" txbb_sf_new[f\"WP2_pt{ptbins_new[i]}to{ptbins_new[i+1]}\"] = txbb_sf_new_pt[\n",
515-
" f\"WP2_pt{ptbins_new[i]}to{ptbins_new[i+1]}\"\n",
516-
" ]\n",
517-
"\n",
518-
"# with open(\n",
519-
"# f\"{package_path}/corrections/data/txbb_sfs/{year}/sf_txbbv11_Jul3_freezeSFs_combinedWPs.json\",\n",
520-
"# \"w\",\n",
521-
"# ) as f:\n",
522-
"# json.dump(txbb_sf_new, f, indent=4)"
523-
]
524-
},
525-
{
526-
"cell_type": "code",
527-
"execution_count": null,
528-
"metadata": {},
529-
"outputs": [],
530-
"source": [
531-
"y_new, yerr_low_new, yerr_high_new = {}, {}, {}\n",
478+
"y, yerr_low, yerr_high = {}, {}, {}\n",
479+
"ptbins = np.array([200, 400, 100000])\n",
532480
"wps = {\n",
533-
" \"WP1\": [0.998, 1],\n",
534-
" \"WP2\": [0.995, 0.998],\n",
535-
" \"WP3\": [0.99, 0.995],\n",
536-
" \"WP4\": [0.975, 0.99],\n",
537-
" \"WP5\": [0.95, 0.975],\n",
538-
" \"WP6\": [0.92, 0.95],\n",
481+
" \"WP1\": [0.99, 1],\n",
482+
" \"WP2\": [0.97, 0.99],\n",
483+
" \"WP3\": [0.94, 0.97],\n",
484+
" \"WP4\": [0.9, 0.94],\n",
485+
" \"WP5\": [0.8, 0.9],\n",
539486
"}\n",
540-
"for wp in range(0, 2):\n",
541-
" y_new[wp] = []\n",
542-
" yerr_low_new[wp] = []\n",
543-
" yerr_high_new[wp] = []\n",
544-
" for i in range(len(ptbins_new) - 1):\n",
545-
" y_new[wp].append(\n",
546-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins_new[i]}to{ptbins_new[i+1]}\"][\"final\"][\"central\"]\n",
547-
" )\n",
548-
" yerr_low_new[wp].append(\n",
549-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins_new[i]}to{ptbins_new[i+1]}\"][\"final\"][\"low\"]\n",
550-
" )\n",
551-
" yerr_high_new[wp].append(\n",
552-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins_new[i]}to{ptbins_new[i+1]}\"][\"final\"][\"high\"]\n",
553-
" )\n",
554-
"for wp in range(2, 6):\n",
555-
" y_new[wp] = []\n",
556-
" yerr_low_new[wp] = []\n",
557-
" yerr_high_new[wp] = []\n",
487+
"extended_wps = [0.8, 0.9, 0.94, 0.97, 0.99, 1]\n",
488+
"\n",
489+
"for wp in range(0, 5):\n",
490+
" y[wp] = []\n",
491+
" yerr_low[wp] = []\n",
492+
" yerr_high[wp] = []\n",
558493
" for i in range(len(ptbins) - 1):\n",
559-
" y_new[wp].append(txbb_sf_new[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"central\"])\n",
560-
" yerr_low_new[wp].append(\n",
561-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"low\"]\n",
562-
" )\n",
563-
" yerr_high_new[wp].append(\n",
564-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"high\"]\n",
565-
" )\n",
494+
" y[wp].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"central\"])\n",
495+
" yerr_low[wp].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"low\"])\n",
496+
" yerr_high[wp].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"high\"])\n",
566497
"\n",
567498
"plt.figure()\n",
568499
"# horizaontal line at 1\n",
569500
"plt.axhline(1, color=\"gray\", linestyle=\"--\", alpha=0.5)\n",
570501
"# vertical line at each ptbin\n",
571502
"for ptbin in ptbins[:-1]:\n",
572503
" plt.axvline(ptbin, color=\"gray\", linestyle=\"-\", alpha=0.5)\n",
573-
"for wp in range(0, 2):\n",
504+
"for wp in range(0, 5):\n",
574505
" plt.errorbar(\n",
575-
" y=y_new[wp],\n",
576-
" x=ptbins_new[:-1] + (wp + 1) * 5,\n",
577-
" yerr=[yerr_low_new[wp], yerr_high_new[wp]],\n",
578-
" fmt=\"o\",\n",
579-
" label=f\"WP{wp+1} {wps[f'WP{wp+1}']}\",\n",
580-
" )\n",
581-
"for wp in range(2, 6):\n",
582-
" plt.errorbar(\n",
583-
" y=y_new[wp],\n",
506+
" y=y[wp],\n",
584507
" x=ptbins[:-1] + (wp + 1) * 5,\n",
585-
" yerr=[yerr_low_new[wp], yerr_high_new[wp]],\n",
508+
" yerr=[yerr_low[wp], yerr_high[wp]],\n",
586509
" fmt=\"o\",\n",
587510
" label=f\"WP{wp+1} {wps[f'WP{wp+1}']}\",\n",
588511
" )\n",
589512
"plt.xlabel(\"$p_T (j)$ [GeV]\")\n",
590513
"plt.ylabel(\"SF (flvB)\")\n",
591514
"plt.ylim([0, 2])\n",
592515
"plt.legend(title=year)\n",
593-
"plt.savefig(f\"new_txbb_sf_{year}.pdf\")"
516+
"plt.savefig(f\"txbb_sf_{year}.pdf\")"
594517
]
595518
},
596519
{
@@ -599,87 +522,55 @@
599522
"metadata": {},
600523
"outputs": [],
601524
"source": [
602-
"y_new, yerr_low_new, yerr_high_new = [], [], []\n",
603-
"wps = {\n",
604-
" \"WP1\": [0.998, 1],\n",
605-
" \"WP2\": [0.995, 0.998],\n",
606-
" \"WP3\": [0.99, 0.995],\n",
607-
" \"WP4\": [0.975, 0.99],\n",
608-
" \"WP5\": [0.95, 0.975],\n",
609-
" \"WP6\": [0.92, 0.95],\n",
610-
"}\n",
525+
"y, yerr_low, yerr_high = [], [], []\n",
526+
"\n",
611527
"for i in range(len(ptbins) - 1):\n",
612-
" y_new.append([])\n",
613-
" yerr_low_new.append([])\n",
614-
" yerr_high_new.append([])\n",
615-
" for wp in reversed(range(2, 6)):\n",
616-
" y_new[i].append(txbb_sf_new[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"central\"])\n",
617-
" yerr_low_new[i].append(\n",
618-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"low\"]\n",
619-
" )\n",
620-
" yerr_high_new[i].append(\n",
621-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"high\"]\n",
622-
" )\n",
623-
" for wp in reversed(range(0, 2)):\n",
624-
" for j in range(len(ptbins_new) - 1):\n",
625-
" if ptbins[i] >= ptbins_new[j] and ptbins[i + 1] <= ptbins_new[j + 1]:\n",
626-
" y_new[i].append(\n",
627-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins_new[j]}to{ptbins_new[j+1]}\"][\"final\"][\n",
628-
" \"central\"\n",
629-
" ]\n",
630-
" )\n",
631-
" yerr_low_new[i].append(\n",
632-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins_new[j]}to{ptbins_new[j+1]}\"][\"final\"][\"low\"]\n",
633-
" )\n",
634-
" yerr_high_new[i].append(\n",
635-
" txbb_sf_new[f\"WP{wp+1}_pt{ptbins_new[j]}to{ptbins_new[j+1]}\"][\"final\"][\"high\"]\n",
636-
" )\n",
637-
" break\n",
528+
" y.append([])\n",
529+
" yerr_low.append([])\n",
530+
" yerr_high.append([])\n",
531+
" for wp in reversed(range(0, 5)):\n",
532+
" y[i].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"central\"])\n",
533+
" yerr_low[i].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"low\"])\n",
534+
" yerr_high[i].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"high\"])\n",
638535
"\n",
639536
"# make 5 subfigures\n",
640-
"fig, axs = plt.subplots(5, 1, figsize=(8, 30))\n",
537+
"fig, axs = plt.subplots(2, 1, figsize=(8, 12))\n",
641538
"for i in range(len(ptbins) - 1):\n",
642539
" plt.sca(axs[i])\n",
643540
" plt.axhline(1, color=\"gray\", linestyle=\"--\", alpha=0.5)\n",
644-
" x = [np.mean(wps[wp]) for wp in [\"WP6\", \"WP5\", \"WP4\", \"WP3\", \"WP2\", \"WP1\"]]\n",
645-
" xerr = [(wps[wp][1] - wps[wp][0]) / 2 for wp in [\"WP6\", \"WP5\", \"WP4\", \"WP3\", \"WP2\", \"WP1\"]]\n",
541+
" x = [np.mean(wps[wp]) for wp in [\"WP5\", \"WP4\", \"WP3\", \"WP2\", \"WP1\"]]\n",
542+
" xerr = [(wps[wp][1] - wps[wp][0]) / 2 for wp in [\"WP5\", \"WP4\", \"WP3\", \"WP2\", \"WP1\"]]\n",
646543
" plt.errorbar(\n",
647-
" y=y_new[i][:-1],\n",
544+
" y=y[i][:-1],\n",
648545
" x=x[:-1],\n",
649546
" xerr=xerr[:-1],\n",
650-
" yerr=[yerr_low_new[i][:-1], yerr_high_new[i][:-1]],\n",
547+
" yerr=[yerr_low[i][:-1], yerr_high[i][:-1]],\n",
651548
" fmt=\"o\",\n",
652-
" label=f\"$[{ptbins[i]}, {ptbins[i+1]}]$ GeV\".replace(\"100000\", \"\\inf\"),\n",
549+
" label=f\"$[{ptbins[i]}, {ptbins[i+1]}]$ GeV\".replace(\"100000\", \"\\infty\"),\n",
653550
" )\n",
654-
" j = 0 if i < 3 else 1\n",
655551
" plt.errorbar(\n",
656-
" y=y_new[i][-2:],\n",
657-
" x=x[-2:],\n",
658-
" xerr=xerr[-2:],\n",
659-
" yerr=[yerr_low_new[i][-2:], yerr_high_new[i][-2:]],\n",
552+
" y=y[i][-1:],\n",
553+
" x=x[-1:],\n",
554+
" xerr=xerr[-1:],\n",
555+
" yerr=[yerr_low[i][-1:], yerr_high[i][-1:]],\n",
660556
" fmt=\"o\",\n",
661-
" label=f\"$[{ptbins_new[j]}, {ptbins_new[j+1]}]$ GeV\".replace(\"100000\", \"\\inf\"),\n",
662557
" )\n",
663-
" extended_wps = np.array([0.92, 0.95, 0.975, 0.99, 0.995, 0.998, 1])\n",
664-
" extended_y = np.array(y_new[i] + [y_new[i][-1]])\n",
665-
" extended_yerr_low = np.array(yerr_low_new[i] + [yerr_low_new[i][-1] * 3])\n",
666-
" extended_yerr_high = np.array(yerr_high_new[i] + [yerr_high_new[i][-1] * 3])\n",
558+
" extended_y = np.array(y[i] + [y[i][-1]])\n",
559+
" extended_yerr_low = np.array(yerr_low[i] + [yerr_low[i][-1] * 3])\n",
560+
" extended_yerr_high = np.array(yerr_high[i] + [yerr_high[i][-1] * 3])\n",
667561
" plt.fill_between(\n",
668-
" extended_wps[:-2],\n",
669-
" extended_y[:-2] - extended_yerr_low[:-2],\n",
670-
" extended_y[:-2] + extended_yerr_high[:-2],\n",
562+
" extended_wps[:-1],\n",
563+
" extended_y[:-1] - extended_yerr_low[:-1],\n",
564+
" extended_y[:-1] + extended_yerr_high[:-1],\n",
671565
" alpha=0.2,\n",
672566
" step=\"post\",\n",
673567
" )\n",
674568
" plt.fill_between(\n",
675-
" extended_wps[-3:-1],\n",
676-
" extended_y[-3] - extended_yerr_low[-3],\n",
677-
" extended_y[-3] + extended_yerr_high[-3],\n",
569+
" extended_wps[-2:-1],\n",
570+
" extended_y[-2] - extended_yerr_low[-2],\n",
571+
" extended_y[-2] + extended_yerr_high[-2],\n",
678572
" alpha=0.2,\n",
679573
" )\n",
680-
" # reset color to orange\n",
681-
" # print(plt.rcParams['axes.prop_cycle'].by_key()['color'])\n",
682-
" # plt.gca().set_prop_cycle(None)\n",
683574
" plt.plot()\n",
684575
" plt.fill_between(\n",
685576
" extended_wps[-2:],\n",
@@ -691,51 +582,9 @@
691582
" plt.xlabel(\"$T_{Xbb}$\")\n",
692583
" plt.ylabel(\"SF (flvB)\")\n",
693584
" plt.ylim([0, 2])\n",
694-
" plt.xlim([0.92, 1])\n",
585+
" plt.xlim([0.8, 1])\n",
695586
" plt.legend(title=year)\n",
696-
"plt.savefig(f\"new_txbb_sf_3x_{year}.pdf\")"
697-
]
698-
},
699-
{
700-
"cell_type": "code",
701-
"execution_count": null,
702-
"metadata": {},
703-
"outputs": [],
704-
"source": [
705-
"y_old, yerr_low_old, yerr_high_old = [], [], []\n",
706-
"wps = {\n",
707-
" \"WP1\": [0.975, 1],\n",
708-
" \"WP2\": [0.95, 0.975],\n",
709-
" \"WP3\": [0.92, 0.95],\n",
710-
"}\n",
711-
"for wp in range(0, 3):\n",
712-
" y_old.append([])\n",
713-
" yerr_low_old.append([])\n",
714-
" yerr_high_old.append([])\n",
715-
" for i in range(len(ptbins) - 1):\n",
716-
" y_old[wp].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"central\"])\n",
717-
" yerr_low_old[wp].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"low\"])\n",
718-
" yerr_high_old[wp].append(txbb_sf[f\"WP{wp+1}_pt{ptbins[i]}to{ptbins[i+1]}\"][\"final\"][\"high\"])\n",
719-
"\n",
720-
"plt.figure()\n",
721-
"# horizaontal line at 1\n",
722-
"plt.axhline(1, color=\"gray\", linestyle=\"--\", alpha=0.5)\n",
723-
"# vertical line at each ptbin\n",
724-
"for ptbin in ptbins[:-1]:\n",
725-
" plt.axvline(ptbin, color=\"gray\", linestyle=\"-\", alpha=0.5)\n",
726-
"for wp in range(0, 3):\n",
727-
" plt.errorbar(\n",
728-
" y=y_old[wp],\n",
729-
" x=ptbins[:-1] + (wp + 3) * 5,\n",
730-
" yerr=[yerr_low_old[wp], yerr_high_old[wp]],\n",
731-
" fmt=\"o\",\n",
732-
" label=f\"WP{wp+1} {wps[f'WP{wp+1}']}\",\n",
733-
" )\n",
734-
"plt.xlabel(\"$p_T (j)$ [GeV]\")\n",
735-
"plt.ylabel(\"SF (flvB)\")\n",
736-
"plt.ylim([0, 2])\n",
737-
"plt.legend(title=year)\n",
738-
"plt.savefig(f\"old_txbb_sf_{year}.pdf\")"
587+
"plt.savefig(f\"txbb_sf_3x_{year}.pdf\")"
739588
]
740589
},
741590
{
@@ -748,7 +597,7 @@
748597
],
749598
"metadata": {
750599
"kernelspec": {
751-
"display_name": "hh4b",
600+
"display_name": "Python 3 (ipykernel)",
752601
"language": "python",
753602
"name": "python3"
754603
},
@@ -766,5 +615,5 @@
766615
}
767616
},
768617
"nbformat": 4,
769-
"nbformat_minor": 2
618+
"nbformat_minor": 4
770619
}

0 commit comments

Comments
 (0)