jets_coffea
#
Calibration methods for jets using coffea functions.
Summary#
|
Replace full file paths in an arbitrary struct by the file basenames. |
|
Create a coffea helper object for looking up information in files of various formats. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
andos.path.basename()
. The loop itself is done using thelaw.util.map_struct()
function.
- 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
orJetCorrectionUncertainty
).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 aitems()
method that returns a structure like (name, type), valueprovider_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:
- 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, seejec_coffea
andjer_coffea
.
- data_only = False#
- 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 processmin_pt_met_prop (
float
, default:15.0
) – If propagate_met variable isTrue
propagate the updated jet values to the missing transverse energy (MET) usingpropagate_met()
for events wheremet.pt > min_pt_met_prop
.max_eta_met_prop (
float
, default:5.2
) – If propagate_met variable isTrue
propagate the updated jet values to the missing transverse energy (MET) usingpropagate_met()
for events wheremet.eta > min_eta_met_prop
.
- Return type:
- data_only = False#
- mc_only = False#
- nominal_only = False#
- produces = {'Jet.mass', 'Jet.pt', 'Jet.rawFactor'}#
- propagate_met = True#
- 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 thisCalibrator
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:
- 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.
- data_only = False#
- 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#
- 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 thisCalibrator
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:
- 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'}#