Skip to content

Commit

Permalink
Merge branch 'uhh-cms:master' into run3_jet_constituents
Browse files Browse the repository at this point in the history
  • Loading branch information
haddadanas authored Aug 30, 2024
2 parents ecf585b + 50e8c64 commit 7ddea7c
Show file tree
Hide file tree
Showing 13 changed files with 473 additions and 250 deletions.
1 change: 1 addition & 0 deletions hbt/config/analysis_hbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def factory(configs: od.UniqueObjectIndex):
campaign.copy(),
config_name=config_name + config_name_postfix,
config_id=config_id,
limit_dataset_files=limit_dataset_files,
**kwargs,
)
return factory
Expand Down
17 changes: 2 additions & 15 deletions hbt/config/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,8 @@ def add_categories(config: od.Config) -> None:
add_category(config, name="noniso", id=13, selection="cat_noniso", label=r"$\tau_{h,2} non-isolated$", tags={"noniso"}) # noqa: E501

# kinematic categories
add_category(
config,
name="incl",
id=100,
selection="cat_incl",
label="inclusive",
)

add_category(
config,
name="2j",
id=110,
selection="cat_2j",
label="2 jets",
)
add_category(config, name="incl", id=100, selection="cat_incl", label="inclusive")
add_category(config, name="2j", id=110, selection="cat_2j", label="2 jets")

#
# build groups
Expand Down
43 changes: 25 additions & 18 deletions hbt/config/configs_hbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def if_era(
"tt_multiboson",
"qcd",
"h",
"hh",
"hh_ggf_hbb_htt_kl1_kt1",
*if_era(run=3, year=2022, values=[
"hh_ggf_hbb_htt_kl0_kt1",
Expand All @@ -118,11 +117,11 @@ def if_era(
"hh_vbf_hbb_htt_kv1_k2v1_kl2",
"hh_vbf_hbb_htt_kv1_k2v2_kl1",
"hh_vbf_hbb_htt_kv1p74_k2v1p37_kl14p4",
"hh_vbf_hbb_htt_kvm0p012_k2v0p030_kl10p2",
"hh_vbf_hbb_htt_kvm0p012_k2v0p03_kl10p2",
"hh_vbf_hbb_htt_kvm0p758_k2v1p44_klm19p3",
"hh_vbf_hbb_htt_kvm0p962_k2v0p959_klm1p43",
"hh_vbf_hbb_htt_kvm1p21_k2v1p94_klm0p94",
"hh_vbf_hbb_htt_kvm1p60_k2v2p72_klm1p36",
"hh_vbf_hbb_htt_kvm1p6_k2v2p72_klm1p36",
"hh_vbf_hbb_htt_kvm1p83_k2v3p57_klm3p39",
"hh_vbf_hbb_htt_kvm2p12_k2v3p87_klm5p96",
]),
Expand Down Expand Up @@ -175,11 +174,11 @@ def if_era(
"hh_vbf_hbb_htt_kv1_k2v0_kl1_madgraph",
"hh_vbf_hbb_htt_kv1_k2v2_kl1_madgraph",
"hh_vbf_hbb_htt_kv1p74_k2v1p37_kl14p4_madgraph",
"hh_vbf_hbb_htt_kvm0p012_k2v0p030_kl10p2_madgraph",
"hh_vbf_hbb_htt_kvm0p012_k2v0p03_kl10p2_madgraph",
"hh_vbf_hbb_htt_kvm0p758_k2v1p44_klm19p3_madgraph",
"hh_vbf_hbb_htt_kvm0p962_k2v0p959_klm1p43_madgraph",
"hh_vbf_hbb_htt_kvm1p21_k2v1p94_klm0p94_madgraph",
"hh_vbf_hbb_htt_kvm1p60_k2v2p72_klm1p36_madgraph",
"hh_vbf_hbb_htt_kvm1p6_k2v2p72_klm1p36_madgraph",
"hh_vbf_hbb_htt_kvm1p83_k2v3p57_klm3p39_madgraph",
"hh_vbf_hbb_htt_kvm2p12_k2v3p87_klm5p96_madgraph",
# some resonances
Expand Down Expand Up @@ -297,14 +296,23 @@ def if_era(
cfg.x.default_selector = "default"
cfg.x.default_producer = "default"
cfg.x.default_ml_model = None
cfg.x.default_inference_model = "test_no_shifts"
cfg.x.default_inference_model = "default_no_shifts"
cfg.x.default_categories = ("incl__os__iso",)
cfg.x.default_variables = ("n_jet", "n_btag", "res_pdnn_hh")
cfg.x.default_variables = ("n_jet", "n_btag", "res_pdnn_hh", "res_dnn_hh")
cfg.x.default_weight_producer = "default"

# process groups for conveniently looping over certain processs
# (used in wrapper_factory and during plotting)
cfg.x.process_groups = {
"signals": [
"hh_ggf_hbb_htt_kl1_kt1",
],
"signals_ggf": [
"hh_ggf_hbb_htt_kl0_kt1",
"hh_ggf_hbb_htt_kl1_kt1",
"hh_ggf_hbb_htt_kl2p45_kt1",
"hh_ggf_hbb_htt_kl5_kt1",
],
"backgrounds": (backgrounds := [
"h",
"tt",
Expand All @@ -316,9 +324,6 @@ def if_era(
"tt_multiboson",
"ewk",
]),
"signals": [
"hh",
],
"sm_ggf": (sm_ggf_group := ["hh_ggf_hbb_htt_kl1_kt1", *backgrounds]),
"sm": (sm_group := ["hh_ggf_hbb_htt_kl1_kt1", "hh_vbf_hbb_htt_kv1_k2v1_kl1", *backgrounds]),
"sm_ggf_data": ["data"] + sm_ggf_group,
Expand Down Expand Up @@ -373,7 +378,7 @@ def if_era(
}
cfg.x.default_custom_style_config = "small_legend"

cfg.x.default_blinding_threshold = 5e-4
cfg.x.default_blinding_threshold = 3e-4

################################################################################################
# luminosity and normalization
Expand Down Expand Up @@ -406,20 +411,20 @@ def if_era(
"lumi_13TeV_correlated": 0.02j,
})
elif year == 2022 and campaign.has_tag("preEE"):
cfg.x.luminosity = Number(7980.4, {
"total": 0.014j,
cfg.x.luminosity = Number(7_980.4, {
"lumi_13p6TeV_correlated": 0.014j,
})
elif year == 2022 and campaign.has_tag("postEE"):
cfg.x.luminosity = Number(26671.7, {
"total": 0.014j,
cfg.x.luminosity = Number(26_671.7, {
"lumi_13p6TeV_correlated": 0.014j,
})
elif year == 2023:
cfg.x.luminosity = Number(27208, {
"lumi_13TeV_correlated": 0.0j,
cfg.x.luminosity = Number(27_208, {
"lumi_13p6TeV_correlated": 0.0j,
})
elif year == 2024:
cfg.x.luminosity = Number(0, {
"lumi_13TeV_correlated": 0.0j,
"lumi_13p6TeV_correlated": 0.0j,
})
else:
assert False
Expand Down Expand Up @@ -952,6 +957,8 @@ def add_external(name, value):
add_external("hh_btag_repo", ("https://github.com/hh-italian-group/HHbtag/archive/df5220db5d4a32d05dc81d652083aece8c99ccab.tar.gz", "v2")) # noqa
# Tobias' tautauNN (https://github.com/uhh-cms/tautauNN)
add_external("res_pdnn", ("/afs/cern.ch/work/m/mrieger/public/hbt/models/res_prod3/model_fold0.tgz", "v1"))
# non-parametric (flat) training up to mX = 800 GeV
add_external("res_dnn", ("/afs/cern.ch/work/m/mrieger/public/hbt/models/res_prod3_nonparam/model_fold0.tgz", "v1"))

# run specific files
if run == 2:
Expand Down
26 changes: 21 additions & 5 deletions hbt/config/hist_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def add_hist_hooks(config: od.Config) -> None:
Add histogram hooks to a configuration.
"""
# helper to convert a histogram to a number object containing bin values and uncertainties
# from variances stored in an array of values
def hist_to_num(h: hist.Histogram, unc_name=str(sn.DEFAULT)) -> sn.Number:
return sn.Number(h.values(), {unc_name: h.variances()**0.5})

# helper to integrate values stored in an array bsaed number object
# helper to integrate values stored in an array based number object
def integrate_num(num: sn.Number, axis=None) -> sn.Number:
return sn.Number(
nominal=num.nominal.sum(axis=axis),
Expand All @@ -51,7 +52,7 @@ def qcd_estimation(task, hists):
if not qcd_proc:
return hists

# extract all uniique category ids and verify that the axis order is exactly
# extract all unique category ids and verify that the axis order is exactly
# "category -> shift -> variable" which is needed to insert values at the end
CAT_AXIS, SHIFT_AXIS, VAR_AXIS = range(3)
category_ids = set()
Expand Down Expand Up @@ -140,21 +141,36 @@ def qcd_estimation(task, hists):

# ABCD method
# shape: (SHIFT, VAR)
os_iso_qcd = os_noniso_qcd * (int_ss_iso / int_ss_noniso)
os_iso_qcd = os_noniso_qcd * ((int_ss_iso / int_ss_noniso)[:, None])

# combine uncertainties and store values in bare arrays
os_iso_qcd_values = os_iso_qcd()
os_iso_qcd_variances = os_iso_qcd(sn.UP, sn.ALL, unc=True)**2

# define uncertainties
unc_data = os_iso_qcd(sn.UP, ["os_noniso_data", "ss_iso_data", "ss_noniso_data"], unc=True)
unc_mc = os_iso_qcd(sn.UP, ["os_noniso_mc", "ss_iso_mc", "ss_noniso_mc"], unc=True)
unc_data_rel = abs(unc_data / os_iso_qcd_values)
unc_mc_rel = abs(unc_mc / os_iso_qcd_values)

# only keep the MC uncertainty if it is larger than the data uncertainty and larger than 15%
keep_variance_mask = (
np.isfinite(unc_mc_rel) &
(unc_mc_rel > unc_data_rel) &
(unc_mc_rel > 0.15)
)
os_iso_qcd_variances[keep_variance_mask] = unc_mc[keep_variance_mask]**2
os_iso_qcd_variances[~keep_variance_mask] = 0

# retro-actively set values to zero for shifts that had negative integrals
neg_int_mask = int_ss_iso_neg | int_ss_noniso_neg
os_iso_qcd_values[neg_int_mask] = 1e-5
os_iso_qcd_variances[neg_int_mask] = 1e-5
os_iso_qcd_variances[neg_int_mask] = 0

# residual zero filling
zero_mask = os_iso_qcd_values <= 0
os_iso_qcd_values[zero_mask] = 1e-5
os_iso_qcd_variances[zero_mask] = 1e-5
os_iso_qcd_variances[zero_mask] = 0

# insert values into the qcd histogram
cat_axis = qcd_hist.axes["category"]
Expand Down
10 changes: 9 additions & 1 deletion hbt/config/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,19 @@ def add_variables(config: od.Config) -> None:
x_title=r"$\eta$",
)

# outputs of the resonant pDNN at SM-like mass and spin values
for proc in ["hh", "tt", "dy"]:
# outputs of the resonant pDNN at SM-like mass and spin values
config.add_variable(
name=f"res_pdnn_{proc}",
expression=f"res_pdnn_s0_m500_{proc}",
binning=(25, 0.0, 1.0),
x_title=rf"{proc.upper()} output node, res. pDNN$_{{m_{{HH}}=500\,GeV,s=0}}$",
)

# outputs of the resonant DNN trained over flat masses
config.add_variable(
name=f"res_dnn_{proc}",
expression=f"res_dnn_{proc}",
binning=(25, 0.0, 1.0),
x_title=rf"{proc.upper()} output node, res. DNN",
)
Loading

0 comments on commit 7ddea7c

Please sign in to comment.