Skip to content

Commit

Permalink
Fix bug in lowPU and restore previous behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwalter2 committed Jan 3, 2025
1 parent c99d2db commit f285e3c
Showing 1 changed file with 58 additions and 17 deletions.
75 changes: 58 additions & 17 deletions scripts/combine/setupCombine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,8 @@ def assertSample(name, startsWith=["W", "Z"], excludeMatch=[]):
cardTool.addProcessGroup(
"MCnoQCD",
lambda x: x
not in ["QCD", "Data", "Fake"] + (["Fake"] if simultaneousABCD else []),
not in ["QCD", "Data", "Fake", "Fake_mu", "Fake_e"]
+ (["Fake"] if simultaneousABCD else []),
)
# FIXME/FOLLOWUP: the following groups may actually not exclude the OOA when it is not defined as an independent process with specific name
cardTool.addProcessGroup(
Expand Down Expand Up @@ -1617,23 +1618,63 @@ def assertSample(name, startsWith=["W", "Z"], excludeMatch=[]):
return cardTool

# Below: experimental uncertainties
cardTool.addSystematic(
cardTool.nominalName,
rename="luminosity",
processes=["MCnoQCD"],
group=f"luminosity",
splitGroup={"experiment": ".*", "expNoCalib": ".*"},
passToFakes=passSystToFakes,
mirror=True,
preOp=hh.scaleHist,
preOpArgs={
"scale": (
cardTool.datagroups.lumi_uncertainty
if args.lumiUncertainty is None
else args.lumiUncertainty

if wmass:
# mirror hist in linear scale, this was done in the old definition of luminosity uncertainty from a histogram
def scale_hist_up_down(h, scale):
hUp = hh.scaleHist(h, scale)
hDown = hh.scaleHist(h, 1 / scale)

hVar = hist.Hist(
*[a for a in h.axes],
common.down_up_axis,
storage=hist.storage.Weight(),
)
},
)
hVar.values(flow=True)[...] = np.stack(
[hUp.values(flow=True), hDown.values(flow=True)], axis=-1
)
hVar.variances(flow=True)[...] = np.stack(
[hUp.variances(flow=True), hDown.variances(flow=True)], axis=-1
)
return hVar

cardTool.addSystematic(
cardTool.nominalName,
rename="luminosity",
processes=["MCnoQCD"],
group=f"luminosity",
splitGroup={"experiment": ".*", "expNoCalib": ".*"},
passToFakes=passSystToFakes,
outNames=["lumiDown", "lumiUp"],
systAxes=["downUpVar"],
labelsByAxis=["downUpVar"],
preOp=scale_hist_up_down,
preOpArgs={
"scale": (
cardTool.datagroups.lumi_uncertainty
if args.lumiUncertainty is None
else args.lumiUncertainty
)
},
)
else:
cardTool.addSystematic(
cardTool.nominalName,
rename="luminosity",
processes=["MCnoQCD"],
group=f"luminosity",
splitGroup={"experiment": ".*", "expNoCalib": ".*"},
passToFakes=passSystToFakes,
mirror=True,
preOp=hh.scaleHist,
preOpArgs={
"scale": (
cardTool.datagroups.lumi_uncertainty
if args.lumiUncertainty is None
else args.lumiUncertainty
)
},
)

if not lowPU: # lowPU does not include PhotonInduced as a process. skip it:
cardTool.addSystematic(
Expand Down

0 comments on commit f285e3c

Please sign in to comment.