awkward_zipper package

Behaviors

Layouts

awkward_zipper.awkward_util

Kernels

awkward_zipper.kernels.children(counts, globalparents)[source]

Compute children

Signature: offsets,globalparents,!children Output will be a jagged array with same outer shape as globalparents content

awkward_zipper.kernels.counts2nestedindex(local_counts, target_offsets)[source]

Turn jagged local counts into doubly-jagged global index into a target Outputs a jagged array with same axis-0 shape as counts axis-1

Example usage: Local counts [[4, 3, 2],

[4, 2]]

Target offsets [9, 6] Target output [[[0, 1, 2, 3], [4, 5, 6], [7, 8]],

[[9, 10, 11, 12], [13, 14]]]

awkward_zipper.kernels.counts2offsets(counts)[source]
awkward_zipper.kernels.dispatch_wrap(function)[source]
awkward_zipper.kernels.distinct_children_deep(counts, global_parents, global_pdgs)[source]

Compute all distinct children, skipping children with same pdg id in between.

Signature: offsets,global_parents,global_pdgs,!distinctChildrenDeep Expects global indexes, flat arrays, which should be same length

awkward_zipper.kernels.distinct_parent(parents, pdg)[source]

Compute first parent with distinct PDG id

Signature: globalparents,globalpdgs,!distinctParent Expects global indexes, flat arrays, which should be same length

awkward_zipper.kernels.ensure_array(arraylike)[source]

Converts arraylike to a Numpy array

awkward_zipper.kernels.local2globalindex(index, counts)[source]

Convert a jagged local index to a global index

This is the same as local2global(index, counts2offsets(counts)) where local2global and counts2offsets are as in coffea.nanoevents.transforms

Example usage: Index array [[], [1], [], [2, 3]] Counts array [8, 7, 4, 7] Output array will be: [[], [9], [], [21, 22]] (here 21=8+7+4+2)

awkward_zipper.kernels.nestedindex(indices)[source]

Concatenate a list of indices along a new axis Outputs a jagged array with same outer shape as index arrays

Example usage: First index array [[0, 2, 4],

[8, 6]]

Second index array [[1, 3, 5],

[-1, 7]]

Output [[[0, 1], [2, 3], [4, 5]],

[[8, -1], [6, 7]]]

Package classes

class awkward_zipper.BaseLayoutBuilder[source]

Base class for all layout builders

classmethod behavior()[source]

Behaviors necessary to implement this schema (dict)

class awkward_zipper.NanoAOD(version='latest')[source]

NanoAOD layout builder

The NanoAOD layout is built from all branches found in the supplied file, based on the naming pattern of the branches. The following additional arrays are constructed:

  • Any branches named n{name} are assumed to be counts branches and converted to offsets o{name}

  • Any local index branches with names matching {source}_{target}Idx* are converted to global indexes for the event chunk (postfix G)

  • Any nested_items are constructed, if the necessary branches are available

  • Any special_items are constructed, if the necessary branches are available

From those arrays, NanoAOD collections are formed as collections of branches grouped by name, where:

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

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

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

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

Collections are assigned mixin types according to the mixins mapping. All collections are then zipped into one base.NanoEvents record and returned.

There is a class-level variable warn_missing_crossrefs which will alter the behavior of NanoAOD. If warn_missing_crossrefs is true then when a missing global index cross-ref target is encountered a warning will be issued. Regardless, the cross-reference is dropped.

The same holds for error_missing_events_id. If error_missing_events_id is true, then when the ‘run’, ‘event’, or ‘luminosityBlock’ fields are missing, an exception will be thrown; if it is false, just a warning will be issued.

all_cross_references: ClassVar = {'Electron_genPartIdx': 'GenPart', 'Electron_jetIdx': 'Jet', 'Electron_photonIdx': 'Photon', 'FatJet_genJetAK8Idx': 'GenJetAK8', 'FatJet_subJetIdx1': 'SubJet', 'FatJet_subJetIdx2': 'SubJet', 'FsrPhoton_muonIdx': 'Muon', 'GenPart_genPartIdxMother': 'GenPart', 'GenVisTau_genPartIdxMother': 'GenPart', 'Jet_electronIdx1': 'Electron', 'Jet_electronIdx2': 'Electron', 'Jet_genJetIdx': 'GenJet', 'Jet_muonIdx1': 'Muon', 'Jet_muonIdx2': 'Muon', 'LowPtElectron_electronIdx': 'Electron', 'LowPtElectron_genPartIdx': 'GenPart', 'LowPtElectron_photonIdx': 'Photon', 'Muon_fsrPhotonIdx': 'FsrPhoton', 'Muon_genPartIdx': 'GenPart', 'Muon_jetIdx': 'Jet', 'Photon_electronIdx': 'Electron', 'Photon_genPartIdx': 'GenPart', 'Photon_jetIdx': 'Jet', 'Tau_genPartIdx': 'GenPart', 'Tau_jetIdx': 'Jet'}

Cross-references, where an index is to be interpreted with respect to another collection

Each such cross-reference will be converted to a global indexer, so that arbitrarily sliced events can still resolve the indirection back the parent events

classmethod behavior()[source]

Behaviors necessary to implement this schema (dict)

error_missing_event_ids = True
event_ids: ClassVar = ['run', 'luminosityBlock', 'event']

List of NanoAOD event IDs

mixins: ClassVar = {'CaloMET': 'MissingET', 'ChsMET': 'MissingET', 'Electron': 'Electron', 'FatJet': 'FatJet', 'FsrPhoton': 'FsrPhoton', 'GenDressedLepton': 'PtEtaPhiMCollection', 'GenIsolatedPhoton': 'PtEtaPhiMCollection', 'GenJet': 'PtEtaPhiMCollection', 'GenJetAK8': 'PtEtaPhiMCollection', 'GenMET': 'MissingET', 'GenPart': 'GenParticle', 'GenVisTau': 'GenVisTau', 'IsoTrack': 'PtEtaPhiMCollection', 'Jet': 'Jet', 'LHEPart': 'PtEtaPhiMCollection', 'LowPtElectron': 'LowPtElectron', 'MET': 'MissingET', 'METFixEE2017': 'MissingET', 'Muon': 'Muon', 'PV': 'Vertex', 'Photon': 'Photon', 'PuppiMET': 'MissingET', 'RawMET': 'MissingET', 'RawPuppiMET': 'MissingET', 'SV': 'SecondaryVertex', 'SoftActivityJet': 'PtEtaPhiMCollection', 'SubGenJetAK8': 'PtEtaPhiMCollection', 'SubJet': 'PtEtaPhiMCollection', 'Tau': 'Tau', 'TkMET': 'MissingET', 'TrigObj': 'PtEtaPhiMCollection'}

Default configuration for mixin types, based on the collection name.

The types are implemented in the coffea.nanoevents.methods.nanoaod module.

nested_index_items: ClassVar = {'FatJet_pFCandsIdxG': ('FatJet_nConstituents', 'FatJetPFCands'), 'GenFatJet_pFCandsIdxG': ('GenJetAK8_nConstituents', 'GenFatJetCands'), 'GenJet_pFCandsIdxG': ('GenJet_nConstituents', 'GenJetCands'), 'Jet_pFCandsIdxG': ('Jet_nConstituents', 'JetPFCands')}

Nested collections, where nesting is accomplished by assuming the target can be unflattened according to a source counts

nested_items: ClassVar = {'FatJet_subJetIdxG': ['FatJet_subJetIdx1G', 'FatJet_subJetIdx2G'], 'Jet_electronIdxG': ['Jet_electronIdx1G', 'Jet_electronIdx2G'], 'Jet_muonIdxG': ['Jet_muonIdx1G', 'Jet_muonIdx2G']}

Nested collections, where nesting is accomplished by a fixed-length set of indexers

special_items: ClassVar = {'GenPart_childrenIdxG': (<function children>, ('nGenPart', 'GenPart_genPartIdxMotherG')), 'GenPart_distinctChildrenDeepIdxG': (<function distinct_children_deep>, ('nGenPart', 'GenPart_genPartIdxMotherG', 'GenPart_pdgId')), 'GenPart_distinctChildrenIdxG': (<function children>, ('nGenPart', 'GenPart_distinctParentIdxG')), 'GenPart_distinctParentIdxG': (<function distinct_parent>, ('GenPart_genPartIdxMotherG', 'GenPart_pdgId'))}

Special arrays, where the callable and input arrays are specified in the value

classmethod v5()[source]

Build the NanoEvents assuming NanoAODv5

Returns:

out – Schema assuming NanoAODv5

Return type:

NanoAOD

classmethod v6()[source]

Build the NanoEvents assuming NanoAODv6

Returns:

out – Schema assuming NanoAODv6

Return type:

NanoAOD

classmethod v7()[source]

Build the NanoEvents assuming NanoAODv7

For example, one can use NanoEventsFactory.from_root("file.root", schemaclass=NanoAOD.v7) to ensure NanoAODv7 compatibility.

Returns:

out – Schema assuming NanoAODv7

Return type:

NanoAOD

warn_missing_crossrefs = True
class awkward_zipper.PFNanoAOD(version='latest')[source]

PFNano schema builder

PFNano is an extended NanoAOD format that includes PF candidates and secondary vertices More info at https://github.com/cms-jet/PFNano

all_cross_references: ClassVar = {'Electron_genPartIdx': 'GenPart', 'Electron_jetIdx': 'Jet', 'Electron_photonIdx': 'Photon', 'FatJetPFCands_jetIdx': 'FatJet', 'FatJetPFCands_pFCandsIdx': 'PFCands', 'FatJetSVs_jetIdx': 'FatJet', 'FatJetSVs_sVIdx': 'SV', 'FatJet_electronIdx3SJ': 'Electron', 'FatJet_genJetAK8Idx': 'GenJetAK8', 'FatJet_muonIdx3SJ': 'Muon', 'FatJet_subJetIdx1': 'SubJet', 'FatJet_subJetIdx2': 'SubJet', 'FsrPhoton_muonIdx': 'Muon', 'GenFatJetCands_jetIdx': 'GenJetAK8', 'GenFatJetCands_pFCandsIdx': 'GenCands', 'GenFatJetSVs_jetIdx': 'GenJetAK8', 'GenFatJetSVs_sVIdx': 'SV', 'GenJetCands_jetIdx': 'GenJet', 'GenJetCands_pFCandsIdx': 'GenCands', 'GenJetSVs_jetIdx': 'GenJet', 'GenJetSVs_sVIdx': 'SV', 'GenPart_genPartIdxMother': 'GenPart', 'GenVisTau_genPartIdxMother': 'GenPart', 'JetPFCands_jetIdx': 'Jet', 'JetPFCands_pFCandsIdx': 'PFCands', 'JetSVs_jetIdx': 'Jet', 'JetSVs_sVIdx': 'SV', 'Jet_electronIdx1': 'Electron', 'Jet_electronIdx2': 'Electron', 'Jet_genJetIdx': 'GenJet', 'Jet_muonIdx1': 'Muon', 'Jet_muonIdx2': 'Muon', 'LowPtElectron_electronIdx': 'Electron', 'LowPtElectron_genPartIdx': 'GenPart', 'LowPtElectron_photonIdx': 'Photon', 'Muon_fsrPhotonIdx': 'FsrPhoton', 'Muon_genPartIdx': 'GenPart', 'Muon_jetIdx': 'Jet', 'Photon_electronIdx': 'Electron', 'Photon_genPartIdx': 'GenPart', 'Photon_jetIdx': 'Jet', 'SubJet_subGenJetAK8Idx': 'SubGenJetAK8', 'Tau_genPartIdx': 'GenPart', 'Tau_jetIdx': 'Jet'}

Cross-references, where an index is to be interpreted with respect to another collection

Each such cross-reference will be converted to a global indexer, so that arbitrarily sliced events can still resolve the indirection back the parent events

mixins: ClassVar = {'CaloMET': 'MissingET', 'ChsMET': 'MissingET', 'Electron': 'Electron', 'FatJet': 'FatJet', 'FatJetPFCands': 'AssociatedPFCand', 'FatJetSVs': 'AssociatedSV', 'FsrPhoton': 'FsrPhoton', 'GenCands': 'PFCand', 'GenDressedLepton': 'PtEtaPhiMCollection', 'GenFatJetCands': 'AssociatedPFCand', 'GenFatJetSVs': 'AssociatedSV', 'GenIsolatedPhoton': 'PtEtaPhiMCollection', 'GenJet': 'PtEtaPhiMCollection', 'GenJetAK8': 'PtEtaPhiMCollection', 'GenJetCands': 'AssociatedPFCand', 'GenJetSVs': 'AssociatedSV', 'GenMET': 'MissingET', 'GenPart': 'GenParticle', 'GenVisTau': 'GenVisTau', 'IsoTrack': 'PtEtaPhiMCollection', 'Jet': 'Jet', 'JetPFCands': 'AssociatedPFCand', 'JetSVs': 'AssociatedSV', 'LHEPart': 'PtEtaPhiMCollection', 'LowPtElectron': 'LowPtElectron', 'MET': 'MissingET', 'METFixEE2017': 'MissingET', 'Muon': 'Muon', 'PFCands': 'PFCand', 'PV': 'Vertex', 'Photon': 'Photon', 'PuppiMET': 'MissingET', 'RawMET': 'MissingET', 'RawPuppiMET': 'MissingET', 'SV': 'SecondaryVertex', 'SoftActivityJet': 'PtEtaPhiMCollection', 'SubGenJetAK8': 'PtEtaPhiMCollection', 'SubJet': 'PtEtaPhiMCollection', 'Tau': 'Tau', 'TkMET': 'MissingET', 'TrigObj': 'PtEtaPhiMCollection'}

Default configuration for mixin types, based on the collection name.

The types are implemented in the coffea.nanoevents.methods.nanoaod module.

class awkward_zipper.ScoutingNanoAOD(version='latest')[source]

ScoutingNano schema builder

ScoutingNano is a NanoAOD format that includes Scouting objects

all_cross_references: ClassVar = {'Electron_genPartIdx': 'GenPart', 'Electron_jetIdx': 'Jet', 'Electron_photonIdx': 'Photon', 'FatJet_genJetAK8Idx': 'GenJetAK8', 'FatJet_subJetIdx1': 'SubJet', 'FatJet_subJetIdx2': 'SubJet', 'FsrPhoton_muonIdx': 'Muon', 'GenPart_genPartIdxMother': 'GenPart', 'GenVisTau_genPartIdxMother': 'GenPart', 'Jet_electronIdx1': 'Electron', 'Jet_electronIdx2': 'Electron', 'Jet_genJetIdx': 'GenJet', 'Jet_muonIdx1': 'Muon', 'Jet_muonIdx2': 'Muon', 'LowPtElectron_electronIdx': 'Electron', 'LowPtElectron_genPartIdx': 'GenPart', 'LowPtElectron_photonIdx': 'Photon', 'Muon_fsrPhotonIdx': 'FsrPhoton', 'Muon_genPartIdx': 'GenPart', 'Muon_jetIdx': 'Jet', 'Photon_electronIdx': 'Electron', 'Photon_genPartIdx': 'GenPart', 'Photon_jetIdx': 'Jet', 'Tau_genPartIdx': 'GenPart', 'Tau_jetIdx': 'Jet'}

Cross-references, where an index is to be interpreted with respect to another collection

Each such cross-reference will be converted to a global indexer, so that arbitrarily sliced events can still resolve the indirection back the parent events

mixins: ClassVar = {'CaloMET': 'MissingET', 'ChsMET': 'MissingET', 'Electron': 'Electron', 'FatJet': 'FatJet', 'FsrPhoton': 'FsrPhoton', 'GenDressedLepton': 'PtEtaPhiMCollection', 'GenIsolatedPhoton': 'PtEtaPhiMCollection', 'GenJet': 'PtEtaPhiMCollection', 'GenJetAK8': 'PtEtaPhiMCollection', 'GenMET': 'MissingET', 'GenPart': 'GenParticle', 'GenVisTau': 'GenVisTau', 'IsoTrack': 'PtEtaPhiMCollection', 'Jet': 'Jet', 'LHEPart': 'PtEtaPhiMCollection', 'LowPtElectron': 'LowPtElectron', 'MET': 'MissingET', 'METFixEE2017': 'MissingET', 'Muon': 'Muon', 'PV': 'Vertex', 'Photon': 'Photon', 'PuppiMET': 'MissingET', 'RawMET': 'MissingET', 'RawPuppiMET': 'MissingET', 'SV': 'SecondaryVertex', 'ScoutingElectron': 'Electron', 'ScoutingFatJet': 'FatJet', 'ScoutingJet': 'Jet', 'ScoutingMET': 'MissingET', 'ScoutingMuonNoVtx': 'Muon', 'ScoutingMuonNoVtxDisplacedVertex': 'Vertex', 'ScoutingMuonVtx': 'Muon', 'ScoutingMuonVtxDisplacedVertex': 'Vertex', 'ScoutingPhoton': 'Photon', 'ScoutingPrimaryVertex': 'Vertex', 'SoftActivityJet': 'PtEtaPhiMCollection', 'SubGenJetAK8': 'PtEtaPhiMCollection', 'SubJet': 'PtEtaPhiMCollection', 'Tau': 'Tau', 'TkMET': 'MissingET', 'TrigObj': 'PtEtaPhiMCollection'}

Default configuration for mixin types, based on the collection name.

The types are implemented in the coffea.nanoevents.methods.nanoaod module.