extractor

class coffea.lookup_tools.extractor[source]

Bases: object

This class defines a common entry point for defining functions that extract the inputs to build lookup tables from various kinds of files.

The files that can be converted are presently defined in the “file_converters” dict.

The file names are used to determine the converter that is used, i.e.:

something.TYPE.FORMAT will apply the TYPE extractor to a file of given FORMAT

If there is no file type specifier the ‘default’ value is used.

The extractor class supports a number of useful file formats by default:
  • .histo.root : 1,2, and 3 dimensional histograms in root files.

  • .histo.json : N-dimensional histograms stored in JSON format.

  • .btag.csv : CMS BTV b-tagging weights in csv files.

  • .ea.txt : CMS EGM effective area text files.

  • ‘.[jec, jersf, jr, junc].txt’ : CMS JME jet energy corrections and systematic error text files.

It is possible to extend the functionality of lookup_tools.extractor by editing coffea.lookup_tools.file_converters to add new types and formats.

You can add sets of lookup tables / weights by calling:

extractor.add_weight_set(<description>)

<description> is formatted like ‘<nickname> <name-in-file> <the file to extract>’

* can be used as a wildcard to import all available lookup tables in a file

Methods Summary

add_weight_set(local_name, thetype, weights)

adds one extracted weight to the extractor

add_weight_sets(weightsdescs)

expects a list of text lines to be formatted as '<local name> <name> <weights file>' allows * * <file> and <prefix> * <file> to do easy imports of whole file

extract_from_file(thefile, name)

import a file and then extract a lookup set

finalize([reduce_list])

stop any further imports and if provided pare down the stored histograms to those specified in reduce_list

import_file(thefile)

cache the whole contents of a file for later processing

make_evaluator()

produce an evaluator based on the finalized extractor

Methods Documentation

add_weight_set(local_name, thetype, weights)[source]

adds one extracted weight to the extractor

add_weight_sets(weightsdescs)[source]

expects a list of text lines to be formatted as ‘<local name> <name> <weights file>’ allows * * <file> and <prefix> * <file> to do easy imports of whole file

extract_from_file(thefile, name)[source]

import a file and then extract a lookup set

finalize(reduce_list=None)[source]

stop any further imports and if provided pare down the stored histograms to those specified in reduce_list

import_file(thefile)[source]

cache the whole contents of a file for later processing

make_evaluator()[source]

produce an evaluator based on the finalized extractor