Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/rkansal47/HHbbVV into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed Sep 1, 2023
2 parents 653681e + 3c94c89 commit c94b3b1
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 25 deletions.
5 changes: 3 additions & 2 deletions inference_scans/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ mkdir ~/work/HH

2. Setup inference as follows
- Set up the environment in a new folder with a clean environment (no `cmsenv`, ETC.)
- Use `some_name` as the name of the environment.
- `v1` is the name of the environment here.

```bash
git clone ssh://[email protected]:7999/hh/tools/inference.git
cd inference
source setup.sh c1
source setup.sh v1
```

TODO: update this with better datacard dirs and setting up card repos.
Expand All @@ -32,6 +32,7 @@ export DHI_DATACARDS_RUN2="/afs/cern.ch/user/r/rkansal/work/hh/datacards_run2"
export DHI_DATA="/afs/cern.ch/user/r/rkansal/work/hh/inference/data"
export DHI_STORE="/eos/user/r/rkansal/bbVV/inference"
export Cbbww4q="bbww_hadronic/v1"
export Cbbww4qInject="$Cbbww4q<$DHI_DATACARDS_RUN2/$Cbbww4q/inject.json"
export VERSION="dev"
export UNBLINDED="False"
```
Expand Down
11 changes: 11 additions & 0 deletions inference_scans/nuisance_renames.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def rename_nuisance(nuisance: str):
if nuisance.startswith("CMS_bbWW_hadronic_"):
nuisance = nuisance.split("CMS_bbWW_hadronic_")[1]

if nuisance.startswith("tf_dataResidual_bbFatJetParticleNetMass_"):
return "TF_" + nuisance.split("tf_dataResidual_bbFatJetParticleNetMass_")[1]

if nuisance.startswith("lp_sf"):
return "Lund plane SF"

return nuisance
22 changes: 22 additions & 0 deletions inference_scans/run_impacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

law run PlotPullsAndImpacts \
--version "$VERSION" \
--datacards "$Cbbww4qInject" \
--file-types "pdf,png" \
--pois r \
--PullsAndImpacts-workflow "htcondor" \
--PullsAndImpacts-tasks-per-job 10 \
--PullsAndImpacts-custom-args="--rMin -40 --rMax 40" \
--parameters-per-page 40 \
--order-by-impact \
--labels "nuisance_renames.py" \
--skip-parameters "*dataResidual_Bin*" \
--campaign run2 \
--page 0 \
--pull-range 3 \
--unblinded $UNBLINDED \
--remove-output 0,a,y
# --print-command 2 \
# --use-snapshot True \ # for (fit to data) after unblinding
# --Snapshot-workflow "local" \
4 changes: 2 additions & 2 deletions inference_scans/run_upper_limits_point_r.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# export DHI_CMS_POSTFIX="Supplementary"
law run PlotUpperLimitsAtPoint \
--version "$VERSION" \
--multi-datacards "$Cbbww4q" \
--multi-datacards "$Cbbww4qInject" \
--datacard-names "bbVV" \
--file-types "pdf,png" \
--pois r \
Expand All @@ -16,5 +16,5 @@ law run PlotUpperLimitsAtPoint \
--h-lines 1 \
--save-hep-data True \
--remove-output 0,a,y
# --use-snapshot True \
# --use-snapshot True \ # for (fit to data) after unblinding
# --Snapshot-workflow "local" \
4 changes: 2 additions & 2 deletions inference_scans/run_upper_limits_r_1d_c2v.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# export DHI_CMS_POSTFIX="Supplementary"
law run PlotUpperLimits \
--version "$VERSION" \
--datacards "$Cbbww4q" \
--datacards "$Cbbww4qInject" \
--xsec fb \
--pois r \
--scan-parameters C2V,-1,3,10 \
Expand All @@ -19,6 +19,6 @@ law run PlotUpperLimits \
--remove-output 0,a,y \
--save-hep-data True \
--frozen-groups signal_norm_xsbr
# --use-snapshot True \ # for after unblinding
# --use-snapshot True \ # for (fit to data) after unblinding
# --Snapshot-workflow "local" \
# --scan-parameters kl,-3,5,8 \
7 changes: 4 additions & 3 deletions inference_scans/run_upper_limits_r_1d_kl.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# export DHI_CMS_POSTFIX="Supplementary"
law run PlotUpperLimits \
--version "$VERSION" \
--datacards "$Cbbww4q" \
--datacards "$Cbbww4qInject" \
--xsec fb \
--pois r \
--scan-parameters kl,-30,-12,7:kl,-7,-5,3:kl:kl,-2,7,19:kl,10,30,6 \
--scan-parameters kl,-30,-7,4:kl,-6,7,14:kl,15,30,4 \
--UpperLimits-workflow "htcondor" \
--UpperLimits-tasks-per-job 1 \
--file-types "png,pdf" \
Expand All @@ -19,5 +19,6 @@ law run PlotUpperLimits \
--remove-output 0,a,y \
--save-hep-data True \
--frozen-groups signal_norm_xsbr
# --use-snapshot True \ # for after unblinding
# --scan-parameters kl,-30,-12,7:kl,-7,-5,3:kl,-2,7,19:kl,10,30,6 \
# --use-snapshot True \ # for (fit to data) after unblinding
# --Snapshot-workflow "local" \
4 changes: 2 additions & 2 deletions paper/latex_tables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -315,7 +315,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.10.11"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
2 changes: 1 addition & 1 deletion paper/samples/MC_bg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ samples:
datasets:
TTToHadronic : /TTToHadronic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM
TTToSemiLeptonic : /TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM
TTToSemiLeptonic_ext1: /TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-PUForMUOVal_106X_mc2017_realistic_v9_ext1-v2/MINIAODSIM
# TTToSemiLeptonic_ext1: /TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-PUForMUOVal_106X_mc2017_realistic_v9_ext1-v2/MINIAODSIM

SingleTop:
datasets:
Expand Down
3 changes: 1 addition & 2 deletions paper/tables/datasets_mcbg.tex
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
& ST\_tW\_antitop\_5f\_inclusiveDecays\_TuneCP5\_13TeV-powheg-pythia8 & 32.51 \\
& ST\_tW\_top\_5f\_inclusiveDecays\_TuneCP5\_13TeV-powheg-pythia8 & 32.45 \\
\hline
\multirow{3}{*}{TTbar} & TTToHadronic\_TuneCP5\_13TeV-powheg-pythia8 & 303.85 \\
& TTToSemiLeptonic\_TuneCP5\_13TeV-powheg-pythia8 & 306.14 \\
\multirow{2}{*}{TTbar} & TTToHadronic\_TuneCP5\_13TeV-powheg-pythia8 & 303.85 \\
& TTToSemiLeptonic\_TuneCP5\_13TeV-powheg-pythia8 & 306.14 \\
\hline
\multirow{6}{*}{V+Jets} & WJetsToQQ\_HT-400to600\_TuneCP5\_13TeV-madgraphMLM-pythia8 & 277.00 \\
Expand Down
24 changes: 14 additions & 10 deletions src/HHbbVV/postprocessing/InferenceAnalysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"metadata": {},
"outputs": [],
"source": [
"# plot_dir = f\"{MAIN_DIR}/plots/TaggerAnalysis/23Apr28\"\n",
"plot_dir = f\"{MAIN_DIR}/plots/BDT/23May12\"\n",
"plot_dir = f\"{MAIN_DIR}/plots/TaggerAnalysis/23Aug28\"\n",
"# plot_dir = f\"{MAIN_DIR}/plots/BDT/23May12\"\n",
"os.system(f\"mkdir -p {plot_dir}\")\n",
"\n",
"samples_dir = f\"{MAIN_DIR}/../data/skimmer/Feb24\"\n",
Expand Down Expand Up @@ -109,10 +109,11 @@
"\n",
"for mX, mY in res_mps:\n",
" res_samples[\n",
" f\"X[{mX}]->H(bb)Y[{mY}](VV)\"\n",
" f\"X[{mX}]->H(bb)Y[{mY}](WW)\"\n",
" ] = f\"NMSSM_XToYH_MX{mX}_MY{mY}_HTo2bYTo2W_hadronicDecay\"\n",
"\n",
"res_sig_keys = list(res_samples.keys())"
"res_sig_keys = list(res_samples.keys())\n",
"nonres_sig_keys = [\"HHbbVV\"]"
]
},
{
Expand Down Expand Up @@ -368,12 +369,12 @@
" \"colour\": \"orange\",\n",
" },\n",
" \"thvv4q\": {\n",
" \"title\": \"ParT MD THWW\",\n",
" \"title\": \"ParT MD THVV\",\n",
" \"score_label\": \"ak8FatJetParTMD_THWW4q\",\n",
" \"colour\": \"green\",\n",
" },\n",
" \"thvv4qt\": {\n",
" \"title\": \"ParT MD THWW\",\n",
" \"title\": \"ParT MD THVV\",\n",
" \"score_label\": \"ak8FatJetParTMD_THWWvsT\",\n",
" \"colour\": \"green\",\n",
" },\n",
Expand Down Expand Up @@ -455,6 +456,7 @@
" np.zeros(int(np.ceil(np.sum(np.concatenate(bg_cuts)) / bg_skip))),\n",
" ]\n",
" )\n",
" # print(y_true[np.sum(sig_cut):])\n",
"\n",
" weights = np.concatenate(\n",
" [events_dict[sig_key][\"weight\"][sig_cut]]\n",
Expand All @@ -463,6 +465,7 @@
" for bg_key, bg_cut in zip(bg_keys, bg_cuts)\n",
" ],\n",
" )\n",
" # print(weights[np.sum(sig_cut):])\n",
"\n",
" for t, pvars in plot_vars.items():\n",
" score_label = pvars[\"score_label\"]\n",
Expand All @@ -473,6 +476,7 @@
" for bg_key, bg_cut in zip(bg_keys, bg_cuts)\n",
" ],\n",
" )\n",
" # print(scores[np.sum(sig_cut):])\n",
" fpr, tpr, thresholds = roc_curve(y_true, scores, sample_weight=weights)\n",
" rocs[cutstr][sig_key][t] = {\n",
" \"fpr\": fpr,\n",
Expand Down Expand Up @@ -522,7 +526,7 @@
"]\n",
"\n",
"sig_splits = [\n",
" [\"HHbbVV\"] + [f\"X[{mX}]->H(bb)Y[{mY}](VV)\" for (mX, mY) in mps] for mps in sig_split_points\n",
" [\"HHbbVV\"] + [f\"X[{mX}]->H(bb)Y[{mY}](WW)\" for (mX, mY) in mps] for mps in sig_split_points\n",
"]"
]
},
Expand Down Expand Up @@ -563,7 +567,7 @@
" # \"colour\": \"green\",\n",
" # },\n",
" \"thvv4qt\": {\n",
" \"title\": \"ParT MD THWW\",\n",
" \"title\": \"ParT MD THVV\",\n",
" \"score_label\": \"ak8FatJetParTMD_THWWvsT\",\n",
" \"colour\": \"green\",\n",
" },\n",
Expand All @@ -588,7 +592,7 @@
" color=c,\n",
" )\n",
" for th in plot_thresholds:\n",
" idx = find_nearest(thresholds, th)\n",
" idx = find_nearest(roc[\"thresholds\"], th)\n",
" pths[th][0].append(roc[\"tpr\"][idx])\n",
" pths[th][1].append(roc[\"fpr\"][idx])\n",
"\n",
Expand All @@ -605,7 +609,7 @@
" *pths[th],\n",
" marker=\"o\",\n",
" s=40,\n",
" label=f\"THWW > {th:.2f}\",\n",
" label=f\"THVV > {th:.2f}\",\n",
" color=th_colours[k],\n",
" zorder=100,\n",
" )\n",
Expand Down
2 changes: 1 addition & 1 deletion src/HHbbVV/postprocessing/hh_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
]

for mX, mY in res_mps:
res_samples[f"X[{mX}]->H(bb)Y[{mY}](VV)"] = f"NMSSM_XToYHTo2W2BTo4Q2B_MX-{mX}_MY-{mY}"
res_samples[f"X[{mX}]->H(bb)Y[{mY}](WW)"] = f"NMSSM_XToYHTo2W2BTo4Q2B_MX-{mX}_MY-{mY}"

res_sig_keys = list(res_samples.keys())

Expand Down
2 changes: 2 additions & 0 deletions src/HHbbVV/processors/corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def add_systs(systlist, qcdcorr, ewkcorr, vpt):
def add_ps_weight(weights, ps_weights):
"""
Parton Shower Weights (FSR and ISR)
"Default" variation: https://twiki.cern.ch/twiki/bin/view/CMS/HowToPDF#Which_set_of_weights_to_use
i.e. scaling ISR up and down
"""

nweights = len(weights.weight())
Expand Down

0 comments on commit c94b3b1

Please sign in to comment.