btag#

Producers for btag scale factor weights.

Classes:

BTagSFConfig(correction_set, jec_sources[, ...])

btag_weights(*args, **kwargs)

BTagWPSFConfig([jet_name, btag_column, ...])

btag_wp_weights(*args, **kwargs)

class BTagSFConfig(correction_set, jec_sources, discriminator='', corrector_kwargs=<factory>)[source]#

Bases: TAFConfig

Attributes:

Methods:

new(obj)

correction_set: str#
jec_sources: list[str]#
discriminator: str = ''#
corrector_kwargs: dict[str, Any]#
classmethod new(obj)[source]#
Return type:

BTagSFConfig

class btag_weights(*args, **kwargs)[source]#

Bases: Producer

Attributes:

Methods:

call_func(events, task[, jet_mask, ...])

B-tag scale factor weight producer.

get_btag_config()

get_btag_file(external_files)

post_init_func(task, **kwargs)

Default post-init function.

requires_func(task, reqs, **kwargs)

Default requires function.

setup_func(task, reqs, inputs, ...)

Default setup function.

skip_func(**kwargs)

Default skip function.

update_cls_dict(cls_name, cls_dict, get_attr)

cache_instances = True#
call_func(events, task, jet_mask=Ellipsis, negative_b_score_action='ignore', negative_b_score_log_mode='warning', **kwargs)#

B-tag scale factor weight producer. Requires an external file in the config as under btag_sf_corr:

cfg.x.external_files = DotDict.wrap({
    "btag_sf_corr": "/afs/cern.ch/work/m/mrieger/public/mirrors/jsonpog-integration-9ea86c4c/POG/BTV/2017_UL/btagging.json.gz",  # noqa
})

get_btag_file can be adapted in a subclass in case it is stored differently in the external files.

The name of the correction set, a list of JEC uncertainty sources which should be propagated through the weight calculation, and the column used for b-tagging should be given as an auxiliary entry in the config:

cfg.x.btag_sf = BTagSFConfig(
    correction_set="deepJet_shape",
    jec_sources=["Absolute", "FlavorQCD", ...],
    discriminator="btagDeepFlavB",
    corrector_kwargs={...},
)

get_btag_config can be adapted in a subclass in case it is stored differently in the config.

Optionally, a jet_mask can be supplied to compute the scale factor weight based only on a subset of jets.

The negative_b_score_action defines the procedure of how to handle jets with a negative b-tag. Supported modes are: :rtype: ak.Array

  • “ignore”: the jet_mask is extended to exclude jets with b_score < 0

  • “remove”: the scale factor is set to 0 for jets with b_score < 0, resulting in an overall

    btag weight of 0 for the event

  • “raise”: an exception is raised

The verbosity of the handling of jets with negative b-score can be set via negative_b_score_log_mode, which offers the following options:

  • "none": no message is given

  • "info": a logger.info message is given

  • "debug": a logger.debug message is given

  • "warning": a logger.warning message is given

Resources:

get_btag_config()#
get_btag_file(external_files)#
mc_only: bool = True#
post_init_func(task, **kwargs)#

Default post-init function.

Return type:

None

requires_func(task, reqs, **kwargs)#

Default requires function.

Return type:

None

setup_func(task, reqs, inputs, reader_targets, **kwargs)#

Default setup function.

Return type:

None

skip_func(**kwargs) bool#

Default skip function.

Return type:

bool

static update_cls_dict(cls_name, cls_dict, get_attr)#
uses = {'Jet.{pt,eta,phi,mass,hadronFlavour}'}#
weight_name = 'btag_weight'#
class BTagWPSFConfig(jet_name='Jet', btag_column='btagUParTAK4B', correction_set='UParTAK4_merged', btag_wps=<factory>, pt_edges=None, abs_eta_edges=None, wp_merging=<factory>, hist_key='btag_wp_counts', weight_name='btag_weight', systs=<factory>, dataset_groups=None)[source]#

Bases: TAFConfig

Attributes:

jet_name: str = 'Jet'#
btag_column: str = 'btagUParTAK4B'#
correction_set: str = 'UParTAK4_merged'#
btag_wps: dict[str, float]#
pt_edges: tuple[float, ...] | None = None#
abs_eta_edges: tuple[float, ...] | None = None#
wp_merging: dict[str, Sequence[str]]#
hist_key: str = 'btag_wp_counts'#
weight_name: str = 'btag_weight'#
systs: dict[str, str]#
dataset_groups: Callable[[od.Dataset], Sequence[od.Dataset | str] | None] | Sequence[Sequence[od.Dataset | str]] | None = None#
class btag_wp_weights(*args, **kwargs)[source]#

Bases: Producer

Attributes:

Methods:

call_func(events, task[, jet_mask])

B-tag scale factor weight producer using the fixed working point method.

get_btag_wp_file(external_files)

get_btag_wp_sf_config()

init_func(**kwargs)

Default init function.

post_init_func(task, **kwargs)

Default post-init function.

requires_func(task, reqs, **kwargs)

Default requires function.

setup_func(task, reqs, inputs, ...)

Default setup function.

skip_func(**kwargs)

Default skip function.

update_cls_dict(cls_name, cls_dict, get_attr)

cache_instances = True#
call_func(events, task, jet_mask=Ellipsis, **kwargs)#

B-tag scale factor weight producer using the fixed working point method. Requires an external file in the config as under btag_wp_sf_corr:

cfg.x.external_files = DotDict.wrap({
    "btag_wp_sf_corr": "/afs/cern.ch/work/m/mrieger/public/hbt/external_files/custom_btv_files/btag_merged_2024.json.gz",  # noqa
})

get_btag_wp_file can be adapted in a subclass in case it is stored differently in the external files.

To configure the tagger, working points, column names and other settings, a BTagWPSFConfig object should be registered in the config like the following.

cfg.x.btag_wp_sf_config = BTagWPSFConfig(
    jet_name="Jet",
    btag_column="btagUParTAK4B",
    correction_set="UParTAK4_merged",
)

get_btag_wp_sf_config can be adapted in a subclass in case it is stored differently in the config.

Return type:

ak.Array

Resources:
  1. https://btv-wiki.docs.cern.ch/PerformanceCalibration/fixedWPSFRecommendations/#recommendations-for-fixed-working-point-sfs # noqa

  2. https://cms-analysis-corrections.docs.cern.ch/corrections_era/Run3-24CDEReprocessingFGHIPrompt-Summer24-NanoAODv15/BTV/2026-01-30/#btagging_preliminaryjsongz # noqa

  3. https://indico.cern.ch/event/1583955/contributions/6771046/attachments/3176162/5648591/BTVreportHIGPAG_18112025.pdf # noqa

get_btag_wp_file(external_files)#
get_btag_wp_sf_config()#
init_func(**kwargs)#

Default init function.

Return type:

None

mc_only: bool = True#
post_init_func(task, **kwargs)#

Default post-init function.

Return type:

None

requires_func(task, reqs, **kwargs)#

Default requires function.

Return type:

None

setup_func(task, reqs, inputs, reader_targets, **kwargs)#

Default setup function.

Return type:

None

skip_func(**kwargs) bool#

Default skip function.

Return type:

bool

static update_cls_dict(cls_name, cls_dict, get_attr)#