Skip to content

Commit 711fe24

Browse files
committed
fix: fix HEM
1 parent 38e4f70 commit 711fe24

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ bash build.sh
5858
# text2workspace.py -P HiggsAnalysis.CombinedLimit.PhysicsModel:multiSignalModel --PO verbose --PO 'map=.*/*hcc*:r[1,-500,500]' model_combined.txt
5959
# text2workspace.py -P HiggsAnalysis.CombinedLimit.PhysicsModel:multiSignalModel --PO verbose --PO 'map=.*/zcc:r[1,-5,5]' model_combined.txt
6060
61-
combine -M FitDiagnostics --expectSignal 1 -d model_combined.root --cminDefaultMinimizerStrategy 0 --robustFit=1 -t -1 --toysFrequentist
61+
combine -M FitDiagnostics -d model_combined.root --cminDefaultMinimizerStrategy 0 --robustFit=1
62+
--setParameters z=1,r=1 -n "" -t -1 --toysFrequentist
6263
combine -M FitDiagnostics --expectSignal 1 -d model_combined.root --cminDefaultMinimizerStrategy 0 --robustFit=1 --saveShapes --saveWithUncertainties -t -1 --toysFrequentist --setParameters z=1 -n ""
6364
combine -M Significance model_combined.root --expectSignal 1 --redefineSignalPOIs z -t -1 --toysFrequentist
6465
combineTool.py -M AsymptoticLimits -m 125 -d model_combined.root --expectSignal 1 --setParameters z=1 --redefineSignalPOIs r -t -1 --toysFrequentist
@@ -83,6 +84,17 @@ combineTool.py -M Impacts -d model_combined.root -m 125 --redefineSignalPOIs z -
8384
plotImpacts.py -i impactsZ.json -o plots/impacts_out_Z
8485
```
8586

87+
Fitting Z unblinding
88+
```
89+
# Baseline
90+
combineTool.py -M Impacts -d model_combined.root -m 125 --doInitialFit --robustFit 1 --setParameterRanges r=-1,5 --cminDefaultMinimizerStrategy 0 --X-rtd FITTER_DYN_STEP --expectSignal 1 --redefineSignalPOIs z
91+
# Condor
92+
combineTool.py -M Impacts -d model_combined.root -m 125 --doFits --robustFit 1 --allPars --setParameterRanges r=-1,5 --redefineSignalPOIs z --cminDefaultMinimizerStrategy 0 --X-rtd MINIMIZER_analytic --job-mode condor --sub-opts='+JobFlavour = "workday"' --task-name ggHccZ --exclude 'rgx{qcdparams*}'
93+
# Collect
94+
combineTool.py -M Impacts -d model_combined.root -m 125 --redefineSignalPOIs z -o impactsZunbl.json
95+
plotImpacts.py -i impactsZunbl.json -o plots/impacts_out_Zunbl --blind
96+
```
97+
8698
Fitting H
8799
```
88100
# Baseline

new_Hxx.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,35 @@ def shape_to_num(f, region, sName, ptbin, syst, mask, muon=False, bound=0.5):
9696
_nom_rate = np.sum(_nom[0] * mask)
9797
if _nom_rate < .1:
9898
return 1.0
99+
100+
_one_side = get_templ(f, region, sName, ptbin, syst=syst, muon=muon)
99101
_up = get_templ(f, region, sName, ptbin, syst=syst + "Up", muon=muon)
100102
_down = get_templ(f, region, sName, ptbin, syst=syst + "Down", muon=muon)
101-
if _up is None and _down is None:
103+
if _up is None and _down is None and _one_side is None:
102104
return None
103105
else:
104-
if _down is not None:
105-
_down_rate = np.sum(_down[0] * mask)
106-
else:
107-
_down_rate = _nom_rate
108-
if _up is not None:
106+
if _one_side is not None:
107+
_up_rate = np.sum(_one_side[0] * mask)
108+
_diff = np.abs(_up_rate - _nom_rate)
109+
magnitude = _diff / _nom_rate
110+
elif _down is not None and _up is not None:
109111
_up_rate = np.sum(_up[0] * mask)
112+
_down_rate = np.sum(_down[0] * mask)
113+
_diff = np.abs(_up_rate - _nom_rate) + np.abs(_down_rate - _nom_rate)
114+
magnitude = _diff / (2. * _nom_rate)
110115
else:
111-
_up_rate = _nom_rate
112-
_diff = np.abs(_up_rate - _nom_rate) + np.abs(_down_rate - _nom_rate)
113-
magnitude = _diff / (2. * _nom_rate)
116+
raise NotImplementedError
114117
if bound is not None:
115118
magnitude = min(magnitude, bound)
116119
return 1.0 + magnitude
117120

118121
def get_templ(f, region, sample, ptbin, syst=None, muon=False):
122+
if "16" in f.name:
123+
year = 2016
124+
elif "17" in f.name:
125+
year = 2017
126+
else:
127+
year = 2018
119128
hist_name = '{}_{}'.format(sample, region)
120129
if syst is not None:
121130
hist_name += "_" + syst
@@ -126,8 +135,16 @@ def get_templ(f, region, sample, ptbin, syst=None, muon=False):
126135
try:
127136
f[hist_name]
128137
except:
129-
print("{}Sample {}, {}, {}, {} not found.".format('(Muon) ' if muon else "",
130-
sample, region, ptbin if not muon else "-", syst))
138+
if syst is not None:
139+
if "HEM" in syst and year in [2016, 2017]: # always empty
140+
pass
141+
elif "HEM" in syst and ("Up" in syst or "Down" in syst) and year == 2018: # always empty
142+
pass
143+
elif "L1Prefiring" in syst and year == 2018: # always empty
144+
pass
145+
else:
146+
print("{}Sample {}, {}, {}, {} not found.".format('(Muon) ' if muon else "",
147+
sample, region, ptbin if not muon else "-", syst))
131148
return None
132149
h_vals = f[hist_name].values
133150
h_edges = f[hist_name].edges
@@ -172,6 +189,9 @@ def dummy_rhalphabet(pseudo,
172189
year=2017,
173190
opts=None):
174191

192+
print(year)
193+
assert year in ['2016', '2017', '2018']
194+
175195
# Default lumi (needs at least one systematics for prefit)
176196
sys_lumi = rl.NuisanceParameter('CMS_lumi_13TeV_{}'.format(year), 'lnN')
177197
sys_lumi_correlated = rl.NuisanceParameter('CMS_lumi_13TeV_correlated', 'lnN')
@@ -389,7 +409,6 @@ def dummy_rhalphabet(pseudo,
389409

390410
for ptbin in range(npt):
391411
for region in ['pass', 'fail']:
392-
#ch = rl.Channel("ptbin%d%s" % (ptbin, region))
393412
ch = rl.Channel("ptbin{}{}{}".format(ptbin, region, year))
394413
model.addChannel(ch)
395414
if justZ:
@@ -953,13 +972,6 @@ def str2bool(v):
953972

954973
parser.add_argument("--year", type=int, default=2017, help="Year")
955974

956-
parser.add_argument("--matched",
957-
type=str2bool,
958-
default='False',
959-
choices={True, False},
960-
help=("Use matched/unmatched templates"
961-
"(w/o there is some W/Z/H contamination from QCD)"))
962-
963975
parser.add_argument("--mcstat",
964976
type=str2bool,
965977
default='True',

0 commit comments

Comments
 (0)