예제 #1
0
 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()
예제 #2
0
 def PrintPDFyields(self, name='PDFvariations'):
     ''' Prints a table with the info of PDF systematics '''
     t = OutText(self.outpath, name)
     s = lambda i: ' ' + t.fix('[%d]' % i, 4, 'l', False
                               ) + ' %1.2f (%1.2f %s)' % (self.GetPDFyield(
                                   i), self.GetRelUncPDF(i) * 100, '%')
     c0 = s(1) + ' (nominal) '
     t.SetSeparatorLength(len(c0))
     t.line('### PDF and alpha_s uncertianties')
     t.line()
     if self.nPDFweights == 33:
         t.line(
             ' Using PDF4LHC15_nlo_nf4_30_pdfas, 1+30+2 weights, see Table 6 in '
         )
         t.line(' > https://arxiv.org/pdf/1510.03865.pdf')
     elif self.nPDFweights == 100:
         t.line('### NNPDF variations: 100 (2 alpha_s variations missing)')
         #cout << " >>>> NNPDF systematic uncertainty" << endl;
         #cout << " Evaluated by taking the RMS under the 100 weights" << endl;
         #cout << " Alpha_s variations are added in quadrature after rescaling by 0.75" << endl;
         #cout << " The formula is: sqrt(RMS^2 + ((alphas var 1 - alphas var 2)*0.75/2)^2 )" << endl;
     t.bar()
     t.line(c0)
     for i in range(2, self.nPDFweights + 1):
         t.line(s(i))
     t.sep()
     pdfunc = self.GetPDFunc()
     alphas = self.GetAlphaSunc()
     totunc = self.GetPDFandAlphaSunc()
     if self.nPDFweights == 33:
         t.line(' See reference: ')
         t.line(' > https://arxiv.org/pdf/1510.03865.pdf')
         t.line(' Eq [20] for PDF unc:  %1.2f (%1.2f %s)' %
                (pdfunc * self.GetPDFnom(), pdfunc * 100, '%'))
         t.line(' Eq [27] for alpha_S:  %1.2f (%1.2f %s)' %
                (alphas * self.GetPDFnom(), alphas * 100, '%'))
         t.sep()
     t.line(' Total PDF + alpha_S uncertainty: ')
     t.line('  ## %1.2f (%1.2f %s)' %
            (totunc * self.GetPDFnom(), totunc * 100, '%'))
     t.bar()
     t.write()
예제 #3
0
 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()
예제 #4
0
 def PrintYields(self, name='yields', doStat=True, doSyst=True):
     t = OutText(self.outpath, name, "new", textformat=self.textformat)
     t.SetTexAlign("l c")
     nsem = 16 + 3 + 8 + (5 + 8 if doStat else 0) + (5 + 8 if doSyst else 0)
     t.SetSeparatorLength(nsem)
     t.line('%' + 'Yields for channel \'%s\' and level \'%s\'' %
            (self.GetChan(), self.GetLevel()))
     t.bar()
     for pr in self.bkg:
         name = t.fix(" %s" % pr.GetName(), 16, 'l', 0)
         y = t.fix("%1.2f" % pr.GetYield(), 8, 0)
         stat = t.fix("%1.2f" % pr.GetStatUnc(), 8, 0)
         syst = t.fix("%1.2f" % pr.GetSystAbsUnc(), 8, 0)
         t.line(name + t.vsep() + y + ((t.pm() + stat) if doStat else '') +
                ((t.pm() + syst) if doSyst else ''))
     t.sep()
     totbkg = t.fix("%1.2f" % self.GetTotBkg(), 8, 0)
     totbkgstat = t.fix("%1.2f" % self.GetTotBkgStatUnc(), 8, 0)
     totbkgsyst = t.fix("%1.2f" % self.GetTotBkgSystUnc(), 8, 0)
     t.line(
         t.fix(" Total bkg", 16, 'l', 0) + t.vsep() + totbkg +
         ((t.pm() + totbkgstat) if doStat else '') +
         ((t.pm() + totbkgsyst) if doSyst else ''))
     t.sep()
     y = self.GetSignalYield()
     signal = t.fix(" %s" % (self.GetSignal().GetName()), 16, 'l', 0)
     ysig = t.fix("%1.2f" % y, 8, 0)
     sigunc = t.fix("%1.2f" % (self.GetXsecSystUnc() * y), 8, 0)
     sigsta = t.fix("%1.2f" % self.GetSignal().GetStatUnc(), 8, 0)
     t.line(signal + t.vsep() + ysig +
            ((t.pm() + sigsta) if doStat else '') +
            ((t.pm() + sigunc) if doSyst else ''))
     t.sep()
     t.line(
         t.fix(" Data", 16, 'l', 0) + t.vsep() +
         t.fix("%i" % self.GetData(), 8, 0))
     t.bar()
     t.write()
예제 #5
0
  nom, uncnom, var, uncvar, syst, systunc = GetGAandUnc(sample, chan)
  print "%s - %s - %s"%(GetValAndUncString(nom, uncnom), GetValAndUncString(var, uncvar), GetValAndUncString(syst, systunc))

PrintLine('hdampUp', 'ElMu')
'''

if printRecoAndGen:
  t = OutText(outpath+'/genSyst/', 'genSyst_'+l, "new", textformat='tex')
  t.SetTexAlign("l c c c c c")
  nsem = 12
  t.SetSeparatorLength(nsem)
  #t.line('Underlying event and hdamp uncertainties at reco and gen level (%s)'%l)
  t.bar()
  firstline = ''
  for lab in snames: 
    firstline += t.vsep() + t.fix(lab,20)
  t.line(firstline)
  t.sep()
  for ch in ['ElEl', 'MuMu', 'ElMu']:
    for mode in ['Reco', 'Gen']:
      name = ('ee' if ch=='ElEl' else ('$\mu\mu$' if ch =='MuMu' else 'e$\mu$')) +' '+ mode
      name = t.fix(name, 10)
      for lab in snames:
        val, unc = GA(lab, ch) if mode == 'Gen' else RS(lab, ch)
        name += t.vsep() + (t.fix("%1.2f %s"%(unc, '\%'), 20) if lab!='tt' else t.fix("%g"%(val), 20))
        #name += t.vsep() + t.fix("%1.1f (%1.2f %s)"%(val, unc, '%'), 20)
      t.line(name)
  t.bar()
  t.write()

if printGenAndStatUnc: