NanoAODSchema

class coffea.processor.NanoAODSchema(base_form, version='latest')[source]

Bases: BaseSchema

NanoAOD schema builder

The NanoAOD schema 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 NanoAODSchema. 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.

Attributes Summary

all_cross_references

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

behavior

Behaviors necessary to implement this schema

mixins

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

nested_index_items

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

nested_items

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

special_items

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

warn_missing_crossrefs

Methods Summary

v5(base_form)

Build the NanoEvents assuming NanoAODv5

v6(base_form)

Build the NanoEvents assuming NanoAODv6

v7(base_form)

Build the NanoEvents assuming NanoAODv7

Attributes Documentation

all_cross_references = {'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

behavior

Behaviors necessary to implement this schema

mixins = {'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 = {'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 = {'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 = {'GenPart_childrenIdxG': (<function children_form>, ('oGenPart', 'GenPart_genPartIdxMotherG')), 'GenPart_distinctChildrenDeepIdxG': (<function distinctChildrenDeep_form>, ('oGenPart', 'GenPart_genPartIdxMotherG', 'GenPart_pdgId')), 'GenPart_distinctChildrenIdxG': (<function children_form>, ('oGenPart', 'GenPart_distinctParentIdxG')), 'GenPart_distinctParentIdxG': (<function distinctParent_form>, ('GenPart_genPartIdxMotherG', 'GenPart_pdgId'))}

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

warn_missing_crossrefs = True

Methods Documentation

classmethod v5(base_form)[source]

Build the NanoEvents assuming NanoAODv5

classmethod v6(base_form)[source]

Build the NanoEvents assuming NanoAODv6

classmethod v7(base_form)[source]

Build the NanoEvents assuming NanoAODv7

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