Skip to content

Commit

Permalink
bdt 995 all sigs fix + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed Aug 26, 2024
1 parent 270f225 commit 7cfd53d
Show file tree
Hide file tree
Showing 118 changed files with 2,997 additions and 13 deletions.
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 @@ -51,7 +51,7 @@ if [[ -z $TAG ]]; then
exit 1
fi

io_args="--data-dir $data_dir --bdt-preds-dir $bdt_preds_dir --plot-dir ${MAIN_DIR}/plots/PostProcessing/$TAG --template-dir templates/$TAG $sig_samples --nonres-ggf-bdt-wp 0.994"
io_args="--data-dir $data_dir --bdt-preds-dir $bdt_preds_dir --plot-dir ${MAIN_DIR}/plots/PostProcessing/$TAG --template-dir templates/$TAG $sig_samples"

echo "get LP SFs first for all regions"
python -u postprocessing.py --year 2016 $io_args --lpsfs --nonres-regions $region
Expand Down
21 changes: 10 additions & 11 deletions src/HHbbVV/postprocessing/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def ratioHistPlot(
sig_keys, bg_keys, bg_colours, sig_scale_dict, bg_order, syst, variation
)

bg_tot = np.maximum(sum([hists[sample, :] for sample in bg_keys]).values(), 0.0)

if syst is not None and variation is None:
# plot up/down variations
wshift, wsamples = syst
Expand All @@ -325,7 +327,7 @@ def ratioHistPlot(
bg_sums.append(hists[f"{sample}_{wshift}_{shift}", :].values())
elif sample != "Hbb":
bg_sums.append(hists[sample, :].values())
bg_err.append(np.sum(bg_sums, axis=0))
bg_err.append(np.maximum(np.sum(bg_sums, axis=0), 0.0))

pre_divide_hists = hists
if divide_bin_width:
Expand Down Expand Up @@ -409,7 +411,6 @@ def ratioHistPlot(
if divide_bin_width:
raise NotImplementedError("Background error for divide bin width not checked yet")

bg_tot = sum([pre_divide_hists[sample, :] for sample in bg_keys])
if len(np.array(bg_err).shape) == 1:
bg_err = [bg_tot - bg_err, bg_tot + bg_err]

Expand All @@ -426,12 +427,12 @@ def ratioHistPlot(
)
else:
ax.stairs(
bg_tot.values(),
bg_tot,
hists.axes[1].edges,
color="black",
linewidth=3,
label="BG Total",
baseline=bg_tot.values(),
baseline=bg_tot,
)

ax.stairs(
Expand Down Expand Up @@ -479,23 +480,22 @@ def ratioHistPlot(
# plot ratio below
if plot_ratio:
if plot_data:
bg_tot = sum([pre_divide_hists[sample, :] for sample in bg_keys])
# new: plotting data errors (black lines) and background errors (shaded) separately
yerr = np.nan_to_num(
np.abs(
poisson_interval(pre_divide_hists[data_key, ...].values())
- pre_divide_hists[data_key, ...].values()
)
/ (bg_tot.values() + 1e-5)
/ (bg_tot + 1e-5)
)

# old version: using Garwood ratio intervals
# yerr = ratio_uncertainty(
# pre_divide_hists[data_key, :].values(), bg_tot.values(), "poisson"
# pre_divide_hists[data_key, :].values(), bg_tot, "poisson"
# )

hep.histplot(
pre_divide_hists[data_key, :] / (bg_tot.values() + 1e-5),
pre_divide_hists[data_key, :] / (bg_tot + 1e-5),
yerr=yerr,
ax=rax,
histtype="errorbar",
Expand All @@ -507,8 +507,8 @@ def ratioHistPlot(
# (bkg + err) / bkg
rax.fill_between(
np.repeat(hists.axes[1].edges, 2)[1:-1],
np.repeat((bg_err[0].values()) / bg_tot, 2),
np.repeat((bg_err[1].values()) / bg_tot, 2),
np.repeat((bg_err[0]) / bg_tot, 2),
np.repeat((bg_err[1]) / bg_tot, 2),
color="black",
alpha=0.1,
hatch="//",
Expand All @@ -526,7 +526,6 @@ def ratioHistPlot(
rax.grid()

if plot_significance:
bg_tot = sum([pre_divide_hists[sample, :] for sample in bg_keys]).values()
sigs = [pre_divide_hists[sig_key, :].values() for sig_key in sig_scale_dict]

if significance_dir == "left":
Expand Down
3 changes: 2 additions & 1 deletion src/HHbbVV/postprocessing/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ def parse_args():
parser.add_argument(
"--nonres-ggf-bdt-wp",
help="BDT WP for ggF signal region. If multiple arguments, will make templates for each.",
default=[0.9965],
default=[0.995],
nargs="*",
type=float,
)
Expand Down Expand Up @@ -2133,6 +2133,7 @@ def parse_args():
args.control_plots = True
args.filters = False

print(args)
return args


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,bbFatJetPt >= 300,VVFatJetPt >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,0 ≤ nGoodElectronsHbb < 0.9,0 ≤ nGoodMuonsHbb < 0.9
HHbbVV,0.9147081031687907,0.9147081031687907,0.9088022319312213,0.9037950499185726,0.30175414428376585,0.30112232829530405,0.2990202748826515
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6649531572120448,0.6617354385600798,0.2299036391879109,0.2295289421882006,0.2280924478485079
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6920514447111688,0.6892047021562906,0.3063302486063932,0.30550315963569236,0.30391351000104144
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.1863493648635597,1.17930333767202,0.39586526060371247,0.39514188691284224,0.39256694301449424
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.017030078444247275,0.016924919012766975,0.00579761879633008,0.0057790354556334165,0.0057248101820241174
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.041934826728792,9.02728294983494,2.4426924669829826,2.43781489891332,2.4243925435159057
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.23647158421826,15.20829496277662,4.13073889572393,4.120987792038875,4.10015685148764
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.017299990201845,0.017214419089199705,0.00846784274434387,0.008440107570873445,0.008373264656125586
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.123943352838433,8.11286122859791,2.1892512907726895,2.1837678445588895,2.1717354106435
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.0459311591300662,0.04565497610400018,0.014190872302543785,0.01416197212352274,0.014112105993637325
QCD,717986.216814939,956785.8146709627,948406.4124347997,941617.267942029,754552.8113641972,752984.4192876149,750107.2737808328
TT,63126.80979180276,63126.80979180276,62714.21430804499,62290.703474200425,49529.77449791308,44329.76646173106,39159.45860664165
ST,5417.824558008516,5417.824558008516,5380.176293677084,5350.773696634727,4335.103148326725,3970.1436871856044,3563.758325231233
W+Jets,9487.889178263631,9487.889178263631,9424.292575831972,9375.118673797197,7834.787103754956,7814.4993526839335,7789.446400547657
Z+Jets,12055.822300436781,12055.822300436781,11968.016139487008,11904.514452147456,6790.915177024769,6773.707406230397,6734.8455822324595
Diboson,544.751536187187,544.751536187187,541.5192000426408,539.5255957808083,336.0954273567496,320.18549221259616,303.48286314956806
ggFHbb,120.74204174793252,120.74204174793252,120.02707196890958,119.27175261578469,38.999571077551494,38.97813391667,38.788894151509346
VBFHbb,32.24173303425971,32.24173303425971,32.089487243194796,31.921442997500897,9.845327900626657,9.826780907273822,9.728638615140152
ZHbb,32.70020301080715,32.70020301080715,32.51666448179822,32.40029638484181,9.92855058278212,9.896574590344532,9.807368124790582
WHbb,56.014320595270185,56.014320595270185,55.69337399997595,55.51504919284625,19.11120104088777,19.06683717160466,18.91991542799836
ggZHbb,4.8805631912185055,4.8805631912185055,4.852821845932874,4.827078996358681,1.9281741450543308,1.9243343671398156,1.9080303961975615
ttHbb,156.94119216557863,156.94119216557863,155.9939482895008,154.97672213467678,97.04622661247781,85.884977667534,74.2696929751333
HWW,80.56791059341468,80.56791059341468,80.1332628058381,79.59897023669294,63.60672027477934,52.77270242090221,43.58177362660231
Data,1047903.0,1047903.0,1047903.0,1047903.0,863853.0,854944.0,844713.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,Pre-selection,QCD SF,bbFatJetPt_JER_down >= 300,VVFatJetPt_JER_down >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,0 ≤ nGoodElectronsHbb < 0.9,0 ≤ nGoodMuonsHbb < 0.9,bbFatJetPt >= 300,VVFatJetPt >= 300
HHbbVV,0.9147081031687907,0.9147081031687907,0.9086202562710456,0.9032729107620694,0.30136641526403185,0.30073459927557006,0.29863254586291754,,
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6650215844188102,0.6616978818114161,0.2299215770147511,0.2295468800150408,0.22811058948062643,,
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6920552540546806,0.6889646563286256,0.3060371693804962,0.30521008040979536,0.30362043077514445,,
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.1860618192897887,1.1784620440607205,0.395068883543628,0.39434550985275774,0.3918356130348024,,
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.017030649078712407,0.016911806406707055,0.005799982669244992,0.005778877997696238,0.00572465272408694,,
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.043185519276458,9.02815771027725,2.442574423607405,2.437696855537743,2.424358564304257,,
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.23819151213184,15.21085147798668,4.130793913429084,4.12104280974403,4.100149537665231,,
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.01731116970053962,0.01721529909865581,0.008463374900600396,0.008435639727129969,0.008371134586267433,,
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.124193038879898,8.112651573642607,2.1889068742669315,2.183430839763076,2.171398405847687,,
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.04594810143671735,0.04559847624848856,0.014189296739562046,0.014160396560541001,0.014110530430655587,,
QCD,717986.216814939,956785.8146709627,948364.0361544128,941611.8267485962,754496.0620880035,752936.7646611074,750077.8617081649,,
TT,63126.80979180276,63126.80979180276,62673.79614323329,62216.48155564703,49469.34874682441,44281.27331024803,39123.833732942854,,
ST,5417.824558008516,5417.824558008516,5377.353115354821,5346.142315388623,4331.322795140036,3966.3474558289413,3560.351662865544,,
W+Jets,9487.889178263631,9487.889178263631,9420.543436555281,9370.593747378542,7830.22486542637,7809.937114355349,7785.400628667634,,
Z+Jets,12055.822300436781,12055.822300436781,11963.681352389223,11895.51750751837,6787.97110352534,6771.117645697598,6732.151861603023,,
Diboson,544.751536187187,544.751536187187,541.5333279703598,539.5308044193844,336.208740931941,320.29880578778756,303.6720365276853,,
ggFHbb,120.74204174793252,120.74204174793252,120.07126024952862,119.40043805803371,39.08114940009345,39.05971223921196,38.87047247405131,,
VBFHbb,32.24173303425971,32.24173303425971,32.09098572075379,31.915490654706662,9.839370046175077,9.820823052822242,9.722680760688572,,
ZHbb,32.70020301080715,32.70020301080715,32.51229709989521,32.39048595448399,9.917885138845206,9.885909146407617,9.796702680853667,,
WHbb,56.014320595270185,56.014320595270185,55.68961912767411,55.51113359847001,19.10746601933774,19.063102150054632,18.916180406448333,,
ggZHbb,4.8805631912185055,4.8805631912185055,4.850277343583236,4.823413122979026,1.925879544563995,1.9220397666494795,1.905669229852938,,
ttHbb,156.94119216557863,156.94119216557863,155.94705721730352,154.8512284574327,96.96277123860979,85.81557467540266,74.21606240134093,,
HWW,80.56791059341468,80.56791059341468,80.06917628289587,79.44977797155293,63.490065562691505,52.68396852595001,43.51687144284523,,
Data,1047903.0,1047903.0,,,863853.0,854944.0,844713.0,1047903.0,1047903.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,Pre-selection,QCD SF,bbFatJetPt_JER_up >= 300,VVFatJetPt_JER_up >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,0 ≤ nGoodElectronsHbb < 0.9,0 ≤ nGoodMuonsHbb < 0.9,bbFatJetPt >= 300,VVFatJetPt >= 300
HHbbVV,0.9147081031687907,0.9147081031687907,0.9087910422523933,0.9039911771807736,0.30181419690901495,0.30118238092055316,0.29909776577343905,,
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6648232888972543,0.6615304688795937,0.22983874093189527,0.229464043932185,0.22802458789429447,,
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6919837261137559,0.6895359500254084,0.30660509644133715,0.3057780074706363,0.30418835783598547,,
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.1863320607318555,1.1793065385470574,0.39609963331825193,0.39537625962738165,0.3927919024361102,,
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.017017363606822954,0.016929960784848687,0.005800912409835287,0.005782329069138623,0.005728103795529325,,
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.040636795335303,9.026372449520458,2.442600216890031,2.4377226488203685,2.424321715421426,,
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.235710988413302,15.208705941882577,4.131227301165773,4.121476197480719,4.100645256929484,,
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.017297188158115442,0.01721631337755096,0.00847691805438527,0.008449182880914844,0.008380206286157436,,
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.123037690630078,8.112049494318502,2.188880801375314,2.1833973551615142,2.171395817825956,,
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.045925054049681675,0.04568813387406423,0.014201551410960465,0.01417265123193942,0.014122785102054006,,
QCD,717986.216814939,956785.8146709627,948644.7035294859,941689.1725997124,754715.5199723188,753134.7479301945,750251.9365345207,,
TT,63126.80979180276,63126.80979180276,62748.65359108715,62350.558550020374,49581.08106018262,44369.23332839295,39189.123306614805,,
ST,5417.824558008516,5417.824558008516,5380.019529035428,5352.781145230527,4336.103656997989,3970.877734250647,3563.181072832113,,
W+Jets,9487.889178263631,9487.889178263631,9424.098448265346,9376.427000646685,7837.1106797885595,7816.822928717539,7791.573471785453,,
Z+Jets,12055.822300436781,12055.822300436781,11970.280347915328,11907.501953889905,6792.360403864935,6775.275920925513,6736.3344008445665,,
Diboson,544.751536187187,544.751536187187,541.0881926888653,539.2414054191454,335.99317001586985,320.005274959971,303.302645896943,,
ggFHbb,120.74204174793252,120.74204174793252,120.07042524743345,119.27825223478067,38.98833072689881,38.96689356601732,38.77765380085667,,
VBFHbb,32.24173303425971,32.24173303425971,32.11233185743809,31.972834248054944,9.851790818054113,9.83324382470128,9.73510153256761,,
ZHbb,32.70020301080715,32.70020301080715,32.50629199227846,32.37127325754241,9.930739682671923,9.898763690234336,9.809557224680384,,
WHbb,56.014320595270185,56.014320595270185,55.67763486575412,55.48629077310594,19.102692705898072,19.05832883661496,18.911407093008663,,
ggZHbb,4.8805631912185055,4.8805631912185055,4.8517784616619,4.8285634978383225,1.9299360112620434,1.926057142399399,1.9095143794842424,,
ttHbb,156.94119216557863,156.94119216557863,156.03648620372667,155.10345329641785,97.15099751928513,85.95956128176189,74.32330052260997,,
HWW,80.56791059341468,80.56791059341468,80.16639644289663,79.67713590709836,63.657224321188984,52.8022508024436,43.60289736509357,,
Data,1047903.0,1047903.0,,,863853.0,854944.0,844713.0,1047903.0,1047903.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,Pre-selection,QCD SF,bbFatJetPt_JES_down >= 300,VVFatJetPt_JES_down >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,0 ≤ nGoodElectronsHbb < 0.9,0 ≤ nGoodMuonsHbb < 0.9,bbFatJetPt >= 300,VVFatJetPt >= 300
HHbbVV,0.9147081031687907,0.9147081031687907,0.9021974589337566,0.8921274934572291,0.29705561791796636,0.29642689137626504,0.29437353650447756,,
ggHH_kl_2p45_kt_1_HHbbVV,0.6688447704532685,0.6688447704532685,0.6606251851799471,0.654055669353281,0.22677336608932416,0.22640279403547958,0.22498524097615225,,
ggHH_kl_5_kt_1_HHbbVV,0.6956895087373941,0.6956895087373941,0.6877389328223249,0.6810698404272066,0.30238891530816125,0.3015618263374604,0.30001786451469337,,
ggHH_kl_0_kt_1_HHbbVV,1.1944766869755938,1.1944766869755938,1.176818579571213,1.1617121639970687,0.38796216995086197,0.3872387962599917,0.38481449923755306,,
VBFHHbbVV,0.017115373482989717,0.017115373482989717,0.016919511679774117,0.016710528233663646,0.005732277356836404,0.005713694016139741,0.0056594687425304425,,
qqHH_CV_1_C2V_0_kl_1_HHbbVV,9.060969753010587,9.060969753010587,9.022591570183286,8.993098263152001,2.43086720934544,2.426008810676389,2.4127860101235914,,
qqHH_CV_1p5_C2V_1_kl_1_HHbbVV,15.269096111629358,15.269096111629358,15.199677089537838,15.145129783948754,4.1073224143626,4.097571310677545,4.076854002554098,,
qqHH_CV_1_C2V_1_kl_2_HHbbVV,0.0173959132140592,0.0173959132140592,0.01720697227181179,0.017039203791830167,0.00836543907682782,0.008337703903357394,0.008276609606428141,,
qqHH_CV_1_C2V_2_kl_1_HHbbVV,8.138882127595444,8.138882127595444,8.1076359787108,8.084305121253376,2.1793140607739483,2.1738463597955895,2.161936336139963,,
qqHH_CV_1_C2V_1_kl_0_HHbbVV,0.04617824244896124,0.04617824244896124,0.045614762720094335,0.045084105521786697,0.013983637533200484,0.013954737354179441,0.013904871224294024,,
QCD,717986.216814939,956785.8146709627,938661.3615136005,924579.0079995885,741099.5872399932,739572.4777698454,736742.0701811812,,
TT,63126.80979180276,63126.80979180276,62281.26379618576,61419.84821786183,48827.039128703036,43710.71917983769,38629.947657615056,,
ST,5417.824558008516,5417.824558008516,5343.110583081037,5284.0364074716335,4279.58513599101,3920.5742801966826,3519.826141176559,,
W+Jets,9487.889178263631,9487.889178263631,9357.72731042376,9249.165805487482,7725.66712348136,7705.534925302555,7681.143967058058,,
Z+Jets,12055.822300436781,12055.822300436781,11862.409496423767,11728.495220567063,6691.981356684962,6675.643989547845,6637.486427045783,,
Diboson,544.751536187187,544.751536187187,538.0128172568578,533.0567491419495,332.7127077180938,316.8027725739403,300.24671632987963,,
ggFHbb,120.74204174793252,120.74204174793252,119.40071843999348,117.91244552095317,38.4118699348613,38.3904327739798,38.20119300881916,,
VBFHbb,32.24173303425971,32.24173303425971,31.963053181455805,31.627848698776596,9.698761154629285,9.680214161276451,9.582071869142782,,
ZHbb,32.70020301080715,32.70020301080715,32.31418583302164,32.04157172822267,9.808835150191184,9.776859157753595,9.687652692199643,,
WHbb,56.014320595270185,56.014320595270185,55.31129788288006,54.93711011186556,18.863712978242347,18.819349108959244,18.677488367729833,,
ggZHbb,4.8805631912185055,4.8805631912185055,4.818097766172652,4.7680686559651555,1.902902173155059,1.8991368209920378,1.8828778052970496,,
ttHbb,156.94119216557863,156.94119216557863,154.9802638394503,152.95156197255415,95.69624798737142,84.69558423256491,73.26421597631409,,
HWW,80.56791059341468,80.56791059341468,79.61251131832795,78.50954646527252,62.74209832945888,52.06892894790838,43.02795122389627,,
Data,1047903.0,1047903.0,,,863853.0,854944.0,844713.0,1047903.0,1047903.0
Loading

0 comments on commit 7cfd53d

Please sign in to comment.