예제 #1
0
def bkg_names_single_mode(datatype,
                          mode,
                          label,
                          limit,
                          bkgmodes,
                          debug,
                          prefix=None):
    bkgname = '%s_%s.txt' % (datatype, mode)
    if prefix != None:
        bkgname = '%s_%s_%s.txt' % (prefix, datatype, mode)

    bkgname = bkgname.replace('/', '_')
    bkgfile = tools.set_file(extbase=attr.bkgpath(),
                             prefix='dir_' + label,
                             comname=bkgname)
    if debug:
        sys.stdout.write('\ndebug: bkgfile %s\n' % bkgfile)

    tab = DHadTable(bkgfile, evalcell=True)
    tab.sort_by_column('Number', reverse=True)

    if limit != None:
        mcddbars = tab.column_get('Mode', 'Number' + limit)[1:]

    if bkgmodes != None:
        mcddbars = tab.column_get('Mode')[1:bkgmodes + 1]

    numbers = tab.column_get('Number')[1:len(mcddbars) + 1]
    mcddbarmodenames = mcddbars_to_modenames(mcddbars)
    return mcddbarmodenames, numbers
예제 #2
0
파일: mctruth.py 프로젝트: zhixing1996/dhad
def mctruth_names_single_mode(datatype,
                              mode,
                              label,
                              limit,
                              mctruthmodes,
                              debug,
                              prefix=None):
    var = 'mctruth'
    mctruthfile = get_evtfile(datatype, mode, label, var)

    if debug:
        sys.stdout.write('\ndebug: mctruthfile %s\n' % mctruthfile)

    tab = DHadTable(mctruthfile, evalcell=True)
    tab.sort_by_column('Number', reverse=True)

    if limit != None:
        mcddbars = tab.column_get('Mode', 'Number' + limit)[1:]

    if mctruthmodes != None:
        mcddbars = tab.column_get('Mode')[1:mctruthmodes + 1]

    numbers = tab.column_get('Number')[1:len(mcddbars) + 1]

    mcddbarmodenames = mcddbars_to_modenames(mcddbars)

    return mcddbarmodenames, numbers
예제 #3
0
파일: syserr.py 프로젝트: zhixing1996/dhad
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 
예제 #4
0
파일: syserr.py 프로젝트: zhixing1996/dhad
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
예제 #5
0
파일: backgrounds.py 프로젝트: xshi/dhad
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
예제 #6
0
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
예제 #7
0
파일: backgrounds.py 프로젝트: xshi/dhad
def bkg_names_single_mode(datatype, mode, label, limit, bkgmodes,
                          debug, prefix=None):
    bkgname = '%s_%s.txt' %(datatype, mode)
    if prefix !=None:
        bkgname = '%s_%s_%s.txt' %(prefix, datatype, mode)
        
    bkgname = bkgname.replace('/', '_')
    bkgfile = tools.set_file(
        extbase=attr.bkgpath(), prefix='dir_'+label, comname=bkgname)
    if debug:
        sys.stdout.write('\ndebug: bkgfile %s\n' %bkgfile)

    tab = DHadTable(bkgfile, evalcell=True)
    tab.sort_by_column('Number', reverse=True)

    if limit != None:
        mcddbars = tab.column_get('Mode', 'Number'+limit)[1:]

    if bkgmodes != None:
        mcddbars = tab.column_get('Mode')[1:bkgmodes+1]

    numbers = tab.column_get('Number')[1:len(mcddbars)+1]
    mcddbarmodenames = mcddbars_to_modenames(mcddbars)
    return mcddbarmodenames, numbers 
예제 #8
0
파일: backgrounds.py 프로젝트: xshi/dhad
def get_bkg_total(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)
    tab = DHadTable(bkgfile)
    col = tab.column_get('Number')
    total = sum(col[1:])

    if 'ddbar' in datatype:
        factor = 20
    if 'cont' in datatype:
        factor = 5

    total = total/float(factor)
    return total
예제 #9
0
def get_bkg_total(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)
    tab = DHadTable(bkgfile)
    col = tab.column_get('Number')
    total = sum(col[1:])

    if 'ddbar' in datatype:
        factor = 20
    if 'cont' in datatype:
        factor = 5

    total = total / float(factor)
    return total
예제 #10
0
 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)