示例#1
0
def render(x):
    ''' Render x (an uncertainties object) with correct sig figs '''
    if isinstance(x, int):
        return '%i' % x
    else:
        #return r'$%s \pm %s$' % (int(x.nominal_value), int(x.std_dev()))
        # Never round greater than unity.  Always include at least 1 sig digit.
        return r'$%s \pm %s$' % (sigfigs(x.nominal_value, x.std_dev(), 1, max_sig_fig=0))
示例#2
0
                    if p == 'TotalSig':
                        nPhantoms1 = 4 - len(str(round(yields[p+'_err'], 1)))
                    elif p == 'Total':
                        nPhantoms2 = 4 - len(str(int(round(yields[p+'_err']))))

            if '7TeV' in cat:
                # yields['category'] = channelToTex[channel] + ' ' + catNames[channel][catDict[cat]] + ' 7\,TeV'
                if 'VBF' in catNames[channel][catDict[cat]]:
                    yields['category'] = catNames[channel][catDict[cat]] + ' 7\,\TeV'
                else:
                    yields['category'] = '\multirow{{2}}{{*}}{{{catName}}} \ 7\,\TeV'.format(catName=catNames[channel][catDict[cat]])
            else:
                # yields['category'] = channelToTex[channel] + ' ' + catNames[channel][catDict[cat]] + ' 8\,TeV'
                if 'VBF' in catNames[channel][catDict[cat]] or channel == 'tt':
                    yields['category'] = catNames[channel][catDict[cat]] + ' 8\,\TeV'
                else:
                    yields['category'] = '\phantom{{{catName}}} \ 8\,\TeV'.format(catName=catNames[channel][catDict[cat]])
            ssb = 0.
            if channel not in ['ee', 'mm']:
                yields['sOverSB'] = sigfigs(sOverSplusBs[channel][cat], sOverSplusBs[channel][cat], min_sig_fig=-3)[0]
                yields['sigma'] = sigmas[channel][cat]
                yields['width'] = widths[channel][cat]
                ssb = sOverSplusBs[channel][cat]
            # yields['obs'] = '0'

            file.write(line.format(**yields).replace('PHANTOM1', '\phantom{{{}}}'.format(nPhantoms1*'0')).replace('PHANTOM2', '\phantom{{{}}}'.format(nPhantoms2*'0')).replace('0.0$', '-$').replace('0.00$', str(int(round(1000*ssb)))+'$\qquad\\textperthousand'))
        file.write(footer)
    file.write(footer)