pocket_coffea.lib.calibrators package#
Subpackages#
Submodules#
pocket_coffea.lib.calibrators.calibrator module#
- class pocket_coffea.lib.calibrators.calibrator.Calibrator(params=None, metadata=None, do_variations=True, **kwargs)#
Bases:
ABCAbstract class for the calibrators.
- abstract calibrate(events, events_original_collections, variation, already_applied_calibrators=None)#
The events objects is passed to the calibrator alongside a dictionary with the original collection. the calibrated_collections are computed and returned to the manager. The method is called also for variations not defined by the correct calibrator. In this was the calibrator can react and customize its output depending on the requested variation.
The calibrator MUST NOT replace in place the events collection. The CalibratorsManager will take care of replacing the collection and of possible coordination between calibrators.
If the variation is not handled by the calibrator, it should return the nominal collection, or the collection that is supposed to be returned in case of no variation.
A list of the calibrators already applied to the events is passed to the calibrator. This is useful for the calibrators that need to know which calibrators have been already applied to the events.
- calibrated_collections: List[str] = []#
- has_variations: ClassVar[bool] = False#
- abstract initialize(events)#
Method called once for chunk for the calibrator to prepare all the necessary data. The list of the variations is set here depending on the chunk metadata. N.B: the events object is passed to the calibrator before any calibrator is applied. If the calibrator prepares the variation values here, it is not incorporating the changes that may be applied by other calibrators. If the user want to prepare the variations based on the events calibrated in the chain, it should be done in the calibrate method.
- isMC_only: ClassVar[bool] = False#
- name: ClassVar[str] = 'base_calibrator'#
- classmethod serialize(src_code=False)#
- property variations#
pocket_coffea.lib.calibrators.calibrators_manager module#
- class pocket_coffea.lib.calibrators.calibrators_manager.CalibratorsManager(calibrators_list: List[Calibrator], events, params, metadata=None, requested_calibrator_variations=None, **kwargs)#
Bases:
objectThis class manages the calibration of collections for each event. The list of calibrators objects to apply is stored in the class. Each calibrator object is initialized in order with parameters and event metadata.
The CalibratorManager exposes the set of shape variations created by the calibrator sequence. The variations are used to create the list of variations used to fill the histograms and columns.
The CalibratorManager keeps a dictionary of calibrated collections by each calibrator: the name is expected to have the format “collection.field” (e.g. “Electron.pt”). The CalibratorManager checkes that each calibrator returns the collections it is supposed to handle, otherwise it raises an error.
The CalibratorManager keeps in memory the original collection. Moreover the calibrator knows which collections are calibrated by each calibrator. If a calibrator needs the original collection, it can be passed by the manager. This can be useful if a calibrator needs to use the original collection to calibrate another one after a previous calibrator has already modified the collection.
kwargs can be passed to the constructor to pass objects necessary for the calibrators to work, such as jme-factor, loaded once by the processor. TO BE IMPROVED
- calibrate(events, variation, debug=False)#
Call the calibrator objects in sequence. The calibrators returns the collections to replace in the events. The original collections are stored in a dictionary and passed to the chain of calibrators in case they need it.
- calibration_loop(events, variations=None, variations_for_calibrators=None, debug=False)#
Loop over all the requested variations and yield the modified events. Keep a reference to the original events.
- get_available_variations(calibrator_name=None)#
‘’’Return the list of available variations for a specific calibrator or all the variations if calibrator_name is None, return all the variations
- reset_events_to_original(events)#
Take the original collection and reset the events to that, practically undoing any calibration