我目前正试图在一个根目录树中使用“连根拔起”进行读取,使用boost直方图对直方图进行预订和填充,并将其写回一个新的根文件。
这似乎对bin内容非常有效,但我似乎无法为最终根文件中的直方图获得正确的bin错误。当我阅读这些柱状图时,h.GetBinError(b)
似乎等于h.GetBinContent(b)
,而我想知道通常为根柱状图生成的熟悉的sumW2错误。
使用python 3.8,我的工作流程如下:
import boost_histogram as bh
import uproot3 as uproot
bins = np.array( [1,2,3,4], dtype='d' )
hist = bh.Histogram( bh.axis.Variable(bins))
然后,我使用uprot4.iterate在输入树上迭代,为每个“chunk”生成一个笨拙的数组,这里用e
表示:
hist.fill(e["pt"], weight=(e["weight"]))
with uproot.recreate(outfilename) as outfile:
outfile["hist_pt"] = hist.to_numpy()
我不确定如何在构建增强直方图时获得sumw2权重,但根据文档,我将直方图定义更改为:
hist = bh.Histogram( bh.axis.Variable(bins), storage=bh.storage.Weight() )
但是,当我运行代码时,这会导致.to_numpy()
行出现问题。错误显示:
“what = uproot3_methods.convert.towriteable(what)
”
“TypeError: cannot perform reduce with flexible type
”
是否有其他方法将sumW2样式的错误从boost直方图传播到在Outlot中创建的根文件?或者我对这个storage=
变量的理解有误。。。。
任何帮助都将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐