Skip to content

Commit

Permalink
used Anas ABCD base and merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan-Wiederspan committed Aug 20, 2024
2 parents 43af169 + 50e8c64 commit 9037de7
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 231 deletions.
36 changes: 22 additions & 14 deletions hbt/config/configs_hbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,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 @@ -174,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 @@ -296,9 +296,9 @@ 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
Expand All @@ -307,6 +307,12 @@ def if_era(
"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 Down Expand Up @@ -372,7 +378,7 @@ def if_era(
}
cfg.x.default_custom_style_config = "small_legend"

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

################################################################################################
# luminosity and normalization
Expand Down Expand Up @@ -405,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 @@ -951,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
10 changes: 9 additions & 1 deletion hbt/config/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,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",
)
167 changes: 167 additions & 0 deletions hbt/inference/default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# coding: utf-8

"""
Default inference model.
"""

from columnflow.inference import inference_model, ParameterType


@inference_model
def default(self):

#
# categories
#

self.add_category(
"incl",
config_category="incl__os__iso",
config_variable="res_dnn_hh",
config_data_datasets=["data_*"],
mc_stats=8.0,
)

#
# processes
#

for kl in ["0", "1", "2p45", "5"]:
self.add_process(
f"ggHH_kl_{kl}_kt_1_13p6TeV_hbbhtt",
is_signal=True,
config_process=f"hh_ggf_hbb_htt_kl{kl}_kt1",
config_mc_datasets=[f"hh_ggf_hbb_htt_kl{kl}_kt1_powheg"],
)
self.add_process(
"TT",
config_process="tt",
config_mc_datasets=["^tt_(sl|dl|fh)_powheg$"],
)
self.add_process(
"DY",
config_process="dy",
config_mc_datasets=["dy_*_amcatnlo"],
)

#
# parameters
#

# general groups
self.add_parameter_group("experiment")
self.add_parameter_group("theory")

# groups that contain parameters that solely affect the signal cross section and/or br
self.add_parameter_group("signal_norm_xs")
self.add_parameter_group("signal_norm_xsbr")

# parameter that is added by the HH physics model, representing kl-dependent QCDscale + mtop
# uncertainties on the ggHH cross section
self.add_parameter_to_group("THU_HH", "theory")
self.add_parameter_to_group("THU_HH", "signal_norm_xs")
self.add_parameter_to_group("THU_HH", "signal_norm_xsbr")

# theory uncertainties
self.add_parameter(
"BR_hbb",
type=ParameterType.rate_gauss,
process=["*_hbb", "*_hbbhtt"],
effect=(0.9874, 1.0124),
group=["theory", "signal_norm_xsbr"],
)
self.add_parameter(
"BR_htt",
type=ParameterType.rate_gauss,
process=["*_htt", "*_hbbhtt"],
effect=(0.9837, 1.0165),
group=["theory", "signal_norm_xsbr"],
)
self.add_parameter(
"pdf_gg", # contains alpha_s
type=ParameterType.rate_gauss,
process="TT",
effect=1.042,
group=["theory"],
)
self.add_parameter(
"pdf_Higgs_ggHH", # contains alpha_s
type=ParameterType.rate_gauss,
process="ggHH_*",
effect=1.023,
group=["theory", "signal_norm_xs", "signal_norm_xsbr"],
)
self.add_parameter(
"pdf_Higgs_qqHH", # contains alpha_s
type=ParameterType.rate_gauss,
process="qqHH_*",
effect=1.027,
group=["theory", "signal_norm_xs", "signal_norm_xsbr"],
)
self.add_parameter(
"QCDscale_ttbar",
type=ParameterType.rate_gauss,
process="TT",
effect=(0.965, 1.024),
group=["theory"],
)
self.add_parameter(
"QCDscale_qqHH",
type=ParameterType.rate_gauss,
process="qqHH_*",
effect=(0.9997, 1.0005),
group=["theory", "signal_norm_xs", "signal_norm_xsbr"],
)

# lumi
lumi = self.config_inst.x.luminosity
for unc_name in lumi.uncertainties:
self.add_parameter(
unc_name,
type=ParameterType.rate_gauss,
effect=lumi.get(names=unc_name, direction=("down", "up"), factor=True),
group="experiment",
)

# btag
for name in self.config_inst.x.btag_unc_names:
self.add_parameter(
f"CMS_btag_{name}",
type=ParameterType.shape,
config_shift_source=f"btag_{name}",
group="experiment",
)

# pileup
self.add_parameter(
"CMS_pileup_2022",
type=ParameterType.shape,
config_shift_source="minbias_xs",
group="experiment",
)

#
# cleanup
#

self.cleanup(keep_parameters="THU_HH")


@inference_model
def default_no_shifts(self):
# same initialization as "default" above
default.init_func.__get__(self, self.__class__)()

#
# remove all parameters that require a shift source other than nominal
#

for category_name, process_name, parameter in self.iter_parameters():
if parameter.type.is_shape or any(trafo.from_shape for trafo in parameter.transformations):
self.remove_parameter(parameter.name, process=process_name, category=category_name)

#
# cleanup
#

self.cleanup(keep_parameters="THU_HH")
4 changes: 1 addition & 3 deletions hbt/inference/inf_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ def test_unc(self):

# electron uncertainty
self.add_parameter(
"CMS_eff_e", # this is the name of the uncertainty as it will show in the datacard. Let's use some variant of the official naming
"CMS_eff_e", # this is the name of the uncertainty as it will show in the datacard. Let's use some variant of the official naming # noqa
process="*",
type=ParameterType.shape,
config_shift_source="e", # this is the name of the shift (alias) in the config
)
self.add_parameter_to_group("CMS_eff_e", "experiment")


# a custom asymmetric uncertainty
self.add_parameter(
"QCDscale_ttbar",
Expand All @@ -78,7 +77,6 @@ def test_unc(self):
)
self.add_parameter_to_group("QCDscale_ttbar", "experiment")


"""
# tune uncertainty
self.add_parameter(
Expand Down
Loading

0 comments on commit 9037de7

Please sign in to comment.