Commit c3881b60 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Improve sample check in physics model.

parent de0138c7
......@@ -576,24 +576,30 @@ class HHModel(PhysicsModel):
def done(self):
super(HHModel, self).done()
# get the number of matched ggF and VBF samples
isamples_ggf = set()
isamples_vbf = set()
for isample, hh_name in sum((self.scalingMap.values()), []):
if hh_name == "GGF":
elif hh_name == "VBF":
# complain when the number of seen samples does not match the amount of model samples
if len(isamples_ggf) not in (0, len(self.ggf_formula.sample_list)):
raise Exception("the number of seen ggF samples ({}) does not match the number of "
"samples expected by the HH physics model ({})".format(
len(isamples_ggf), len(self.ggf_formula.sample_list)))
if len(isamples_vbf) not in (0, len(self.vbf_formula.sample_list)):
raise Exception("the number of seen VBF samples ({}) does not match the number of "
"samples expected by the HH physics model ({})".format(
len(isamples_vbf), len(self.vbf_formula.sample_list)))
# get the labels of ggF and VBF samples and store a flag to check if they were matched
matches = OrderedDict(
(s.label, [])
for s in self.ggf_formula.sample_list + self.vbf_formula.sample_list
# go through the scaling map and match to samples
for sample_name in self.scalingMap:
for sample_label in matches:
if sample_name.startswith(sample_label):
# print matches
max_len = max(len(label) for label in matches)
print("Matching signal samples:")
for label, names in matches.items():
print(" {}{} -> {}".format(label, " " * (max_len - len(label)), ", ".join(names)))
# complain about samples that were not matched by any process
unmatched_samples = [label for label, names in matches.items() if not names]
if unmatched_samples:
raise Exception("{} HH signal samples were not matched by any process: {}".format(
len(unmatched_samples), ", ".join(unmatched_samples)))
# ggf samples with keys (kl, kt), ordered by kl
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment