Install libraries

[ ]:
!pip install git+https://github.com/maxymnaumchyk/awkward-zipper.git
Collecting git+https://github.com/maxymnaumchyk/awkward-zipper.git
  Cloning https://github.com/maxymnaumchyk/awkward-zipper.git to /tmp/pip-req-build-mvp0qy7q
  Running command git clone --filter=blob:none --quiet https://github.com/maxymnaumchyk/awkward-zipper.git /tmp/pip-req-build-mvp0qy7q
  Resolved https://github.com/maxymnaumchyk/awkward-zipper.git to commit dd3613d1da6b934240f01845392317c6e94b731d
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting awkward@ git+https://github.com/scikit-hep/awkward@main (from awkward-zipper==0.0.1)
  Cloning https://github.com/scikit-hep/awkward (to revision main) to /tmp/pip-install-r9r8y74u/awkward_3d58eb0a685741c0bbc580e5c5080ec1
  Running command git clone --filter=blob:none --quiet https://github.com/scikit-hep/awkward /tmp/pip-install-r9r8y74u/awkward_3d58eb0a685741c0bbc580e5c5080ec1
  Resolved https://github.com/scikit-hep/awkward to commit 8e2d4a85420e89617ccf5be0edef841d3b2d57bf
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numba in /usr/local/lib/python3.11/dist-packages (from awkward-zipper==0.0.1) (0.60.0)
Collecting vector (from awkward-zipper==0.0.1)
  Downloading vector-1.6.2-py3-none-any.whl.metadata (15 kB)
Collecting awkward-cpp==46 (from awkward@ git+https://github.com/scikit-hep/awkward@main->awkward-zipper==0.0.1)
  Downloading awkward_cpp-46-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Requirement already satisfied: fsspec>=2022.11.0 in /usr/local/lib/python3.11/dist-packages (from awkward@ git+https://github.com/scikit-hep/awkward@main->awkward-zipper==0.0.1) (2025.3.2)
Requirement already satisfied: importlib-metadata>=4.13.0 in /usr/local/lib/python3.11/dist-packages (from awkward@ git+https://github.com/scikit-hep/awkward@main->awkward-zipper==0.0.1) (8.7.0)
Requirement already satisfied: numpy>=1.18.0 in /usr/local/lib/python3.11/dist-packages (from awkward@ git+https://github.com/scikit-hep/awkward@main->awkward-zipper==0.0.1) (2.0.2)
Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from awkward@ git+https://github.com/scikit-hep/awkward@main->awkward-zipper==0.0.1) (24.2)
Requirement already satisfied: llvmlite<0.44,>=0.43.0dev0 in /usr/local/lib/python3.11/dist-packages (from numba->awkward-zipper==0.0.1) (0.43.0)
Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.11/dist-packages (from importlib-metadata>=4.13.0->awkward@ git+https://github.com/scikit-hep/awkward@main->awkward-zipper==0.0.1) (3.22.0)
Downloading awkward_cpp-46-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (638 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 638.7/638.7 kB 13.9 MB/s eta 0:00:00
Downloading vector-1.6.2-py3-none-any.whl (177 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 177.8/177.8 kB 12.1 MB/s eta 0:00:00
Building wheels for collected packages: awkward-zipper, awkward
  Building wheel for awkward-zipper (pyproject.toml) ... done
  Created wheel for awkward-zipper: filename=awkward_zipper-0.0.1-py3-none-any.whl size=23500 sha256=4b59bd8410f92e5013eeaced62f0f3ab5fa66fdbbddbe33990b90254dfdcf6de
  Stored in directory: /tmp/pip-ephem-wheel-cache-gvugxi0d/wheels/13/ff/6a/a86ac1ebbfd7f56ba74dec9ccffa35df23b6890fac28284fed
  Building wheel for awkward (pyproject.toml) ... done
  Created wheel for awkward: filename=awkward-2.8.3-py3-none-any.whl size=852964 sha256=ccdbcbdcabe7a578319d02cf78d7d8122baecd9204526d03999630d739e61048
  Stored in directory: /tmp/pip-ephem-wheel-cache-gvugxi0d/wheels/b9/90/e9/6455c7a94885426a7e2fc34b49d59ee756873090f777c368b0
Successfully built awkward-zipper awkward
Installing collected packages: vector, awkward-cpp, awkward, awkward-zipper
Successfully installed awkward-2.8.3 awkward-cpp-46 awkward-zipper-0.0.1 vector-1.6.2

Use a branch from main to load virtual arrays with uproot

[ ]:
!pip install uproot@git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy
Collecting uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy
  Cloning https://github.com/scikit-hep/uproot5 (to revision pfackeldey/uproot_lazy) to /tmp/pip-install-gc9d60kr/uproot_34e3315b4eb448c89caf404c61e204ab
  Running command git clone --filter=blob:none --quiet https://github.com/scikit-hep/uproot5 /tmp/pip-install-gc9d60kr/uproot_34e3315b4eb448c89caf404c61e204ab
  Running command git checkout -b pfackeldey/uproot_lazy --track origin/pfackeldey/uproot_lazy
  Switched to a new branch 'pfackeldey/uproot_lazy'
  Branch 'pfackeldey/uproot_lazy' set up to track remote branch 'pfackeldey/uproot_lazy' from 'origin'.
  Resolved https://github.com/scikit-hep/uproot5 to commit 892961513afd630bacd2495628c70b2c878da63a
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting awkward>=2.8.2 (from uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy)
  Downloading awkward-2.8.4-py3-none-any.whl.metadata (7.0 kB)
Requirement already satisfied: cramjam>=2.5.0 in /usr/local/lib/python3.11/dist-packages (from uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy) (2.10.0)
Requirement already satisfied: fsspec in /usr/local/lib/python3.11/dist-packages (from uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy) (2025.3.2)
Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy) (2.0.2)
Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy) (24.2)
Requirement already satisfied: xxhash in /usr/local/lib/python3.11/dist-packages (from uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy) (3.5.0)
Collecting awkward-cpp==46 (from awkward>=2.8.2->uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy)
  Downloading awkward_cpp-46-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Requirement already satisfied: importlib-metadata>=4.13.0 in /usr/local/lib/python3.11/dist-packages (from awkward>=2.8.2->uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy) (8.7.0)
Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.11/dist-packages (from importlib-metadata>=4.13.0->awkward>=2.8.2->uproot@ git+https://github.com/scikit-hep/uproot5@pfackeldey/uproot_lazy) (3.23.0)
Downloading awkward-2.8.4-py3-none-any.whl (886 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 886.3/886.3 kB 11.6 MB/s eta 0:00:00
Downloading awkward_cpp-46-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (638 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 638.7/638.7 kB 35.6 MB/s eta 0:00:00
Building wheels for collected packages: uproot
  Building wheel for uproot (pyproject.toml) ... done
  Created wheel for uproot: filename=uproot-5.6.2.dev25+g8929615-py3-none-any.whl size=377052 sha256=20d26986a5b56e6f7b3d8d155f2a128e1b9ebf773fae7237551abcdb33cec25c
  Stored in directory: /tmp/pip-ephem-wheel-cache-23008dtr/wheels/6d/4a/38/cca594ce698fdd158d6039640034edca9dda20c890c171703a
Successfully built uproot
Installing collected packages: awkward-cpp, awkward, uproot
Successfully installed awkward-2.8.4 awkward-cpp-46 uproot-5.6.2.dev25+g8929615

Download test root file

[ ]:
!wget {'https://raw.githubusercontent.com/scikit-hep/coffea/refs/heads/master/tests/samples/nano_dy.root'}
--2025-06-09 16:22:50--  https://raw.githubusercontent.com/scikit-hep/coffea/refs/heads/master/tests/samples/nano_dy.root
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 352599 (344K) [application/octet-stream]
Saving to: ‘nano_dy.root’

nano_dy.root        100%[===================>] 344.33K  --.-KB/s    in 0.03s

2025-06-09 16:22:50 (13.2 MB/s) - ‘nano_dy.root’ saved [352599/352599]

Import libraries

[ ]:
import awkward
import uproot

Let’s load the example data in NanoAOD format:

[ ]:
# Create a TTree from root
tree = uproot.open("nano_dy.root")["Events"]
# TTree -> awkward.Array[awkward.Record[str, awkward.Array]]
array = tree.arrays(ak_add_doc=True)
[ ]:
array.show()
[{run: 1, luminosityBlock: 13889, event: 3749778, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749762, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749777, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749768, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749761, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749773, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749781, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749786, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749788, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749783, HTXS_Higgs_pt: 0, ...},
 ...,
 {run: 1, luminosityBlock: 13889, event: 3749862, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749866, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749861, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749863, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749875, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749865, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749883, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749882, HTXS_Higgs_pt: 0, ...},
 {run: 1, luminosityBlock: 13889, event: 3749892, HTXS_Higgs_pt: 0, ...}]

The resulting data is a list of records. Each record represents a single event and all of its parameters data. For example here’s some of the data for the first event in our file:

[ ]:
array[0].show(50)
{run: 1,
 luminosityBlock: 13889,
 event: 3749778,
 HTXS_Higgs_pt: 0,
 HTXS_Higgs_y: nan,
 HTXS_stage1_1_cat_pTjet25GeV: 0,
 HTXS_stage1_1_cat_pTjet30GeV: 0,
 HTXS_stage1_1_fine_cat_pTjet25GeV: 0,
 HTXS_stage1_1_fine_cat_pTjet30GeV: 0,
 HTXS_stage_0: 0,
 HTXS_stage_1_pTjet25: 0,
 HTXS_stage_1_pTjet30: 0,
 HTXS_njets25: 0,
 HTXS_njets30: 0,
 btagWeight_CSVV2: 0.951,
 btagWeight_DeepCSVB: 0.893,
 CaloMET_phi: 2.79,
 CaloMET_pt: 32.1,
 CaloMET_sumEt: 652,
 ChsMET_phi: 2.51,
 ChsMET_pt: 33.7,
 ChsMET_sumEt: 784,
 nCorrT1METJet: 5,
 CorrT1METJet_area: [0.579, 0.449, 0.509, 0.519, 0.638],
 CorrT1METJet_eta: [-2.36, 4.33, 2.27, 3.92, 2.62],
 CorrT1METJet_muonSubtrFactor: [3.59e-08, 1.08e-08, ..., 7.16e-09, -2.98e-08],
 CorrT1METJet_phi: [0.387, 2.03, 1.56, 2.39, -0.405],
 CorrT1METJet_rawPt: [12.9, 15.3, 10.2, 14.9, 9.41],
 nElectron: 0,
 Electron_deltaEtaSC: [],
 Electron_dr03EcalRecHitSumEt: [],
 Electron_dr03HcalDepth1TowerSumEt: [],
 Electron_dr03TkSumPt: [],
 Electron_dr03TkSumPtHEEP: [],
 Electron_dxy: [],
 Electron_dxyErr: [],
 Electron_dz: [],
 Electron_dzErr: [],
 Electron_eCorr: [],
 Electron_eInvMinusPInv: [],
 Electron_energyErr: [],
 Electron_eta: [],
 Electron_hoe: [],
 Electron_ip3d: [],
 Electron_jetPtRelv2: [],
 Electron_jetRelIso: [],
 Electron_mass: [],
 Electron_miniPFRelIso_all: [],
 Electron_miniPFRelIso_chg: [],
 ...}

Awkward-zipper example usage

The goal of the awkward-zipper package is to restructure the record of each event. These records are restructured in the same manner as in Coffea package.

[ ]:
from awkward_zipper import NanoAOD

restructure = NanoAOD(version="latest")
result = restructure(array)
<ipython-input-16-4e778724ceb1>:4: RuntimeWarning: Missing cross-reference index for LowPtElectron_electronIdx => Electron
  result = restructure(array)
<ipython-input-16-4e778724ceb1>:4: RuntimeWarning: Missing cross-reference index for LowPtElectron_genPartIdx => GenPart
  result = restructure(array)
<ipython-input-16-4e778724ceb1>:4: RuntimeWarning: Missing cross-reference index for LowPtElectron_photonIdx => Photon
  result = restructure(array)
<ipython-input-16-4e778724ceb1>:4: RuntimeWarning: Missing cross-reference index for FatJet_genJetAK8Idx => GenJetAK8
  result = restructure(array)
/usr/local/lib/python3.11/dist-packages/awkward_zipper/kernels.py:122: DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.
  out[i::n] = idx
[ ]:
# awkward.materialize(result)
[ ]:
result
[{SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 ...,
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...},
 {SoftActivityJetNjets5: ??, LHEReweightingWeight: ??, Generator: {...}, ...}]
------------------------------------------------------------------------------
backend: cpu
nbytes: unknown
type: 40 * event

Now let’s go step by step how awkward-zipper reconstructs the original NanoAOD data.

[ ]:

How the new fields are added

Now let’s go step by step how awkward-zipper reconstructs the original NanoAOD data.

[ ]:
from awkward_zipper.kernels import counts2offsets, local2globalindex, nestedindex

Any branches named n{name} are assumed to be counts branches can be converted to offsets o{name} using using counts2offsets helper function

[ ]:
array["nJet"]
[5,
 8,
 5,
 3,
 5,
 8,
 4,
 4,
 1,
 9,
 ...,
 2,
 4,
 9,
 3,
 2,
 3,
 1,
 6,
 2]
--------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: 160 B
type: 40 * uint32[parameters={"__doc__": "slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (pt > 15)"}]

Note: How the functions(kernels) like ``counts2offsets`` work is the main difference between awkward-zipper and coffea. awkward-zipper does its inner calculations on awkward arrays, while coffea does them using forms and buffers.

This change will make it easier for users to create their own ‘schemas’ (or modify existing ones)

[ ]:
counts2offsets(array["nJet"])
array([  0,   5,  13,  18,  21,  26,  34,  38,  42,  43,  52,  54,  62,
        64,  68,  73,  77,  82,  87,  94,  98, 101, 106, 115, 118, 123,
       127, 134, 139, 147, 152, 156, 158, 162, 171, 174, 176, 179, 180,
       186, 188])

Any local index branches with names matching {source}_{target}Idx* are converted to global indexes for the event chunk (postfix G). All local indices and their correlating global indices are taken from NanoAOD.all_cross_references dictionary

[ ]:
local_index = "Jet_electronIdx1"

cross_referense = NanoAOD.all_cross_references[local_index]
global_index = "n" + cross_referense

array["Jet_electronIdx1G"] = local2globalindex(array[local_index], array[global_index])
array["Jet_electronIdx1G"]
[[-1, -1, -1, -1, -1],
 [-1, 0, -1, -1, -1, -1, -1, -1],
 [-1, 1, 2, -1, -1],
 [-1, -1, 3],
 [-1, -1, -1, -1, -1],
 [5, -1, -1, -1, -1, -1, -1, -1],
 [6, -1, -1, -1],
 [-1, -1, -1, -1],
 [-1],
 [-1, 7, -1, -1, -1, -1, -1, -1, -1],
 ...,
 [21, -1],
 [-1, -1, -1, -1],
 [22, -1, -1, -1, -1, -1, -1, -1, -1],
 [-1, -1, -1],
 [23, -1],
 [-1, -1, -1],
 [24],
 [-1, -1, -1, -1, -1, -1],
 [-1, -1]]
------------------------------------------------------------------------------------
backend: cpu
nbytes: 1.8 kB
type: 40 * [var * int64, parameters={"__doc__": "index of first matching electron"}]

Any NanoAOD.nested_items are constructed, if the necessary branches are available

[ ]:
array["Jet_electronIdx2G"] = local2globalindex(
    array["Jet_electronIdx2"], array["nElectron"]
)
nestedindex([array["Jet_electronIdx1G"], array["Jet_electronIdx2G"]])
/usr/local/lib/python3.11/dist-packages/awkward_zipper/kernels.py:100: DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.
  out[i::n] = idx
[[[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]],
 [[-1, -1], [0, -1], [-1, -1], [-1, ...], ..., [-1, -1], [-1, -1], [-1, -1]],
 [[-1, -1], [1, -1], [2, -1], [-1, -1], [-1, -1]],
 [[-1, -1], [-1, -1], [3, -1]],
 [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]],
 [[5, -1], [-1, -1], [-1, -1], [-1, ...], ..., [-1, -1], [-1, -1], [-1, -1]],
 [[6, -1], [-1, -1], [-1, -1], [-1, -1]],
 [[-1, -1], [-1, -1], [-1, -1], [-1, -1]],
 [[-1, -1]],
 [[-1, -1], [7, -1], [-1, -1], [-1, ...], ..., [-1, -1], [-1, -1], [-1, -1]],
 ...,
 [[21, -1], [-1, -1]],
 [[-1, -1], [-1, -1], [-1, -1], [-1, -1]],
 [[22, -1], [-1, -1], [-1, -1], [-1, ...], ..., [-1, -1], [-1, -1], [-1, -1]],
 [[-1, -1], [-1, -1], [-1, -1]],
 [[23, -1], [-1, -1]],
 [[-1, -1], [-1, -1], [-1, -1]],
 [[24, -1]],
 [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1]],
 [[-1, -1], [-1, -1]]]
--------------------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: 4.8 kB
type: 40 * [var * var * int64, parameters={"__doc__": "nested from index of first matching electron and index of second matching electron"}]

In the same manner any awkward_zipper.NanoAOD.nested_index_items and awkward_zipper.NanoAOD.special_items are constructed, if the necessary branches are available. You can find all these functions at awkward_zipper.kernels

[ ]:

These fields are then grouped by name, where if:

one branch exists named name and no branches start with name_, it gets interpreted as a single flat array;

[ ]:
# Example: Each event has only one Run Id. Interpreted flat array will look look like this:
result.run
[1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 ...,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1]
--------------------------------------------------
backend: cpu
nbytes: 160 B
type: 40 * uint32[parameters={"__doc__": "run/i"}]

one branch exists named name, one named n{name}, and no branches start with name_, it gets interpreted as a single jagged array;

[ ]:
# Example: Each event has a flat array of PS Weights. Interpreted single jagged array will look look like this:
result.PSWeight
[[1.01, 1.26, 0.99, 0.791],
 [2.06, 0.872, 0.535, 0.962],
 [1.07, 0.887, 0.933, 1.02],
 [0.833, 0.827, 1.15, 1.1],
 [0.936, 0.622, 1.04, 1.17],
 [1.17, 1, 0.86, 0.978],
 [1.12, 1.59, 0.906, 0.688],
 [0.946, 0.922, 1.04, 0.997],
 [0.88, 0.855, 1.09, 0.811],
 [0.854, 0.518, 1.11, 1.16],
 ...,
 [0.906, 0.687, 1.07, 1.18],
 [0.917, 0.977, 1.07, 1.01],
 [0.858, 0.812, 1.11, 0.841],
 [0.884, 1, 1.09, 1],
 [0.919, 0.848, 1.07, 1.08],
 [0.953, 1.02, 1.04, 0.968],
 [0.946, 1, 1.04, 1],
 [1.08, 2.17, 0.932, 0.57],
 [0.856, 1.41, 1.12, 0.761]]
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: 968 B
type: 40 * [var * float32, parameters={"__doc__": "PS weights (w_var / w_nominal); [0] is ISR=0.5 FSR=1; [1] is ISR=1 FSR=0.5; [2] is ISR=2 FSR=1; [3] is ISR=1 FSR=2 "}]

no branch exists named {name} and many branches start with name_*, they get interpreted as a flat table; or

[ ]:
# Example: Each event has a SINGLE Generator. Each Generator consists of a record of Generator parameters. These parameters can be scalars or flat arrays. Interpreted flat table will look look like this:
result.Generator
[{id2: -1, x1: 0.214, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 1, ...},
 {id2: 1, x1: 0.0142, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: -1, ...},
 {id2: 21, x1: 0.00564, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: -1, ...},
 {id2: -1, x1: 0.00173, xpdf2: 0, xpdf1: 0, weight: 2.58e+04, id1: 21, ...},
 {id2: 1, x1: 0.0432, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 21, ...},
 {id2: -4, x1: 0.00337, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 4, ...},
 {id2: 2, x1: 0.0051, xpdf2: 0, xpdf1: 0, weight: -2.63e+04, id1: 2, ...},
 {id2: 2, x1: 0.000154, xpdf2: 0, xpdf1: 0, weight: 2.61e+04, id1: -2, ...},
 {id2: -2, x1: 0.0541, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 2, ...},
 {id2: -1, x1: 0.011, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 1, ...},
 ...,
 {id2: -1, x1: 0.0069, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 1, ...},
 {id2: 2, x1: 0.000121, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: -2, ...},
 {id2: 21, x1: 0.229, xpdf2: 0, xpdf1: 0, weight: -2.63e+04, id1: 2, ...},
 {id2: -1, x1: 0.00506, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 1, ...},
 {id2: -2, x1: 0.00608, xpdf2: 0, xpdf1: 0, weight: -2.63e+04, id1: 2, ...},
 {id2: 2, x1: 0.000411, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: -2, ...},
 {id2: 1, x1: 0.0004, xpdf2: 0, xpdf1: 0, weight: -2.63e+04, id1: -1, ...},
 {id2: -2, x1: 0.184, xpdf2: 0, xpdf1: 0, weight: 2.63e+04, id1: 2, ...},
 {id2: -1, x1: 0.00268, xpdf2: 0, xpdf1: 0, weight: -2.63e+04, id1: 1, ...}]
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: 1.4 kB
type: 40 * NanoCollection[
    id2: int32[parameters={"__doc__": "id of second parton"}],
    x1: float32[parameters={"__doc__": "x1 fraction of proton momentum carried by the first parton"}],
    xpdf2: float32[parameters={"__doc__": "x*pdf(x) for the second parton"}],
    xpdf1: float32[parameters={"__doc__": "x*pdf(x) for the first parton"}],
    weight: float32[parameters={"__doc__": "MC generator weight"}],
    id1: int32[parameters={"__doc__": "id of first parton"}],
    x2: float32[parameters={"__doc__": "x2 fraction of proton momentum carried by the second parton"}],
    binvar: float32[parameters={"__doc__": "MC generation binning value"}],
    scalePDF: float32[parameters={"__doc__": "Q2 scale for PDF"}],
parameters={"collection_name": "Generator"}]

one branch exists named n{name} and many branches start with name_*, they interpreted as a jagged table.

[ ]:
# Example: Each event has an array of Jets. Each Jet consists of a record of Jet parameters. These parameters can be scalars or flat arrays. Interpreted jagged table will look look like this:
result.Jet
[[Jet, ...],
 [Jet, ...],
 [Jet, ...],
 [Jet, ...],
 [Jet, ...],
 [Jet, ..., Jet],
 [Jet, ...],
 [Jet, ...],
 [{cleanmask: 1, pt: 20.4, jetId: 6, neEmEF: 0.139, phi: 1.54, mass: ..., ...}],
 [Jet, ..., Jet],
 ...,
 [Jet, ...],
 [Jet, ..., Jet],
 [Jet, ...],
 [Jet, ...],
 [Jet, ...],
 [Jet, ...],
 [{cleanmask: 0, pt: 22.1, jetId: 6, neEmEF: 0.391, phi: 2.11, mass: ..., ...}],
 [Jet, ...],
 [Jet, ...]]
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: 43.4 kB
type: 40 * var * Jet[
    cleanmask: uint8[parameters={"__doc__": "simple cleaning mask with priority to leptons"}],
    pt: float32[parameters={"__doc__": "pt"}],
    jetId: int32[parameters={"__doc__": "Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"}],
    neEmEF: float32[parameters={"__doc__": "neutral Electromagnetic Energy Fraction"}],
    phi: float32[parameters={"__doc__": "phi"}],
    mass: float32[parameters={"__doc__": "mass"}],
    puId: int32[parameters={"__doc__": "Pilup ID flags"}],
    hadronFlavour: int32[parameters={"__doc__": "flavour from hadron ghost clustering"}],
    genJetIdx: int32[parameters={"__doc__": "index of matched gen jet"}],
    qgl: float32[parameters={"__doc__": "Quark vs Gluon likelihood discriminator"}],
    area: float32[parameters={"__doc__": "jet catchment area, for JECs"}],
    eta: float32[parameters={"__doc__": "eta"}],
    neHEF: float32[parameters={"__doc__": "neutral Hadron Energy Fraction"}],
    muonIdx1: int32[parameters={"__doc__": "index of first matching muon"}],
    nMuons: int32[parameters={"__doc__": "number of muons in the jet"}],
    btagDeepC: float32[parameters={"__doc__": "DeepCSV charm btag discriminator"}],
    jercCHF: float32[parameters={"__doc__": "Charged Hadron Energy Fraction with the JERC group definition"}],
    partonFlavour: int32[parameters={"__doc__": "flavour from parton matching"}],
    muonSubtrFactor: float32[parameters={"__doc__": "1-(muon-subtracted raw pt)/(raw pt)"}],
    btagCSVV2: float32[parameters={"__doc__": " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)"}],
    rawFactor: float32[parameters={"__doc__": "1 - Factor to get back to raw pT"}],
    btagDeepFlavB: float32[parameters={"__doc__": "DeepFlavour b+bb+lepb tag discriminator"}],
    bRegRes: float32[parameters={"__doc__": "res on pt corrected with b-jet regression"}],
    nConstituents: int32[parameters={"__doc__": "Number of particles in the jet"}],
    jercCHPUF: float32[parameters={"__doc__": "Pileup Charged Hadron Energy Fraction with the JERC group definition"}],
    muEF: float32[parameters={"__doc__": "muon Energy Fraction"}],
    nElectrons: int32[parameters={"__doc__": "number of electrons in the jet"}],
    btagDeepFlavC: float32[parameters={"__doc__": "DeepFlavour charm tag discriminator"}],
    electronIdx1: int32[parameters={"__doc__": "index of first matching electron"}],
    electronIdx2: int32[parameters={"__doc__": "index of second matching electron"}],
    chEmEF: float32[parameters={"__doc__": "charged Electromagnetic Energy Fraction"}],
    muonIdx2: int32[parameters={"__doc__": "index of second matching muon"}],
    btagDeepB: float32[parameters={"__doc__": "DeepCSV b+bb tag discriminator"}],
    btagCMVA: float32[parameters={"__doc__": "CMVA V2 btag discriminator"}],
    chHEF: float32[parameters={"__doc__": "charged Hadron Energy Fraction"}],
    bRegCorr: float32[parameters={"__doc__": "pt correction for b-jet energy regression"}],
    electronIdx1G: int64[parameters={"__doc__": "global index of first matching electron"}],
    muonIdx1G: int64[parameters={"__doc__": "global index of first matching muon"}],
    muonIdxG: [var * int64, parameters={"__doc__": "nested from global index of first matching muon and global index of second matching muon"}],
    electronIdxG: [var * int64, parameters={"__doc__": "nested from global index of first matching electron and global index of second matching electron"}],
    electronIdx2G: int64[parameters={"__doc__": "global index of second matching electron"}],
    muonIdx2G: int64[parameters={"__doc__": "global index of second matching muon"}],
    genJetIdxG: int64[parameters={"__doc__": "global index of matched gen jet"}],
parameters={"collection_name": "Jet", "__doc__": "slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (pt > 15)"}]

Finally, all collections are then zipped into one NanoEvents record and returned.

Final result:

[ ]:
result
[{btagWeight: {CSVV2: 0.951, ...}, GenVisTau: [GenVisTau, ...], ...},
 {btagWeight: {CSVV2: 0.996, ...}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1.01, ...}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1.55, ...}, GenVisTau: [{...}], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 0.805, ...}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 0.84, ...}, GenVisTau: [{...}], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 0.997, ...}, GenVisTau: [], CorrT1METJet: [], ...},
 {btagWeight: {CSVV2: 1, DeepCSVB: 1}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1, DeepCSVB: 1}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1.03, ...}, GenVisTau: [], CorrT1METJet: [...], ...},
 ...,
 {btagWeight: {CSVV2: 0.804, ...}, GenVisTau: [{...}], CorrT1METJet: ..., ...},
 {btagWeight: {CSVV2: 1, DeepCSVB: 1}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 0.97, ...}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1.05, ...}, GenVisTau: [{...}], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1, DeepCSVB: 1}, GenVisTau: [{...}], ...},
 {btagWeight: {CSVV2: 0.954, ...}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1, DeepCSVB: 1}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1, DeepCSVB: 1}, GenVisTau: [], CorrT1METJet: [...], ...},
 {btagWeight: {CSVV2: 1, DeepCSVB: 1}, GenVisTau: [{...}], ...}]
--------------------------------------------------------------------------------
backend: cpu
nbytes: 192.0 kB
type: 40 * event
[ ]:
result.Jet.mass
[[11.7, 8.94, 2.69, 3.81, 4.23],
 [17, 6.25, 6.07, 5, 3.89, 4, 4.31, 4.55],
 [12.4, 5.99, 2.78, 5.88, 4.64],
 [5.82, 6.14, 2.63],
 [12.5, 6.99, 4.14, 3.24, 3.68],
 [6.9, 7.5, 3.17, 6.78, 5.36, 4.16, 4.66, 4.62],
 [9.49, 0.111, 7.05, 4.96],
 [6.51, 4.98, 6.54, 5.12],
 [3.69],
 [4.89, 5.16, 7.83, 8.38, 6.3, 4.62, 4.41, 2.9, 3.54],
 ...,
 [2.28, 3.78],
 [4.92, 4.43, 4.37, 3.54],
 [7.45, 6.52, 7.59, 4.74, 4.27, 4.32, 5.01, 4, 4.23],
 [4.83, 5.8, 4.85],
 [3.62, 3.87],
 [6.04, 4.84, 4.29],
 [5.33],
 [10.8, 9.75, 6.52, 5.45, 3.94, 3.42],
 [3.88, 4.47]]
--------------------------------------------------------
backend: cpu
nbytes: 1.1 kB
type: 40 * var * float32[parameters={"__doc__": "mass"}]
[ ]:

Zipper with virtual arrays

Let’s load the same root file but as virtual arrays. Virtual arrays don’t load the data from disk (or in other words don’t materialize the data).

[ ]:
# Create a TTree from root
tree = uproot.open("nano_dy.root")["Events"]
# to load virtual arrays
access_log = []  # which of the data was materialized
# TTree -> awkward.Array[awkward.Record[str, awkward.Array]]
array = tree.virtual_arrays(ak_add_doc=True, access_log=access_log)

Calling zipper

[ ]:
restructure = NanoAOD(version="latest")
result = restructure(array)
<ipython-input-19-76941848e4f5>:2: RuntimeWarning: Missing cross-reference index for LowPtElectron_electronIdx => Electron
  result = restructure(array)
<ipython-input-19-76941848e4f5>:2: RuntimeWarning: Missing cross-reference index for LowPtElectron_genPartIdx => GenPart
  result = restructure(array)
<ipython-input-19-76941848e4f5>:2: RuntimeWarning: Missing cross-reference index for LowPtElectron_photonIdx => Photon
  result = restructure(array)
<ipython-input-19-76941848e4f5>:2: RuntimeWarning: Missing cross-reference index for FatJet_genJetAK8Idx => GenJetAK8
  result = restructure(array)
[ ]:
access_log
[]
[ ]:
result
[{btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 ...,
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...},
 {btagWeight: {CSVV2: ??, ...}, GenVisTau: ??, CorrT1METJet: ??, ...}]
----------------------------------------------------------------------
backend: cpu
nbytes: unknown
type: 40 * event
[ ]:
result.Jet
[??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ...,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??,
 ??]
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: unknown
type: 40 * var * Jet[
    cleanmask: uint8[parameters={"__doc__": "simple cleaning mask with priority to leptons"}],
    pt: float32[parameters={"__doc__": "pt"}],
    jetId: int32[parameters={"__doc__": "Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"}],
    neEmEF: float32[parameters={"__doc__": "neutral Electromagnetic Energy Fraction"}],
    phi: float32[parameters={"__doc__": "phi"}],
    mass: float32[parameters={"__doc__": "mass"}],
    puId: int32[parameters={"__doc__": "Pilup ID flags"}],
    hadronFlavour: int32[parameters={"__doc__": "flavour from hadron ghost clustering"}],
    genJetIdx: int32[parameters={"__doc__": "index of matched gen jet"}],
    qgl: float32[parameters={"__doc__": "Quark vs Gluon likelihood discriminator"}],
    area: float32[parameters={"__doc__": "jet catchment area, for JECs"}],
    eta: float32[parameters={"__doc__": "eta"}],
    neHEF: float32[parameters={"__doc__": "neutral Hadron Energy Fraction"}],
    muonIdx1: int32[parameters={"__doc__": "index of first matching muon"}],
    nMuons: int32[parameters={"__doc__": "number of muons in the jet"}],
    btagDeepC: float32[parameters={"__doc__": "DeepCSV charm btag discriminator"}],
    jercCHF: float32[parameters={"__doc__": "Charged Hadron Energy Fraction with the JERC group definition"}],
    partonFlavour: int32[parameters={"__doc__": "flavour from parton matching"}],
    muonSubtrFactor: float32[parameters={"__doc__": "1-(muon-subtracted raw pt)/(raw pt)"}],
    btagCSVV2: float32[parameters={"__doc__": " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)"}],
    rawFactor: float32[parameters={"__doc__": "1 - Factor to get back to raw pT"}],
    btagDeepFlavB: float32[parameters={"__doc__": "DeepFlavour b+bb+lepb tag discriminator"}],
    bRegRes: float32[parameters={"__doc__": "res on pt corrected with b-jet regression"}],
    nConstituents: int32[parameters={"__doc__": "Number of particles in the jet"}],
    jercCHPUF: float32[parameters={"__doc__": "Pileup Charged Hadron Energy Fraction with the JERC group definition"}],
    muEF: float32[parameters={"__doc__": "muon Energy Fraction"}],
    nElectrons: int32[parameters={"__doc__": "number of electrons in the jet"}],
    btagDeepFlavC: float32[parameters={"__doc__": "DeepFlavour charm tag discriminator"}],
    electronIdx1: int32[parameters={"__doc__": "index of first matching electron"}],
    electronIdx2: int32[parameters={"__doc__": "index of second matching electron"}],
    chEmEF: float32[parameters={"__doc__": "charged Electromagnetic Energy Fraction"}],
    muonIdx2: int32[parameters={"__doc__": "index of second matching muon"}],
    btagDeepB: float32[parameters={"__doc__": "DeepCSV b+bb tag discriminator"}],
    btagCMVA: float32[parameters={"__doc__": "CMVA V2 btag discriminator"}],
    chHEF: float32[parameters={"__doc__": "charged Hadron Energy Fraction"}],
    bRegCorr: float32[parameters={"__doc__": "pt correction for b-jet energy regression"}],
    electronIdx1G: int64[parameters={"__doc__": "global index of first matching electron"}],
    muonIdx1G: int64[parameters={"__doc__": "global index of first matching muon"}],
    muonIdxG: [var * int64, parameters={"__doc__": "nested from global index of first matching muon and global index of second matching muon"}],
    electronIdxG: [var * int64, parameters={"__doc__": "nested from global index of first matching electron and global index of second matching electron"}],
    electronIdx2G: int64[parameters={"__doc__": "global index of second matching electron"}],
    muonIdx2G: int64[parameters={"__doc__": "global index of second matching muon"}],
    genJetIdxG: int64[parameters={"__doc__": "global index of matched gen jet"}],
parameters={"collection_name": "Jet", "__doc__": "slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (pt > 15)"}]
[ ]:
result[0].Jet
[{cleanmask: ??, pt: ??, jetId: ??, neEmEF: ??, phi: ??, mass: ??, ...},
 {cleanmask: ??, pt: ??, jetId: ??, neEmEF: ??, phi: ??, mass: ??, ...},
 {cleanmask: ??, pt: ??, jetId: ??, neEmEF: ??, phi: ??, mass: ??, ...},
 {cleanmask: ??, pt: ??, jetId: ??, neEmEF: ??, phi: ??, mass: ??, ...},
 {cleanmask: ??, pt: ??, jetId: ??, neEmEF: ??, phi: ??, mass: ??, ...}]
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: unknown
type: 5 * Jet[
    cleanmask: uint8[parameters={"__doc__": "simple cleaning mask with priority to leptons"}],
    pt: float32[parameters={"__doc__": "pt"}],
    jetId: int32[parameters={"__doc__": "Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"}],
    neEmEF: float32[parameters={"__doc__": "neutral Electromagnetic Energy Fraction"}],
    phi: float32[parameters={"__doc__": "phi"}],
    mass: float32[parameters={"__doc__": "mass"}],
    puId: int32[parameters={"__doc__": "Pilup ID flags"}],
    hadronFlavour: int32[parameters={"__doc__": "flavour from hadron ghost clustering"}],
    genJetIdx: int32[parameters={"__doc__": "index of matched gen jet"}],
    qgl: float32[parameters={"__doc__": "Quark vs Gluon likelihood discriminator"}],
    area: float32[parameters={"__doc__": "jet catchment area, for JECs"}],
    eta: float32[parameters={"__doc__": "eta"}],
    neHEF: float32[parameters={"__doc__": "neutral Hadron Energy Fraction"}],
    muonIdx1: int32[parameters={"__doc__": "index of first matching muon"}],
    nMuons: int32[parameters={"__doc__": "number of muons in the jet"}],
    btagDeepC: float32[parameters={"__doc__": "DeepCSV charm btag discriminator"}],
    jercCHF: float32[parameters={"__doc__": "Charged Hadron Energy Fraction with the JERC group definition"}],
    partonFlavour: int32[parameters={"__doc__": "flavour from parton matching"}],
    muonSubtrFactor: float32[parameters={"__doc__": "1-(muon-subtracted raw pt)/(raw pt)"}],
    btagCSVV2: float32[parameters={"__doc__": " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)"}],
    rawFactor: float32[parameters={"__doc__": "1 - Factor to get back to raw pT"}],
    btagDeepFlavB: float32[parameters={"__doc__": "DeepFlavour b+bb+lepb tag discriminator"}],
    bRegRes: float32[parameters={"__doc__": "res on pt corrected with b-jet regression"}],
    nConstituents: int32[parameters={"__doc__": "Number of particles in the jet"}],
    jercCHPUF: float32[parameters={"__doc__": "Pileup Charged Hadron Energy Fraction with the JERC group definition"}],
    muEF: float32[parameters={"__doc__": "muon Energy Fraction"}],
    nElectrons: int32[parameters={"__doc__": "number of electrons in the jet"}],
    btagDeepFlavC: float32[parameters={"__doc__": "DeepFlavour charm tag discriminator"}],
    electronIdx1: int32[parameters={"__doc__": "index of first matching electron"}],
    electronIdx2: int32[parameters={"__doc__": "index of second matching electron"}],
    chEmEF: float32[parameters={"__doc__": "charged Electromagnetic Energy Fraction"}],
    muonIdx2: int32[parameters={"__doc__": "index of second matching muon"}],
    btagDeepB: float32[parameters={"__doc__": "DeepCSV b+bb tag discriminator"}],
    btagCMVA: float32[parameters={"__doc__": "CMVA V2 btag discriminator"}],
    chHEF: float32[parameters={"__doc__": "charged Hadron Energy Fraction"}],
    bRegCorr: float32[parameters={"__doc__": "pt correction for b-jet energy regression"}],
    electronIdx1G: int64[parameters={"__doc__": "global index of first matching electron"}],
    muonIdx1G: int64[parameters={"__doc__": "global index of first matching muon"}],
    muonIdxG: [var * int64, parameters={"__doc__": "nested from global index of first matching muon and global index of second matching muon"}],
    electronIdxG: [var * int64, parameters={"__doc__": "nested from global index of first matching electron and global index of second matching electron"}],
    electronIdx2G: int64[parameters={"__doc__": "global index of second matching electron"}],
    muonIdx2G: int64[parameters={"__doc__": "global index of second matching muon"}],
    genJetIdxG: int64[parameters={"__doc__": "global index of matched gen jet"}],
parameters={"collection_name": "Jet", "__doc__": "slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (pt > 15)"}]
[ ]:
access_log
[Accessed(branch='nJet', buffer_key="('<root>', 'nJet')-data")]
[ ]:
array.nJet
[5,
 8,
 5,
 3,
 5,
 8,
 4,
 4,
 1,
 9,
 ...,
 2,
 4,
 9,
 3,
 2,
 3,
 1,
 6,
 2]
--------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: 160 B
type: 40 * uint32[parameters={"__doc__": "slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (pt > 15)"}]

Example calculation of a Z-peak

[ ]:
zcands = awkward.combinations(result.Muon, 2)
[ ]:
access_log
[Accessed(branch='nMuon', buffer_key="('<root>', 'nMuon')-data")]
[ ]:
# count invariant mass
mass = awkward.flatten((zcands["0"] + zcands["1"]).mass)

We can see that for this, 4-vector coordinates were loaded, which were used to add the combinations

[ ]:
access_log
[Accessed(branch='nMuon', buffer_key="('<root>', 'nMuon')-data"),
 Accessed(branch='Muon_pt', buffer_key="('<root>', 'Muon_pt', None)-data"),
 Accessed(branch='Muon_phi', buffer_key="('<root>', 'Muon_phi', None)-data"),
 Accessed(branch='Muon_eta', buffer_key="('<root>', 'Muon_eta', None)-data"),
 Accessed(branch='Muon_mass', buffer_key="('<root>', 'Muon_mass', None)-data"),
 Accessed(branch='Muon_charge', buffer_key="('<root>', 'Muon_charge', None)-data")]
[ ]:
%%capture
!pip install "hist[plot]"
[ ]:
from hist import Hist

Hist.new.Reg(10, 80, 100).Double().fill(mass).plot()
[StairsArtists(stairs=<matplotlib.patches.StepPatch object at 0x7b4d8583b350>, errorbar=<ErrorbarContainer object of 3 artists>, legend_artist=<ErrorbarContainer object of 3 artists>)]
../_images/notebooks_Usage_example_of_awkward_zipper_65_1.png
[ ]:
result.Muon
[[],
 [],
 [],
 [],
 [Muon, Muon],
 [{jetRelIso: ??, pt: 31, sip3d: ??, isTracker: ??, mediumPromptId: ??, ...}],
 [Muon, Muon],
 [],
 [],
 [],
 ...,
 [{jetRelIso: ??, pt: 10.1, sip3d: ??, isTracker: ??, ...}],
 [],
 [],
 [{jetRelIso: ??, pt: 17.9, sip3d: ??, isTracker: ??, ...}],
 [],
 [],
 [],
 [],
 []]
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
backend: cpu
nbytes: 3.4 kB
type: 40 * var * Muon[
    jetRelIso: float32[parameters={"__doc__": "Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)"}],
    pt: float32[parameters={"__doc__": "pt"}],
    sip3d: float32[parameters={"__doc__": "3D impact parameter significance wrt first PV"}],
    isTracker: bool[parameters={"__doc__": "muon is tracker muon"}],
    mediumPromptId: bool[parameters={"__doc__": "cut-based ID, medium prompt WP"}],
    nTrackerLayers: int32[parameters={"__doc__": "number of layers in the tracker"}],
    pfRelIso03_chg: float32[parameters={"__doc__": "PF relative isolation dR=0.3, charged component"}],
    cleanmask: uint8[parameters={"__doc__": "simple cleaning mask with priority to leptons"}],
    pfIsoId: uint8[parameters={"__doc__": "PFIso ID from miniAOD selector (1=PFIsoVeryLoose, 2=PFIsoLoose, 3=PFIsoMedium, 4=PFIsoTight, 5=PFIsoVeryTight, 6=PFIsoVeryVeryTight)"}],
    pfRelIso04_all: float32[parameters={"__doc__": "PF relative isolation dR=0.4, total (deltaBeta corrections)"}],
    dzErr: float32[parameters={"__doc__": "dz uncertainty, in cm"}],
    genPartFlav: uint8[parameters={"__doc__": "Flavour of genParticle for MC matching to status==1 muons: 1 = prompt muon (including gamma*->mu mu), 15 = muon from prompt tau, 5 = muon from b, 4 = muon from c, 3 = muon from light or unknown, 0 = unmatched"}],
    tunepRelPt: float32[parameters={"__doc__": "TuneP relative pt, tunePpt/pt"}],
    miniPFRelIso_chg: float32[parameters={"__doc__": "mini PF relative isolation, charged component"}],
    eta: float32[parameters={"__doc__": "eta"}],
    genPartIdx: int32[parameters={"__doc__": "Index into genParticle list for MC matching to status==1 muons"}],
    miniIsoId: uint8[parameters={"__doc__": "MiniIso ID from miniAOD selector (1=MiniIsoLoose, 2=MiniIsoMedium, 3=MiniIsoTight, 4=MiniIsoVeryTight)"}],
    tightId: bool[parameters={"__doc__": "cut-based ID, tight WP"}],
    dxy: float32[parameters={"__doc__": "dxy (with sign) wrt first PV, in cm"}],
    tightCharge: int32[parameters={"__doc__": "Tight charge criterion using pterr/pt of muonBestTrack (0:fail, 2:pass)"}],
    triggerIdLoose: bool[parameters={"__doc__": "TriggerIdLoose ID"}],
    jetIdx: int32[parameters={"__doc__": "index of the associated jet (-1 if none)"}],
    ptErr: float32[parameters={"__doc__": "ptError of the muon track"}],
    nStations: int32[parameters={"__doc__": "number of matched stations with default arbitration (segment & track)"}],
    miniPFRelIso_all: float32[parameters={"__doc__": "mini PF relative isolation, total (with scaled rho*EA PU corrections)"}],
    pfRelIso03_all: float32[parameters={"__doc__": "PF relative isolation dR=0.3, total (deltaBeta corrections)"}],
    mvaTTH: float32[parameters={"__doc__": "TTH MVA lepton ID score"}],
    softMva: float32[parameters={"__doc__": "soft MVA ID score"}],
    pdgId: int32[parameters={"__doc__": "PDG code assigned by the event reconstruction (not by MC truth)"}],
    mediumId: bool[parameters={"__doc__": "cut-based ID, medium WP"}],
    isGlobal: bool[parameters={"__doc__": "muon is global muon"}],
    highPtId: uint8[parameters={"__doc__": "high-pT cut-based ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)"}],
    looseId: bool[parameters={"__doc__": "muon is loose muon"}],
    ip3d: float32[parameters={"__doc__": "3D impact parameter wrt first PV, in cm"}],
    inTimeMuon: bool[parameters={"__doc__": "inTimeMuon ID"}],
    isPFcand: bool[parameters={"__doc__": "muon is PF candidate"}],
    mass: float32[parameters={"__doc__": "mass"}],
    tkRelIso: float32[parameters={"__doc__": "Tracker-based relative isolation dR=0.3 for highPt, trkIso/tunePpt"}],
    phi: float32[parameters={"__doc__": "phi"}],
    dz: float32[parameters={"__doc__": "dz (with sign) wrt first PV, in cm"}],
    softId: bool[parameters={"__doc__": "soft cut-based ID"}],
    charge: int32[parameters={"__doc__": "electric charge"}],
    mvaId: uint8[parameters={"__doc__": "Mva ID from miniAOD selector (1=MvaLoose, 2=MvaMedium, 3=MvaTight)"}],
    segmentComp: float32[parameters={"__doc__": "muon segment compatibility"}],
    mvaLowPt: float32[parameters={"__doc__": "Low pt muon ID score"}],
    tkIsoId: uint8[parameters={"__doc__": "TkIso ID (1=TkIsoLoose, 2=TkIsoTight)"}],
    multiIsoId: uint8[parameters={"__doc__": "MultiIsoId from miniAOD selector (1=MultiIsoLoose, 2=MultiIsoMedium)"}],
    fsrPhotonIdx: int32[parameters={"__doc__": "Index of the associated FSR photon"}],
    dxyErr: float32[parameters={"__doc__": "dxy uncertainty, in cm"}],
    jetPtRelv2: float32[parameters={"__doc__": "Relative momentum of the lepton with respect to the closest jet after subtracting the lepton"}],
    softMvaId: bool[parameters={"__doc__": "soft MVA ID"}],
    fsrPhotonIdxG: int64[parameters={"__doc__": "global Index of the associated FSR photon"}],
    jetIdxG: int64[parameters={"__doc__": "global index of the associated jet (-1 if none)"}],
    genPartIdxG: int64[parameters={"__doc__": "global Index into genParticle list for MC matching to status==1 muons"}],
parameters={"collection_name": "Muon", "__doc__": "slimmedMuons after basic selection (pt > 3 && (passed('CutBasedIdLoose') || passed('SoftCutBasedId') || passed('SoftMvaId') || passed('CutBasedIdGlobalHighPt') || passed('CutBasedIdTrkHighPt')))"}]
[ ]:
result.Muon[4][0].show(300)
{jetRelIso: ??,
 pt: 76.8,
 sip3d: ??,
 isTracker: ??,
 mediumPromptId: ??,
 nTrackerLayers: ??,
 pfRelIso03_chg: ??,
 cleanmask: ??,
 pfIsoId: ??,
 pfRelIso04_all: ??,
 dzErr: ??,
 genPartFlav: ??,
 tunepRelPt: ??,
 miniPFRelIso_chg: ??,
 eta: 0.714,
 genPartIdx: ??,
 miniIsoId: ??,
 tightId: ??,
 dxy: ??,
 tightCharge: ??,
 triggerIdLoose: ??,
 jetIdx: ??,
 ptErr: ??,
 nStations: ??,
 miniPFRelIso_all: ??,
 pfRelIso03_all: ??,
 mvaTTH: ??,
 softMva: ??,
 pdgId: ??,
 mediumId: ??,
 isGlobal: ??,
 highPtId: ??,
 looseId: ??,
 ip3d: ??,
 inTimeMuon: ??,
 isPFcand: ??,
 mass: 0.106,
 tkRelIso: ??,
 phi: 1.64,
 dz: ??,
 softId: ??,
 charge: -1,
 mvaId: ??,
 segmentComp: ??,
 mvaLowPt: ??,
 tkIsoId: ??,
 multiIsoId: ??,
 fsrPhotonIdx: ??,
 dxyErr: ??,
 jetPtRelv2: ??,
 softMvaId: ??,
 fsrPhotonIdxG: ??,
 jetIdxG: ??,
 genPartIdxG: ??}
[ ]: