def make_ratio(nom, up, down, channel):
    ratio1 = up.Clone("ratio")
    #ratio1.Sumw2()
    ratio1.SetStats(0)
    ratio1.Add(nom, -1)
    ratio1.Divide(nom)
    ratio1.Scale(100)
    ratio1.SetTitle("")
    y = ratio1.GetYaxis()
    y.SetTitle("#frac{Syst-Nom.}{Nom.} [%]")
    y.SetNdivisions(505)
    y.SetTitleOffset(2.3)
    y.SetTitleSize(10)
    x = ratio1.GetXaxis()
    x.SetTitle("event level descriminator")
    x.SetTitleOffset(6.2)
    ratio1.SetLineColor(632)
    ratio1.SetFillColor(632)
    ratio1.SetMarkerColor(632)
    ratio1.SetMarkerStyle(0)
    ratio2 = down.Clone("ratio")
    #ratio2.Sumw2()
    ratio2.Add(nom, -1)
    ratio2.Divide(nom)
    ratio2.Scale(100)
    ratio2.SetLineColor(857)
    ratio2.SetFillColor(857)
    ratio2.SetMarkerColor(857)
    ratio2.SetMarkerStyle(0)
    line = TF1("fa1", "0", -1000, 1000)
    line.SetLineColor(1)
    ymax = abs(ratio1.GetMaximum())
    ymin = abs(ratio2.GetMaximum())
    Range = [ymax, ymin]
    maxv = max(Range)
    if maxv < 0.8:
        offset = 0.2
    else:
        offset = 0.8
    ratio1.SetMinimum(-maxv - offset)
    ratio1.SetMaximum(maxv + offset)
    ratio2.SetMinimum(-maxv - offset)
    ratio2.SetMaximum(maxv + offset)

    ratio1.Draw("hist")
    ratio2.Draw("same hist")
    line.Draw("same")

    #axis1 = TGaxis(0,-maxv-offset,1,-maxv-offset,-maxv-offset,-maxv-offset,50510,"-");
    #axis1.SetName("axis1");

    channel_label = TLatex()
    channel_label.SetNDC()
    channel_label.SetTextAlign(12)
    channel_label.SetTextFont(63)
    channel_label.SetTextSizePixels(15)
    channel_label.DrawLatex(0.45, 0.89, channel)
    channel_label.Draw("same")

    return ratio1, ratio2, line, channel_label
Ejemplo n.º 2
0
def AddText(txt):
    texcms = TLatex(-20.0, 50.0, txt)
    texcms.SetNDC()
    texcms.SetTextAlign(12)
    texcms.SetX(0.5)
    texcms.SetY(0.34)
    texcms.SetTextSize(0.02)
    texcms.SetTextSizePixels(32)
    return texcms
Ejemplo n.º 3
0
 def DrawTextCMS(self):
     texcms = TLatex(0, 0, self.cmstex)
     texcms.SetNDC()
     texcms.SetX(self.cmstexX)
     texcms.SetY(self.cmstexY)
     texcms.SetTextAlign(12)
     texcms.SetTextSize(self.cmstexS)
     texcms.SetTextSizePixels(22)
     return texcms
Ejemplo n.º 4
0
 def DrawTextCMSmode(self):
     texpre = TLatex(0, 0, self.texcmsMode)
     texpre.SetNDC()
     texpre.SetTextAlign(12)
     texpre.SetX(self.texcmsModeX)
     texpre.SetY(self.texcmsModeY)
     texpre.SetTextFont(52)
     texpre.SetTextSize(self.texcmsModeS)
     texpre.SetTextSizePixels(22)
     return texpre
Ejemplo n.º 5
0
 def DrawTextLumi(self):
   if not hasattr(self, 'lumi'): self.lumi = 0
   t = self.texlumi if not '%' in self.texlumi else (self.texlumi%self.lumi if not self.doinvfb else self.texlumi%(self.lumi/1000.))
   tlum = TLatex(-20., 50., t)
   tlum.SetNDC()
   tlum.SetTextAlign(12)
   tlum.SetTextFont(42)
   tlum.SetX(self.texlumiX)
   tlum.SetY(self.texlumiY)
   tlum.SetTextSize(self.texlumiS)
   tlum.SetTextSizePixels(22)
   return tlum
Ejemplo n.º 6
0
def DrawBazil(diagonal=175, doData=False, pname='limits'):
    import numpy as np
    # 'mstop','mlsp','sm2','sm1','central','sp1','sp2', 'data'
    d = GetDic(pname + '.p', diagonal)
    x = np.array(d['mstop'])
    e = np.array(d['exp'])
    y1max = np.array(d['s+1'])
    y2max = np.array(d['s+2'])
    y1min = np.array(d['s-1'])
    y2min = np.array(d['s-2'])
    # observed
    if (doData): o = np.array(d['obs'])
    else: o = np.array(d['exp'])

    c1 = TCanvas("c1", "CL", 10, 10, 800, 600)
    #c1.SetGrid();

    ymax = 7.5
    ymin = 0.3
    if (diagonal == 'down' or diagonal == 'Down' or diagonal == 'DOWN'):
        ymax = 3.1
        ymin = 0.30
    elif (diagonal == 'up' or diagonal == 'Up' or diagonal == 'UP'):
        ymax = 2.5
        ymin = 0.15

    #c1.DrawFrame(min(x)-2,min(d['sp2']+d['sm2'])-0.2,max(x)+2,max(d['sp2']+d['sm2'])+0.2);
    c1.DrawFrame(min(x), ymin, max(x), ymax)

    n = len(e)
    gr1min = TGraph(n, x, y1min)
    gr1max = TGraph(n, x, y1max)
    gr2min = TGraph(n, x, y2min)
    gr2max = TGraph(n, x, y2max)
    gro = TGraph(n, x, o)
    gre = TGraph(n, x, e)
    gh = TGraph(n, x, np.linspace(0.999, 1, n))
    gr1shade = TGraph(2 * n)
    gr2shade = TGraph(2 * n)

    #color1shade = 3; color2shade = 5;
    color1shade = kOrange
    color2shade = kGreen + 1
    for i in range(n):
        gr1shade.SetPoint(i, x[i], y1max[i] * scalefact)
        gr1shade.SetPoint(n + i, x[n - i - 1], y1min[n - i - 1] * scalefact)
        gr2shade.SetPoint(i, x[i], y2max[i] * scalefact)
        gr2shade.SetPoint(n + i, x[n - i - 1], y2min[n - i - 1] * scalefact)
        gre.SetPoint(i, x[i], e[i] * scalefact)
        gh.SetPoint(i, x[i], np.linspace(0.999, 1, n)[i] * scalefact)
        gro.SetPoint(i, x[i], o[i] * scalefact if doData else e[i] * scalefact)

    gr2shade.SetFillColor(color2shade)
    gr2shade.Draw("f")
    gr1shade.SetFillColor(color1shade)
    gr1shade.Draw("f")
    gh.SetLineWidth(2)
    gh.SetMarkerStyle(0)
    gh.SetLineColor(46)
    gh.SetLineStyle(2)
    gh.Draw("LP")
    gro.SetLineWidth(2)
    gro.SetMarkerStyle(20)
    gro.SetMarkerSize(0.7)
    gro.SetLineColor(1)
    if doData: gro.Draw("LP")
    gre.SetLineWidth(2)
    gre.SetMarkerStyle(0)
    gre.SetLineColor(1)
    gre.SetLineStyle(6)
    gre.Draw("LP")

    gre.SetTitle("Expected")
    gro.SetTitle("Observed")
    gr1shade.SetTitle("Expected 1#sigma")
    gr2shade.SetTitle("Expected 2#sigma")

    leg = TLegend(.1, .65, .4, .9)
    leg.AddEntry(gro)
    leg.AddEntry(gre)
    leg.AddEntry(gr1shade, '', 'f')
    leg.AddEntry(gr2shade, '', 'f')
    leg.SetFillColor(0)
    leg.Draw("same")

    gre.SetFillColor(0)
    gro.SetFillColor(0)
    gr1shade.SetLineColor(color1shade)
    gr2shade.SetLineColor(color2shade)

    tit = "m_{#tilde{t}_{1}} - m_{#tilde{#chi}_{1}^{0}} = "
    dm = "0"
    ymax = 4.1
    ymin = 0.3
    if (diagonal == 'down' or diagonal == 'Down' or diagonal == 'DOWN'):
        tit += "182.5 GeV"  #" + 7.5 GeV"
        dm = "m7p5"
        ymax = 2.2
        ymin = 0.15

    elif (diagonal == 'up' or diagonal == 'Up' or diagonal == 'UP'):
        tit += "167.5 GeV"  #" - 7.5 GeV"
        dm = "7p5"
        ymax = 3.3
        ymin = 0.30
    else:
        tit += "175 GeV"
    Title = TLatex()
    Title.SetTextSize(0.060)
    Title.DrawLatexNDC(.42, .84, tit)
    Xaxis = TLatex()
    Xaxis.SetTextFont(42)
    Xaxis.DrawLatexNDC(0.8, 0.03, "m_{#tilde{t}_{1}} (GeV)")
    Yaxis = TLatex()
    Yaxis.SetTextFont(42)
    Yaxis.SetTextAngle(90)
    Yaxis.DrawLatexNDC(0.05, 0.15, "95% CL limit on signal strength")
    textCMS = TLatex()
    textCMS.SetTextSize(0.06)
    textCMS.SetTextSizePixels(22)
    textCMS.SetTextAlign(12)
    textCMS.DrawLatexNDC(.12, .93, "CMS")
    textLumi = TLatex()
    textLumi.SetTextFont(42)
    textLumi.SetTextSize(0.06)
    textLumi.SetTextSizePixels(22)
    textLumi.DrawLatexNDC(.58, .91, "%1.1f fb^{-1} (13 TeV)" % (lumi))  #35.9

    name = "brazil_%i" % diagonal
    name = "brazil_%s" % pname
    for form in ['pdf', 'png']:
        c1.Print(outputdir + name + '.%s' % form)