示例#1
0
文件: divide.py 项目: xshi/dhad
def divide_yields(args):

    if args[0] not in ['signal', 'data'] :
	raise NameError(args)

    variable = 'yields'
    rnd='.01'

    dt_type = args[0]
    tag = args[1]

    tab_A =  args[2]
    tab_B =  args[3]

    label_A, fitbase_A, prefix_A = tools.parse_tabname(_opts, tab_A) 
    label_B, fitbase_B, prefix_B = tools.parse_tabname(_opts, tab_B) 

    sys.stdout.write('dhad.tab : Divide %s of %s by %s:' %(
        variable, tab_A, tab_B))
    
    tab = DHadTable()
    namestyle = 'fname,fnamebar'
    tab.column_append_from_dict('Mode', namestyle)     

    tab.column_append_from_files(label_A, 'N1,N2', fitbase_A, prefix_A,
                                 dt_type, tag ,'txt', rnd='1.')
    tab.column_append_from_files(label_B, 'N1,N2', fitbase_B, prefix_B,
                                 dt_type, tag ,'txt', rnd='1.')
    tab.column_append_by_divide('%s/%s' %(label_A, label_B), label_A,
                                label_B, rnd=rnd, err_type='Indp')
    tab.output(_tabname)
示例#2
0
文件: parse.py 项目: zhixing1996/dhad
def events(args):
    parsed = yld.parse_args(args)
    datatype = parsed[0]
    tag = parsed[1]
    modes = parsed[2]
    label = parsed[3]

    unique_evt_label = label
    if _set and 'events' in _set:
        unique_evt_label = _set.split('=')[1]

    tab = DHadTable()

    row = ['Mode']
    row.extend(attr.datasets_281)
    tab.row_append(row)

    for mode in modes:
        modename = mode.replace('Single_', '')
        evtfile = get_unique_evtfile(datatype,
                                     mode,
                                     unique_evt_label,
                                     debug=_debug)
        f = EventsFile(evtfile)
        row = map(str, f.datasets_sorted)
        row.insert(0, modename)
        tab.row_append(row)

    tab.output(_tabname)
示例#3
0
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)
示例#4
0
def para_argus(para, args):
    namestyle = 'fname'
    rnd = '0.01'
    tag = 's'

    rowName = para
    extbase = attr.fitbase
    ext = 'txt'

    dt_type = args[0]
    tab_A = args[1]
    tab_B = args[2]

    label_A = tab_A
    label_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_files(label_A, rowName, extbase, 'dir_'+tab_A, 
                                 dt_type, tag, ext, rnd=rnd)
    tab.column_append_from_files(label_B, rowName, extbase, 'dir_'+tab_B, 
                                 dt_type, tag, ext, rnd=rnd)
    tab.column_append_by_diff_pct('diff(%)', label_B, label_A, rnd=rnd)
    tab.output(_tabname)
示例#5
0
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)
示例#6
0
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)
示例#7
0
def vary_argus_single(opts, tabname, label):
    tab = DHadTable()

    print tabname

    tabprefix0 = 'dir_818ipbv7/argus_low/fix_n1n2'
    tabprefix1 = 'dir_818ipbv7'
    tabprefix2 = 'dir_818ipbv7/argus_high/fix_n1n2'

    tab.column_append_from_dict('Mode', 'fname,fnamebar')
    titles = ['argus_low', 'std', 'argus_high']
    tab.column_append_from_files(titles[0], 'N1,N2', fitbase, tabprefix0, 'd',
                                 's', 'txt')
    tab.column_append_from_files(titles[1], 'N1,N2', fitbase, tabprefix1, 'd',
                                 's', 'txt')
    tab.column_append_from_files(titles[2], 'N1,N2', fitbase, tabprefix2, 'd',
                                 's', 'txt')

    std = titles[1]
    colA = titles[0]
    colB = titles[2]
    headA = 'diff(%s)' % colA
    headB = 'diff(%s)' % colB
    headC = 'max-diff(%)'
    tab.column_append_by_diff_pct(headA, colA, std)
    tab.column_append_by_diff_pct(headB, colB, std)
    tab.column_append_by_max(headC, headA, headB)
    #tab.columns_delete([headA, headB])
    tab.columns_trim(titles, rnd='1.')

    tab.output()  #tabname, texhead, outputtxt=True)
示例#8
0
def momentum(opts, tabname, args):
    if args[0] != 'resolution': 
        raise NameError(args)

    label = args[1] 
    dt_type = 'signal'
    tag = 'double'
    #ver = opts.analysis
    fitbase = attr.fitpath

    prefix = 'dir_%s/resolution' % label

    # Mode | sigma(MeV) | fa | fb | sa | sb | [sigmaE (MeV)]
    tab = DHadTable()
    tab.column_append_from_dict('Mode', 'fname')     
    tab.column_append_from_files(
        'sigma (MeV)', 'sigmacommon1', fitbase, prefix, 
        dt_type, tag,  'txt', rnd='.01', factor=1000)

    tab.column_append_from_files('fa', 'f1a',  fitbase, prefix, 
                                 dt_type, tag,  'txt', rnd='.001')
    tab.column_append_from_files('fb', 'f1b', fitbase, prefix, 
                                 dt_type, tag,  'txt', rnd='.0001')
    tab.column_append_from_files('sa', 's1a',  fitbase, prefix, 
                                 dt_type, tag,  'txt', rnd='.01')
    tab.column_append_from_files('sb', 's1b',  fitbase, prefix, 
                                 dt_type, tag,  'txt', rnd='.01')


    tab.output(tabname, test=opts.test)
示例#9
0
def md(opts, tabname, args):
    para = 'md'
    namestyle = 'fname'
    rnd = '0.0000001'
    tag = 's'
    
    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 args[0] == '281ipb':
        tab_A_name = args[1]
        tab_B_name = args[2]
        tab_C_name = args[3]

        if label:
            labels = label.split(',')
            tab_A_name = labels[0]
            tab_B_name = labels[1]
            tab_C_name = labels[2]
            
        tab = DHadTable()
        tab.column_append_from_dict('Mode', namestyle)
        tab.column_append_from_fit_files(tab_A_name, args[1], para, tag, rnd)
        tab.column_append_from_fit_files(tab_B_name, args[2], para, tag, rnd)
        tab.column_append_from_fit_files(tab_C_name, args[3], para, tag, rnd)

        tab.output(_tabname)
    else:
        raise ValueError(args)
示例#10
0
文件: parse.py 项目: xshi/dhad
def events(args):
    parsed = yld.parse_args(args)
    datatype = parsed[0]
    tag = parsed[1]
    modes = parsed[2]
    label = parsed[3]

    unique_evt_label = label 
    if _set and 'events' in _set:
        unique_evt_label = _set.split('=')[1]

    tab = DHadTable()

    row = ['Mode']
    row.extend(attr.datasets_281)
    tab.row_append(row)

    for mode in modes:
        modename = mode.replace('Single_', '')
        evtfile = get_unique_evtfile(
            datatype, mode, unique_evt_label, debug=_debug)
        f = EventsFile(evtfile)
        row = map(str, f.datasets_sorted)
        row.insert(0, modename)
        tab.row_append(row)

    tab.output(_tabname)
示例#11
0
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)
示例#12
0
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)
示例#13
0
文件: backgrounds.py 项目: xshi/dhad
def make_overview_table(tabname, datatype, modes, label, test=False):
    tab = DHadTable()
    tab.row_append(['Mode', 'Backgrounds'])
    for mode in modes:
        modename = mode.replace('Single_', '')
        bkgtable = get_bkg_tab_link(datatype, mode, label)
        line = [modename, bkgtable]
        tab.row_append(line)
    tab.output(tabname, test=test)
示例#14
0
def bkg_generic_cont(tabname, datatype, tag, modes, label, test, debug):
    tab = DHadTable()
    row = ['Mode', 'Continuum Backgrounds']
    tab.row_append(row)
    for mode in modes:
        new_row = bkg_cont_single_mode(datatype, mode, label, debug)
        tab.row_append(new_row)

    tab.output(tabname, test=test)
示例#15
0
def make_overview_table(tabname, datatype, modes, label, test=False):
    tab = DHadTable()
    tab.row_append(['Mode', 'Backgrounds'])
    for mode in modes:
        modename = mode.replace('Single_', '')
        bkgtable = get_bkg_tab_link(datatype, mode, label)
        line = [modename, bkgtable]
        tab.row_append(line)
    tab.output(tabname, test=test)
示例#16
0
def evt(opts, args):
    tabname = 'entries_evt_' + '_'.join(args).replace('/', '_')

    if args[0] == 'log':
        return evt_log(args[1:])

    if args[0] not in ['data']:
        raise NameError(args)

    dt_type = args[0]
    tag = args[1]
    label = args[2]

    evtpath = attr.evtpath()
    if '/' in label:
        ver = label.split('/')[0]
        label = label.split('/')[1]
        evtpath = attr.evtpath(ver)

    prefix = 'dir_' + label

    tab = DHadTable()
    tab.row_append(['Mode', 'fname', 'fnamebar', 'combined', 'sum(theory)'])

    for mode in attr.modes:
        evtfile1 = tools.set_file('evt',
                                  dt_type,
                                  mode,
                                  tag,
                                  sign=-1,
                                  prefix=prefix,
                                  extbase=evtpath)
        evtfile2 = tools.set_file('evt',
                                  dt_type,
                                  mode,
                                  tag,
                                  sign=1,
                                  prefix=prefix,
                                  extbase=evtpath)
        evtfile_combined = tools.set_file('evt',
                                          dt_type,
                                          mode,
                                          tag,
                                          prefix=prefix,
                                          extbase=evtpath)
        entries1 = tools.count_lines(evtfile1)
        entries2 = tools.count_lines(evtfile2)

        sumup = entries1 + entries2

        entries_combined = tools.count_lines(evtfile_combined)
        row = [mode, entries1, entries2, entries_combined, sumup]

        tab.row_append(map(str, row))

    tab.output(tabname)
示例#17
0
文件: backgrounds.py 项目: xshi/dhad
def bkg_generic_cont(tabname, datatype, tag, modes,
                     label, test, debug):
    tab = DHadTable()
    row = ['Mode', 'Continuum Backgrounds']
    tab.row_append(row)
    for mode in modes:
        new_row = bkg_cont_single_mode(datatype, mode, label, debug)
        tab.row_append(new_row)

    tab.output(tabname, test=test)
示例#18
0
def yields(opts, tabname, args):
    if args[0] not in ['signal', 'data'] :
	raise NameError(args)

    rnd='.01'
    err_type=None
    diff = 'pct'
    sign = 1 
    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 == 'diff':
                diff = value
            if name == 'err_type':
                err_type = value
            if name == 'sign':
                sign = value

    variable = 'yields'
    dt_type = args[0]
    tag = args[1]
    label_A = args[2]
    label_B = args[3]
    fitbase = attr.fitbase

    sys.stdout.write('dhad.tab : Compare %s between %s and %s:\n' %(
        variable, label_A, label_B ))

    tab = DHadTable()
    namestyle = 'fname,fnamebar'
    tab.column_append_from_dict('Mode', namestyle)     
    tab.column_append_from_files(label_A, 'N1,N2', fitbase, 'dir_%s' %label_A,
                                 dt_type, tag ,'txt', rnd='1.')
    tab.column_append_from_files(label_B, 'N1,N2', fitbase, 'dir_%s' %label_B,
                                 dt_type, tag ,'txt', rnd='1.')

    if sign == '0':
        tab.rows_join_by_average(rnd='1.')

    if diff == 'pct':
        tab.column_append_by_diff_pct(
            'diff(%)', label_B,label_A, rnd=rnd, err_type=err_type)
    elif diff == 'sigma_pct':
        tab.column_append_by_diff_sigma_pct('diff(%)', label_B,label_A, rnd=rnd)
    elif diff == 'sigma2_pct':
        tab.column_append_by_diff_sigma2_pct('diff(%)', label_B,label_A, rnd=rnd)
    elif diff == 'ratio':
        tab.column_append_by_divide(
            'ratio', label_B,label_A, rnd=rnd, err_type='Indp')
    else:
        raise NameError(diff)

    tab.output(tabname, test=opts.test)
示例#19
0
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)
示例#20
0
def bkg_generic_ddbar(tabname, datatype, tag, modes, label, test, debug):
    ranges = ['>0', '>50', '>100', '>200', '>500', '>1000', '>2000', '>3000']

    tab = DHadTable()
    row = ['Mode', 'Backgrounds']
    row.extend(ranges)
    tab.row_append(row)

    for mode in modes:
        new_row = bkg_ddbar_single_mode(datatype, mode, label, ranges, debug)
        tab.row_append(new_row)

    tab.output(tabname, test=test)
示例#21
0
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)
示例#22
0
def eff_kkpi_comp(opts, tabname, label):
    tab = DHadTable()
    tabprefix = 'dir_' + label
    mode = 205

    tab.column_append_from_dict('Mode', 'fname,fnamebar', mode=mode)
    tab.column_append([20000, 20000], 'Generated')
    tab.column_append_from_files('Yield',
                                 'N1,N2',
                                 fitbase,
                                 tabprefix,
                                 's',
                                 's',
                                 'txt',
                                 rnd='1.',
                                 mode=mode)
    tab.column_append_by_divide('Eff(%)', 'Yield', 'Generated', 'Efcy', '.01',
                                100)
    tab.columns_delete(['Generated', 'Yield'])

    def get_eff(subdir):
        logname = 'signal_Single_%s.txt' % modes[mode]['fname']
        logpath = os.path.join(attr.logpath, label, subdir, 'yld')
        logfile = tools.set_file(extbase=logpath, comname=logname)
        for line in file(logfile):
            if 'selected' in line:
                total = int(line.split()[-1].replace('.', ''))
                break
        t = DHadTable()
        t.column_append([total, total], 'Generated')
        t.column_append_from_files('Yield',
                                   'N1,N2',
                                   fitbase,
                                   '%s/%s' % (tabprefix, subdir),
                                   's',
                                   's',
                                   'txt',
                                   rnd='1.',
                                   mode=mode)
        t.column_append_by_divide('%s(%%)' % subdir, 'Yield', 'Generated',
                                  'Efcy', '.01', 100)
        return t.column_get('%s(%%)' % subdir)

    for subdir in ['phipi', 'k0star', 'phsp']:
        tab.column_append(get_eff(subdir))
        #head_diff =  subdir
        #col = '%s(%%)' % subdir
        #std = 'Eff(%)'
        #tab.column_append_by_diff_pct(head_diff, col, std)

    tab.output(tabname, label=label)
示例#23
0
文件: backgrounds.py 项目: xshi/dhad
def bkg_names(opts, args):
    debug_ = opts.debug
    test_ = opts.test
    set_ = opts.set

    prefix = None
    if args[0] == 'peak':
        prefix = 'peak'
        args = args[1:]
    
    parsed = yld.parse_args(args)
    datatype  = parsed[0]
    tag       = parsed[1]
    modes     = parsed[2]
    label     = parsed[3]

    limit = None
    if set_ != None and 'min' in set_:
        min_ = set_.split('=')[1]
        limit = '>%s' %min_

    bkgmodes = 20
    if set_ != None and 'bkgmodes' in set_:
        bkgmodes = int(set_.split('=')[1])

    for mode in modes:
        tabname = 'bkg_names_%s_%s_%s'  %(
            datatype, mode, label)
        if prefix != None:
            tabname = 'bkg_names_%s_%s_%s_%s' %(
                prefix, datatype, mode, label)
        tabname = tabname.replace('/', '_')

        tab = DHadTable()
        modename = get_orgname_from_fname(mode)
        bkg_names, bkg_numbers = bkg_names_single_mode(
            datatype, mode, label, limit, bkgmodes, debug_, prefix)
        tab.column_append(bkg_names, title='Backgrounds for %s' %modename)
        tab.column_append(bkg_numbers, title='Number of Events')
        tab.sort_by_column('Number of Events', reverse=True)

        orgfooter = ': '+sys.argv[0].split('/')[-1]+\
                    ' tab backgrounds names %s %s %s ' %(
            datatype, mode, label)
        if prefix != None:
            orgfooter = ': '+sys.argv[0].split('/')[-1]+\
                        ' tab backgrounds names %s %s %s %s ' %(
                prefix, datatype, mode, label)
        
        tab.output(tabname, orgfooter=orgfooter, test=test_)
示例#24
0
文件: backgrounds.py 项目: xshi/dhad
def bkg_generic_ddbar(tabname, datatype, tag, modes, label, test, debug):
    ranges = ['>0', '>50', '>100', '>200', '>500',
                  '>1000', '>2000', '>3000']

    tab = DHadTable()
    row = ['Mode', 'Backgrounds']
    row.extend(ranges)
    tab.row_append(row)

    for mode in modes:
        new_row = bkg_ddbar_single_mode(datatype, mode, label, ranges, debug)
        tab.row_append(new_row)

    tab.output(tabname, test=test)
示例#25
0
def mctruth_names(opts, args):
    debug_ = opts.debug
    test_ = opts.test
    set_ = opts.set

    prefix = None
    if args[0] == 'peak':
        prefix = 'peak'
        args = args[1:]

    parsed = yld.parse_args(args)
    datatype = parsed[0]
    tag = parsed[1]
    modes = parsed[2]
    label = parsed[3]

    limit = None
    if set_ != None and 'min' in set_:
        min_ = set_.split('=')[1]
        limit = '>%s' % min_

    mctruthmodes = 50
    if set_ != None and 'mctruthmodes' in set_:
        mctruthmodes = int(set_.split('=')[1])

    for mode in modes:
        tabname = 'mctruth_names_%s_%s_%s' % (datatype, mode, label)
        if prefix != None:
            tabname = 'mctruth_names_%s_%s_%s_%s' % (prefix, datatype, mode,
                                                     label)
        tabname = tabname.replace('/', '_')

        tab = DHadTable()
        modename = get_orgname_from_fname(mode)
        mctruth_names, mctruth_numbers = mctruth_names_single_mode(
            datatype, mode, label, limit, mctruthmodes, debug_, prefix)

        tab.column_append(mctruth_names, title='MC Truth for %s' % modename)
        tab.column_append(mctruth_numbers, title='Number of Events')
        tab.sort_by_column('Number of Events', reverse=True)

        orgfooter = ': '+sys.argv[0].split('/')[-1]+\
                    ' tab mctruth names %s %s %s ' %(
            datatype, mode, label)
        if prefix != None:
            orgfooter = ': '+sys.argv[0].split('/')[-1]+\
                        ' tab mctruth names %s %s %s %s ' %(
                prefix, datatype, mode, label)

        tab.output(tabname, orgfooter=orgfooter, test=test_)
示例#26
0
def compare_yields_data_signal_divide_537ipb(args):
    
    sys.stdout.write('dhad.table: Creating %s ...\n' % _tabname)
    tabpath1 = os.path.join(
        attr.base, '7.06', 'tab')
    tabfile1 = os.path.join(
        tabpath1, 'compare_yields_data_divide_281ipb_537ipb.txt')
    tabfile2 = os.path.join(
        attr.tabpath, 'compare_yields_signal_divide_537ipb_9.03_regular12.txt')
    
    tab  = DHadTable()
    tab.column_append_from_tab_file('Mode', tabfile1, 'Mode')
    tab.column_append_from_tab_file('Data', tabfile1, '537ipb/281ipb')
    tab.column_append_from_tab_file('Signal', tabfile2, '537ipb/281ipb')
    tab.column_append_by_diff_sigma_pct('diff(%)', 'Signal', 'Data')
    tab.output(_tabname)
示例#27
0
def divide_yields(args):

    if args[0] not in ['signal', 'data']:
        raise NameError(args)

    variable = 'yields'
    rnd = '.01'

    dt_type = args[0]
    tag = args[1]

    tab_A = args[2]
    tab_B = args[3]

    label_A, fitbase_A, prefix_A = tools.parse_tabname(_opts, tab_A)
    label_B, fitbase_B, prefix_B = tools.parse_tabname(_opts, tab_B)

    sys.stdout.write('dhad.tab : Divide %s of %s by %s:' %
                     (variable, tab_A, tab_B))

    tab = DHadTable()
    namestyle = 'fname,fnamebar'
    tab.column_append_from_dict('Mode', namestyle)

    tab.column_append_from_files(label_A,
                                 'N1,N2',
                                 fitbase_A,
                                 prefix_A,
                                 dt_type,
                                 tag,
                                 'txt',
                                 rnd='1.')
    tab.column_append_from_files(label_B,
                                 'N1,N2',
                                 fitbase_B,
                                 prefix_B,
                                 dt_type,
                                 tag,
                                 'txt',
                                 rnd='1.')
    tab.column_append_by_divide('%s/%s' % (label_A, label_B),
                                label_A,
                                label_B,
                                rnd=rnd,
                                err_type='Indp')
    tab.output(_tabname)
示例#28
0
文件: entries.py 项目: xshi/dhad
def evt(opts, args):
    tabname = 'entries_evt_' + '_'.join(args).replace('/', '_')

    if args[0] == 'log':
        return evt_log(args[1:])
    
    if args[0] not in ['data'] :
	raise NameError(args)

    dt_type = args[0]
    tag = args[1]
    label = args[2]

    evtpath = attr.evtpath()
    if '/' in label:
        ver = label.split('/')[0]
        label = label.split('/')[1]
        evtpath = attr.evtpath(ver)
        
    prefix = 'dir_' + label

    tab = DHadTable()
    tab.row_append(['Mode', 'fname', 'fnamebar', 'combined', 'sum(theory)'])

    for mode in attr.modes:
        evtfile1 = tools.set_file('evt', dt_type, mode, tag, sign=-1,
                                  prefix=prefix, extbase=evtpath)
        evtfile2 = tools.set_file('evt', dt_type, mode, tag, sign=1,
                                  prefix=prefix, extbase=evtpath)
        evtfile_combined = tools.set_file('evt', dt_type, mode, tag,
                                          prefix=prefix, extbase=evtpath)
        entries1 = tools.count_lines(evtfile1)
        entries2 = tools.count_lines(evtfile2)

        sumup = entries1 + entries2
        
        entries_combined = tools.count_lines(evtfile_combined)
        row = [mode, entries1, entries2, entries_combined, sumup]
        
        tab.row_append(map(str, row))

    tab.output(tabname)
示例#29
0
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)
示例#30
0
def argus(opts, tabname, args):
    if args[0] == 'slope':
        rowname_A = 'xi'
        rowname_B = 'xi'
        rowname_C = 'xi'

    if args[0] == 'power':
        rowname_A = 'p'
        rowname_B = 'p'
        rowname_C = 'p'
    
    label = args[1]
    
    if args[2] != 'desidebands':
        raise NameError(args)

    namestyle = 'fname'
    rnd = '0.01'
    tag = 's'
    extbase = attr.fitbase
    ext = 'txt'
    dt_type = 'data'

    label_A = label
    prefix_A = 'dir_%s' % label_A

    label_B = 'desideband_low'
    prefix_B = 'dir_%s/%s' % (label, label_B)

    label_C = 'desideband_high'
    prefix_C = 'dir_%s/%s' % (label, label_C)

    tab = DHadTable()
    tab.column_append_from_dict('Mode', namestyle)
    tab.column_append_from_files(label_A, rowname_A, extbase, prefix_A,
                                 dt_type, tag, ext, rnd=rnd)
    tab.column_append_from_files(label_B, rowname_B, extbase, prefix_B,
                                 dt_type, tag, ext, rnd=rnd)
    tab.column_append_from_files(label_C, rowname_C, extbase, prefix_C,
                                 dt_type, tag, ext, rnd=rnd)
    tab.output(tabname)
示例#31
0
文件: diff.py 项目: zhixing1996/dhad
def brf_data_syst(args):
    print args

    label_A = args[0]
    label_B = args[1]

    bffilename = 'bf_stat_sys'
    tab = DHadTable()

    bffileA = os.path.join(attr.brfpath, label_A, bffilename)
    tab.column_append(tools.parse_result(bffileA, 'paras'), 'Parameters')
    tab.column_append(tools.parse_result(bffileA, 'value'), 'value_A')
    tab.column_append(tools.parse_result(bffileA, 'syst'), label_A)

    bffileB = os.path.join(attr.brfpath, label_B, bffilename)
    tab.column_append(tools.parse_result(bffileB, 'value'), 'value_B')
    tab.column_append(tools.parse_result(bffileB, 'syst'), label_B)

    #tab.column_append_by_diff_sigma_pct('diff(%)', label_B,label_A, rnd=rnd)

    tab.output()
示例#32
0
def evtfile(args):

    if args[0] not in ['signal', 'data'] :
	raise NameError(args)

    variable = 'yields'
    dt_type = args[0]
    tag = args[1]
    
    evt_A =  args[2]
    evt_B =  args[3]

    label_A, evtbase_A, prefix_A = tools.parse_evtname(opts, evt_A) 
    label_B, evtbase_B, prefix_B = tools.parse_evtname(opts, evt_B) 

    filelist_A = tools.set_file_list(evtbase_A, prefix_A, dt_type, tag, 'evt')
    filelist_B = tools.set_file_list(evtbase_B, prefix_B, dt_type, tag, 'evt')
    zipped = zip(filelist_A, filelist_B)

    for f in zipped:
        fa = f[0]
        fb = f[1]

        diff = tools.diff(fa, fb)
        print diff
    sys.exit()

    sys.stdout.write('dhad.tab : Compare %s between %s and %s:' %(
        variable, tab_A, tab_B ))
    
    tab = DHadTable()
    namestyle = 'fname,fnamebar'
    tab.column_append_from_dict('Mode', namestyle)     
    tab.column_append_from_files(label_A, 'N1,N2', fitbase_A, prefix_A,
                                 dt_type, tag ,'txt', rnd='1.')
    tab.column_append_from_files(label_B, 'N1,N2', fitbase_B, prefix_B,
                                 dt_type, tag ,'txt', rnd='1.')
    tab.column_append_by_diff_sigma_pct('diff(%)', label_B,label_A, rnd=rnd)
    
    tab.output(_tabname)
示例#33
0
文件: backgrounds.py 项目: xshi/dhad
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)
示例#34
0
文件: diff.py 项目: xshi/dhad
def brf_data_syst(args):
    print args
    
    label_A = args[0]
    label_B = args[1]
   
    bffilename = 'bf_stat_sys'
    tab = DHadTable()


    bffileA = os.path.join(attr.brfpath, label_A, bffilename)
    tab.column_append(tools.parse_result(bffileA, 'paras'), 'Parameters')   
    tab.column_append(tools.parse_result(bffileA, 'value'), 'value_A')
    tab.column_append(tools.parse_result(bffileA, 'syst'), label_A)

    bffileB = os.path.join(attr.brfpath, label_B, bffilename)
    tab.column_append(tools.parse_result(bffileB, 'value'), 'value_B')
    tab.column_append(tools.parse_result(bffileB, 'syst'), label_B)

    #tab.column_append_by_diff_sigma_pct('diff(%)', label_B,label_A, rnd=rnd)
    
    tab.output()
示例#35
0
文件: entries.py 项目: xshi/dhad
def evt_log(args):
    print args
    if args[0] not in ['data'] :
	raise NameError(args)

    dt_type = args[0]
    tag = args[1]
    label = args[2]

    evtpath = attr.evtpath()
    if '/' in label:
        ver = label.split('/')[0]
        label = label.split('/')[1]
        evtpath = attr.evtpath(ver)
        
    prefix = 'dir_' + label
    evttab = 'entries_evt' + '_'.join(args).replace('/', '_') + '.tab'

    tab = DHadTable()
    tab.column_append_from_tab_file('Mode', evttab)
    tab.output()
    sys.exit()
示例#36
0
def evt_log(args):
    print args
    if args[0] not in ['data']:
        raise NameError(args)

    dt_type = args[0]
    tag = args[1]
    label = args[2]

    evtpath = attr.evtpath()
    if '/' in label:
        ver = label.split('/')[0]
        label = label.split('/')[1]
        evtpath = attr.evtpath(ver)

    prefix = 'dir_' + label
    evttab = 'entries_evt' + '_'.join(args).replace('/', '_') + '.tab'

    tab = DHadTable()
    tab.column_append_from_tab_file('Mode', evttab)
    tab.output()
    sys.exit()
示例#37
0
def fsr_syst(args):
    '''
    --------------------
       FSR systematics
    --------------------
    '''
    tab_name = 'FSR_syst'

    tabbase = os.path.join(attr.base, '7.06', 'tab')
    
    tab = DHadTable()
    tab.column_append_from_dict('Mode', 'fname,fnamebar')
    tab_file = os.path.join(tabbase, 'noFSR_single_signal_eff.txt')
    columnA    = 'Efficiency without FSR(%)'
    tab.column_append_from_tab_file(columnA, tab_file)
    columnB     = 'Efficiency with FSR(%)'
    tab.column_append_from_tab_file(columnB, tab_file)
    tab.column_append_by_diff('diff(%)', columnA, columnB, factor=100)
    tab.column_append_by_times_number('diff X 30%', 'diff(%)', '0.3',
                                      rnd='.01')
    tab.rows_join_by_max('diff X 30%')
    tab.output(tab_name)
示例#38
0
文件: parse.py 项目: xshi/dhad
def runs(args):
    parsed = yld.parse_args(args)
    datatype = parsed[0]
    tag = parsed[1]
    modes = parsed[2]
    label = parsed[3]

    unique_evt_label = label 

    datatype = 'data'
    run_event_set = Set([])
    for mode in attr.single_mode_list:
        evtname = '%s_%s_unqiue_%s.evt' %(datatype, mode, label)
        evtpath = os.path.join(attr.datpath, 'evt', label, 'events')
        unique_file = os.path.join(evtpath, evtname)
        f = UserFile(unique_file)
        events = Set(f.data)
        run_event_set.update(events)


    fe = EventsFile()
    fe.data = list(run_event_set)
    fe.parse()

    tab = DHadTable()
    row = ['Dataset', 'Run', 'Number of Events']
    tab.row_append(row)
    for run, num in sorted(fe.runs.iteritems()):
        dataset = get_dataset_by_run(run)
        row = [dataset, run, num]
        tab.row_append(map(str, row))

    if _test:
        tab.output()
        sys.stdout.write('\ntest: Will write to %s\n' %_tabname)
    else:
        tab.output(_tabname)
示例#39
0
def signal_line_shape_syst(args):
    '''
    --------------------------------------------------
       Signal line shape systematics
    --------------------------------------------------
    '''
    tab_name = 'signal_line_shape_syst'

    tabbase = os.path.join(attr.base, '7.06', 'tab')
    
    tab = DHadTable()
    tab.column_append_from_dict('Mode', 'fname,fnamebar')
    tab_file_A = os.path.join(
        tabbase, 'yields_M_3.7713_regular_M_3.7723_data_Single.txt')

    name_A  = 'Mass(+/-0.5 MeV)%'
    column = 'max-diff(%)'
    tab.column_append_from_tab_file(name_A, tab_file_A, column)

    tab_file_B = os.path.join(
        tabbase, 'yields_Gamma_0.0261_regular_Gamma_0.0311_data_Single.txt')
    name_B  = 'Gamma(+/-2.5 MeV)%'
    tab.column_append_from_tab_file(name_B, tab_file_B, column)


    tab_file_C = os.path.join(
        tabbase, 'yields_R_8.3_regular_R_16.3_data_Single.txt')
    name_C  = 'R(+/- 4)%'
    tab.column_append_from_tab_file(name_C, tab_file_C, column)

    name_D = 'Total(%)'
    tab.column_append_by_add_quadrature3(name_D, name_A,
                                        name_B, name_C, rnd='.01')

    tab.rows_join_by_max(name_D)
    
    tab.output(tab_name)
示例#40
0
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)
示例#41
0
文件: parse.py 项目: zhixing1996/dhad
def runs(args):
    parsed = yld.parse_args(args)
    datatype = parsed[0]
    tag = parsed[1]
    modes = parsed[2]
    label = parsed[3]

    unique_evt_label = label

    datatype = 'data'
    run_event_set = Set([])
    for mode in attr.single_mode_list:
        evtname = '%s_%s_unqiue_%s.evt' % (datatype, mode, label)
        evtpath = os.path.join(attr.datpath, 'evt', label, 'events')
        unique_file = os.path.join(evtpath, evtname)
        f = UserFile(unique_file)
        events = Set(f.data)
        run_event_set.update(events)

    fe = EventsFile()
    fe.data = list(run_event_set)
    fe.parse()

    tab = DHadTable()
    row = ['Dataset', 'Run', 'Number of Events']
    tab.row_append(row)
    for run, num in sorted(fe.runs.iteritems()):
        dataset = get_dataset_by_run(run)
        row = [dataset, run, num]
        tab.row_append(map(str, row))

    if _test:
        tab.output()
        sys.stdout.write('\ntest: Will write to %s\n' % _tabname)
    else:
        tab.output(_tabname)
示例#42
0
文件: trkmtm1.py 项目: xshi/dhad
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)