jets_coffea#

Calibration methods for jets using coffea functions.

Summary#

get_basenames(struct)

Replace full file paths in an arbitrary struct by the file basenames.

get_lookup_provider(files, conversion_func, ...)

Create a coffea helper object for looking up information in files of various formats.

jets_coffea(*args[, requires_func, ...])

jets_coffea_init

jec_coffea(*args[, requires_func, ...])

jec_coffea_init

jec_coffea_requires

jec_coffea_setup

jer_coffea(*args[, requires_func, ...])

jer_coffea_init

jer_coffea_requires

jer_coffea_setup

Functions#

get_basenames(struct)[source]#

Replace full file paths in an arbitrary struct by the file basenames.

The function loops through the structure and extracts the base name using a combination of os.path.splitext() and os.path.basename(). The loop itself is done using the law.util.map_struct() function.

Parameters:

struct (Iterable) – Iterable of arbitrary nested structure containing full file paths

Return type:

Iterable

Returns:

Iterable of same structure as struct containing only basenames of paths.

get_lookup_provider(files, conversion_func, provider_cls, names=None)[source]#

Create a coffea helper object for looking up information in files of various formats.

This function reads in the files containing lookup tables (e.g. JEC text files), extracts the table of values (“weights”) using the conversion function conversion_func implemented in coffea, and uses them to construct a helper object of type provider_cls that can be passed event data to yield the lookup values (e.g. a FactorizedJetCorrector or JetCorrectionUncertainty).

Optionally, a list of names can be supplied to select only a subset of weight tables for constructing the provider object (the default is to use all of them). This is intended to be useful for e.g. selecting only a particular set of jet energy uncertainties from an “UncertaintySources” file. By convention, the names always start with the basename of the file that contains the corresponding weight table.

Entries in names may also be tuples of the form (src_name, dst_name), in which case the src_name will be replaced by dst_name when passing the names to the provider_cls.

The user must ensure that the files can be parsed by the conversion_func supplied, and that the information contained in the files is meaningful in connection with the provider_cls.

Parameters:
  • files (list) – List of files containing lookup tables (e.g. JEC text files).

  • conversion_func (Callable) – Callable that extracts the table of weights from the files in files. Must return an Iterable that provides a items() method that returns a structure like (name, type), value

  • provider_cls (Type) – Class method that is used to construct the provider instance that finally provides the weights for the events. Examples: FactorizedJetCorrector, JetCorrectionUncertainty

  • names (Optional[list[str]], default: None) – Optional list of weight names to include, see text above.

Raises:

ValueError – If names contains weight names that are not present in the source file

Return type:

Type

Returns:

helper class that provides the weights for the events of same type as provider_cls (e.g. FactorizedJetCorrector, JetCorrectionUncertainty)

Calibrators#

class jets_coffea(*args, requires_func=law.util.no_value, setup_func=law.util.no_value, sandbox=law.util.no_value, call_force=law.util.no_value, pick_cached_result=law.util.no_value, inst_dict=None, **kwargs)[source]#

Bases: Calibrator

call_func(events, **kwargs)#

Instance of Calibrator that does all relevant calibrations for jets, i.e. JEC and JER. For more information, see jec_coffea and jer_coffea.

Parameters:

events (Array) – awkward array containing events to process.

Return type:

Array

data_only = False#
init_func()#
Return type:

None

mc_only = False#
nominal_only = False#
produces = {<class 'columnflow.calibration.cms.jets_coffea.jer_coffea'>, <class 'columnflow.calibration.cms.jets_coffea.jec_coffea'>}#
propagate_met = True#
shifts_only = None#
uses = {<class 'columnflow.calibration.cms.jets_coffea.jer_coffea'>, <class 'columnflow.calibration.cms.jets_coffea.jec_coffea'>}#
class jec_coffea(*args, requires_func=law.util.no_value, setup_func=law.util.no_value, sandbox=law.util.no_value, call_force=law.util.no_value, pick_cached_result=law.util.no_value, inst_dict=None, **kwargs)[source]#

Bases: Calibrator

call_func(events, min_pt_met_prop=15.0, max_eta_met_prop=5.2, **kwargs)#

Apply jet energy corrections and calculate shifts for jet energy uncertainty sources.

Parameters:
  • events (Array) – awkward array containing events to process

  • min_pt_met_prop (float, default: 15.0) – If propagate_met variable is True propagate the updated jet values to the missing transverse energy (MET) using propagate_met() for events where met.pt > min_pt_met_prop.

  • max_eta_met_prop (float, default: 5.2) – If propagate_met variable is True propagate the updated jet values to the missing transverse energy (MET) using propagate_met() for events where met.eta > min_eta_met_prop.

Return type:

Array

data_only = False#
init_func()#
Return type:

None

mc_only = False#
nominal_only = False#
produces = {'Jet.mass', 'Jet.pt', 'Jet.rawFactor'}#
propagate_met = True#
requires_func(reqs)#
Return type:

None

setup_func(reqs, inputs, reader_targets)#

Determine correct JEC files for task based on config/dataset and inject them into the calibrator function call.

Parameters:
  • reqs (dict) – Requirement dictionary for this Calibrator instance.

  • inputs (dict) – Additional inputs, currently not used.

  • reader_targets (InsertableDict) – TODO: add docs

Raises:

ValueError – If module is provided with more than one JEC uncertainty source file.

Return type:

None

shifts_only = None#
uncertainty_sources = None#
uses = {'Jet.eta', 'Jet.area', 'Jet.pt', 'Jet.jetId', 'fixedGridRhoFastjetAll', <class 'columnflow.production.util.attach_coffea_behavior'>, 'Rho.fixedGridRhoFastjetAll', 'Jet.rawFactor', 'Jet.phi', 'Jet.mass'}#
class jer_coffea(*args, requires_func=law.util.no_value, setup_func=law.util.no_value, sandbox=law.util.no_value, call_force=law.util.no_value, pick_cached_result=law.util.no_value, inst_dict=None, **kwargs)[source]#

Bases: Calibrator

call_func(events, **kwargs)#

Apply jet energy resolution smearing and calculate shifts for Jet Energy Resolution (JER) scale factor variations.

Follows the recommendations given in https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetResolution.

The module applies the scale factors associated to the JER and performs the stochastic smearing to make the energy resolution in simulation more realistic.

Parameters:

events (Array) – awkward array containing events to process

Return type:

Array

data_only = False#
init_func()#
Return type:

None

mc_only = True#
nominal_only = False#
produces = {'Jet.mass', 'Jet.mass_jer_down', 'Jet.mass_jer_up', 'Jet.mass_unsmeared', 'Jet.pt', 'Jet.pt_jer_down', 'Jet.pt_jer_up', 'Jet.pt_unsmeared', 'MET.phi', 'MET.phi_jer_down', 'MET.phi_jer_up', 'MET.pt', 'MET.pt_jer_down', 'MET.pt_jer_up'}#
propagate_met = True#
requires_func(reqs)#
Return type:

None

setup_func(reqs, inputs, reader_targets)#

Determine correct JER files for task based on config/dataset and inject them into the calibrator function call.

Parameters:
  • reqs (dict) – Requirement dictionary for this Calibrator instance.

  • inputs (dict) – Additional inputs, currently not used.

  • reader_targets (InsertableDict) – TODO: add docs.

Raises:

ValueError – If module is provided with more than one JER uncertainty source file.

Return type:

None

shifts_only = None#
skip_func()#
uses = {'GenJet.phi', 'Jet.eta', 'GenJet.pt', 'MET.pt', 'Jet.genJetIdx', 'Jet.pt', 'fixedGridRhoFastjetAll', <class 'columnflow.production.util.attach_coffea_behavior'>, 'Rho.fixedGridRhoFastjetAll', 'GenJet.eta', 'MET.phi', 'Jet.phi', 'Jet.mass'}#