You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已用zfit的ExtendedUnbinnedNLL拟合,如何获取sWeights做背景扣除?

获取zfit拟合后的sWeights(基于hepstats)

前置准备

确保已安装hepstats(执行pip install hepstats完成安装),且已完成ExtendedUnbinnedNLL拟合,得到:

  • 拟合用的数据集data(信号区域数据)
  • 包含信号、背景组分的扩展式组合PDFmodel
  • zfit的FitResult对象result(拟合输出结果)

计算sWeights步骤

  1. 导入依赖模块

    import zfit
    from hepstats.splot import compute_sweights
    
  2. 调用sWeight计算函数
    直接传入数据集、组合模型和拟合结果:

    sweights_dict = compute_sweights(data, model, result)
    

    返回的sweights_dict是字典结构,键为模型中各组分的名称(比如你定义信号时用的'signal'、背景的'background'),值为对应每个事件的sWeight数组。

  3. 提取目标组分的sWeights
    以信号和背景为例:

    signal_sweights = sweights_dict['signal']
    bkg_sweights = sweights_dict['background']
    

    数组长度与数据集一致,每个元素对应数据集中单个事件的sWeight,可直接用于后续背景扣除分析。

关键注意点

  • 必须使用扩展式组合PDF(与ExtendedUnbinnedNLL拟合匹配),compute_sweights会自动处理扩展模型的归一化因子。
  • result必须是zfit拟合返回的FitResult对象,确保拟合参数已正确收敛。
  • sWeights的本质是通过拟合后模型的概率密度,为每个事件分配权重,加权后可单独分离出信号或背景的分布特征。

内容的提问来源于stack exchange,提问作者jonas-eschle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 00:42:04