Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/rkansal47/HHbbVV
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed Mar 24, 2024
2 parents 907f8e3 + eb182ed commit a7ee047
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 30 deletions.
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_schedule: quarterly

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "24.2.0"
rev: "24.3.0"
hooks:
- id: black-jupyter
args: [--line-length=100]
Expand Down Expand Up @@ -47,7 +48,7 @@ repos:
# args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.2"
rev: "v0.3.3"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -70,7 +71,7 @@ repos:
args: ["--ignore-words", ".codespell-whitelist.txt"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
rev: "v0.10.0.1"
hooks:
- id: shellcheck

Expand Down
136 changes: 109 additions & 27 deletions src/HHbbVV/VBF_binder/VBFKinematicsStudyRK.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"source": [
"events = nanoevents.NanoEventsFactory.from_root(\n",
" # \"root://cmseos.fnal.gov///store/user/lpcpfnano/cmantill/v2_3/2018/HH/VBF_HHTobbVV_CV_1_C2V__C3_1_TuneCP5_13TeV-madgraph-pythia8/VBF_HHTobbVV_CV_1_C2V_1_C3_1/220808_150149/0000/nano_mc2018_1-1.root\",\n",
" \"root://cmseos.fnal.gov///store/user/lpcpfnano/cmantill/v2_3/2018/HH/VBF_HHTobbVV_CV_1_C2V_0_C3_1_TuneCP5_13TeV-madgraph-pythia8/VBF_HHTobbVV_CV_1_C2V_0_C3_1/220808_150000/0000/nano_mc2018_1-1.root\",\n",
" # \"root://cmseos.fnal.gov///store/user/lpcpfnano/cmantill/v2_3/2018/HH/VBF_HHTobbVV_CV_1_C2V_0_C3_1_TuneCP5_13TeV-madgraph-pythia8/VBF_HHTobbVV_CV_1_C2V_0_C3_1/220808_150000/0000/nano_mc2018_1-1.root\",\n",
" \"/uscms/home/rkansal/nobackup/vbf.root\",\n",
" schemaclass=nanoevents.NanoAODSchema,\n",
").events()\n",
"\n",
Expand Down Expand Up @@ -223,15 +224,6 @@
"metadata": {},
"outputs": [],
"source": [
"ak4_jet_selection = { # noqa: RUF012\n",
" \"pt\": 25,\n",
" \"eta\": 2.7,\n",
" \"jetId\": \"tight\",\n",
" \"puId\": \"medium\",\n",
" \"dR_fatjetbb\": 1.2,\n",
" \"dR_fatjetVV\": 0.8,\n",
"}\n",
"\n",
"# ak8 jet preselection\n",
"preselection = { # noqa: RUF012\n",
" \"pt\": 300.0,\n",
Expand Down Expand Up @@ -259,6 +251,10 @@
"source": [
"fatjets = events.FatJet\n",
"\n",
"fatjets = ak.pad_none(\n",
" fatjets[(fatjets.pt > 300) * (fatjets.isTight) * (np.abs(fatjets.eta) <= 2.4)], 2, axis=1\n",
")\n",
"\n",
"# particlenet xbb vs qcd\n",
"\n",
"txbb = pad_val(\n",
Expand All @@ -273,13 +269,45 @@
"bb_mask = np.stack((bb_mask, ~bb_mask)).T"
]
},
{
"cell_type": "markdown",
"id": "6922c210",
"metadata": {},
"source": [
"Leptons"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fa386f98",
"metadata": {},
"outputs": [],
"source": [
"electrons = events.Electron\n",
"electrons = electrons[(electrons.pt > 5) & (electrons.cutBased >= electrons.LOOSE)]\n",
"\n",
"muons = events.Muon\n",
"muons = muons[(muons.pt > 7) & (muons.looseId)]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "629523e9",
"metadata": {},
"outputs": [],
"source": [
"ak4_jet_selection = { # noqa: RUF012\n",
" \"pt\": 15,\n",
" \"eta_min\": 0,\n",
" \"eta_max\": 4.9,\n",
" \"jetId\": \"tight\",\n",
" \"puId\": \"medium\",\n",
" \"dR_fatjetbb\": 1.15,\n",
" \"dR_fatjetVV\": 0.95,\n",
"}\n",
"\n",
"jets = events.Jet\n",
"\n",
"# dR_fatjetVV = 0.8 used from last two cells of VBFgenInfoTests.ipynb with data generated from SM signal vbf\n",
Expand All @@ -288,48 +316,102 @@
"vbf_jet_mask = (\n",
" jets.isTight\n",
" & (jets.pt > ak4_jet_selection[\"pt\"])\n",
" & (np.abs(jets.eta) < 4.7)\n",
" & (np.abs(jets.eta) < ak4_jet_selection[\"eta_max\"])\n",
" & (np.abs(jets.eta) >= ak4_jet_selection[\"eta_min\"])\n",
" # medium puId https://twiki.cern.ch/twiki/bin/viewauth/CMS/PileupJetIDUL\n",
" & ((jets.pt > 50) | ((jets.puId & 2) == 2))\n",
" & (\n",
" ak.all(\n",
" jets.metric_table(\n",
" ak.singletons(ak.pad_none(fatjets, num_jets, axis=1, clip=True)[bb_mask])\n",
" )\n",
" > ak4_jet_selection[\"dR_fatjetbb\"],\n",
" axis=-1,\n",
" )\n",
" ak.pad_none(fatjets, num_jets, axis=1, clip=True)[bb_mask].delta_r(jets)\n",
" > ak4_jet_selection[\"dR_fatjetbb\"]\n",
" )\n",
" & (\n",
" ak.all(\n",
" jets.metric_table(\n",
" ak.singletons(ak.pad_none(fatjets, num_jets, axis=1, clip=True)[~bb_mask])\n",
" )\n",
" > ak4_jet_selection[\"dR_fatjetVV\"],\n",
" axis=-1,\n",
" )\n",
" ak.pad_none(fatjets, num_jets, axis=1, clip=True)[~bb_mask].delta_r(jets)\n",
" > ak4_jet_selection[\"dR_fatjetVV\"]\n",
" )\n",
" & ak.all(jets.metric_table(electrons) > 0.4, axis=2)\n",
" & ak.all(jets.metric_table(muons) > 0.4, axis=2)\n",
")\n",
"\n",
"vbf_jets = jets[vbf_jet_mask]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b44eb17d",
"metadata": {},
"outputs": [],
"source": [
"sel = ak.fill_none(\n",
" (\n",
" (txbb[bb_mask] > 0.97)\n",
" * (fatjets.particleNet_H4qvsQCD[~bb_mask] > 0.6)\n",
" * (fatjets.pt[:, 0] > 500)\n",
" * (fatjets.pt[:, 1] > 400)\n",
" * (np.abs(fatjets[:, 0].delta_phi(fatjets[:, 1])) > 2.6)\n",
" * (np.abs(fatjets[:, 0].eta - fatjets[:, 1].eta) < 2.0)\n",
" ),\n",
" False,\n",
")\n",
"\n",
"matching_efficiency(gen_quarks[sel], vbf_jets[sel])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d2998910",
"metadata": {},
"outputs": [],
"source": [
"etas = pad_val(vbf_jets.eta, 2, axis=1)\n",
"etas = pad_val(\n",
" vbf_jets[ak.fill_none(sel & (ak.count(vbf_jets.pt, axis=1) >= 2), False)].eta, 2, axis=1\n",
")\n",
"\n",
"plt.rcParams.update({\"font.size\": 24})\n",
"plt.figure(figsize=(12, 12))\n",
"plt.hist(np.abs(etas[:, 0] - etas[:, 1]), np.arange(0, 6, 0.25), histtype=\"step\", density=True)\n",
"plt.hist(np.abs(etas[:, 0] - etas[:, 1]), np.arange(0, 10, 0.25), histtype=\"step\", density=True)\n",
"plt.xlabel(r\"$\\eta_{jj}$\")\n",
"plt.ylabel(\"Events (A. U.)\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "f820fb8e",
"metadata": {},
"source": [
"Checking how many events have jets which match with the gen quarks"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b5c0658f",
"metadata": {},
"outputs": [],
"source": [
"jets = events.Jet\n",
"np.mean(ak.all(ak.any(gen_quarks.metric_table(jets) < 0.4, axis=2), axis=1))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7901612f",
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(8, 8))\n",
"plt.hist(\n",
" ak.sum(ak.any(gen_quarks.metric_table(jets) < 0.4, axis=2), axis=1),\n",
" [0, 1, 2, 3],\n",
" histtype=\"step\",\n",
" density=True,\n",
")\n",
"plt.title(\"Fraction of Gen VBF Quarks which have\\n a matching AK4 jet in the event\")\n",
"plt.show()"
]
}
],
"metadata": {
Expand Down

0 comments on commit a7ee047

Please sign in to comment.