def brf_data_results(opts, tabname, args): ''' ----------------------------- Results of the Data Fit ----------------------------- ''' label_A = args[0] label_B = args[1] verbose = opts.verbose bffilename = 'bf_stat_sys' labels = [] labels.append(label_A) labels.append(label_B) tab = DHadTable() paras = False for label in labels: if '281ipb' in label: factor = 0.000001 elif '537ipb' in label: factor = 0.000001*281/537 elif '818ipb' in label or 'v13' in label: factor = 0.000001*281/818 else: raise NameError(label) if '818ipb' in label_A and '818ipb' in label_B: factor = 0.000001 if '818ipb' in label_A and 'v13' in label_B: factor = 0.000001 bffile = os.path.join(attr.brfpath, label, bffilename) if not paras: tab.column_append(tools.parse_result(bffile, 'paras'), 'Parameters') paras = True tab.column_append(tools.parse_result(bffile, 'value'), 'value', rnd='.00001' ) tab.column_append(tools.parse_result(bffile, 'stat'), 'stat') tab.column_append(tools.parse_result(bffile, 'syst'), 'syst') tab.columns_join3('Fitted Value', 'value', 'stat', 'syst') tab.column_trim('Fitted Value', row=['ND0D0Bar', 'ND+D-'], rnd='.0001', factor=factor, opt='(cell)x1E6') tab.column_trim('Fitted Value', rnd='.00001', except_row=['ND0D0Bar', 'ND+D-']) tab.column_append(tools.parse_result(bffile, 'err_frac'), 'Frac. Err', rnd='.1', opt='(cell%)') tab.columns_join(label, 'Fitted Value','Frac. Err', str=' ') tab.column_append_by_diff_sigma('Difference', label_B,label_A) tab.output(tabname, test=opts.test)
def main(opts, args): if args[0] == 'names': return bkg_names(opts, args[1:]) tabname = 'bkg_' + '_'.join(args).replace('/', '_') debug = opts.debug test = opts.test parsed = yld.parse_args(args) datatype = parsed[0] tag = parsed[1] modes = parsed[2] label = parsed[3] if args[0] == 'generic': return bkg_generic_ddbar(tabname, datatype, tag, modes, label, test, debug) elif args[0] == 'generic/cont': return bkg_generic_cont(tabname, datatype, tag, modes, label, test, debug) elif args[0] == 'generic/ddbar': return bkg_generic_ddbar(tabname, datatype, tag, modes, label, test, debug) tab = DHadTable() row = [ 'Mode', 'Number of DDbar Backgrounds', 'Number of Continuum Backgrounds' ] tab.row_append(row) for mode in modes: modename = mode.replace('Single_', '') ddbarnum = get_bkg_total('generic/ddbar', mode, label, debug) contnum = get_bkg_total('generic/cont', mode, label, debug) row = [modename, ddbarnum, contnum] tab.row_append(row) tab.column_trim('Number of DDbar Backgrounds', rnd='1') tab.column_trim('Number of Continuum Backgrounds', rnd='1') tab.output(tabname, test=test)
def main(opts, args): if args[0] == 'names': return bkg_names(opts, args[1:]) tabname = 'bkg_' + '_'.join(args).replace('/', '_') debug = opts.debug test = opts.test parsed = yld.parse_args(args) datatype = parsed[0] tag = parsed[1] modes = parsed[2] label = parsed[3] if args[0] == 'generic': return bkg_generic_ddbar(tabname, datatype, tag, modes, label, test, debug) elif args[0] == 'generic/cont': return bkg_generic_cont(tabname, datatype, tag, modes, label, test, debug) elif args[0] == 'generic/ddbar': return bkg_generic_ddbar(tabname, datatype, tag, modes, label, test, debug) tab = DHadTable() row = ['Mode', 'Number of DDbar Backgrounds', 'Number of Continuum Backgrounds'] tab.row_append(row) for mode in modes: modename = mode.replace('Single_', '') ddbarnum = get_bkg_total('generic/ddbar', mode, label, debug) contnum = get_bkg_total('generic/cont', mode, label, debug) row = [modename, ddbarnum, contnum] tab.row_append(row) tab.column_trim('Number of DDbar Backgrounds', rnd='1') tab.column_trim('Number of Continuum Backgrounds', rnd='1') tab.output(tabname, test=test)
def pdg2009(args): ''' -------------------------------------------------------- Results of the Data Fit Compare with PDG 2009 -------------------------------------------------------- ''' label = args[0] verbose = opts.verbose bffilename = 'bf_stat_sys' bffile = os.path.join(attr.brfpath, label, bffilename) tab = DHadTable() tab.column_append(tools.parse_result(bffile, 'paras'), 'Parameters') tab.column_append(tools.parse_result(bffile, 'value'), 'value') tab.column_append(tools.parse_result(bffile, 'stat'), 'stat') tab.column_append(tools.parse_result(bffile, 'syst'), 'syst') tab.columns_join3('Fitted Value', 'value', 'stat', 'syst') tab.column_trim('Fitted Value', row = ['ND0D0Bar', 'ND+D-'], rnd = '.001', factor = 0.000001, opt = '(cell)x10E6') tab.column_trim('Fitted Value', rnd = '.0001', except_row = ['ND0D0Bar', 'ND+D-']) tab.column_append(tools.parse_result(bffile, 'err_frac'), 'Frac. Err', rnd = '.1', opt = '(cell%)') tab.columns_join('Fitted Value','Fitted Value','Frac. Err', str=' ') tab.column_append(attr.PDG2009_NBF, 'PDG 2009') tab.column_append_by_diff_sigma('Difference', 'Fitted Value', 'PDG 2009') tab.output(_tabname)
def fitResultsMC(opts, tabname, label): bffilename = 'bf_stat' bffile = tools.set_file(extbase=attr.brfpath, prefix='dir_' + label, comname=bffilename) if '281ipbv0' in label and '/generic' in label: generated = attr.Generic281v0_NBF power = '10E6' factor = 0.000001 elif '281ipbv12' in label and '/generic' in label: generated = attr.Generic281_NBF power = '10E7' factor = 0.0000001 elif '818ipbv12' in label and '/generic' in label: generated = attr.Generic818_NBF power = '10E7' factor = 0.0000001 else: raise NameError(label) tab = DHadTable() tab.column_append(parse_result(bffile, 'paras'), 'Parameters') tab.column_append(parse_result(bffile, 'value_err'), 'Fitted Value') tab.column_append(generated, 'Generated Value') tab.column_append_by_diff_sigma('Difference', 'Fitted Value', 'Generated Value') tab.column_trim('Fitted Value', row=['ND0D0Bar', 'ND+D-'], rnd='.001', factor=factor, opt='(cell)x%s' % power) tab.column_trim('Fitted Value', rnd='.00001', except_row=['ND0D0Bar', 'ND+D-']) tab.column_append(parse_result(bffile, 'err_frac'), 'Frac. Err', rnd='.1', opt='(cell%)') tab.columns_join('Fitted Value', 'Fitted Value', 'Frac. Err', str=' ') tab.column_trim('Generated Value', row=['ND0D0Bar', 'ND+D-'], rnd='.001', factor=factor, opt='cellx%s' % power) tab.output(tabname, label=label)
def draw_momenta_ks3pi(datatype, mode, label, test): modekey = tools.get_modekey(mode) sname = attr.modes[modekey]['sname'].lower() figname = '%s_momenta' % sname figpath = os.path.join(attr.figpath, label, 'trkmtm') epsfile = set_file(extbase=figpath, comname=figname, ext='eps') tab = DHadTable() tab.row_append(['Name', 'Data/MC']) # -------------------------------------------------- h_pks = {}; h_ppi1 = {}; h_ppi2 = {}; h_ppim = {} h_pks_c = {}; h_ppi1_c = {}; h_ppi2_c = {}; h_ppim_c = {} for datatype in datatype.split('/'): selfile = get_selfile(datatype, mode, label, test=test) selfile = selfile.replace('/trkmtm/', '/trkmtm2/') f = TFile(selfile) if datatype == 'signal' or datatype == 'generic': tp = 'mc' if datatype == 'data': tp = 'data' h_pks[tp]= f.Get('h_pks'+tp) h_ppi1[tp]= f.Get('h_ppi1'+tp) h_ppi2[tp]= f.Get('h_ppi2'+tp) h_ppim[tp]= f.Get('h_ppim'+tp) h_pks_c[tp]= f.Get('h_pk_c'+tp) h_ppi1_c[tp]= f.Get('h_ppi1_c'+tp) h_ppi2_c[tp]= f.Get('h_ppi2_c'+tp) h_ppim_c[tp]= f.Get('h_ppim_c'+tp) f.Clear() ratio = h_pks['data'].Integral()/h_pks['mc'].Integral() c1 = TCanvas('c1', 'canvas', 900, 900) c1.Divide(2,2) c1.cd(1) h_pks['data'].Draw('PE') h_pks['mc'].Scale(ratio) h_pks['mc'].Draw('SAME') c1.cd(2) h_ppi1['data'].Draw('PE') h_ppi1['mc'].Scale(ratio) h_ppi1['mc'].Draw('SAME') c1.cd(3) h_ppi2['data'].Draw('PE') h_ppi2['mc'].Scale(ratio) h_ppi2['mc'].Draw('SAME') c1.cd(4) h_ppim['data'].Draw('PE') h_ppim['mc'].Scale(ratio) h_ppim['mc'].Draw('SAME') c1.Print(epsfile) tools.eps2pdf(epsfile) # -------------------------------------------------- c1.Clear() c1.Divide(2,2) c1.cd(1) h_pks_c['data'].Draw('PE') lratio = h_pks_c['data'].Integral()/h_pks_c['mc'].Integral() #print 'k:', lratio/ratio tab.row_append(['K', lratio/ratio]) h_pks_c['mc'].Scale(lratio) h_pks_c['mc'].Draw('SAME,HIST') c1.cd(2) h_ppi1_c['data'].Draw('PE') lratio = h_ppi1_c['data'].Integral()/h_ppi1_c['mc'].Integral() #print 'pi1:', lratio/ratio tab.row_append(['pi1', lratio/ratio]) h_ppi1_c['mc'].Scale(lratio) h_ppi1_c['mc'].Draw('SAME,HIST') c1.cd(3) h_ppi2_c['data'].Draw('PE') lratio = h_ppi2_c['data'].Integral()/h_ppi2_c['mc'].Integral() #print 'pi2:', lratio/ratio tab.row_append(['pi2', lratio/ratio]) h_ppi2_c['mc'].Scale(lratio) h_ppi2_c['mc'].Draw('SAME,HIST') c1.cd(4) h_ppim_c['data'].Draw('PE') lratio = h_ppim_c['data'].Integral()/h_ppim_c['mc'].Integral() #print 'pim:', lratio/ratio tab.row_append(['pim', lratio/ratio]) h_ppim_c['mc'].Scale(lratio) h_ppim_c['mc'].Draw('SAME,HIST') tab.column_trim('Data/MC', rnd='.0001') figname = '%s_momentacor' % sname epsfile = set_file(extbase=figpath, comname=figname, ext='eps') c1.Print(epsfile) tools.eps2pdf(epsfile) tabname = '%s_syst' % sname tab.output(tabname, label=label, export_html=False)
def draw_momenta_kkpi(figpath, datatype, mode, label, test): modekey = tools.get_modekey(mode) sname = attr.modes[modekey]['sname'].lower() figname = '%s_momenta' % sname epsfile = set_file(extbase=figpath, comname=figname, ext='eps') tab = DHadTable() tab.row_append(['Name', 'Data/MC']) # -------------------------------------------------- h_pkm = {}; h_pkp = {}; h_ppi = {} h_pkm_c = {}; h_pkp_c = {}; h_ppi_c = {} for datatype in datatype.split('/'): selfile = get_selfile(datatype, mode, label, test=test) selfile = selfile.replace('/trkmtm/', '/trkmtm2/') f = TFile(selfile) if datatype == 'signal' or datatype == 'generic': tp = 'mc' if datatype == 'data': tp = 'data' h_pkm[tp]= f.Get('h_pk'+tp) h_pkp[tp]= f.Get('h_ppi1'+tp) h_ppi[tp]= f.Get('h_ppiz'+tp) h_pkm_c[tp]= f.Get('h_pk_c'+tp) h_pkp_c[tp]= f.Get('h_ppi1_c'+tp) h_ppi_c[tp]= f.Get('h_ppiz_c'+tp) f.Clear() ratio = h_pkm['data'].Integral()/h_pkm['mc'].Integral() c1 = TCanvas('c1', 'canvas', 900, 900) c1.Divide(2,2) c1.cd(1) h_pkm['data'].Draw('PE') h_pkm['mc'].Scale(ratio) h_pkm['mc'].Draw('SAME') c1.cd(2) h_pkp['data'].Draw('PE') h_pkp['mc'].Scale(ratio) h_pkp['mc'].Draw('SAME') c1.cd(3) c1.cd(4) h_ppi['data'].Draw('PE') h_ppi['mc'].Scale(ratio) h_ppi['mc'].Draw('SAME') c1.Print(epsfile) tools.eps2pdf(epsfile) # -------------------------------------------------- c1.Clear() c1.Divide(2,2) c1.cd(1) h_pkm_c['data'].Draw('PE') lratio = h_pkm_c['data'].Integral()/h_pkm_c['mc'].Integral() #print 'km:', lratio/ratio tab.row_append(['Km', lratio/ratio]) h_pkm_c['mc'].Scale(lratio) h_pkm_c['mc'].Draw('SAME') c1.cd(2) h_pkp_c['data'].Draw('PE') lratio = h_pkp_c['data'].Integral()/h_pkp_c['mc'].Integral() #print 'kp:', lratio/ratio tab.row_append(['Kp', lratio/ratio]) h_pkp_c['mc'].Scale(lratio) h_pkp_c['mc'].Draw('SAME') c1.cd(3) c1.cd(4) h_ppi_c['data'].Draw('PE') lratio = h_ppi_c['data'].Integral()/h_ppi_c['mc'].Integral() #print 'pi:', lratio/ratio tab.row_append(['pi', lratio/ratio]) h_ppi_c['mc'].Scale(lratio) h_ppi_c['mc'].Draw('SAME') tab.column_trim('Data/MC', rnd='.0001') figname = '%s_momentacor' % sname epsfile = set_file(extbase=figpath, comname=figname, ext='eps') c1.Print(epsfile) tools.eps2pdf(epsfile) tabname = '%s_syst' % sname tab.output(tabname, label=label, export_html=False)
def draw_momenta_kpipi0(datatype, mode, label, test): modekey = tools.get_modekey(mode) sname = attr.modes[modekey]['sname'].lower() figname = '%s_momenta' % sname figpath = os.path.join(attr.figpath, label, 'trkmtm') epsfile = set_file(extbase=figpath, comname=figname, ext='eps') h_mbc = {}; kpi1 = {} ; pipih = {}; kpiz = {}; kpipih = {}; h_pk = {}; h_ppi1 = {}; h_ppiz = {} h_pk_c = {}; h_ppi1_c = {}; h_ppiz_c = {} h_pk_sb = {}; h_ppi1_sb = {}; h_ppiz_sb = {} h_pk_sb_c = {}; h_ppi1_sb_c = {}; h_ppiz_sb_c = {} h_angk = {}; h_angpi1 = {}; h_angpiz = {} for datatype in datatype.split('/'): selfile = get_selfile(datatype, mode, label, test=test) selfile = selfile.replace('/trkmtm/', '/trkmtm2/') f = TFile(selfile) if datatype == 'signal' or datatype == 'generic': tp = 'mc' if datatype == 'data': tp = 'data' h_mbc[tp]= f.Get('h_mbc_'+tp) kpi1[tp]= f.Get('kpi1_'+tp) pipih[tp]= f.Get('pipih_'+tp) kpiz[tp]= f.Get('kpiz_'+tp) kpipih[tp]= f.Get('kpipih_'+tp) h_pk[tp]= f.Get('h_pk_'+tp) h_ppi1[tp]= f.Get('h_ppi1_'+tp) h_ppiz[tp]= f.Get('h_ppiz_'+tp) h_pk_c[tp]= f.Get('h_pk_c_'+tp) h_ppi1_c[tp]= f.Get('h_ppi1_c_'+tp) h_ppiz_c[tp]= f.Get('h_ppiz_c_'+tp) h_pk_sb[tp]= f.Get('h_pk_sb_'+tp) h_ppi1_sb[tp]= f.Get('h_ppi1_sb_'+tp) h_ppiz_sb[tp]= f.Get('h_ppiz_sb_'+tp) h_pk_sb_c[tp]= f.Get('h_pk_sb_c_'+tp) h_ppi1_sb_c[tp]= f.Get('h_ppi1_sb_c_'+tp) h_ppiz_sb_c[tp]= f.Get('h_ppiz_sb_c_'+tp) h_angk[tp]= f.Get('h_angk_'+tp) h_angpi1[tp]= f.Get('h_angpi1_'+tp) h_angpiz[tp]= f.Get('h_angpiz_'+tp) f.Clear() ratio = h_pk['data'].Integral()/h_pk['mc'].Integral() c1 = TCanvas('c1', 'canvas', 900, 900) c1.Divide(2,2) c1.cd(1) h_pk['data'].Draw('PE') h_pk['mc'].Scale(ratio) h_pk['mc'].Draw('SAME') c1.cd(2) h_ppi1['data'].Draw('PE') h_ppi1['mc'].Scale(ratio) h_ppi1['mc'].Draw('SAME') c1.cd(3) c1.cd(4) h_ppiz['data'].Draw('PE') h_ppiz['mc'].Scale(ratio) h_ppiz['mc'].Draw('SAME') c1.Print(epsfile) tools.eps2pdf(epsfile) tab = DHadTable() tab.row_append(['Name', 'Data/MC']) c1.Clear() c1.Divide(2,2) c1.cd(1) h_pk_c['data'].Draw('PE') lratio = h_pk_c['data'].Integral()/h_pk_c['mc'].Integral() #print 'k:', lratio/ratio tab.row_append(['K', lratio/ratio]) h_pk_c['mc'].Scale(lratio) h_pk_c['mc'].Draw('SAME') c1.cd(2) h_ppi1_c['data'].Draw('PE') lratio = h_ppi1_c['data'].Integral()/h_ppi1_c['mc'].Integral() #print 'pi1:', lratio/ratio tab.row_append(['pi1', lratio/ratio]) h_ppi1_c['mc'].Scale(lratio) h_ppi1_c['mc'].Draw('SAME') c1.cd(3) c1.cd(4) h_ppiz_c['data'].Draw('PE') lratio = h_ppiz_c['data'].Integral()/h_ppiz_c['mc'].Integral() #print 'piz:', lratio/ratio tab.row_append(['piz', lratio/ratio]) h_ppiz_c['mc'].Scale(lratio) h_ppiz_c['mc'].Draw('SAME') tab.column_trim('Data/MC', rnd='.0001') figname = '%s_momentacor' % sname epsfile = set_file(extbase=figpath, comname=figname, ext='eps') c1.Print(epsfile) tools.eps2pdf(epsfile) tabname = '%s_syst' % sname tab.output(tabname, label=label, export_html=False)