本文整理匯總了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