Exemple #1
0
def fitResultsData(opts, tabname, label):
    bffilename = 'bf_stat_sys'
    bffile = tools.set_file(extbase=attr.brfpath,
                            prefix='dir_' + label,
                            comname=bffilename)
    tab = PRDTable()
    tab.column_append(parse_result(bffile, 'paras'), 'Parameters')
    tab.column_append(parse_result(bffile, 'value'), 'value')
    tab.column_append(parse_result(bffile, 'stat'), 'stat')
    tab.column_append(parse_result(bffile, 'syst'), 'syst')
    tab.column_append_by_divide('Stat.(%)',
                                'stat',
                                'value',
                                rnd='.1',
                                factor=100)
    tab.column_append_by_divide('Syst.(%)',
                                'syst',
                                'value',
                                rnd='.1',
                                factor=100)
    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='.001',
                    factor=100,
                    except_row=['ND0D0Bar', 'ND+D-'],
                    opt='(cell)%')
    texhead = r'''Parameter & Fitted value & \multicolumn{2}{c}{Fractional error}\\[-0.6ex] & & Stat.(\%) & Syst.(\%)'''
    tab.output(tabname, texhead, trans_dict=attr.NBF_dict)
Exemple #2
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)
Exemple #3
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)
Exemple #4
0
def fitResultsRatiosData(opts, tabname, label):
    bffilename = 'bf_stat_sys'
    bffile = tools.set_file(
        extbase=attr.brfpath, prefix='dir_'+label, comname=bffilename)
    tab = THSTable()
    tab.column_append(parse_result(bffile, 'para_bf_ratio'),
                      'Parameters')
    tab.column_append(parse_result(bffile, 'value_bf_ratio'), 'value')
    tab.column_append(parse_result(bffile, 'stat_bf_ratio'), 'stat')
    tab.column_append(parse_result(bffile, 'syst_bf_ratio'), 'syst')
    tab.column_append_by_divide('Stat.(%)', 'stat', 'value',
                                rnd='.1', factor=100)
    tab.column_append_by_divide('Syst.(%)', 'syst', 'value',
                                rnd='.1', factor=100)
    tab.columns_join3('Fitted value','value','stat','syst', rnd='.001')
    texhead = r'''Parameter & Fitted value & \multicolumn{2}{c}{Fractional error}\\[-0.6ex] & & Stat.(\%) & Syst.(\%)'''
    tab.output(tabname, texhead, trans_dict=attr.BF_Ratio_dict)
Exemple #5
0
def yieldDTResidualsDataDp(opts, tabname, label):
    bffilename = 'bf_stat_sys'
    bffile = tools.set_file(
        extbase=attr.brfpath, prefix='dir_'+label, comname=bffilename)
    tab = THSTable()
    tab.column_append_from_dict('Mode', 'fname,fnamebar', 'double-dp')
    tab.column_append(parse_result(bffile, 'residual_double_dp'),
                      'Residual', rnd = '1.')
    tab.output(tabname, trans_dict=attr.BF_Ratio_dict)
Exemple #6
0
Fichier : sld.py Projet : xshi/dhad
def brf_data_results(opts, tabname, args):
    label_A = args[0]
    label_B = args[1]
    tabbase = os.path.join(attr.base, 'doc', args[2], 'tab')
    
    labels = []
    labels.append(label_A)
    labels.append(label_B)

    bffilename = 'bf_stat_sys'
    tab = DHadCBXTable()
    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:
            factor =  0.000001*281/818
        else:
            raise NameError(label)

        if '818ipb' in label_A and '818ipb' 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')
        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=factor, opt='(cell)x1E6')
        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(label, 'Fitted Value','Frac. Err', str=' ')
    tab.column_append_by_diff_sigma('Difference', label_B,label_A)
    tab.output(tabname, tabbase=tabbase, trans_dict=attr.NBF_dict)
Exemple #7
0
def get_brs_from_file(label):
    tab = DHadTable()
    bffilename = 'bf_stat_sys'

    bffile = os.path.join(attr.brfpath, label, bffilename)
    tab.column_append(parse_result(bffile, 'paras'), 'Parameters')
    tab.column_append(parse_result(bffile, 'value'), 'value')
    tab.column_append(parse_result(bffile, 'stat'),  'stat')
    tab.column_append(parse_result(bffile, 'syst'),  'syst')
    tab.rows_delete(['Parameters', 'ND0D0Bar', 'ND+D-'])

    content = []
    n = 0
    for row in tab.data:
        n += 1
        line = 'exec addData %s %s %s %s \n' %(
            n, row[1], row[2], row[3])
        content.append(line)
    return content
Exemple #8
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
    else:
        raise NameError(label)

    tab = THSTable()
    tab.column_append(parse_result(bffile, 'paras'), 'Parameters')
    tab.column_append(generated, 'Input value')
    tab.column_append(parse_result(bffile, 'value_err'), 'Fitted value')

    tab.column_append_by_diff_sigma('Difference', 'Fitted value',
                                    'Input 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('Input value', row=['ND0D0Bar', 'ND+D-'],
                    rnd='.001', factor=factor, opt='cellx%s'%power)
    tab.output(tabname, trans_dict=attr.NBF_dict)

    diff_from_seeds = 'chisq 13.5813 ndof 11 prob 0.257036'
    sys.stdout.write('%s\n' %diff_from_seeds)
    sys.exit()
    chisq = tab.cell_get_by_square_sum(column='Difference')
    ndof = 11
    from ROOT import TMath
    prob = TMath.Prob(float(chisq), ndof)
    prob = tab.cell_trim(prob, rnd='.1', factor=100)
    sys.stdout.write('Chisq is %s for %s d.o.f, Prob = %s%% \n' % (
        chisq, ndof, prob))
Exemple #9
0
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()
Exemple #10
0
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()
Exemple #11
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)