{ "cells": [ { "cell_type": "markdown", "id": "e5722934-9a3f-4e0d-8178-f4ea63e53db8", "metadata": {}, "source": [ "# Object systematics\n", "This is a rendered copy of [systematics.ipynb](https://github.com/scikit-hep/coffea/blob/master/binder/systematics.ipynb). You can optionally run it interactively on [binder at this link](https://mybinder.org/v2/gh/coffeateam/coffea/master?filepath=binder%2Fsystematics.ipynb)\n", "\n", "This notebook presents how to add systematics to objects in coffea.\\\n", "Coffea currently implements two types of object systematics. `UpDownSystematic` which varies one field on the object it is applied on and `UpDownMultiSystematic` which varies multiple fields on the object it is applied on.\\\n", "Check the snippets below for example usage." ] }, { "cell_type": "code", "execution_count": 1, "id": "839ca214", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/iason/Dropbox/work/pyhep_dev/coffea/src/coffea/nanoevents/schemas/nanoaod.py:264: RuntimeWarning: Missing cross-reference index for LowPtElectron_electronIdx => Electron\n", " warnings.warn(\n", "/home/iason/Dropbox/work/pyhep_dev/coffea/src/coffea/nanoevents/schemas/nanoaod.py:264: RuntimeWarning: Missing cross-reference index for LowPtElectron_genPartIdx => GenPart\n", " warnings.warn(\n", "/home/iason/Dropbox/work/pyhep_dev/coffea/src/coffea/nanoevents/schemas/nanoaod.py:264: RuntimeWarning: Missing cross-reference index for LowPtElectron_photonIdx => Photon\n", " warnings.warn(\n", "/home/iason/Dropbox/work/pyhep_dev/coffea/src/coffea/nanoevents/schemas/nanoaod.py:264: RuntimeWarning: Missing cross-reference index for FatJet_genJetAK8Idx => GenJetAK8\n", " warnings.warn(\n" ] } ], "source": [ "import awkward\n", "import numpy as np\n", "from coffea import nanoevents\n", "\n", "\n", "def get_array(array):\n", " return array.compute() if nanoevents_mode == \"dask\" else array\n", "\n", "\n", "nanoevents_mode = \"virtual\"\n", "\n", "access_log = []\n", "events = nanoevents.NanoEventsFactory.from_root({\"coffea/tests/samples/nano_dy.root\": \"Events\"}, mode=nanoevents_mode, access_log=access_log).events()\n", "\n", "muons = events.Muon\n", "jets = events.Jet\n", "met = events.MET" ] }, { "cell_type": "code", "execution_count": 2, "id": "b803b91b", "metadata": {}, "outputs": [], "source": [ "def some_event_weight(ones):\n", " return (1.0 + np.array([0.05, -0.05], dtype=np.float32)) * ones[:, None]\n", "\n", "\n", "events.add_systematic(\"RenFactScale\", \"UpDownSystematic\", \"weight\", some_event_weight)\n", "events.add_systematic(\"XSectionUncertainty\", \"UpDownSystematic\", \"weight\", some_event_weight)\n", "\n", "\n", "def muon_pt_scale(pt):\n", " return (1.0 + np.array([0.05, -0.05], dtype=np.float32)) * pt[:, None]\n", "\n", "\n", "def muon_pt_resolution(pt):\n", " return np.random.normal(pt[:, None], np.array([0.02, 0.01], dtype=np.float32))\n", "\n", "\n", "def muon_eff_weight(ones):\n", " return (1.0 + np.array([0.05, -0.05], dtype=np.float32)) * ones[:, None]\n", "\n", "\n", "def muon_pt_phi_systematic(ptphi):\n", " pt_var = (1.0 + np.array([0.05, -0.05], dtype=np.float32)) * ptphi.pt[:, None]\n", " phi_var = (1.0 + np.array([0.1, -0.1], dtype=np.float32)) * ptphi.phi[:, None]\n", " return awkward.zip({\"pt\": pt_var, \"phi\": phi_var}, depth_limit=1)\n", "\n", "\n", "muons.add_systematic(\"PtScale\", \"UpDownSystematic\", \"pt\", muon_pt_scale)\n", "muons.add_systematic(\"PtResolution\", \"UpDownSystematic\", \"pt\", muon_pt_resolution)\n", "muons.add_systematic(\"EfficiencySF\", \"UpDownSystematic\", \"weight\", muon_eff_weight)\n", "muons.add_systematic(\"PtPhiSystematic\", \"UpDownMultiSystematic\", (\"pt\", \"phi\"), muon_pt_phi_systematic)\n", "\n", "\n", "def jet_pt_scale(pt):\n", " return (1.0 + np.array([0.10, -0.10], dtype=np.float32)) * pt[:, None]\n", "\n", "\n", "def jet_pt_resolution(pt):\n", " return np.random.normal(pt[:, None], np.array([0.20, 0.10], dtype=np.float32))\n", "\n", "\n", "def jet_pt_phi_systematic(ptphi):\n", " pt_var = (1.0 + np.array([0.10, -0.10], dtype=np.float32)) * ptphi.pt[:, None]\n", " phi_var = (1.0 + np.array([0.2, -0.2], dtype=np.float32)) * ptphi.phi[:, None]\n", " return awkward.zip({\"pt\": pt_var, \"phi\": phi_var}, depth_limit=1)\n", "\n", "\n", "jets.add_systematic(\"PtScale\", \"UpDownSystematic\", \"pt\", jet_pt_scale)\n", "jets.add_systematic(\"PtResolution\", \"UpDownSystematic\", \"pt\", jet_pt_resolution)\n", "jets.add_systematic(\"PtPhiSystematic\", \"UpDownMultiSystematic\", (\"pt\", \"phi\"), jet_pt_phi_systematic)\n", "\n", "\n", "def met_pt_scale(pt):\n", " return (1.0 + np.array([0.03, -0.03], dtype=np.float32)) * pt[:, None]\n", "\n", "\n", "def met_pt_phi_systematic(ptphi):\n", " pt_var = (1.0 + np.array([0.03, -0.03], dtype=np.float32)) * ptphi.pt[:, None]\n", " phi_var = (1.0 + np.array([0.05, -0.05], dtype=np.float32)) * ptphi.phi[:, None]\n", " return awkward.zip({\"pt\": pt_var, \"phi\": phi_var}, depth_limit=1)\n", "\n", "\n", "met.add_systematic(\"PtScale\", \"UpDownMultiSystematic\", \"pt\", met_pt_scale)\n", "met.add_systematic(\"PtPhiSystematic\", \"UpDownMultiSystematic\", (\"pt\", \"phi\"), met_pt_phi_systematic)" ] }, { "cell_type": "code", "execution_count": 3, "id": "5891478d-fa9c-416f-9bc8-4998135be1c5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " ...,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05,\n",
       " 1.05]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 320 B\n",
       "type: 40 * float64
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "renfact_up = events.systematics.RenFactScale.up.weight_RenFactScale\n", "get_array(renfact_up)" ] }, { "cell_type": "code", "execution_count": 4, "id": "b88cf664", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[76.8,\n",
       " 20.1,\n",
       " 31,\n",
       " 50.6,\n",
       " 14.3,\n",
       " 16.7,\n",
       " 13.9,\n",
       " 46.5,\n",
       " 40.7,\n",
       " 51.4,\n",
       " 39.6,\n",
       " 38.9,\n",
       " 33.7,\n",
       " 17.1,\n",
       " 14.5,\n",
       " 4.36,\n",
       " 10.1,\n",
       " 17.9]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 72 B\n",
       "type: 18 * float32[parameters={"__doc__": "pt", "typename": "float[]"}]
" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "muon_pt = awkward.flatten(muons.pt)\n", "get_array(muon_pt)" ] }, { "cell_type": "code", "execution_count": 5, "id": "c89f8fd1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[{dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...}]\n",
       "------------------------------------------------------------------\n",
       "backend: cpu\n",
       "nbytes: 3.1 kB\n",
       "type: 18 * Muon[\n",
       "    dxy: float32[parameters={"__doc__": "dxy (with sign) wrt first PV, in cm", "typename": "float[]"}],\n",
       "    dxyErr: float32[parameters={"__doc__": "dxy uncertainty, in cm", "typename": "float[]"}],\n",
       "    dz: float32[parameters={"__doc__": "dz (with sign) wrt first PV, in cm", "typename": "float[]"}],\n",
       "    dzErr: float32[parameters={"__doc__": "dz uncertainty, in cm", "typename": "float[]"}],\n",
       "    eta: float32[parameters={"__doc__": "eta", "typename": "float[]"}],\n",
       "    ip3d: float32[parameters={"__doc__": "3D impact parameter wrt first PV, in cm", "typename": "float[]"}],\n",
       "    jetPtRelv2: float32[parameters={"__doc__": "Relative momentum of the lepton with respect to the closest jet after subtracting the lepton", "typename": "float[]"}],\n",
       "    jetRelIso: float32[parameters={"__doc__": "Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)", "typename": "float[]"}],\n",
       "    mass: float32[parameters={"__doc__": "mass", "typename": "float[]"}],\n",
       "    miniPFRelIso_all: float32[parameters={"__doc__": "mini PF relative isolation, total (with scaled rho*EA PU corrections)", "typename": "float[]"}],\n",
       "    ...\n",
       "parameters={"__doc__": "slimmedMuons after basic selection (pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('SoftMvaId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt')))", "collection_name": "Muon", "variation": "PtScale-pt-up"}]
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "muon_PtScale_up = awkward.flatten(muons.systematics.PtScale.up)\n", "get_array(muon_PtScale_up)" ] }, { "cell_type": "code", "execution_count": 6, "id": "3f484489", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[80.6,\n",
       " 21.1,\n",
       " 32.6,\n",
       " 53.2,\n",
       " 15,\n",
       " 17.6,\n",
       " 14.6,\n",
       " 48.8,\n",
       " 42.7,\n",
       " 54,\n",
       " 41.6,\n",
       " 40.8,\n",
       " 35.4,\n",
       " 17.9,\n",
       " 15.3,\n",
       " 4.58,\n",
       " 10.6,\n",
       " 18.8]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 72 B\n",
       "type: 18 * float32
" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "muon_PtScale_up_pt = awkward.flatten(muons.systematics.PtScale.up.pt)\n", "get_array(muon_PtScale_up_pt)" ] }, { "cell_type": "code", "execution_count": 7, "id": "73aa4936-eca2-4382-ac00-15ecd69580f1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[{dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...},\n",
       " {dxy: ??, dxyErr: ??, dz: ??, dzErr: ??, eta: ??, ip3d: ??, ...}]\n",
       "------------------------------------------------------------------\n",
       "backend: cpu\n",
       "nbytes: 3.1 kB\n",
       "type: 18 * Muon[\n",
       "    dxy: float32[parameters={"__doc__": "dxy (with sign) wrt first PV, in cm", "typename": "float[]"}],\n",
       "    dxyErr: float32[parameters={"__doc__": "dxy uncertainty, in cm", "typename": "float[]"}],\n",
       "    dz: float32[parameters={"__doc__": "dz (with sign) wrt first PV, in cm", "typename": "float[]"}],\n",
       "    dzErr: float32[parameters={"__doc__": "dz uncertainty, in cm", "typename": "float[]"}],\n",
       "    eta: float32[parameters={"__doc__": "eta", "typename": "float[]"}],\n",
       "    ip3d: float32[parameters={"__doc__": "3D impact parameter wrt first PV, in cm", "typename": "float[]"}],\n",
       "    jetPtRelv2: float32[parameters={"__doc__": "Relative momentum of the lepton with respect to the closest jet after subtracting the lepton", "typename": "float[]"}],\n",
       "    jetRelIso: float32[parameters={"__doc__": "Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)", "typename": "float[]"}],\n",
       "    mass: float32[parameters={"__doc__": "mass", "typename": "float[]"}],\n",
       "    miniPFRelIso_all: float32[parameters={"__doc__": "mini PF relative isolation, total (with scaled rho*EA PU corrections)", "typename": "float[]"}],\n",
       "    ...\n",
       "parameters={"__doc__": "slimmedMuons after basic selection (pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('SoftMvaId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt')))", "collection_name": "Muon", "variation": "PtPhiSystematic-('pt', 'phi')-up"}]
" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "muons_PtPhiSystematic_up = awkward.flatten(muons.systematics.PtPhiSystematic.up)\n", "get_array(muons_PtPhiSystematic_up)" ] }, { "cell_type": "code", "execution_count": 8, "id": "59ebd13c-3a9c-4cbf-a94d-08dc67332eb3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[80.6,\n",
       " 21.1,\n",
       " 32.6,\n",
       " 53.2,\n",
       " 15,\n",
       " 17.6,\n",
       " 14.6,\n",
       " 48.8,\n",
       " 42.7,\n",
       " 54,\n",
       " 41.6,\n",
       " 40.8,\n",
       " 35.4,\n",
       " 17.9,\n",
       " 15.3,\n",
       " 4.58,\n",
       " 10.6,\n",
       " 18.8]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 72 B\n",
       "type: 18 * float32
" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "muons_PtPhiSystematic_up_pt = awkward.flatten(muons.systematics.PtPhiSystematic.up.pt)\n", "get_array(muons_PtPhiSystematic_up_pt)" ] }, { "cell_type": "code", "execution_count": 9, "id": "c225ac29-f177-45c5-b47d-aedb94150c7d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[1.8,\n",
       " -3.16,\n",
       " -1.54,\n",
       " 0.522,\n",
       " -2.9,\n",
       " -3.34,\n",
       " -1.08,\n",
       " -2.14,\n",
       " 1.66,\n",
       " 3.17,\n",
       " -0.407,\n",
       " -0.385,\n",
       " 3.26,\n",
       " 0.532,\n",
       " -2.88,\n",
       " -0.784,\n",
       " -2.41,\n",
       " 3.19]\n",
       "--------\n",
       "backend: cpu\n",
       "nbytes: 72 B\n",
       "type: 18 * float32
" ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "muons_PtPhiSystematic_up_phi = awkward.flatten(muons.systematics.PtPhiSystematic.up.phi)\n", "get_array(muons_PtPhiSystematic_up_phi)" ] }, { "cell_type": "code", "execution_count": 10, "id": "7c806b7d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[80.8,\n",
       " 45.6,\n",
       " 29.6,\n",
       " 17.6,\n",
       " 15.2,\n",
       " 106,\n",
       " 38.9,\n",
       " 26,\n",
       " 19.9,\n",
       " 18.2,\n",
       " ...,\n",
       " 22.1,\n",
       " 56.9,\n",
       " 53.6,\n",
       " 24.7,\n",
       " 21.6,\n",
       " 20.2,\n",
       " 15.2,\n",
       " 18.8,\n",
       " 18.3]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 752 B\n",
       "type: 188 * float32[parameters={"__doc__": "pt", "typename": "float[]"}]
" ], "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jets_pt = awkward.flatten(jets.pt)\n", "get_array(jets_pt)" ] }, { "cell_type": "code", "execution_count": 11, "id": "e7adf5de", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[{area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " ...,\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...}]\n",
       "----------------------------------------------------------------------------\n",
       "backend: cpu\n",
       "nbytes: unknown\n",
       "type: 188 * Jet[\n",
       "    area: float32[parameters={"__doc__": "jet catchment area, for JECs", "typename": "float[]"}],\n",
       "    btagCMVA: float32[parameters={"__doc__": "CMVA V2 btag discriminator", "typename": "float[]"}],\n",
       "    btagCSVV2: float32[parameters={"__doc__": " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)", "typename": "float[]"}],\n",
       "    btagDeepB: float32[parameters={"__doc__": "DeepCSV b+bb tag discriminator", "typename": "float[]"}],\n",
       "    btagDeepC: float32[parameters={"__doc__": "DeepCSV charm btag discriminator", "typename": "float[]"}],\n",
       "    btagDeepFlavB: float32[parameters={"__doc__": "DeepFlavour b+bb+lepb tag discriminator", "typename": "float[]"}],\n",
       "    btagDeepFlavC: float32[parameters={"__doc__": "DeepFlavour charm tag discriminator", "typename": "float[]"}],\n",
       "    chEmEF: float32[parameters={"__doc__": "charged Electromagnetic Energy Fraction", "typename": "float[]"}],\n",
       "    chHEF: float32[parameters={"__doc__": "charged Hadron Energy Fraction", "typename": "float[]"}],\n",
       "    eta: float32[parameters={"__doc__": "eta", "typename": "float[]"}],\n",
       "    ...\n",
       "parameters={"__doc__": "slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (pt > 15)", "collection_name": "Jet", "variation": "PtScale-pt-up"}]
" ], "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jets_PtScale_up = awkward.flatten(jets.systematics.PtScale.up)\n", "get_array(jets_PtScale_up)" ] }, { "cell_type": "code", "execution_count": 12, "id": "f01ca3a9", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[88.8,\n",
       " 50.2,\n",
       " 32.6,\n",
       " 19.3,\n",
       " 16.8,\n",
       " 116,\n",
       " 42.8,\n",
       " 28.5,\n",
       " 21.9,\n",
       " 20,\n",
       " ...,\n",
       " 24.3,\n",
       " 62.6,\n",
       " 59,\n",
       " 27.2,\n",
       " 23.8,\n",
       " 22.2,\n",
       " 16.7,\n",
       " 20.7,\n",
       " 20.1]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 752 B\n",
       "type: 188 * float32
" ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jets_PtScale_up_pt = awkward.flatten(jets.systematics.PtScale.up.pt)\n", "get_array(jets_PtScale_up_pt)" ] }, { "cell_type": "code", "execution_count": 13, "id": "b25c46d6-07c0-444b-9627-f9507ca17130", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[{area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " ...,\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...},\n",
       " {area: ??, btagCMVA: ??, btagCSVV2: ??, btagDeepB: ??, btagDeepC: ??, ...}]\n",
       "----------------------------------------------------------------------------\n",
       "backend: cpu\n",
       "nbytes: unknown\n",
       "type: 188 * Jet[\n",
       "    area: float32[parameters={"__doc__": "jet catchment area, for JECs", "typename": "float[]"}],\n",
       "    btagCMVA: float32[parameters={"__doc__": "CMVA V2 btag discriminator", "typename": "float[]"}],\n",
       "    btagCSVV2: float32[parameters={"__doc__": " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)", "typename": "float[]"}],\n",
       "    btagDeepB: float32[parameters={"__doc__": "DeepCSV b+bb tag discriminator", "typename": "float[]"}],\n",
       "    btagDeepC: float32[parameters={"__doc__": "DeepCSV charm btag discriminator", "typename": "float[]"}],\n",
       "    btagDeepFlavB: float32[parameters={"__doc__": "DeepFlavour b+bb+lepb tag discriminator", "typename": "float[]"}],\n",
       "    btagDeepFlavC: float32[parameters={"__doc__": "DeepFlavour charm tag discriminator", "typename": "float[]"}],\n",
       "    chEmEF: float32[parameters={"__doc__": "charged Electromagnetic Energy Fraction", "typename": "float[]"}],\n",
       "    chHEF: float32[parameters={"__doc__": "charged Hadron Energy Fraction", "typename": "float[]"}],\n",
       "    eta: float32[parameters={"__doc__": "eta", "typename": "float[]"}],\n",
       "    ...\n",
       "parameters={"__doc__": "slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (pt > 15)", "collection_name": "Jet", "variation": "PtPhiSystematic-('pt', 'phi')-up"}]
" ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jets_PtPhiSystematic_up = awkward.flatten(jets.systematics.PtPhiSystematic.up)\n", "get_array(jets_PtPhiSystematic_up)" ] }, { "cell_type": "code", "execution_count": 14, "id": "624e0a92-7c25-4837-936e-6f1a2d779840", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[88.8,\n",
       " 50.2,\n",
       " 32.6,\n",
       " 19.3,\n",
       " 16.8,\n",
       " 116,\n",
       " 42.8,\n",
       " 28.5,\n",
       " 21.9,\n",
       " 20,\n",
       " ...,\n",
       " 24.3,\n",
       " 62.6,\n",
       " 59,\n",
       " 27.2,\n",
       " 23.8,\n",
       " 22.2,\n",
       " 16.7,\n",
       " 20.7,\n",
       " 20.1]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 752 B\n",
       "type: 188 * float32
" ], "text/plain": [ "" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jets_PtPhiSystematic_up_pt = awkward.flatten(jets.systematics.PtPhiSystematic.up.pt)\n", "get_array(jets_PtPhiSystematic_up_pt)" ] }, { "cell_type": "code", "execution_count": 15, "id": "57ed7ef4-1108-4b66-8711-6e4f6d6ec582", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[-1.09,\n",
       " 1.98,\n",
       " -3.43,\n",
       " -2.77,\n",
       " 2.58,\n",
       " -0.778,\n",
       " -3.49,\n",
       " 2.69,\n",
       " 3.45,\n",
       " 2.13,\n",
       " ...,\n",
       " 2.54,\n",
       " 0.0636,\n",
       " -3.63,\n",
       " 0.638,\n",
       " 0.462,\n",
       " -3.23,\n",
       " 1.89,\n",
       " 3.14,\n",
       " 2.85]\n",
       "--------\n",
       "backend: cpu\n",
       "nbytes: 752 B\n",
       "type: 188 * float32
" ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jets_PtPhiSystematic_up_phi = awkward.flatten(jets.systematics.PtPhiSystematic.up.phi)\n", "get_array(jets_PtPhiSystematic_up_phi)" ] }, { "cell_type": "code", "execution_count": 16, "id": "f19c117d-22e9-41ee-a53b-4277902c20a2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[25.9,\n",
       " 40.5,\n",
       " 38.7,\n",
       " 9.41,\n",
       " 10.9,\n",
       " 14.1,\n",
       " 4.82,\n",
       " 50.9,\n",
       " 39.7,\n",
       " 61.8,\n",
       " ...,\n",
       " 23.8,\n",
       " 45.1,\n",
       " 16.8,\n",
       " 13.1,\n",
       " 4.5,\n",
       " 82.1,\n",
       " 24.8,\n",
       " 24.2,\n",
       " 42.5]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 160 B\n",
       "type: 40 * float32[parameters={"__doc__": "pt", "typename": "float"}]
" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "met_pt = met.pt\n", "get_array(met_pt)" ] }, { "cell_type": "code", "execution_count": 17, "id": "64291981-0bca-4d53-bf13-3694b946174c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[{MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " ...,\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...}]\n",
       "----------------------------------------------------------------------\n",
       "backend: cpu\n",
       "nbytes: 1.8 kB\n",
       "type: 40 * MissingET[\n",
       "    MetUnclustEnUpDeltaX: float32[parameters={"__doc__": "Delta (METx_mod-METx) Unclustered Energy Up", "typename": "float"}],\n",
       "    MetUnclustEnUpDeltaY: float32[parameters={"__doc__": "Delta (METy_mod-METy) Unclustered Energy Up", "typename": "float"}],\n",
       "    covXX: float32[parameters={"__doc__": "xx element of met covariance matrix", "typename": "float"}],\n",
       "    covXY: float32[parameters={"__doc__": "xy element of met covariance matrix", "typename": "float"}],\n",
       "    covYY: float32[parameters={"__doc__": "yy element of met covariance matrix", "typename": "float"}],\n",
       "    phi: float32[parameters={"__doc__": "phi", "typename": "float"}],\n",
       "    pt: float32,\n",
       "    significance: float32[parameters={"__doc__": "MET significance", "typename": "float"}],\n",
       "    sumEt: float32[parameters={"__doc__": "scalar sum of Et", "typename": "float"}],\n",
       "    fiducialGenPhi: float32[parameters={"__doc__": "phi", "typename": "float"}],\n",
       "    ...\n",
       "parameters={"collection_name": "MET", "variation": "PtScale-pt-up"}]
" ], "text/plain": [ "" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "met_PtScale_up = met.systematics.PtScale.up\n", "get_array(met_PtScale_up)" ] }, { "cell_type": "code", "execution_count": 18, "id": "aa95b610-55f8-4c6d-8c48-22e5b7294914", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[26.7,\n",
       " 41.7,\n",
       " 39.9,\n",
       " 9.69,\n",
       " 11.2,\n",
       " 14.5,\n",
       " 4.96,\n",
       " 52.4,\n",
       " 40.9,\n",
       " 63.6,\n",
       " ...,\n",
       " 24.5,\n",
       " 46.5,\n",
       " 17.3,\n",
       " 13.5,\n",
       " 4.63,\n",
       " 84.5,\n",
       " 25.6,\n",
       " 24.9,\n",
       " 43.8]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 160 B\n",
       "type: 40 * float32
" ], "text/plain": [ "" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "met_PtScale_up_pt = met.systematics.PtScale.up.pt\n", "get_array(met_PtScale_up_pt)" ] }, { "cell_type": "code", "execution_count": 19, "id": "217b8f22-d4c9-4136-8de8-8335c893c40a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[{MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " ...,\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...},\n",
       " {MetUnclustEnUpDeltaX: ??, MetUnclustEnUpDeltaY: ??, covXX: ??, ...}]\n",
       "----------------------------------------------------------------------\n",
       "backend: cpu\n",
       "nbytes: 1.8 kB\n",
       "type: 40 * MissingET[\n",
       "    MetUnclustEnUpDeltaX: float32[parameters={"__doc__": "Delta (METx_mod-METx) Unclustered Energy Up", "typename": "float"}],\n",
       "    MetUnclustEnUpDeltaY: float32[parameters={"__doc__": "Delta (METy_mod-METy) Unclustered Energy Up", "typename": "float"}],\n",
       "    covXX: float32[parameters={"__doc__": "xx element of met covariance matrix", "typename": "float"}],\n",
       "    covXY: float32[parameters={"__doc__": "xy element of met covariance matrix", "typename": "float"}],\n",
       "    covYY: float32[parameters={"__doc__": "yy element of met covariance matrix", "typename": "float"}],\n",
       "    phi: float32,\n",
       "    pt: float32,\n",
       "    significance: float32[parameters={"__doc__": "MET significance", "typename": "float"}],\n",
       "    sumEt: float32[parameters={"__doc__": "scalar sum of Et", "typename": "float"}],\n",
       "    fiducialGenPhi: float32[parameters={"__doc__": "phi", "typename": "float"}],\n",
       "    ...\n",
       "parameters={"collection_name": "MET", "variation": "PtPhiSystematic-('pt', 'phi')-up"}]
" ], "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "met_PtPhiSystematic_up = met.systematics.PtPhiSystematic.up\n", "get_array(met_PtPhiSystematic_up)" ] }, { "cell_type": "code", "execution_count": 20, "id": "94a768e6-89e1-41a1-83ee-b20e2baeaf3f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[26.7,\n",
       " 41.7,\n",
       " 39.9,\n",
       " 9.69,\n",
       " 11.2,\n",
       " 14.5,\n",
       " 4.96,\n",
       " 52.4,\n",
       " 40.9,\n",
       " 63.6,\n",
       " ...,\n",
       " 24.5,\n",
       " 46.5,\n",
       " 17.3,\n",
       " 13.5,\n",
       " 4.63,\n",
       " 84.5,\n",
       " 25.6,\n",
       " 24.9,\n",
       " 43.8]\n",
       "------\n",
       "backend: cpu\n",
       "nbytes: 160 B\n",
       "type: 40 * float32
" ], "text/plain": [ "" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "met_PtPhiSystematic_up_pt = met.systematics.PtPhiSystematic.up.pt\n", "get_array(met_PtPhiSystematic_up_pt)" ] }, { "cell_type": "code", "execution_count": 21, "id": "33b36c1e-988b-459b-9067-ad3ad63d7997", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[1.75,\n",
       " 2.05,\n",
       " -2.47,\n",
       " 3.01,\n",
       " 0.818,\n",
       " -3.16,\n",
       " -0.339,\n",
       " -0.0646,\n",
       " 0.0881,\n",
       " 1.37,\n",
       " ...,\n",
       " -0.541,\n",
       " 0.421,\n",
       " 0.818,\n",
       " -1.82,\n",
       " -2.36,\n",
       " 1.62,\n",
       " -2.47,\n",
       " -2.54,\n",
       " -0.687]\n",
       "---------\n",
       "backend: cpu\n",
       "nbytes: 160 B\n",
       "type: 40 * float32
" ], "text/plain": [ "" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "met_PtPhiSystematic_up_phi = met.systematics.PtPhiSystematic.up.phi\n", "get_array(met_PtPhiSystematic_up_phi)" ] }, { "cell_type": "code", "execution_count": null, "id": "3591fbf3", "metadata": {}, "outputs": [], "source": [ "# TODO: Make it so that syst_muons.Y > X returns boolean values\n", "# for all variations over Y.\n", "# Requires some tracking of (pieces of) \"what\"." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.0" } }, "nbformat": 4, "nbformat_minor": 5 }