本文整理汇总了Python中tools.DHadTable类的典型用法代码示例。如果您正苦于以下问题:Python DHadTable类的具体用法?Python DHadTable怎么用?Python DHadTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DHadTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parsefile
def parsefile(f, lowmass, highmass, indict):
x0 = lowmass
x1 = highmass
xc = (x0 + x1)/2.
tab = DHadTable(f)
N1 = float(tab.cell_get('N1', 'Value'))
N2 = float(tab.cell_get('N2', 'Value'))
if N1 > 1000 or N2 > 1000 :
return
indict['x'].append(xc)
indict['exl'].append(xc-x0)
indict['exh'].append(x1-xc)
N = N1 + N2
err_low_N1 = float(tab.cell_get('N1', 'Low'))
err_low_N2 = float(tab.cell_get('N2', 'Low'))
err_low = (err_low_N1**2 + err_low_N2**2)**.5
err_high_N1 = float(tab.cell_get('N1', 'High'))
err_high_N2 = float(tab.cell_get('N2', 'High'))
err_high = (err_high_N1**2 + err_high_N2**2)**.5
yc = float(N)
yl = float(err_low)
yh = float(err_high)
indict['y'].append(yc)
indict['eyl'].append(yl)
indict['eyh'].append(yh)
示例2: entries
def entries(args):
dt_type = args[0]
tag = args[1]
label_A = args[2]
label_B = args[3]
evtpath = attr.evtpath
rnd='.01'
err_type=None
label = None
diff = 'pct'
tab = DHadTable()
tab.row_append(['Mode', label_A, label_B])
tab.head = tab.data[0]
for mode in attr.modes:
for sign in [1, -1]:
evtfile_A = tools.set_file('evt', dt_type, mode, tag, sign=sign,
prefix='dir_'+label_A, extbase=evtpath)
evtfile_B = tools.set_file('evt', dt_type, mode, tag, sign=sign,
prefix='dir_'+label_B, extbase=evtpath)
entries_A = tools.count_lines(evtfile_A)
entries_B = tools.count_lines(evtfile_B)
if sign == 1:
modename = attr.modes[mode]['fname']
else:
modename = attr.modes[mode]['fnamebar']
row = [modename, entries_A, entries_B]
tab.row_append(map(str, row))
tab.column_append_by_diff_pct('diff(%)', label_B,label_A, rnd=rnd, err_type=err_type)
tab.output(_tabname)
示例3: create_fig_mode
def create_fig_mode(opts, tag, datatype, mode, lowmass, highmass, label):
modekey = tools.get_modekey(mode)
comname = '%s_%s' %(datatype.replace('/', '_'), mode)
prefix = 'dir_%s/kkmass/%s_%s' % (label, lowmass, highmass)
epsfile = tools.set_file('eps', datatype, modekey, tag,
prefix=prefix, extbase=attr.figpath)
txtfile = tools.set_file('txt', datatype, modekey, tag,
prefix=prefix, extbase=attr.fitpath)
head, figname = os.path.split(epsfile)
figname = figname.replace('.eps', '')
subdir = 'kkmass/%s_%s' % (lowmass, highmass)
pdflink = './%s/%s.pdf' %(subdir, figname)
pnglink = './%s/%s.png' %(subdir, figname)
loglink = '[[../../log/%s/%s/%s.txt][log]]' %(label, subdir, comname)
figlink = '[[%s][%s]]' %(pdflink, pnglink)
modename = tools.get_orgname_from_fname(mode)
secname = 'KK mass: %s - %s' % (lowmass, highmass)
tablink = ''
if os.access(txtfile, os.F_OK):
orgtabfile = txtfile.replace('.txt', '.org')
tab = DHadTable(txtfile)
tab.output_org(orgtabfile)
tablink = '#+INCLUDE: "%s"\n' % orgtabfile
msg = '\n* %s \n %s \n\n%s\n %s\n' % (
secname, figlink, tablink, loglink)
return msg
示例4: get_generated_numbers_single
def get_generated_numbers_single(i, prefix=''):
if '281ipb' in prefix:
mult_fact = 10
elif '537ipb' in prefix:
mult_fact = 20
elif '818ipb' in prefix or 'v13' in prefix:
mult_fact = 30
else:
raise NameError(prefix)
mode = i[0]
sign = i[1]
tag_number = modes[mode]['tag_num_s']
count = tag_number*mult_fact
if mode == 205:
if sign == 1:
count = 29972 # 30000
if sign == -1:
count = 35969 # 36000
if 'noFSR' in prefix:
mode = i[0]
sign = i[1]
logfile = tools.set_file('log', 's', mode, 's', sign, prefix,
extbase=evtlogbase)
tab = DHadTable(logfile)
FSR = tab.cell_get('FSR', 'Value')
count = count - int(FSR)
return count
示例5: get_generated_numbers_double
def get_generated_numbers_double(pair, prefix=''):
if '281ipb' in prefix:
mult_fact = 10
elif '537ipb' in prefix:
mult_fact = 20
elif '818ipb' in prefix or 'v13' in prefix:
mult_fact = 30
else:
raise NameError(prefix)
i = pair[0]
j = pair[1]
#genpath = attr.genpath
#print genpath
#sys.exit()
#if attr.analysis == '10.1' and '281ipbv0' in prefix :
# genpath = '/nfs/cor/user/ponyisi/cleog/scripts-summerconf/'
tag_number = 2000
count = tag_number * mult_fact
if 'v13' in prefix:
fname = modes[i]['fname']
fnamebar = modes[j]['fnamebar']
modename = 'Double_%s__%s' %(fname, fnamebar)
if modename == 'Double_Dp_to_KKpi__Dm_to_KKpi':
count = 47966
if modename == 'Double_Dp_to_KKpi__Dm_to_Kpipipi0':
count = 58403
if modename == 'Double_Dp_to_KKpi__Dm_to_Kpipi':
count = 57954
if modename == 'Double_Dp_to_KKpi__Dm_to_Kspipi0':
count = 57969
if modename == 'Double_Dp_to_KKpi__Dm_to_Kspipipi':
count = 24693
if modename == 'Double_Dp_to_KKpi__Dm_to_Kspi':
count = 57953
if modename == 'Double_Dp_to_Kpipi__Dm_to_KKpi':
count = 59952
if modename == 'Double_Dp_to_Kpipipi0__Dm_to_KKpi':
count = 55955
if modename == 'Double_Dp_to_Kspi__Dm_to_KKpi':
count = 57954
if modename == 'Double_Dp_to_Kspipi0__Dm_to_KKpi':
count = 57956
if modename == 'Double_Dp_to_Kspipipi__Dm_to_KKpi':
count = 57954
if 'noFSR' in prefix:
logfile = tools.set_file('log', 's', pair, 'd', prefix=prefix,
extbase=evtlogbase)
tab =DHadTable(logfile)
FSR = tab.cell_get('FSR', 'Value')
count = count - int(FSR)
return count
示例6: get_fsr_sys
def get_fsr_sys(label):
if label == '281ipbv12.0':
tabfile = os.path.join(attr.tabpath, '281ipbv0', 'FSR_syst.txt')
tab = DHadTable(tabfile)
print 'Loading %s ...' % tabfile
fsr_sys = tab.column_get('diff X 30%')
else:
tab = get_mode_dependent_syst_tab(label)
fsr_sys = tab.row_get('FSR')
return fsr_sys
示例7: para_md
def para_md(args):
para = 'md'
namestyle = 'fname'
rnd = '0.0000001'
tag = 's'
tab_A = args[0]
tab_B = args[1]
latel_A = tab_A
latel_B = tab_B
label = tools.parseopts_set(opts.set, 'label')
if label:
labels = label.split(',')
label_A = labels[0]
label_B = labels[1]
tab = DHadTable()
tab.column_append_from_dict('Mode', namestyle)
tab.column_append_from_fit_files(label_A, tab_A, para, tag, rnd)
tab.column_append_from_fit_files(label_B, tab_B, para, tag, rnd)
tab.column_append_by_diff('diff[MeV]', label_B,label_A, rnd=rnd, factor=1000)
tab.output(_tabname)
示例8: diff
def diff(args):
label= None
if opts.set:
for li in opts.set.split(':'):
name = li.split('=')[0]
value = li.split('=')[1]
sys.stdout.write('Set %s = %s \n' % (name, value))
if name == 'label':
label = value
if label:
labels = label.split(',')
label_A = labels[0]
label_B = labels[1]
tab_A = 'compare_%s.txt' % args[0]
tab_B = 'compare_%s.txt' % args[1]
tabfile_A = os.path.join(attr.tabpath, tab_A)
tabfile_B = os.path.join(attr.tabpath, tab_B)
tab = DHadTable()
tab.column_append_from_tab_file('Mode', tabfile_A, 'Mode')
tab.column_append_from_tab_file(label_A, tabfile_A, 'diff(%)')
tab.column_append_from_tab_file(label_B, tabfile_B, 'diff(%)')
tab.column_append_by_diff('diff', label_B,label_A)
tab.output(_tabname)
示例9: ratios_signal
def ratios_signal(args):
if args[0] == '537ipb/281ipb' and args[1] == '537ipbv2/281ipb':
tabfilename1 = 'compare_yields_signal_divide_537ipb_9.03_regular12.txt'
title1 = args[0]
headname1 = title1
tabfilename2 = 'compare_yields_signal_divide_537ipbv2_9.03_regular12.txt'
title2 = args[1]
headname2 = title2
else:
raise NameError(args)
tabfile1 = os.path.join(attr.tabpath, tabfilename1)
tabfile2 = os.path.join(attr.tabpath, tabfilename2)
if opts.set and opts.set == 'info':
print 'here'
tab = DHadTable()
tab.column_append_from_tab_file('Mode', tabfile1, 'Mode')
tab.column_append_from_tab_file(title1, tabfile1, headname1)
tab.column_append_from_tab_file(title2, tabfile2, headname2)
tab.column_append_by_diff_sigma_pct('diff(%)', title2, title1)
tab.output(_tabname)
示例10: get_signal_shape_sys
def get_signal_shape_sys(label):
if label == '281ipbv12.0':
tabfile = os.path.join(attr.tabpath, '281ipbv0',
'signal_line_shape_syst.txt')
print 'Loading %s ...' % tabfile
tab = DHadTable(tabfile)
line_shape_sys = tab.column_get('Total(%)')
else:
tab = get_mode_dependent_syst_tab(label)
line_shape_sys = tab.row_get('Signal shape')
return line_shape_sys
示例11: bkg_cont_single_mode
def bkg_cont_single_mode(datatype, mode, label, debug):
prefix = 'dir_'+label
bkgname = '%s_%s.txt' %(datatype, mode)
bkgname = bkgname.replace('/', '_')
bkgfile = tools.set_file(
extbase=attr.bkgpath(), prefix=prefix, comname=bkgname)
if debug:
sys.stdout.write('\ndebug: bkgfile %s\n' %bkgfile)
modename = mode.replace('Single_', '')
result = [modename]
tab = DHadTable(bkgfile)
result.extend(tab.column_get('Number')[1:])
return result
示例12: events
def events(args):
parsed = yld.parse_args(args)
datatype = parsed[0]
tag = parsed[1]
modes = parsed[2]
label_A = parsed[3]
label_B = args[3]
datpath = attr.datpath
tab = DHadTable()
tab.row_append(['Mode', label_A, label_B, 'Common',
'Unique(%s)' %label_A, 'Unique(%s)' %label_B ])
tab.head = tab.data[0]
for mode in modes:
modename = mode.replace('Single_', '')
evtname = datatype + '_' + mode + '.evt'
evtpath_A = os.path.join(datpath, 'evt', label_A, 'events')
evtfile_A = os.path.join(evtpath_A, evtname)
f_A = UserFile(evtfile_A)
events_A = Set(f_A.data)
evtpath_B = os.path.join(datpath, 'evt', label_B, 'events')
evtfile_B = os.path.join(evtpath_B, evtname)
f_B = UserFile(evtfile_B)
events_B = Set(f_B.data)
events_inter = events_A & events_B
entries_A = len(events_A)
entries_B = len(events_B)
common = len(events_inter)
unique_A = len(events_A - events_inter)
unique_B = len(events_B - events_inter)
row = [modename, entries_A, entries_B, common, unique_A, unique_B]
tab.row_append(map(str, row))
tab.output(_tabname)
示例13: get_argus_paras_single
def get_argus_paras_single(label, dt_type, tag, mode):
if 'argus' in label:
prefix = 'dir_' + label.replace('argus', 'desideband')
argus_para_base = attr.fitpath
tabfile = tools.set_file('txt', dt_type, mode, tag,
prefix=prefix,
extbase=argus_para_base)
sys.stdout.write('Loading ARGUS parameters from %s ...\n' %tabfile)
tab = DHadTable(tabfile)
xi = float(tab.cell_get('xi', 'Value'))
p = float(tab.cell_get('p', 'Value'))
return xi, p
示例14: bkg_ddbar_single_mode
def bkg_ddbar_single_mode(datatype, mode, label, ranges, debug):
prefix = 'dir_'+label
bkgname = '%s_%s.txt' %(datatype, mode)
bkgname = bkgname.replace('/', '_')
bkgfile = tools.set_file(
extbase=attr.bkgpath(), prefix=prefix, comname=bkgname)
if debug:
sys.stdout.write('\ndebug: bkgfile %s\n' %bkgfile)
modename = mode.replace('Single_', '')
bkgtable = get_bkg_tab_link(datatype, mode, label)
result = [modename, bkgtable]
tab = DHadTable(bkgfile)
result.extend(tab.column_analyze('Number', ranges))
return result
示例15: create_fig_mode
def create_fig_mode(tag, dt_type, mode, label):
if tag == 'single':
modename = attr.modes[mode]['orgname']
else:
if mode == 'double_all_d0s':
modename = 'Double all D0s'
elif mode == 'double_all_dps':
modename = 'Double all Dps'
else:
mode1 = mode[0]
mode2 = mode[1]
modename = '%s, %s' % (attr.modes[mode1]['orgname'],
attr.modes[mode2]['orgnamebar'])
prefix = 'dir_' + label
epsfile = tools.set_file('eps', dt_type, mode, tag,
prefix=prefix, extbase=attr.figpath)
head, tail = os.path.split(epsfile)
comname = tail.replace('.eps', '')
figlabel = label.split('/')[0]
relpath = label.replace(figlabel, '')
pdflink = '.%s/%s.pdf' %(relpath, comname)
pnglink = '.%s/%s.png' %(relpath, comname)
loglink = '[[../../log/%s/%s.txt][log]]' %(label, comname)
figlink = '[[%s][%s]]' %(pdflink, pnglink)
fitpath = attr.fitpath
tabfile = tools.set_file('txt', dt_type, mode, tag,
prefix=prefix, extbase=fitpath)
if os.access(tabfile, os.F_OK):
orgtabfile = tools.set_file('org', dt_type, mode, tag,
prefix=prefix, extbase=fitpath)
tab = DHadTable(tabfile)
tab.output_org(orgtabfile)
abspath = os.path.join(attr.base)#, attr.analysis)
orgtabfile = orgtabfile.replace(abspath, '../..')
tablink = '#+INCLUDE: "%s"\n' % orgtabfile
msg = '\n* %s \n %s \n\n%s\n %s\n' % (
modename, figlink, tablink, loglink)
else:
sys.stdout.write('File does not exist: %s \n' %tabfile)
sys.stdout.write('Skipping mode %s ... \n' % str(mode))
msg = '\n* %s \n Skipped.\n' % modename
return msg