def PrintSystTable(self, name='uncertainties'):
     t = OutText(self.outpath, name, "new", textformat=self.textformat)
     t.SetTexAlign("l c")
     t.SetSeparatorLength(30)
     t.SetDefaultFixOption(False)
     t.line('%Uncertainties on tt inclusive cross section \n% ' +
            'for channel \'%s\' and level \'%s\'' %
            (self.GetChan(), self.GetLevel()))
     exp = self.GetExpUnc()
     mod = self.GetModUnc()
     stat = self.GetXsecStatUnc()
     lum = self.GetXsecLumiUnc()
     syst = self.GetXsecSystUnc()
     xsec = self.GetXsec()
     t.bar()
     t.line(t.fix(' Source', 18, 'l') + t.vsep() + fix("value (\%)", 6))
     t.sep()
     for b in [x.GetName() for x in self.bkg]:
         t.line(
             fix(' ' + b, 18, 'r') + t.vsep() +
             fix('%1.2f' % (self.GetXsecBkgRelUnc(b) * 100), 6))
     t.sep()
     for e in exp.keys():
         t.line(
             fix(' ' + e, 18, 'l') + t.vsep() +
             fix('%1.2f' % (exp[e] * 100), 6))
     t.sep()
     for e in mod.keys():
         t.line(
             fix(' ' + e, 18, 'l') + t.vsep() +
             fix('%1.2f' % (mod[e] * 100), 6))
     t.sep()
     t.line(
         fix(' Total systematic', 18, 'l') + t.vsep() +
         fix('%1.2f' % (syst * 100), 6))
     t.sep()
     t.line(
         fix(' Statistics', 18, 'l') + t.vsep() +
         fix('%1.2f' % (stat * 100), 6))
     t.sep()
     t.line(
         fix(' Luminosity', 18, 'l') + t.vsep() +
         fix('%1.2f' % (lum * 100), 6))
     t.bar()
     t.write()
 def PrintXsec(self, name='xsec'):
     t = OutText(self.outpath, name, "new", textformat=self.textformat)
     t.SetTexAlign("l c")
     t.SetSeparatorLength(26 + 3 + 20 + 5)
     t.SetDefaultFixOption(False)
     t.line('%' + 'tt cross section for channel \'%s\' and level \'%s\'' %
            (self.GetChan(), self.GetLevel()))
     acc = self.GetAcc()
     eff = self.GetEff()
     t.bar()
     t.line(
         t.fix(' Acceptance', 16, 'r') + t.vsep() +
         t.fix("%1.4f" % acc, 6) + t.pm() +
         t.fix("%1.2f" % (acc * self.GetAccUnc()), 8))
     t.line(
         t.fix(' Efficiency', 16, 'r') + t.vsep() +
         t.fix("%1.4f" % eff, 6) + t.pm() +
         t.fix("%1.2f" % (eff * self.GetEffUnc()), 8))
     t.sep()
     t.line(
         t.fix(' Branching ratio', 16, 'r') + t.vsep() +
         t.fix("%1.4f" % self.GetBR(), 6))
     t.line(
         t.fix(' Gen events', 16, 'r') + t.vsep() +
         t.fix("%d" % self.GetGenEvents(), 9))
     t.line(
         t.fix(' Fiducial events', 16, 'r') + t.vsep() +
         t.fix("%d" % self.GetFiduEvents(), 9))
     if self.doFiducial:
         t.sep()
         xsec = self.GetFiduXsec()
         stat = self.GetXsecStatUnc()
         syst = self.GetEffUnc()
         lumi = self.GetXsecLumiUnc()
         #t.line(t.fix(' Fiducial cross section', 26, 'r') + t.vsep() + t.fix("%1.2f"%xsec,6))
         #t.line(t.fix(' +\- ', 26, 'r')            + '   ' + t.fix('%1.2f (%1.2f'%(stat*xsec,stat*100) + ' %) (stat)',20, 'l'))
         #t.line(t.fix(' +\- ', 26, 'r')            + '   ' + t.fix('%1.2f (%1.2f'%(syst*xsec,syst*100) + ' %) (syst)',20, 'l'))
         #t.line(t.fix(' +\- ', 26, 'r')            + '   ' + t.fix('%1.2f (%1.2f'%(lumi*xsec,lumi*100) + ' %) (lumi)',20, 'l'))
     t.sep()
     xsec = self.GetXsec()
     stat = self.GetXsecStatUnc()
     syst = self.GetXsecSystUnc()
     lumi = self.GetXsecLumiUnc()
     t.line(
         t.fix(' Inclusive cross section', 26, 'r') + t.vsep() +
         t.fix("%1.2f" % xsec, 6))
     t.line(
         t.fix(' $\pm$ ', 26, 'r') + '   ' +
         t.fix('%1.2f (%1.2f' %
               (stat * xsec, stat * 100) + ' \%) (stat)', 20, 'l') +
         t.vsep())
     t.line(
         t.fix(' $\pm$ ', 26, 'r') + '   ' +
         t.fix('%1.2f (%1.2f' %
               (syst * xsec, syst * 100) + ' \%) (syst)', 20, 'l') +
         t.vsep())
     t.line(
         t.fix(' $\pm$ ', 26, 'r') + '   ' +
         t.fix('%1.2f (%1.2f' %
               (lumi * xsec, lumi * 100) + ' \%) (lumi)', 20, 'l') +
         t.vsep())
     t.bar()
     t.write()