Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
55436a1
Use 20 quantiles for yll instead of 10
davidwalter2 Jan 15, 2026
150189d
Update wremnants-data
davidwalter2 Jan 16, 2026
90eb410
Merge branch 'main' of github.com:WMass/WRemnants into 260116_updBinning
davidwalter2 Jan 16, 2026
c947d3f
Use new quantile file
davidwalter2 Jan 16, 2026
50b474f
Synchronize sample paths; Treat DY low mass similar to Zmumu
davidwalter2 Jan 16, 2026
eff3a82
Some more harminizations in datasets; common xsec definitions
davidwalter2 Jan 17, 2026
650b069
Use single file for angular coefficients shared across main analysis,…
davidwalter2 Jan 17, 2026
162950d
Fixes to previous commits
davidwalter2 Jan 17, 2026
e486a7c
Update wremnants-data with new angular cofficient file
davidwalter2 Jan 17, 2026
c6c2197
fix ci
davidwalter2 Jan 17, 2026
de9dc1a
Rename samples ending with 'PostVFP' to '_2016PostVFP' and introduce …
davidwalter2 Jan 19, 2026
db06e92
Further unify binning; adapt 'make_theory_corr' to use different eras
davidwalter2 Jan 19, 2026
a388aaf
Change logic to maintain backwards compatibility with previous byHeli…
davidwalter2 Jan 19, 2026
e0ece9d
Fix typos
davidwalter2 Jan 20, 2026
9558dcb
Fix CI
davidwalter2 Jan 20, 2026
56485e3
Revert correcting DYLowMass dataset
davidwalter2 Jan 20, 2026
17db1fa
Update wremnants-data with new theory corrections
davidwalter2 Jan 20, 2026
35cb7d0
Add fine binning in ptVgen and absYVGen option for theory corrections…
davidwalter2 Jan 20, 2026
f81bbb2
Add reference to new BSM sample
davidwalter2 Jan 20, 2026
e6750b9
Use more fine binning for byHelicity corrections and uncertainties
davidwalter2 Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ env:
OUTFILE_LOWPU_EE: "mz_lowPU_ee.hdf5"
OUTFILE_LOWPU_MUMU: "mz_lowPU_mumu.hdf5"
DATAPATH: "/scratch/shared/NanoAOD/"
DATAPATH_LOWPU: "/scratch/shared/NanoAOD/LowPU/"
NOMINAL_FAKE_SMOOTHING: "hybrid"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
Expand Down Expand Up @@ -315,7 +314,7 @@ jobs:
- name: bsm rabbit setup
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run_python.sh scripts/rabbit/setupRabbit.py
-i $HIST_FILE --lumiScale $LUMI_SCALE --addBSMMixing WtoNMu_5 0.01 --breitwignerWMassWeights
-i $HIST_FILE --lumiScale $LUMI_SCALE --addBSMMixing WtoNMuMass5 0.01 --breitwignerWMassWeights
--postfix bsm -o $WREMNANTS_OUTDIR

- name: bsm rabbit fit
Expand All @@ -330,19 +329,19 @@ jobs:
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run.sh rabbit_limit.py
$WREMNANTS_OUTDIR/WMass_eta_pt_charge_bsm/WMass.hdf5 -o $WREMNANTS_OUTDIR/WMass_eta_pt_charge_bsm/
-t -1 --asymptoticLimits WtoNMu_5_mixing --modes gaussian
-t -1 --asymptoticLimits WtoNMuMass5_mixing --modes gaussian

- name: bsm plot postfit variations
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run.sh rabbit_plot_hists.py '$WREMNANTS_OUTDIR/WMass_eta_pt_charge_bsm/fitresults.hdf5'
-o $WEB_DIR/$PLOT_DIR/BSM -m Project -m Normalize --title CMS --subtitle Preliminary --titlePos 0 --yscale '1.3'
--result asimov --lowerLegCols 3 --rrange 0.98 1.02
--varNames massShiftW100MeV 'WtoNMu_5_mixing' --varColors red blue
--varNames massShiftW100MeV 'WtoNMuMass5_mixing' --varColors red blue

# - name: bsm plot parameter correlations
# run: >-
# scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run.sh rabbit_plot_hists_cov.py '$WREMNANTS_OUTDIR/WMass_eta_pt_charge_bsm/fitresults.hdf5'
# -o $WEB_DIR/$PLOT_DIR/BSM --params 'WtoNMu_5' massShiftW100MeV
# -o $WEB_DIR/$PLOT_DIR/BSM --params 'WtoNMuMass5' massShiftW100MeV
# --title CMS --subtitle Preliminary --titlePos 0 --config 'utilities/styles/styles.py' --correlation --showNumbers

# - name: bsm plot pulls and impacts
Expand All @@ -354,7 +353,7 @@ jobs:
# - name: bsm likelihood scan
# run: >-
# scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run.sh rabbit_plot_likelihood_scan.py '$WREMNANTS_OUTDIR/WMass_eta_pt_charge_bsm/fitresults.hdf5'
# -o $WEB_DIR/$PLOT_DIR/BSM --params 'WtoNMu_5' --title CMS --subtitle Preliminary --titlePos 0 --config 'utilities/styles/styles.py'
# -o $WEB_DIR/$PLOT_DIR/BSM --params 'WtoNMuMass5' --title CMS --subtitle Preliminary --titlePos 0 --config 'utilities/styles/styles.py'

w-plotting:
# The type of runner that the job will run on
Expand Down Expand Up @@ -537,7 +536,7 @@ jobs:
- name: lowpu w mu analysis
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run_python.sh scripts/histmakers/mw_lowPU.py
--dataPath $DATAPATH_LOWPU -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName --unfolding --unfoldingLevels postfsr
--dataPath $DATAPATH -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName --unfolding --unfoldingLevels postfsr

- name: lowpu w mu plot ptW
run: >-
Expand Down Expand Up @@ -567,7 +566,7 @@ jobs:
- name: lowpu w e analysis
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run_python.sh scripts/histmakers/mw_lowPU.py
--dataPath $DATAPATH_LOWPU -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName --flavor e --unfolding --unfoldingLevels postfsr
--dataPath $DATAPATH -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName --flavor e --unfolding --unfoldingLevels postfsr

- name: lowpu w e plot ptW
run: >-
Expand Down Expand Up @@ -639,7 +638,7 @@ jobs:
- name: lowpu z mumu analysis
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run_python.sh scripts/histmakers/mz_lowPU.py --unfolding --unfoldingLevels postfsr
--dataPath $DATAPATH_LOWPU -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName
--dataPath $DATAPATH -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName

- name: lowpu z mumu plot ptll yll
run: >-
Expand All @@ -659,7 +658,7 @@ jobs:
- name: lowpu z ee analysis
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run_python.sh scripts/histmakers/mz_lowPU.py --unfolding --unfoldingLevels postfsr
--dataPath $DATAPATH_LOWPU -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName --flavor ee
--dataPath $DATAPATH -o $WREMNANTS_OUTDIR -j $NTHREADS --forceDefaultName --flavor ee

- name: lowpu z ee plot ptll yll
run: >-
Expand Down Expand Up @@ -1165,7 +1164,7 @@ jobs:
- name: dilepton plotting yll
run: >-
scripts/ci/run_with_singularity.sh scripts/ci/setup_and_run_python.sh scripts/plotting/makeDataMCStackPlot.py
--yscale 1.3 --baseName nominal_yll --nominalRef nominal_yll --hists yll --fineGroups -o $WEB_DIR -f $PLOT_DIR -p z $HIST_FILE
--yscale 1.3 --baseName nominal_ptll_yll --nominalRef nominal_ptll_yll --hists yll --fineGroups -o $WEB_DIR -f $PLOT_DIR -p z $HIST_FILE

- name: dilepton plotting cosThetaStarll
run: >-
Expand Down
12 changes: 6 additions & 6 deletions scripts/corrections/make_muon_response_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
hist_response_smeared = None

procs = []
procs.append("ZmumuPostVFP")
procs.append("ZtautauPostVFP")
procs.append("WplusmunuPostVFP")
procs.append("WminusmunuPostVFP")
procs.append("WplustaunuPostVFP")
procs.append("WminustaunuPostVFP")
procs.append("Zmumu_2016PostVFP")
procs.append("Ztautau_2016PostVFP")
procs.append("Wplusmunu_2016PostVFP")
procs.append("Wminusmunu_2016PostVFP")
procs.append("Wplustaunu_2016PostVFP")
procs.append("Wminustaunu_2016PostVFP")


with h5py.File(infile, "r") as f:
Expand Down
2 changes: 1 addition & 1 deletion scripts/corrections/make_ptv_unfolding_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

logger = logging.setup_logger("make_ptv_unfolding_corr", 4 if args.debug else 3)

genh = input_tools.read_and_scale(args.genFile, "ZmumuPostVFP", "nominal_gen")
genh = input_tools.read_and_scale(args.genFile, "Zmumu_2016PostVFP", "nominal_gen")

unfolded_res = pickle.load(open(args.unfoldingFile, "rb"))
unfolded_datah = unfolded_res["results"]["pmaskedexp"]["chan_13TeV"]["Z"][
Expand Down
158 changes: 98 additions & 60 deletions scripts/corrections/make_theory_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ def parse_args():
action="store_true",
help="Normalize the corrections",
)
parser.add_argument(
"--eras",
type=str,
nargs="+",
choices=common.supported_eras,
help="Data set to process",
default=["2016PostVFP", "2017", "2018"],
)
args = parser.parse_args()

return args
Expand Down Expand Up @@ -147,9 +155,6 @@ def read_corr(procName, generator, corrFiles, axes, smooth=None):

fo_func = getattr(input_tools, f"read_matched_scetlib_{fo_generator}_hist")

zero_nons_bins = (
0 if "nnlojet" not in fo_generator else hist.tag.Slicer()[0:2]
)
# TODO: Should probably be more general...
smooth_args = {}
if smooth == "fo_sing":
Expand All @@ -160,7 +165,7 @@ def read_corr(procName, generator, corrFiles, axes, smooth=None):
fo_files[0],
axes,
charge=charge,
zero_nons_bins=zero_nons_bins,
zero_nons_bins=slice(0j, 1j), # set bins qT < 1GeV to 0
**smooth_args,
)
else:
Expand Down Expand Up @@ -212,8 +217,8 @@ def main():
}

if args.proc == "z":
eventgen_procs = ["ZmumuPostVFP"]
filesByProc = {"ZmumuPostVFP": args.corrFiles}
eventgen_procs = ["Zmumu"] # , "DYJetsToMuMuMass10to50"]
filesByProc = {"Zmumu": args.corrFiles}
else:
wpfiles = list(
filter(
Expand All @@ -232,32 +237,33 @@ def main():
if len(wpfiles) != len(wmfiles):
if args.duplicateWminus:
logger.warning("Using W- correction as a proxy for W+!")
filesByProc = {
"WplusmunuPostVFP": wmfiles,
"WminusmunuPostVFP": wmfiles,
}
filesByProc = {"Wplusmunu": wmfiles, "Wminusmunu": wmfiles}

else:
raise ValueError(
f"Expected equal number of files for W+ and W-, found {len(wpfiles)} (Wp) and {len(wmfiles)} (Wm)"
)
else:
filesByProc = {"WplusmunuPostVFP": wpfiles, "WminusmunuPostVFP": wmfiles}
filesByProc = {"Wplusmunu": wpfiles, "Wminusmunu": wmfiles}

if args.proc == "w":
eventgen_procs = ["WplusmunuPostVFP", "WminusmunuPostVFP"]
eventgen_procs = ["Wplusmunu", "Wminusmunu"]
elif args.proc == "bsm":
eventgen_procs = [
"WtoNMu_MN-5-V-0p001",
"WtoNMu_MN-10-V-0p001",
"WtoNMu_MN-30-V-0p001",
"WtoNMu_MN-50-V-0p001",
"WtoNMuMN5V0p001",
"WtoNMuMN10V0p001",
"WtoNMuMN30V0p001",
"WtoNMuMN50V0p001",
]

minnloh = hh.sumHists(
[
input_tools.read_mu_hist_combine_tau(
args.minnloFile, proc, args.minnloh, combine_with_tau=args.proc != "bsm"
args.minnloFile,
proc,
args.minnloh,
eras=args.eras,
combine_with_tau=args.proc != "bsm",
)
for proc in eventgen_procs
]
Expand Down Expand Up @@ -354,8 +360,8 @@ def main():

generator = args.generator
if args.postfix:
generator += args.postfix
outfile = f"{args.outpath}/{generator}Corr{args.proc.upper()}.pkl.lz4"
generator += f"_{args.postfix}"
outfile = f"{args.outpath}/{generator}_Corr{args.proc.upper()}.pkl.lz4"

meta_dict = {}
for f in [args.minnloFile] + args.corrFiles:
Expand Down Expand Up @@ -409,6 +415,10 @@ def main():
"absY": "$|y^{{{final_state}}}|$",
}

outdir = output_tools.make_plot_dir(
*args.plotdir.rsplit("/", 1), eoscp=args.eoscp
)

for charge in minnloh.axes["charge"].centers:
if args.duplicateWminus and charge == 1:
continue
Expand All @@ -420,48 +430,76 @@ def main():
proc = "Wp" if charge.imag > 0 else "Wm"
final_state = "\\ell^{+}\\nu" if charge.imag > 0 else "\\ell^{-}\\nu"

fig, ax = plt.subplots(figsize=(6, 6))
corrh[{"vars": 0, "charge": charge, "Q": 0}].plot(ax=ax, cmin=0.5, cmax=1.5)

outdir = output_tools.make_plot_dir(
*args.plotdir.rsplit("/", 1), eoscp=args.eoscp
)
plot_name = f"corr2D_{generator}_MiNNLO_{proc}"
plot_tools.save_pdf_and_png(outdir, plot_name)
output_tools.write_index_and_log(
outdir, plot_name, args=args, analysis_meta_info=meta_dict
)
for imass, mass_edges in enumerate(minnloh.axes["Q"]):
if len(minnloh.axes["Q"].centers) > 1:
suffix = f"_{int(mass_edges[0])}to{int(mass_edges[1])}GeV"
extra_text_base = [
f"{int(mass_edges[0])} < Q < {int(mass_edges[1])} GeV"
]
else:
suffix = ""
extra_text_base = []

for ivar, var in enumerate(corrh.axes["vars"]):

if len(corrh.axes["vars"]) > 1:
suffix += f"_{var}"
extra_text = [*extra_text_base, var]
else:
extra_text = extra_text_base

if "vars" in minnloh.axes.name:
iminnloh = minnloh[{"Q": imass, "charge": charge, "vars": ivar}]
else:
iminnloh = minnloh[{"Q": imass, "charge": charge}]

inumh = numh[{"Q": imass, "charge": charge, "vars": ivar}]
icorrh = corrh[{"Q": imass, "charge": charge, "vars": ivar}]

fig, ax = plt.subplots(figsize=(6, 6))
icorrh.plot(ax=ax, cmin=0.5, cmax=1.5)

plot_name = f"corr2D_{generator}_MiNNLO_{proc}{suffix}"
plot_tools.save_pdf_and_png(outdir, plot_name)
output_tools.write_index_and_log(
outdir, plot_name, args=args, analysis_meta_info=meta_dict
)

for varm, varn in zip(minnloh.axes.name[:-1], numh.axes.name[:-2]):
fig = plot_tools.makePlotWithRatioToRef(
[
minnloh[{"charge": charge}].project(varm),
numh[{"vars": 0, "charge": charge}].project(varn),
],
[
"MiNNLO",
generator,
],
colors=["orange", "mediumpurple"],
linestyles=[
"solid",
"dashed",
],
xlabel=xlabel[varm].format(final_state=final_state),
ylabel="Events/bin",
rlabel="x/MiNNLO",
legtext_size=24,
rrange=[0.8, 1.2],
yscale=1.1,
xlim=None,
binwnorm=1.0,
baseline=True,
)
plot_name = f"{varm}_{generator}_MiNNLO_{proc}"
plot_tools.save_pdf_and_png(outdir, plot_name)
output_tools.write_index_and_log(
outdir, plot_name, args=args, analysis_meta_info=meta_dict
)
for varm, varn in zip(iminnloh.axes.name, inumh.axes.name):
fig = plot_tools.makePlotWithRatioToRef(
[
iminnloh.project(varm),
inumh.project(varn),
],
[
"MiNNLO",
generator.replace("_", " ").replace("FineBins ", ""),
],
colors=["orange", "mediumpurple"],
linestyles=[
"solid",
"dashed",
],
xlabel=xlabel[varm].format(final_state=final_state),
ylabel="Events/bin",
rlabel="x/MiNNLO",
legtext_size=24,
nlegcols=1,
rrange=[0.8, 1.2],
yscale=1.1,
xlim=None,
binwnorm=1.0,
baseline=True,
extra_text=extra_text,
extra_text_loc=(0.5, 0.7) if varm == "qT" else (0.1, 0.2),
)
plot_name = f"{varm}_{generator}_MiNNLO_{proc}{suffix}"
plot_tools.save_pdf_and_png(outdir, plot_name)
output_tools.write_index_and_log(
outdir, plot_name, args=args, analysis_meta_info=meta_dict
)

break # only plot first variation
if output_tools.is_eosuser_path(args.plotdir) and args.eoscp:
output_tools.copy_to_eos(outdir, args.plotdir)

Expand Down
8 changes: 6 additions & 2 deletions scripts/corrections/make_theory_corr_by_helicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@
raise ValueError("Must specify at least one correction file")

processes = (
["ZmumuPostVFP"] if args.proc == "z" else ["WplusmunuPostVFP", "WminusmunuPostVFP"]
["Zmumu_2016PostVFP"]
if args.proc == "z"
else ["Wplusmunu_2016PostVFP", "Wminusmunu_2016PostVFP"]
)

binning = {
"qT": common.ptV_corr_binning,
"qT": (
common.ptZgen_binning_corr if args.proc == "z" else common.ptWgen_binning_corr
),
"absY": [0 + 0.5 * i for i in range(9)] + [5.0],
}
binning["absy"] = binning["absY"]
Expand Down
6 changes: 3 additions & 3 deletions scripts/corrections/make_theory_corr_ew.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
charge_dict = {"Zmumu": 0, "Wplusmunu": 1, "Wminusmunu": 0}

procs_dict = {
"Zmumu": "ZmumuPostVFP",
"Wminusmunu": "WminusmunuPostVFP",
"Wplusmunu": "WplusmunuPostVFP",
"Zmumu": "Zmumu_2016PostVFP",
"Wminusmunu": "Wminusmunu_2016PostVFP",
"Wplusmunu": "Wplusmunu_2016PostVFP",
}

project = args.project
Expand Down
2 changes: 1 addition & 1 deletion scripts/corrections/make_theory_corr_ew_powhegFO.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

# integrate over pt and phistar
h = h[{"ptVlhe": hist.sum, "phiStarlhe": hist.sum}]
h = hh.rebinHist(h, "absYVlhe", common.absYV_binning)
h = hh.rebinHist(h, "absYVlhe", common.absYZgen_binning_corr)

hcorr = hist.Hist(*h.axes)
# safe default
Expand Down
Loading