예제 #1
0
 def draw(self, hist, on_main, *args, **kwargs):
     yaxis = hist.GetYaxis()
     xaxis = hist.GetXaxis()
     if on_main:
         self.main.cd()
         yaxis.SetLabelSize( gStyle.GetLabelSize("Y")/(1-self.splitPad) )
         yaxis.SetTitleSize( gStyle.GetTitleSize("Y")/(1-self.splitPad) )
         yaxis.SetTitleOffset( gStyle.GetTitleOffset("Y")*(1-self.splitPad) )
         xaxis.SetLabelSize( 0 )
         xaxis.SetTitleSize( 0 )
         cmsPrel(self.lumi, self.energy, self.simOnly, True, self.splitPad)
         self.main.Update()
         
     else:
         self.ratio.cd()
         yaxis.SetLabelSize( gStyle.GetLabelSize("Y")/self.splitPad )
         yaxis.SetTitleSize( gStyle.GetTitleSize("Y")/self.splitPad )
         xaxis.SetLabelSize( gStyle.GetLabelSize("Y")/self.splitPad )
         xaxis.SetTitleSize( gStyle.GetTitleSize("Y")/self.splitPad )
         yaxis.SetTitleOffset( gStyle.GetTitleOffset("Y")*self.splitPad )
         yaxis.SetNdivisions(5,5,0)
         yaxis.SetRangeUser(0.71, 1.29)
     hist.Draw(*args, **kwargs)
     self.Update()
        legend.AddEntry(h_nominal, "nominal", "f")
        legend.AddEntry(h_Up, "%s_Up" % item, "f")
        legend.AddEntry(h_Down, "%s_Down" % item, "f")

        h_nominal.Draw()
        h_Up.Draw("same")
        h_Down.Draw("same")

        legend.Draw("same")

        h_nominal.GetXaxis().SetTitle('')
        h_nominal.GetXaxis().SetLabelSize(0)
        h_nominal.GetYaxis().SetLabelSize(gStyle.GetLabelSize() /
                                          (1. - padRatio + padOverlap))
        h_nominal.GetYaxis().SetTitleSize(gStyle.GetTitleSize() /
                                          (1. - padRatio + padOverlap))
        h_nominal.GetYaxis().SetTitleOffset(gStyle.GetTitleYOffset() *
                                            (1. - padRatio + padOverlap))
        h_nominal.SetTitle(';;Events')  # '%rebin)

        maxVal = max(h_nominal.GetMaximum(), h_Up.GetMaximum(),
                     h_Down.GetMaximum())
        #minVal = 1
        minVal = min(h_nominal.GetMinimum(), h_Up.GetMinimum(),
                     h_Down.GetMinimum())
        h_nominal.SetMaximum(1.1 * maxVal)
        h_nominal.SetMinimum(minVal)

        print maxVal, minVal
        #CMS_lumi.channelText = (channelText+"\\n"+regionText)
legend.AddEntry(rebinnedData, "Data", 'pe')
legend.AddEntry(errorband, "Uncertainty", "f")

for ih in rebinnedHist:
    legend.AddEntry(rebinnedHist[ih], ih, 'f')

pad1.cd()

stack.Draw('HIST')
rebinnedData.Draw('E,X0,SAME')
legend.Draw("same")
stack.GetXaxis().SetTitle('')
stack.GetXaxis().SetLabelSize(0)
stack.GetYaxis().SetLabelSize(gStyle.GetLabelSize() /
                              (1. - padRatio + padOverlap))
stack.GetYaxis().SetTitleSize(gStyle.GetTitleSize() /
                              (1. - padRatio + padOverlap))
stack.GetYaxis().SetTitleOffset(gStyle.GetTitleYOffset() *
                                (1. - padRatio + padOverlap))
#stack.SetTitle(';;<Events/GeV>')# '%rebin)

#CMS_lumi.channelText = (channelText+"\\n"+regionText)
#if postfitPlots: CMS_lumi.channelText =channelText+"\\n "+regionText+"\\n "+chi2Text

CMS_lumi.channelText = "#splitline{%s}{%s}" % (channelText, regionText)
if postfitPlots:
    CMS_lumi.channelText = "#splitline{%s}{%s}" % (channelText + ";" +
                                                   regionText, chi2Text)

CMS_lumi.writeChannelText = True
CMS_lumi.writeExtraText = True
예제 #4
0
    legend.AddEntry(rebinnedData, "Data", 'pe')
    legend.AddEntry(rebinnedHist['myZJets'], 'ZJets', 'f')
    legend.AddEntry(rebinnedHist['myBackground'], 'Background', 'f')
    #legend.AddEntry(rebinnedHist['myTotal'],'myTotal','f')
    legend.AddEntry(errorband, "Uncertainty", "f")

    pad1.cd()

    stack.Draw('HIST')
    rebinnedData.Draw('E,X0,SAME')
    legend.Draw("same")
    stack.GetXaxis().SetTitle('')
    stack.GetXaxis().SetLabelSize(0)
    stack.GetYaxis().SetLabelSize(gStyle.GetLabelSize() /
                                  (1. - padRatio + padOverlap))
    stack.GetYaxis().SetTitleSize(gStyle.GetTitleSize() /
                                  (1. - padRatio + padOverlap))
    stack.GetYaxis().SetTitleOffset(gStyle.GetTitleYOffset() *
                                    (1. - padRatio + padOverlap))
    stack.SetTitle(';;Events/%i GeV ' % rebin)

    CMS_lumi.channelText = channelText
    CMS_lumi.channelText = regionText
    CMS_lumi.writeChannelText = True
    CMS_lumi.writeExtraText = True
    CMS_lumi.CMS_lumi(pad1, 4, 11)

    if not noData:
        ratio = rebinnedData.Clone("temp")
        temp = stack.GetStack().Last().Clone("temp")
        for i_bin in range(1, temp.GetNbinsX() + 1):
            pad1.Draw()
            pad2.Draw()

            pad1.cd()

            _ratiomax = 1 + 1.1 * (_ratiomax - 1)
            _ratiomin = 1 - 1.1 * (1 - _ratiomin)
            ratioUp.SetMaximum(_ratiomax)
            ratioUp.SetMinimum(_ratiomin)

            ratioUp.SetTitle('')
            ratioUp.GetXaxis().SetLabelSize(gStyle.GetLabelSize() /
                                            (padRatio + padOverlap))
            ratioUp.GetYaxis().SetLabelSize(gStyle.GetLabelSize() /
                                            (padRatio + padOverlap))
            ratioUp.GetXaxis().SetTitleSize(gStyle.GetTitleSize() /
                                            (padRatio + padOverlap))
            ratioUp.GetYaxis().SetTitleSize(gStyle.GetTitleSize() /
                                            (padRatio + padOverlap))

            ratioUp.GetYaxis().SetTitle("Rel. Change")
            ratioUp.GetYaxis().SetTitleOffset(gStyle.GetTitleYOffset() *
                                              (padRatio + padOverlap - 0.02))
            ratioUp.GetYaxis().CenterTitle()
            ratioUp.GetXaxis().SetTitle(up.GetXaxis().GetTitle())

            up.GetXaxis().SetTitle('')
            up.SetTitle('')
            up.GetXaxis().SetLabelSize(0)
            up.GetYaxis().SetLabelSize(gStyle.GetLabelSize() /
                                       (1. - padRatio + padOverlap))