本文整理汇总了Python中tools.DHadTable.cell_trim方法的典型用法代码示例。如果您正苦于以下问题:Python DHadTable.cell_trim方法的具体用法?Python DHadTable.cell_trim怎么用?Python DHadTable.cell_trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools.DHadTable
的用法示例。
在下文中一共展示了DHadTable.cell_trim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: yields_and_efficiencies
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import cell_trim [as 别名]
def yields_and_efficiencies(opts, args):
label = args[0]
prefix = 'dir_'+label
yldfile = tools.set_file(extbase=attr.brfpath, prefix=prefix,
comname='yields_and_efficiencies')
f = UserFile()
single_modes = [(pair, sign) for pair in modes for sign in [-1, 1]]
input_label = label
if '.' in label:
input_label = label.split('.')[0]
prefix='dir_'+input_label+'/crossfeeds'
dt_type = 'signal'
for x in single_modes:
if x[1] == 1:
uname = modes[x[0]]['uname']
fname = modes[x[0]]['fname']
else:
uname = modes[x[0]]['unamebar']
fname = modes[x[0]]['fnamebar']
txtname = '%s_Single_%s_fakes_Single_%s.txt' % (dt_type, fname, fname)
txtfile = tools.set_file(extbase=attr.fitpath, prefix=prefix, comname=txtname)
tab = DHadTable(txtfile)
entries = tab.cell_get('entries', 'Value')
entries = tab.cell_trim(entries, rnd='1')
yld = tab.cell_get('yield', 'Value')
yld = tab.cell_trim(yld, rnd='.000001')
ratio = tab.cell_get('ratio', 'Value')
ratio = tab.cell_trim(ratio, rnd='.000001')
f.data.append('%s: %s %s %s\n' % (fname, entries, yld, ratio))
for x, y in [(x, y) for x in single_modes for y in single_modes if x!=y]:
if x[1] == 1:
uname = modes[x[0]]['uname']
fname = modes[x[0]]['fname']
else:
uname = modes[x[0]]['unamebar']
fname = modes[x[0]]['fnamebar']
if y[1] == 1:
unameb = modes[y[0]]['uname']
fnameb = modes[y[0]]['fname']
else:
unameb = modes[y[0]]['unamebar']
fnameb = modes[y[0]]['fnamebar']
txtname = '%s_Single_%s_fakes_Single_%s.txt' % (dt_type, fname, fnameb)
txtfile = tools.set_file(extbase=attr.fitpath, prefix=prefix, comname=txtname)
tab = DHadTable(txtfile)
entries = tab.cell_get('entries', 'Value')
entries = tab.cell_trim(entries, rnd='1')
yld = tab.cell_get('yld', 'Value')
ylderr = tab.cell_get('yld', 'Error')
try:
float(yld)/float(ylderr)
except:
sys.stdout.write('The original ylderr is %s, set to 1.0e10.\n' % ylderr)
ylderr = 1.0e10
yldsigma = str(float(yld)/float(ylderr))
yldsigma = tab.cell_trim(yldsigma, rnd='.000001')
yld = tab.cell_trim(yld, rnd='.000001')
ratio = str(float(yld)/float(entries))
ratio = tab.cell_trim(ratio, rnd='.000001')
ratioerr = str(float(ylderr)/float(entries))
ratioerr = tab.cell_trim(ratioerr, rnd='.000001')
f.data.append('%s fakes %s: %s %s %s %s %s\n' % (
fname, fnameb, yldsigma, entries, yld, ratio, ratioerr))
f.output(yldfile, verbose=1)
return yldfile