Skip to content

Commit

Permalink
new templates
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed Mar 9, 2024
1 parent c0e56a1 commit e956b9e
Show file tree
Hide file tree
Showing 69 changed files with 1,607 additions and 13 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ repos:
rev: "v4.5.0"
hooks:
- id: check-added-large-files
args: ["--maxkb=2000"]
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
Expand Down
6 changes: 3 additions & 3 deletions src/HHbbVV/postprocessing/CreateDatacard.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
]
)

# TODO: float VJets normalization!
# TODO: float VJets normalization?

bg_keys = list(mc_samples.keys())
nonres_sig_keys_ggf = [
Expand All @@ -145,7 +145,7 @@
"qqHH_CV_1_C2V_1_kl_2_HHbbVV",
"qqHH_CV_1_C2V_2_kl_1_HHbbVV",
"qqHH_CV_1_C2V_1_kl_0_HHbbVV",
"qqHH_CV_0p5_C2V_1_kl_1_HHbbVV",
# "qqHH_CV_0p5_C2V_1_kl_1_HHbbVV",
]

if args.only_sm:
Expand Down Expand Up @@ -222,7 +222,7 @@
"pdf_qqbar": Syst(prior="lnN", samples=["ST"], value=1.027),
"pdf_Higgs_ggHH": Syst(prior="lnN", samples=nonres_sig_keys_ggf, value=1.030),
"pdf_Higgs_qqHH": Syst(prior="lnN", samples=nonres_sig_keys_vbf, value=1.021),
# TODO: add these for single Higgs backgrounds
# TODO: add these if fitting single Higgs backgrounds
# "pdf_Higgs_gg": Syst(prior="lnN", samples=ggfh_keys, value=1.019),
"QCDscale_ttbar": Syst(
prior="lnN",
Expand Down
2 changes: 1 addition & 1 deletion src/HHbbVV/postprocessing/bash_scripts/NonresTemplates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if [[ -z $TAG ]]; then
fi

# for year in 2016APV 2016 2017 2018
for year in 2016APV
for year in 2016 2017 2018
do
python -u postprocessing.py --year $year --data-dir "$data_dir" --templates \
--bdt-preds-dir "$MAIN_DIR/../data/skimmer/24Mar6AllYearsBDTVars/24_03_07_new_samples_max_depth_5/inferences" \
Expand Down
48 changes: 48 additions & 0 deletions src/HHbbVV/postprocessing/bash_scripts/NonresTemplatesScan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
# shellcheck disable=SC2086,SC2043

####################################################################################################
# Script for creating nonresonant templates scanning over variables
# Author: Raghav Kansal
####################################################################################################

MAIN_DIR="../../.."
data_dir="$MAIN_DIR/../data/skimmer/24Mar6AllYearsBDTVars"
TAG=""


options=$(getopt -o "" --long "tag:" -- "$@")
eval set -- "$options"

while true; do
case "$1" in
--tag)
shift
TAG=$1
;;
--)
shift
break;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
shift
done

if [[ -z $TAG ]]; then
echo "Tag required using the --tag option. Exiting"
exit 1
fi

for year in 2016APV 2016 2017 2018
do
python -u postprocessing.py --year $year --data-dir "$data_dir" --templates \
--bdt-preds-dir "$MAIN_DIR/../data/skimmer/24Mar6AllYearsBDTVars/24_03_07_new_samples_max_depth_5/inferences" \
--template-dir "templates/$TAG" --no-do-jshifts --lepton-veto "None Hbb HH"
done
47 changes: 39 additions & 8 deletions src/HHbbVV/postprocessing/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,26 @@ def get_nonres_selection_regions(
year: str,
txbb_wp: str = "MP",
bdt_wp: float = 0.998,
lepton_veto="None",
):
pt_cuts = [300, CUT_MAX_VAL]
txbb_cut = txbb_wps[year][txbb_wp]

if lepton_veto == "None":
lepton_cuts = {}
elif lepton_veto == "Hbb":
lepton_cuts = {
"nGoodElectronsHbb": [0, 0.9],
"nGoodMuonsHbb": [0, 0.9],
}
elif lepton_veto == "HH":
lepton_cuts = {
"nGoodElectronsHH": [0, 0.9],
"nGoodMuonsHH": [0, 0.9],
}
else:
raise ValueError(f"Invalid lepton veto: {lepton_veto}")

return {
# {label: {cutvar: [min, max], ...}, ...}
"pass": Region(
Expand All @@ -150,6 +166,7 @@ def get_nonres_selection_regions(
"VVFatJetPt": pt_cuts,
"BDTScore": [bdt_wp, CUT_MAX_VAL],
"bbFatJetParticleNetMD_Txbb": [txbb_cut, CUT_MAX_VAL],
**lepton_cuts,
},
label="Pass",
),
Expand All @@ -158,6 +175,7 @@ def get_nonres_selection_regions(
"bbFatJetPt": pt_cuts,
"VVFatJetPt": pt_cuts,
"bbFatJetParticleNetMD_Txbb": [0.8, txbb_cut],
**lepton_cuts,
},
label="Fail",
),
Expand Down Expand Up @@ -478,7 +496,12 @@ def main(args):
if args.resonant:
sig_scale_dict = None
else:
sig_scale_dict = {key: 10 for key in plot_sig_keys_nonres}
sig_scale_dict = {
"HHbbVV": 50,
"VBFHHbbVV": 1000,
"qqHH_CV_1_C2V_0_kl_1_HHbbVV": 10,
"qqHH_CV_1_C2V_2_kl_1_HHbbVV": 10,
}

for wps in scan_wps: # if not scanning, this will just be a single WP
cutstr = "_".join([f"{cut}_{wp}" for cut, wp in zip(scan_cuts, wps)]) if scan else ""
Expand Down Expand Up @@ -518,11 +541,7 @@ def main(args):
jshifts = [""] + jec_shifts + jmsr_shifts if args.do_jshifts else [""]
for jshift in jshifts:
print(jshift)
plot_dir = (
args.templates_plots_dir / cutstr / f"{'jshifts' if jshift != '' else ''}"
if args.plot_dir != ""
else ""
)
plot_dir = args.templates_plots_dir / cutstr if args.plot_dir != "" else ""
temps = get_templates(
events_dict,
bb_masks,
Expand Down Expand Up @@ -577,8 +596,12 @@ def _init(args):
scan_cuts = res_scan_cuts
shape_vars = res_shape_vars
elif not args.vbf:
scan = len(args.nonres_txbb_wp) > 1 or len(args.nonres_bdt_wp) > 1
scan_wps = list(itertools.product(args.nonres_txbb_wp, args.nonres_bdt_wp))
scan = (
len(args.nonres_txbb_wp) > 1 or len(args.nonres_bdt_wp) > 1 or len(args.lepton_veto) > 1
)
scan_wps = list(
itertools.product(args.nonres_txbb_wp, args.nonres_bdt_wp, args.lepton_veto)
)
scan_cuts = nonres_scan_cuts
shape_vars = nonres_shape_vars
else:
Expand Down Expand Up @@ -2053,6 +2076,14 @@ def parse_args():
type=float,
)

parser.add_argument(
"--lepton-veto",
help="lepton vetoes: None, Hbb, or HH",
default=["None"],
nargs="*",
type=str,
)

args = parser.parse_args()

if args.templates and args.template_dir == "":
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt >= 300,VVFatJetPt >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735
HHbbVV,0.9147081031687907,0.9147081031687907,0.9147081031687907,0.9088022319312213,0.9037950499185726,0.30175414428376585
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6688447704532685,0.6649531572120448,0.6617354385600798,0.2299036391879109
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6956895087373941,0.6920514447111688,0.6892047021562906,0.3063302486063932
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.1944766869755938,1.1863493648635597,1.17930333767202,0.39586526060371247
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.017115373482989717,0.017030078444247275,0.016924919012766975,0.00579761879633008
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.060969753010587,9.041934826728792,9.02728294983494,2.4426924669829826
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.269096111629358,15.23647158421826,15.20829496277662,4.13073889572393
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.0173959132140592,0.017299990201845,0.017214419089199705,0.00846784274434387
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.138882127595444,8.123943352838433,8.11286122859791,2.1892512907726895
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.04617824244896124,0.0459311591300662,0.04565497610400018,0.014190872302543785
QCD,717986.216814939,970717.8146709627,970717.8146709627,962216.3978416026,955328.3949004482,765540.0455045162
TT,63126.80979180276,63126.80979180276,63126.80979180276,62714.21430804499,62290.703474200425,49529.77449791308
ST,5417.824558008516,5417.824558008516,5417.824558008516,5380.176293677084,5350.773696634727,4335.103148326725
W+Jets,9487.889178263631,9487.889178263631,9487.889178263631,9424.292575831972,9375.118673797197,7834.787103754956
Z+Jets,12055.822300436781,12055.822300436781,12055.822300436781,11968.016139487008,11904.514452147456,6790.915177024769
Diboson,544.751536187187,544.751536187187,544.751536187187,541.5192000426408,539.5255957808083,336.0954273567496
ggFHbb,120.74204174793252,120.74204174793252,120.74204174793252,120.02707196890958,119.27175261578469,38.999571077551494
VBFHbb,32.24173303425971,32.24173303425971,32.24173303425971,32.089487243194796,31.921442997500897,9.845327900626657
ZHbb,32.70020301080715,32.70020301080715,32.70020301080715,32.51666448179822,32.40029638484181,9.92855058278212
WHbb,56.014320595270185,56.014320595270185,56.014320595270185,55.69337399997595,55.51504919284625,19.11120104088777
ggZHbb,4.8805631912185055,4.8805631912185055,4.8805631912185055,4.852821845932874,4.827078996358681,1.9281741450543308
ttHbb,156.94119216557863,156.94119216557863,156.94119216557863,155.9939482895008,154.97672213467678,97.04622661247781
HWW,80.56791059341468,80.56791059341468,80.56791059341468,80.1332628058381,79.59897023669294,63.60672027477934
Data,1061835.0,1061835.0,1061835.0,1061835.0,1061835.0,875363.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt_JER_down >= 300,VVFatJetPt_JER_down >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,bbFatJetPt >= 300,VVFatJetPt >= 300
HHbbVV,0.9147081031687907,0.9147081031687907,0.9147081031687907,0.9086202562710456,0.9032729107620694,0.30136641526403185,,
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6688447704532685,0.6650215844188102,0.6616978818114161,0.2299215770147511,,
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6956895087373941,0.6920552540546806,0.6889646563286256,0.3060371693804962,,
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.1944766869755938,1.1860618192897887,1.1784620440607205,0.395068883543628,,
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.017115373482989717,0.017030649078712407,0.016911806406707055,0.005799982669244992,,
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.060969753010587,9.043185519276458,9.02815771027725,2.442574423607405,,
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.269096111629358,15.23819151213184,15.21085147798668,4.130793913429084,,
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.0173959132140592,0.01731116970053962,0.01721529909865581,0.008463374900600396,,
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.138882127595444,8.124193038879898,8.112651573642607,2.1889068742669315,,
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.04617824244896124,0.04594810143671735,0.04559847624848856,0.014189296739562046,,
QCD,717986.216814939,970717.8146709627,970717.8146709627,962173.4045094895,955322.8744764234,765482.4698877732,,
TT,63126.80979180276,63126.80979180276,63126.80979180276,62673.79614323329,62216.48155564703,49469.34874682441,,
ST,5417.824558008516,5417.824558008516,5417.824558008516,5377.353115354821,5346.142315388623,4331.322795140036,,
W+Jets,9487.889178263631,9487.889178263631,9487.889178263631,9420.543436555281,9370.593747378542,7830.22486542637,,
Z+Jets,12055.822300436781,12055.822300436781,12055.822300436781,11963.681352389223,11895.51750751837,6787.97110352534,,
Diboson,544.751536187187,544.751536187187,544.751536187187,541.5333279703598,539.5308044193844,336.208740931941,,
ggFHbb,120.74204174793252,120.74204174793252,120.74204174793252,120.07126024952862,119.40043805803371,39.08114940009345,,
VBFHbb,32.24173303425971,32.24173303425971,32.24173303425971,32.09098572075379,31.915490654706662,9.839370046175077,,
ZHbb,32.70020301080715,32.70020301080715,32.70020301080715,32.51229709989521,32.39048595448399,9.917885138845206,,
WHbb,56.014320595270185,56.014320595270185,56.014320595270185,55.68961912767411,55.51113359847001,19.10746601933774,,
ggZHbb,4.8805631912185055,4.8805631912185055,4.8805631912185055,4.850277343583236,4.823413122979026,1.925879544563995,,
ttHbb,156.94119216557863,156.94119216557863,156.94119216557863,155.94705721730352,154.8512284574327,96.96277123860979,,
HWW,80.56791059341468,80.56791059341468,80.56791059341468,80.06917628289587,79.44977797155293,63.490065562691505,,
Data,1061835.0,1061835.0,1061835.0,,,875363.0,1061835.0,1061835.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt_JER_up >= 300,VVFatJetPt_JER_up >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,bbFatJetPt >= 300,VVFatJetPt >= 300
HHbbVV,0.9147081031687907,0.9147081031687907,0.9147081031687907,0.9087910422523933,0.9039911771807736,0.30181419690901495,,
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6688447704532685,0.6648232888972543,0.6615304688795937,0.22983874093189527,,
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6956895087373941,0.6919837261137559,0.6895359500254084,0.30660509644133715,,
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.1944766869755938,1.1863320607318555,1.1793065385470574,0.39609963331825193,,
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.017115373482989717,0.017017363606822954,0.016929960784848687,0.005800912409835287,,
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.060969753010587,9.040636795335303,9.026372449520458,2.442600216890031,,
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.269096111629358,15.235710988413302,15.208705941882577,4.131227301165773,,
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.0173959132140592,0.017297188158115442,0.01721631337755096,0.00847691805438527,,
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.138882127595444,8.123037690630078,8.112049494318502,2.188880801375314,,
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.04617824244896124,0.045925054049681675,0.04568813387406423,0.014201551410960465,,
QCD,717986.216814939,970717.8146709627,970717.8146709627,962458.1587531276,955401.3465800203,765705.1233537928,,
TT,63126.80979180276,63126.80979180276,63126.80979180276,62748.65359108715,62350.558550020374,49581.08106018262,,
ST,5417.824558008516,5417.824558008516,5417.824558008516,5380.019529035428,5352.781145230527,4336.103656997989,,
W+Jets,9487.889178263631,9487.889178263631,9487.889178263631,9424.098448265346,9376.427000646685,7837.1106797885595,,
Z+Jets,12055.822300436781,12055.822300436781,12055.822300436781,11970.280347915328,11907.501953889905,6792.360403864935,,
Diboson,544.751536187187,544.751536187187,544.751536187187,541.0881926888653,539.2414054191454,335.99317001586985,,
ggFHbb,120.74204174793252,120.74204174793252,120.74204174793252,120.07042524743345,119.27825223478067,38.98833072689881,,
VBFHbb,32.24173303425971,32.24173303425971,32.24173303425971,32.11233185743809,31.972834248054944,9.851790818054113,,
ZHbb,32.70020301080715,32.70020301080715,32.70020301080715,32.50629199227846,32.37127325754241,9.930739682671923,,
WHbb,56.014320595270185,56.014320595270185,56.014320595270185,55.67763486575412,55.48629077310594,19.102692705898072,,
ggZHbb,4.8805631912185055,4.8805631912185055,4.8805631912185055,4.8517784616619,4.8285634978383225,1.9299360112620434,,
ttHbb,156.94119216557863,156.94119216557863,156.94119216557863,156.03648620372667,155.10345329641785,97.15099751928513,,
HWW,80.56791059341468,80.56791059341468,80.56791059341468,80.16639644289663,79.67713590709836,63.657224321188984,,
Data,1061835.0,1061835.0,1061835.0,,,875363.0,1061835.0,1061835.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt_JES_down >= 300,VVFatJetPt_JES_down >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,bbFatJetPt >= 300,VVFatJetPt >= 300
HHbbVV,0.9147081031687907,0.9147081031687907,0.9147081031687907,0.9021974589337566,0.8921274934572291,0.29705561791796636,,
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6688447704532685,0.6606251851799471,0.654055669353281,0.22677336608932416,,
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6956895087373941,0.6877389328223249,0.6810698404272066,0.30238891530816125,,
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.1944766869755938,1.176818579571213,1.1617121639970687,0.38796216995086197,,
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.017115373482989717,0.016919511679774117,0.016710528233663646,0.005732277356836404,,
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.060969753010587,9.022591570183286,8.993098263152001,2.43086720934544,,
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.269096111629358,15.199677089537838,15.145129783948754,4.1073224143626,,
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.0173959132140592,0.01720697227181179,0.017039203791830167,0.00836543907682782,,
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.138882127595444,8.1076359787108,8.084305121253376,2.1793140607739483,,
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.04617824244896124,0.045614762720094335,0.045084105521786697,0.013983637533200484,,
QCD,717986.216814939,970717.8146709627,970717.8146709627,952329.4467716418,938042.036549902,751890.9255845926,,
TT,63126.80979180276,63126.80979180276,63126.80979180276,62281.26379618576,61419.84821786183,48827.039128703036,,
ST,5417.824558008516,5417.824558008516,5417.824558008516,5343.110583081037,5284.0364074716335,4279.58513599101,,
W+Jets,9487.889178263631,9487.889178263631,9487.889178263631,9357.72731042376,9249.165805487482,7725.66712348136,,
Z+Jets,12055.822300436781,12055.822300436781,12055.822300436781,11862.409496423767,11728.495220567063,6691.981356684962,,
Diboson,544.751536187187,544.751536187187,544.751536187187,538.0128172568578,533.0567491419495,332.7127077180938,,
ggFHbb,120.74204174793252,120.74204174793252,120.74204174793252,119.40071843999348,117.91244552095317,38.4118699348613,,
VBFHbb,32.24173303425971,32.24173303425971,32.24173303425971,31.963053181455805,31.627848698776596,9.698761154629285,,
ZHbb,32.70020301080715,32.70020301080715,32.70020301080715,32.31418583302164,32.04157172822267,9.808835150191184,,
WHbb,56.014320595270185,56.014320595270185,56.014320595270185,55.31129788288006,54.93711011186556,18.863712978242347,,
ggZHbb,4.8805631912185055,4.8805631912185055,4.8805631912185055,4.818097766172652,4.7680686559651555,1.902902173155059,,
ttHbb,156.94119216557863,156.94119216557863,156.94119216557863,154.9802638394503,152.95156197255415,95.69624798737142,,
HWW,80.56791059341468,80.56791059341468,80.56791059341468,79.61251131832795,78.50954646527252,62.74209832945888,,
Data,1061835.0,1061835.0,1061835.0,,,875363.0,1061835.0,1061835.0
Loading

0 comments on commit e956b9e

Please sign in to comment.