Skip to content

Commit

Permalink
leptonvetoscan
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed Mar 9, 2024
1 parent e956b9e commit c895f19
Show file tree
Hide file tree
Showing 45 changed files with 564 additions and 14 deletions.
11 changes: 7 additions & 4 deletions src/HHbbVV/postprocessing/CreateDatacard.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
param: rl.NuisanceParameter(param, syst.prior) for param, syst in nuisance_params.items()
}

# TODO: pileupID, ECal firing, lepton IDs
# TODO: pileupID, lepton IDs

# dictionary of correlated shape systematics: name in templates -> name in cards, etc.
corr_year_shape_systs = {
Expand Down Expand Up @@ -300,9 +300,12 @@
uncorr_year_shape_systs = {
"pileup": Syst(name="CMS_pileup", prior="shape", samples=all_mc),
# TODO: add 2016APV template into this
# "L1EcalPrefiring": Syst(
# name="CMS_l1_ecal_prefiring", prior="shape", samples=all_mc, uncorr_years=["2016", "2017"]
# ),
"L1EcalPrefiring": Syst(
name="CMS_l1_ecal_prefiring",
prior="shape",
samples=all_mc,
uncorr_years=["2016APV", "2016", "2017"],
),
"JER": Syst(name="CMS_res_j", prior="shape", samples=all_mc),
"JMS": Syst(name=f"{CMS_PARAMS_LABEL}_jms", prior="shape", samples=all_mc),
"JMR": Syst(name=f"{CMS_PARAMS_LABEL}_jmr", prior="shape", samples=all_mc),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ 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"
--template-dir "templates/$TAG" --no-do-jshifts --lepton-veto "None" "Hbb" "HH" --sig-samples HHbbVV
done
19 changes: 10 additions & 9 deletions src/HHbbVV/postprocessing/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,25 @@ def get_nonres_selection_regions(
year: str,
txbb_wp: str = "MP",
bdt_wp: float = 0.998,
lepton_veto="None",
lepton_veto_wp="None",
):
pt_cuts = [300, CUT_MAX_VAL]
txbb_cut = txbb_wps[year][txbb_wp]

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

return {
# {label: {cutvar: [min, max], ...}, ...}
Expand Down Expand Up @@ -363,7 +363,7 @@ def get_res_selection_regions(
),
]

nonres_scan_cuts = ["txbb", "bdt"]
nonres_scan_cuts = ["txbb", "bdt", "lepton_veto"]
nonres_vbf_scan_cuts = ["txbb", "thww"] # TODO: add more cuts being scanned over
res_scan_cuts = ["txbb", "thww", "leadingpt", "subleadingpt"]

Expand Down Expand Up @@ -506,6 +506,7 @@ def main(args):
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 ""
template_dir = args.template_dir / cutstr / args.templates_name
(template_dir / "cutflows" / args.year).mkdir(parents=True, exist_ok=True)

cutargs = {f"{cut}_wp": wp for cut, wp in zip(scan_cuts, wps)}
if args.resonant:
Expand Down Expand Up @@ -904,7 +905,7 @@ def load_samples(
year: str,
filters: list = None,
columns: list = None,
hem_cleaning: bool = True,
hem_cleaning: bool = False,
variations: bool = True,
) -> dict[str, pd.DataFrame]:
"""
Expand Down Expand Up @@ -1192,7 +1193,7 @@ def load_bdt_preds(
events["BDTScore"] = bdt_preds[i : i + num_events, 0]
events["BDTScoreQCD"] = bdt_preds[i : i + num_events, 1]
events["BDTScoreTT"] = bdt_preds[i : i + num_events, 2]
events["BDTScoreVJets"] = 1 - np.sum(bdt_preds[i : i + num_events], axis=1)
events["BDTScoreZJets"] = 1 - np.sum(bdt_preds[i : i + num_events], axis=1)

if jec_jmsr_shifts and sample != data_key:
for jshift in jec_shifts + jmsr_shifts:
Expand All @@ -1202,7 +1203,7 @@ def load_bdt_preds(
events["BDTScore_" + jshift] = shift_preds[jshift][i : i + num_events, 0]
events["BDTScoreQCD_" + jshift] = shift_preds[jshift][i : i + num_events, 1]
events["BDTScoreTT_" + jshift] = shift_preds[jshift][i : i + num_events, 2]
events["BDTScoreVJets_" + jshift] = 1 - np.sum(
events["BDTScoreZJets_" + jshift] = 1 - np.sum(
shift_preds[jshift][i : i + num_events], axis=1
)

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,16 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt >= 300,VVFatJetPt >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9735,0 ≤ nGoodElectronsHH < 0.9,0 ≤ nGoodMuonsHH < 0.9
HHbbVV,0.9147081031687907,0.9147081031687907,0.9147081031687907,0.9088022319312213,0.9037950499185726,0.30175414428376585,0.30037113365179574,0.29562826254742125
QCD,717986.216814939,970717.8146709627,970717.8146709627,962216.3978416026,955328.3949004482,765540.0455045162,763273.8221732039,754991.1726389715
TT,63126.80979180276,63126.80979180276,63126.80979180276,62714.21430804499,62290.703474200425,49529.77449791308,43768.796048175915,36610.28886415474
ST,5417.824558008516,5417.824558008516,5417.824558008516,5380.176293677084,5350.773696634727,4335.103148326725,3943.1701625064798,3418.1563118628696
W+Jets,9487.889178263631,9487.889178263631,9487.889178263631,9424.292575831972,9375.118673797197,7834.787103754956,7817.129293149831,7759.030053757153
Z+Jets,12055.822300436781,12055.822300436781,12055.822300436781,11968.016139487008,11904.514452147456,6790.915177024769,6765.341305261672,6673.291625210607
Diboson,544.751536187187,544.751536187187,544.751536187187,541.5192000426408,539.5255957808083,336.0954273567496,319.7396958527538,299.43733315139815
ggFHbb,120.74204174793252,120.74204174793252,120.74204174793252,120.02707196890958,119.27175261578469,38.999571077551494,38.78189109039274,38.272107494245176
VBFHbb,32.24173303425971,32.24173303425971,32.24173303425971,32.089487243194796,31.921442997500897,9.845327900626657,9.801530845864143,9.608009804446692
ZHbb,32.70020301080715,32.70020301080715,32.70020301080715,32.51666448179822,32.40029638484181,9.92855058278212,9.878049364810785,9.6609207159397
WHbb,56.014320595270185,56.014320595270185,56.014320595270185,55.69337399997595,55.51504919284625,19.11120104088777,19.037810876794147,18.70293912981623
ggZHbb,4.8805631912185055,4.8805631912185055,4.8805631912185055,4.852821845932874,4.827078996358681,1.9281741450543308,1.91738059617006,1.8773335223627405
ttHbb,156.94119216557863,156.94119216557863,156.94119216557863,155.9939482895008,154.97672213467678,97.04622661247781,83.81171540130855,67.41081282055664
HWW,80.56791059341468,80.56791059341468,80.56791059341468,80.1332628058381,79.59897023669294,63.60672027477934,50.810598935127274,37.614146366686114
Data,1061835.0,1061835.0,1061835.0,1061835.0,1061835.0,875363.0,865204.0,848245.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt >= 300,VVFatJetPt >= 300,BDTScore >= 0.998,bbFatJetParticleNetMD_Txbb >= 0.9735,0 ≤ nGoodElectronsHH < 0.9,0 ≤ nGoodMuonsHH < 0.9
HHbbVV,0.9147081031687907,0.9147081031687907,0.9147081031687907,0.9088022319312213,0.9037950499185726,0.05441352339876381,0.03737274258601056,0.037311071905366894,0.036815987205584155
QCD,717986.216814939,970717.8146709627,970717.8146709627,962216.3978416026,955328.3949004482,28.987473683008364,0.5639335232714174,0.5639335232714174,0.5639335232714174
TT,63126.80979180276,63126.80979180276,63126.80979180276,62714.21430804499,62290.703474200425,9.956638177588577,1.5990511203879654,1.509247601557974,1.538365154433708
ST,5417.824558008516,5417.824558008516,5417.824558008516,5380.176293677084,5350.773696634727,1.0695126604080243,0.30245845618708966,0.30245845618708966,0.30245845618708966
W+Jets,9487.889178263631,9487.889178263631,9487.889178263631,9424.292575831972,9375.118673797197,2.579765822019367,0.8188762732166077,0.8188762732166077,0.8188762732166077
Z+Jets,12055.822300436781,12055.822300436781,12055.822300436781,11968.016139487008,11904.514452147456,1.3432418892387723,0.42252551921661946,0.42252551921661946,0.42252551921661946
Diboson,544.751536187187,544.751536187187,544.751536187187,541.5192000426408,539.5255957808083,0.0,0.0,0.0,0.0
ggFHbb,120.74204174793252,120.74204174793252,120.74204174793252,120.02707196890958,119.27175261578469,0.0,0.0,0.0,0.0
VBFHbb,32.24173303425971,32.24173303425971,32.24173303425971,32.089487243194796,31.921442997500897,0.0,0.0,0.0,0.0
ZHbb,32.70020301080715,32.70020301080715,32.70020301080715,32.51666448179822,32.40029638484181,0.0017282926164173262,0.0017282926164173262,0.0017282926164173262,0.0017282926164173262
WHbb,56.014320595270185,56.014320595270185,56.014320595270185,55.69337399997595,55.51504919284625,0.0032032489110863063,0.0015999289769654825,0.0015999289769654825,0.0015999289769654825
ggZHbb,4.8805631912185055,4.8805631912185055,4.8805631912185055,4.852821845932874,4.827078996358681,0.00040401257297512083,0.0,0.0,0.0
ttHbb,156.94119216557863,156.94119216557863,156.94119216557863,155.9939482895008,154.97672213467678,0.026779530104425155,0.012937011715639823,0.012937011715639823,0.012820677168142627
HWW,80.56791059341468,80.56791059341468,80.56791059341468,80.1332628058381,79.59897023669294,0.5483200146749663,0.18862053374335175,0.1839372034262029,0.17118706185362587
Data,1061835.0,1061835.0,1061835.0,1061835.0,1061835.0,103.0,18.0,18.0,17.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt >= 300,VVFatJetPt >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9737,0 ≤ nGoodElectronsHH < 0.9,0 ≤ nGoodMuonsHH < 0.9
HHbbVV,1.108127280079604,1.108127280079604,1.108127280079604,1.1005594143174928,1.0940812392241102,0.3689082675908363,0.36746805904444957,0.3618189711900976
QCD,900603.372757249,1219440.0804636534,1219440.0804636534,1208187.047601593,1199914.6854996895,968194.6958131382,965451.9415942215,955293.5245867345
TT,76537.02908224265,76537.02908224265,76537.02908224265,76036.67089183381,75504.25522211792,59756.04620421225,53003.468170514476,44397.03578687173
ST,6617.229257123121,6617.229257123121,6617.229257123121,6568.071623368754,6530.558860743446,5277.663381085969,4800.531262180159,4188.0582926224315
W+Jets,12421.273275458932,12421.273275458932,12421.273275458932,12341.31450378544,12265.115729916284,10267.98041055657,10243.5609054278,10174.271703690129
Z+Jets,14717.02364266734,14717.02364266734,14717.02364266734,14601.426751424733,14517.101697865306,8391.373012782422,8361.548495690613,8252.38285452732
Diboson,703.6912877316817,703.6912877316817,703.6912877316817,699.1389217855917,695.3097641927543,427.8095451515573,410.0556121167997,389.95026568113224
ggFHbb,138.81856362723408,138.81856362723408,138.81856362723408,138.12124620347993,137.14696515108136,45.30216339603112,44.979982887223954,44.223788212697784
VBFHbb,40.60062332311162,40.60062332311162,40.60062332311162,40.47235839402518,40.3369080970762,12.910667691672323,12.854549382280249,12.634901215378125
ZHbb,38.56092725636813,38.56092725636813,38.56092725636813,38.30734801182328,38.14508043229702,11.799771340315372,11.736426745162136,11.521034524277757
WHbb,66.232275837835,66.232275837835,66.232275837835,65.79568909543664,65.5789510146088,22.935801367330377,22.844437718358833,22.513501377662102
ggZHbb,5.921431593700421,5.921431593700421,5.921431593700421,5.88900772329133,5.855043713430598,2.3432337853521314,2.33112325212995,2.282691514973073
ttHbb,187.9810602386041,187.9810602386041,187.9810602386041,186.85674951555848,185.63841488932138,116.0286360102471,100.71679505102459,81.41339405390781
HWW,97.55810924622651,97.55810924622651,97.55810924622651,97.00857794271565,96.26976864081334,77.25306730184919,62.10701605753843,46.22675358353963
Data,1331012.0,1331012.0,1331012.0,1331012.0,1331012.0,1100458.0,1089365.0,1069464.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt >= 300,VVFatJetPt >= 300,BDTScore >= 0.998,bbFatJetParticleNetMD_Txbb >= 0.9737,0 ≤ nGoodElectronsHH < 0.9,0 ≤ nGoodMuonsHH < 0.9
HHbbVV,1.108127280079604,1.108127280079604,1.108127280079604,1.1005594143174928,1.0940812392241102,0.06714241913967475,0.045644827042487415,0.045482187506865425,0.04491874242621979
QCD,900603.372757249,1219440.0804636534,1219440.0804636534,1208187.047601593,1199914.6854996895,22.244014442857914,0.0,0.0,0.0
TT,76537.02908224265,76537.02908224265,76537.02908224265,76036.67089183381,75504.25522211792,14.293673833696102,3.069949835812113,2.7866372960843795,2.53826990519935
ST,6617.229257123121,6617.229257123121,6617.229257123121,6568.071623368754,6530.558860743446,1.0947397108178452,0.3627477842497195,0.3627477842497195,0.3627477842497195
W+Jets,12421.273275458932,12421.273275458932,12421.273275458932,12341.31450378544,12265.115729916284,2.8159263601477633,0.0754741537378946,0.0754741537378946,0.0754741537378946
Z+Jets,14717.02364266734,14717.02364266734,14717.02364266734,14601.426751424733,14517.101697865306,1.6375935574256633,0.9182214590567984,0.9182214590567984,0.9182214590567984
Diboson,703.6912877316817,703.6912877316817,703.6912877316817,699.1389217855917,695.3097641927543,0.0,0.0,0.0,0.0
ggFHbb,138.81856362723408,138.81856362723408,138.81856362723408,138.12124620347993,137.14696515108136,0.0,0.0,0.0,0.0
VBFHbb,40.60062332311162,40.60062332311162,40.60062332311162,40.47235839402518,40.3369080970762,0.0,0.0,0.0,0.0
ZHbb,38.56092725636813,38.56092725636813,38.56092725636813,38.30734801182328,38.14508043229702,0.004885259938253187,0.004885259938253187,0.004885259938253187,0.004885259938253187
WHbb,66.232275837835,66.232275837835,66.232275837835,65.79568909543664,65.5789510146088,0.006068461144207527,0.006068461144207527,0.006068461144207527,0.006068461144207527
ggZHbb,5.921431593700421,5.921431593700421,5.921431593700421,5.88900772329133,5.855043713430598,0.0002400427404862805,0.0,0.0,0.0
ttHbb,187.9810602386041,187.9810602386041,187.9810602386041,186.85674951555848,185.63841488932138,0.036411335689232854,0.014362441727037082,0.014362441727037082,0.01228423772057041
HWW,97.55810924622651,97.55810924622651,97.55810924622651,97.00857794271565,96.26976864081334,0.7098670190069944,0.20864489243884723,0.19782687870836316,0.18843300290239307
Data,1331012.0,1331012.0,1331012.0,1331012.0,1331012.0,151.0,28.0,28.0,27.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt >= 300,VVFatJetPt >= 300,0.8 ≤ bbFatJetParticleNetMD_Txbb < 0.9714,0 ≤ nGoodElectronsHH < 0.9,0 ≤ nGoodMuonsHH < 0.9
HHbbVV,1.676130328580837,1.676130328580837,1.676130328580837,1.6712036429905937,1.6670538167650584,0.542187458384658,0.5396610489292449,0.5318591076184602
QCD,1117757.9198795073,1146810.7163518853,1146810.7163518853,1143003.1288380893,1140195.6701715398,907041.6234455233,903988.513180142,892962.3741017526
TT,114729.52068857195,114729.52068857195,114729.52068857195,114375.90267312861,114019.19131760647,91522.20073198747,79821.6970089395,66023.02115112776
ST,9991.097357360093,9991.097357360093,9991.097357360093,9956.444147193402,9930.244963807756,8028.465559025532,7171.691075340353,6191.447228016618
W+Jets,14710.822213085146,14710.822213085146,14710.822213085146,14672.491652608198,14641.631954844934,12114.962805740633,12083.890830533694,11985.29075177099
Z+Jets,21597.004857058182,21597.004857058182,21597.004857058182,21522.694272012075,21479.126831498128,12030.152212440837,11979.353032553374,11800.977521732788
Diboson,936.1606241609028,936.1606241609028,936.1606241609028,932.3120773317856,930.6761200627391,534.0385200420062,505.02146991183054,468.85445953312353
ggFHbb,224.56874142701201,224.56874142701201,224.56874142701201,224.09132954605533,223.5656191986538,70.97896134381715,70.78035954682528,69.64922646633534
VBFHbb,66.27722451912622,66.27722451912622,66.27722451912622,66.16198883813554,66.0249915252132,19.951217913629037,19.868460965579263,19.435944935745326
ZHbb,63.465766584473805,63.465766584473805,63.465766584473805,63.322797344840964,63.235634550720064,19.098962248557314,18.99404620470836,18.58717479258809
WHbb,108.86564442012758,108.86564442012758,108.86564442012758,108.63886528171966,108.52664862322723,36.560850981465876,36.37889329234338,35.74996974597222
ggZHbb,9.5080271296301,9.5080271296301,9.5080271296301,9.483212575914823,9.46312346044892,3.8187478189469157,3.7966988368166823,3.7127499480798276
ttHbb,312.2634270090423,312.2634270090423,312.2634270090423,311.1744105719533,310.21793216817366,196.26913656336373,167.939191985903,134.26329795809994
HWW,150.72907678953348,150.72907678953348,150.72907678953348,150.22850888691733,149.66583899443282,120.76628093672662,94.7572440919209,69.17954851770176
Data,1309711.0,1309711.0,1309711.0,1309711.0,1309711.0,1062010.0,1046184.0,1022200.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
,Pre-selection,QCD SF,LP SF,bbFatJetPt >= 300,VVFatJetPt >= 300,BDTScore >= 0.998,bbFatJetParticleNetMD_Txbb >= 0.9714,0 ≤ nGoodElectronsHH < 0.9,0 ≤ nGoodMuonsHH < 0.9
HHbbVV,1.676130328580837,1.676130328580837,1.676130328580837,1.6712036429905937,1.6670538167650584,0.1348657476260752,0.09451863521740458,0.09425463526379319,0.09258595999225357
QCD,1117757.9198795073,1146810.7163518853,1146810.7163518853,1143003.1288380893,1140195.6701715398,81.43075384779243,11.743785163150324,11.743785163150324,11.743785163150324
TT,114729.52068857195,114729.52068857195,114729.52068857195,114375.90267312861,114019.19131760647,20.851580224873963,3.3184434980811437,2.8822193601792008,2.7897675265821
ST,9991.097357360093,9991.097357360093,9991.097357360093,9956.444147193402,9930.244963807756,2.50507160856611,0.6894987125411937,0.6894987125411937,0.6894987125411937
W+Jets,14710.822213085146,14710.822213085146,14710.822213085146,14672.491652608198,14641.631954844934,6.247174843697289,1.2144252967096187,1.2144252967096187,1.2144252967096187
Z+Jets,21597.004857058182,21597.004857058182,21597.004857058182,21522.694272012075,21479.126831498128,4.1633434974680235,2.1482291128058835,2.090873324162296,2.016920170636187
Diboson,936.1606241609028,936.1606241609028,936.1606241609028,932.3120773317856,930.6761200627391,0.28001420954562,0.0,0.0,0.0
ggFHbb,224.56874142701201,224.56874142701201,224.56874142701201,224.09132954605533,223.5656191986538,0.0,0.0,0.0,0.0
VBFHbb,66.27722451912622,66.27722451912622,66.27722451912622,66.16198883813554,66.0249915252132,0.0,0.0,0.0,0.0
ZHbb,63.465766584473805,63.465766584473805,63.465766584473805,63.322797344840964,63.235634550720064,0.019165071246600798,0.011562703181241899,0.011562703181241899,0.010593743223856235
WHbb,108.86564442012758,108.86564442012758,108.86564442012758,108.63886528171966,108.52664862322723,0.02283551089152013,0.01675278403292014,0.01675278403292014,0.01675278403292014
ggZHbb,9.5080271296301,9.5080271296301,9.5080271296301,9.483212575914823,9.46312346044892,0.0007379976097465021,0.0007379976097465021,0.0007379976097465021,0.0007379976097465021
ttHbb,312.2634270090423,312.2634270090423,312.2634270090423,311.1744105719533,310.21793216817366,0.0958537670996162,0.036958633172860515,0.03232516206023441,0.03232516206023441
HWW,150.72907678953348,150.72907678953348,150.72907678953348,150.22850888691733,149.66583899443282,1.2098880271012145,0.37276893952874834,0.3673049896251192,0.3399937997893017
Data,1309711.0,1309711.0,1309711.0,1309711.0,1309711.0,197.0,42.0,42.0,39.0
Loading

0 comments on commit c895f19

Please sign in to comment.