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
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
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
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
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
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
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
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
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
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)