NanoEventsFactory
- class coffea.nanoevents.NanoEventsFactory(schema, mapping, partition_key, cache=None)[source]
Bases:
object
A factory class to build NanoEvents objects
Methods Summary
events
()Build events
from_parquet
(file[, treepath, entry_start, ...])Quickly build NanoEvents from a parquet file
from_preloaded
(array_source[, entry_start, ...])Quickly build NanoEvents from a pre-loaded array source
from_root
(file[, treepath, entry_start, ...])Quickly build NanoEvents from a root file
Methods Documentation
- classmethod from_parquet(file, treepath='/Events', entry_start=None, entry_stop=None, runtime_cache=None, persistent_cache=None, schemaclass=<class 'coffea.nanoevents.schemas.nanoaod.NanoAODSchema'>, metadata=None, parquet_options={}, skyhook_options={}, access_log=None)[source]
Quickly build NanoEvents from a parquet file
- Parameters:
file (str, pathlib.Path, pyarrow.NativeFile, or python file-like) – The filename or already opened file using e.g.
uproot.open()
treepath (str, optional) – Name of the tree to read in the file
entry_start (int, optional) – Start at this entry offset in the tree (default 0)
entry_stop (int, optional) – Stop at this entry offset in the tree (default end of tree)
runtime_cache (dict, optional) – A dict-like interface to a cache object. This cache is expected to last the duration of the program only, and will be used to hold references to materialized awkward arrays, etc.
persistent_cache (dict, optional) – A dict-like interface to a cache object. Only bare numpy arrays will be placed in this cache, using globally-unique keys.
schemaclass (BaseSchema) – A schema class deriving from
BaseSchema
and implementing the desired view of the filemetadata (dict, optional) – Arbitrary metadata to add to the
base.NanoEvents
objectparquet_options (dict, optional) – Any options to pass to
pyarrow.parquet.ParquetFile
access_log (list, optional) – Pass a list instance to record which branches were lazily accessed by this instance
- classmethod from_preloaded(array_source, entry_start=None, entry_stop=None, runtime_cache=None, persistent_cache=None, schemaclass=<class 'coffea.nanoevents.schemas.nanoaod.NanoAODSchema'>, metadata=None, access_log=None)[source]
Quickly build NanoEvents from a pre-loaded array source
- Parameters:
array_source (Mapping[str, awkward.Array]) – A mapping of names to awkward arrays, it must have a metadata attribute with uuid, num_rows, and path sub-items.
entry_start (int, optional) – Start at this entry offset in the tree (default 0)
entry_stop (int, optional) – Stop at this entry offset in the tree (default end of tree)
runtime_cache (dict, optional) – A dict-like interface to a cache object. This cache is expected to last the duration of the program only, and will be used to hold references to materialized awkward arrays, etc.
persistent_cache (dict, optional) – A dict-like interface to a cache object. Only bare numpy arrays will be placed in this cache, using globally-unique keys.
schemaclass (BaseSchema) – A schema class deriving from
BaseSchema
and implementing the desired view of the filemetadata (dict, optional) – Arbitrary metadata to add to the
base.NanoEvents
objectaccess_log (list, optional) – Pass a list instance to record which branches were lazily accessed by this instance
- classmethod from_root(file, treepath='/Events', entry_start=None, entry_stop=None, runtime_cache=None, persistent_cache=None, schemaclass=<class 'coffea.nanoevents.schemas.nanoaod.NanoAODSchema'>, metadata=None, uproot_options={}, access_log=None, iteritems_options={})[source]
Quickly build NanoEvents from a root file
- Parameters:
file (str or uproot.reading.ReadOnlyDirectory) – The filename or already opened file using e.g.
uproot.open()
treepath (str, optional) – Name of the tree to read in the file
entry_start (int, optional) – Start at this entry offset in the tree (default 0)
entry_stop (int, optional) – Stop at this entry offset in the tree (default end of tree)
runtime_cache (dict, optional) – A dict-like interface to a cache object. This cache is expected to last the duration of the program only, and will be used to hold references to materialized awkward arrays, etc.
persistent_cache (dict, optional) – A dict-like interface to a cache object. Only bare numpy arrays will be placed in this cache, using globally-unique keys.
schemaclass (BaseSchema) – A schema class deriving from
BaseSchema
and implementing the desired view of the filemetadata (dict, optional) – Arbitrary metadata to add to the
base.NanoEvents
objectuproot_options (dict, optional) – Any options to pass to
uproot.open
access_log (list, optional) – Pass a list instance to record which branches were lazily accessed by this instance