Skip to content

Commit

Permalink
Merge pull request #57 from uhh-cms/dev
Browse files Browse the repository at this point in the history
v0.2
  • Loading branch information
apaasch authored Nov 14, 2023
2 parents 7681adb + e1e16cf commit d1d4ecc
Show file tree
Hide file tree
Showing 41 changed files with 1,740 additions and 434 deletions.
3 changes: 3 additions & 0 deletions hbw/config/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def kwargs_fn(root_cats):
kwargs = {
"id": sum([c.id for c in root_cats.values()]),
"label": ", ".join([c.name for c in root_cats.values()]),
"aux": {
"root_cats": {key: value.name for key, value in root_cats.items()},
},
}
return kwargs

Expand Down
2 changes: 1 addition & 1 deletion hbw/config/config_run2.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def make_jme_filename(jme_aux, sample_type, name, era=None):
return f"{jme_aux.source}/{jme_full_version}/{jme_full_version}_{name}_{jme_aux.jet_type}.txt"

# external files
json_mirror = "/afs/cern.ch/user/m/mrieger/public/mirrors/jsonpog-integration-dfd90038"
json_mirror = "/afs/cern.ch/user/m/mrieger/public/mirrors/jsonpog-integration-9ea86c4c"
cfg.x.external_files = DotDict.wrap({
# jet energy correction
"jet_jerc": (f"{json_mirror}/POG/JME/{year}{corr_postfix}_UL/jet_jerc.json.gz", "v1"),
Expand Down
2 changes: 1 addition & 1 deletion hbw/config/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def add_hbw_datasets(config: od.Config, campaign: od.Campaign):
"st_twchannel_t_powheg",
"st_twchannel_tbar_powheg",
"st_schannel_lep_amcatnlo",
# "st_schannel_had_amcatnlo", # NOTE: this dataset produces some weird errors, so skip it for now
"st_schannel_had_amcatnlo",
# WJets
"w_lnu_ht70To100_madgraph",
"w_lnu_ht100To200_madgraph",
Expand Down
8 changes: 7 additions & 1 deletion hbw/config/defaults_and_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def set_config_defaults_and_groups(config_inst):
"default": ["Lepton", "VetoLepton", "Jet", "Bjet", "Trigger"],
"thesis": ["Lepton", "Muon", "Jet", "Trigger", "Bjet"], # reproduce master thesis cuts for checks
"test": ["Lepton", "Jet", "Bjet"],
"dilep": ["Jet", "Bjet", "Lepton", "Trigger", "TriggerAndLep"],
"dilep": ["Jet", "Bjet", "Lepton", "Trigger"],
}

# plotting settings groups
Expand Down Expand Up @@ -257,12 +257,16 @@ def set_config_defaults_and_groups(config_inst):
"SR": ("cat_1e_ggHH_kl_1_kt_1_sl_hbbhww", "cat_1mu_ggHH_kl_1_kt_1_sl_hbbhww"),
"vbfSR": ("cat_1e_qqHH_CV_1_C2V_1_kl_1_sl_hbbhww", "cat_1mu_qqHH_CV_1_C2V_1_kl_1_sl_hbbhww"),
"BR": ("cat_1e_tt", "cat_1e_st", "cat_1e_v_lep", "cat_1mu_tt", "cat_1mu_st", "cat_1mu_v_lep"),
"SR_dl": ("cat_2e_ggHH_kl_5_kt_1_dl_hbbhww", "cat_2mu_ggHH_kl_5_kt_1_dl_hbbhww"),
"BR_dl": ("cat_2e_t_bkg", "cat_2e_v_lep", "cat_2mu_t_bkg", "cat_2mu_v_lep"),
}

config_inst.x.default_bins_per_category = {
"SR": 10,
"vbfSR": 5,
"BR": 3,
# "SR_dl": 10,
# "BR_dl": 3,
# "cat_1e_ggHH_kl_1_kt_1_sl_hbbhww": 10,
# "cat_1e_tt": 3,
# "cat_1e_st": 3,
Expand All @@ -277,6 +281,8 @@ def set_config_defaults_and_groups(config_inst):
"SR": ("ggHH_kl_1_kt_1_sl_hbbhww", "qqHH_CV_1_C2V_1_kl_1_sl_hbbhww"),
"vbfSR": ("ggHH_kl_1_kt_1_sl_hbbhww", "qqHH_CV_1_C2V_1_kl_1_sl_hbbhww"),
"BR": lambda proc_name: "hbbhww" not in proc_name,
# "SR_dl": ("ggHH_kl_5_kt_1_dl_hbbhww",),
# "BR_dl": lambda proc_name: "hbbhww" not in proc_name,
# "cat_1e_ggHH_kl_1_kt_1_sl_hbbhww": ("ggHH_kl_1_kt_1_sl_hbbhww", "qqHH_CV_1_C2V_1_kl_1_sl_hbbhww"),
# "cat_1e_tt": lambda proc_name: "hbbhww" not in proc_name,
# "cat_1e_st": lambda proc_name: "hbbhww" not in proc_name,
Expand Down
157 changes: 156 additions & 1 deletion hbw/config/dl/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
np = maybe_import("numpy")
ak = maybe_import("awkward")

from columnflow.columnar_util import EMPTY_FLOAT # noqa
from hbw.config.styling import default_var_binning, default_var_unit
from hbw.util import call_once_on_config


@call_once_on_config()
def add_dl_variables(config: od.Config) -> None:
# bjet features
config.add_variable(
Expand Down Expand Up @@ -99,3 +101,156 @@ def add_dl_variables(config: od.Config) -> None:
binning=(40, 0, 3),
x_title=r"$ \Delta \phi(ll,jj)$",
)


@call_once_on_config()
def add_dl_ml_variables(config: od.Config) -> None:
"""
Adds ML input variables to a *config*.
"""

# reconstructed variables
config.add_variable(
name="mli_ht",
expression="mli_ht",
binning=(40, 0, 1200),
unit="GeV",
x_title="HT",
)
config.add_variable(
name="mli_n_jet",
expression="mli_n_jet",
binning=(11, -0.5, 10.5),
x_title="Number of jets",
)
config.add_variable(
name="mli_n_deepjet",
expression="mli_n_deepjet",
binning=(11, -0.5, 10.5),
x_title="Number of b-tagged jets (deepjet medium WP)",
)
config.add_variable(
name="mli_deepjetsum",
expression="mli_deepjetsum",
binning=(40, 0, 4),
x_title="sum of deepjet scores",
)
config.add_variable(
name="mli_b_deepjetsum",
expression="mli_b_deepjetsum",
binning=(40, 0, 4),
x_title="sum of bjet deepjet scores",
)
config.add_variable(
name="mli_dr_bb",
expression="mli_dr_bb",
binning=(40, 0, 8),
x_title=r"$\Delta R(b,b)$",
)
config.add_variable(
name="mli_dphi_bb",
expression="mli_dphi_bb",
binning=(40, 0, 3.2),
x_title=r"$\Delta\Phi(b,b)$",
)
config.add_variable(
name="mli_mbb",
expression="mli_mbb",
binning=(40, 0, 400),
unit="GeV",
x_title=r"m(b,b)",
)
config.add_variable(
name="mli_mindr_lb",
expression="mli_mindr_lb",
binning=(40, 0, 8),
x_title=r"min $\Delta R(l,b)$",
)
config.add_variable(
name="mli_dphi_bb_nu",
expression="mli_dphi_bb_nu",
binning=(40, 0, 3.2),
x_title=r"$\Delta\Phi(bb,\nu)$",
)
config.add_variable(
name="mli_dr_bb_l",
expression="mli_dr_bb_l",
binning=(40, 0, 8),
x_title=r"$\Delta R(bb,l)$",
)
config.add_variable(
name="mli_mll",
expression="mli_mll",
binning=(40, 0, 80),
x_title=r"$m_{ll}$",
)
config.add_variable(
name="mli_dr_ll",
expression="mli_dr_ll",
binning=(40, 0, 8),
x_title=r"$\Delta R(ll)$",
)
config.add_variable(
name="mli__min_dr_llbb",
expression="mli_min_dr_llbb",
binning=(40, 0, 8),
x_title=r"$\Delta R(bb,ll)$",
)
config.add_variable(
name="mli_bb_pt",
expression="mli_bb_pt",
binning=(40, 0, 500),
unit="GeV",
x_title=r"$bb_p_T$",
)
config.add_variable(
name="mli_mllMET",
expression="mli_mllMET",
binning=(40, 0, 200),
x_title=r"$m_{llMET}$",
)
config.add_variable(
name="mli_dr_bb_llMET",
expression="mli_dr_bb_llMET",
binning=(40, 0, 8),
x_title=r"$\Delta R(bb,llMET)$",
)
config.add_variable(
name="mli_dphi_bb_llMET",
expression="mli_dphi_bb_llMET",
binning=(40, 0, 8),
x_title=r"$\Delta \phi(bb,llMET)$",
)
config.add_variable(
name="mli_mbbllMET",
expression="mli_mbbllMET",
binning=(40, 0, 500),
unit="GeV",
x_title=r"$m_{bbllMET}$",
)
config.add_variable(
name="mli_dphi_ll",
expression="mli_dphi_ll",
binning=(40, 0, 8),
unit="GeV",
x_title=r"$\Delta \phi_{ll}$",
)
config.add_variable(
name="mli_ll_pt",
expression="mli_ll_pt",
binning=(40, 0, 200),
unit="GeV",
x_title=r"$ll p_T$",
)

for obj in ["b1", "b2", "lep", "lep2", "met"]:
for var in ["pt", "eta"]:
if var == "eta" and obj == "met":
continue
config.add_variable(
name=f"mli_{obj}_{var}",
expression=f"mli_{obj}_{var}",
binning=default_var_binning[var],
unit=default_var_unit.get(var, var),
x_title="{obj} {var}".format(obj=obj, var=var),
)
16 changes: 16 additions & 0 deletions hbw/config/ml_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ def add_ml_variables(config: od.Config) -> None:
log_x=True,
x_title=r"$S_{min}$",
)
config.add_variable(
name="mli_mindr_jj",
expression="mli_mindr_jj",
binning=(40, 0, 8),
x_title=r"min $\Delta R(j,j)$",
)
config.add_variable(
name="mli_vbf_deta",
expression="mli_vbf_deta",
Expand All @@ -221,6 +227,16 @@ def add_ml_variables(config: od.Config) -> None:
x_title="existence of at least two vbf jets = 1, else 0",
)

for obj in ["b1", "b2", "j1", "j2"]:
for var in ["btagDeepFlavB"]:
config.add_variable(
name=f"mli_{obj}_{var}",
expression=f"mli_{obj}_{var}",
binning=default_var_binning[var],
unit=default_var_unit.get(var, var),
x_title="{obj} {var}".format(obj=obj, var=var),
)

for obj in ["b1", "b2", "j1", "j2", "lep", "met"]:
for var in ["pt", "eta"]:
config.add_variable(
Expand Down
27 changes: 27 additions & 0 deletions hbw/config/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,30 @@ def add_hbw_processes(config: od.Config, campaign: od.Campaign):
)
v_lep.add_process(config.get_process("w_lnu"))
v_lep.add_process(config.get_process("dy_lep"))

# Custom t_bkg process for ML Training, combining tt+st
t_bkg = config.add_process(
name="t_bkg",
id=97842611, # random number
xsecs={13: config.get_process("tt").get_xsec(13) + config.get_process("st").get_xsec(13)},
label="tt + st",
)
t_bkg.add_process(config.get_process("tt"))
t_bkg.add_process(config.get_process("st"))

if config.has_tag("is_dl") and config.has_tag("is_nonresonant"):
# Custom signal process for ML Training, combining multiple kl signal samples
signal_processes = [
config.get_process(f"ggHH_kl_{kl}_kt_1_dl_hbbhww")
for kl in [0, 1, "2p45"]
]
sig = config.add_process(
name="sig",
id=75835213, # random number
xsecs={
13: sum([proc.get_xsec(13) for proc in signal_processes]),
},
label="signal",
)
for proc in signal_processes:
sig.add_process(proc)
2 changes: 2 additions & 0 deletions hbw/config/styling.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"v_lep": "#4daf4a", # green
"higgs": "#984ea3", # purple
"st": "#ff7f00", # orange
"t_bkg": "#e41a1c", # orange
"dy_lep": "#ffff33", # yellow
"ttV": "#a65628", # brown
"VV": "#f781bf", # pink
Expand Down Expand Up @@ -64,6 +65,7 @@
"w_lnu": "W",
"dy_lep": "DY",
"v_lep": "W+DY",
"t_bkg": "tt+st",
}


Expand Down
Loading

0 comments on commit d1d4ecc

Please sign in to comment.