Ejemplo n.º 1
0
def plotEtaRangesSame(name,
                      graphs,
                      colors,
                      styles,
                      plotCaloJet=False,
                      plotPFJet=False,
                      plotPuppiJet=False,
                      plotOffJet=False,
                      plotDeepCSV=False,
                      workingPts=None,
                      rocType=None,
                      plotDeepJet=False):

    can = ROOT.TCanvas(name, name)
    can.cd().SetLogy(1)
    for gItr, g in enumerate(graphs):
        g.SetLineColor(colors[gItr])
        g.SetLineStyle(styles[gItr])
        if not gItr:
            g.Draw("AL")
        else:
            g.Draw("L")

    if not workingPts == None:
        g_wrkPts = ROOT.TGraph(len(workingPts))
        g_wrkPts.SetMarkerSize(2)
        g_wrkPts.SetMarkerColor(colors[1])
        g_wrkPts.SetMarkerStyle(34)
        for wpItr, wp in enumerate(workingPts):
            print wpItr, wp

            g_wrkPts.SetPoint(wpItr, wp[0], wp[1])

        g_wrkPts.Draw("P")

    cmsLine1, cmsLine2 = getCMSText(xStart=0.2,
                                    yStart=0.875,
                                    subtext=o.cmsText)
    cmsLine1.Draw("same")
    cmsLine2.Draw("same")

    yStart = 0.75
    xStart = 0.2
    if rocType == "Rej":
        xStart = 0.5
        yStart = 0.875

    if plotOffJet:
        offJetText = getText("Offline Jets  (Solid)",
                             xStart=xStart,
                             yStart=yStart,
                             size=0.04,
                             color=ROOT.kBlack)
        yStart = yStart - 0.05
        offJetText.Draw("same")

    if plotPFJet:
        pfJetText = getText("HLT PFCHS Jets  (Dashed) ",
                            xStart=xStart,
                            yStart=yStart,
                            size=0.04,
                            color=ROOT.kBlack)
        pfJetText.Draw("same")
    if plotPuppiJet:
        puppiJetText = getText("HLT Puppi Jets  (Dashed) ",
                               xStart=xStart,
                               yStart=yStart,
                               size=0.04,
                               color=ROOT.kBlack)
        puppiJetText.Draw("same")

    yStart = 0.35
    # xStart = 0.6
    xStart = 0.67
    if rocType == "Rej":
        xStart = 0.2

    if plotDeepCSV:
        deepCSVText = getText("DeepCSV (all Jets)",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.04,
                              color=ROOT.kBlack)
        deepCSVText.Draw("same")
        yStart = yStart - 0.05

        eta1text = getText("DeepCSV (|#eta|<1.5)",
                           xStart=xStart,
                           yStart=yStart,
                           size=0.04,
                           color=ROOT.kBlue + 1)
        yStart = yStart - 0.05
        eta2text = getText("DeepCSV (1.5<|#eta|<3)",
                           xStart=xStart,
                           yStart=yStart,
                           size=0.04,
                           color=ROOT.kRed)
        yStart = yStart - 0.05
        eta3text = getText("DeepCSV (|#eta|>3)",
                           xStart=xStart,
                           yStart=yStart,
                           size=0.04,
                           color=ROOT.kGreen + 2)
        eta1text.Draw("same")
        eta2text.Draw("same")
        eta3text.Draw("same")
    elif plotDeepJet:
        deepCSVText = getText("DeepJet (all Jets)",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.04,
                              color=ROOT.kBlack)
        deepCSVText.Draw("same")
        yStart = yStart - 0.05

        eta1text = getText("DeepJet (|#eta|<1.5)",
                           xStart=xStart,
                           yStart=yStart,
                           size=0.04,
                           color=ROOT.kBlue + 1)
        yStart = yStart - 0.05
        eta2text = getText("DeepJet (1.5<|#eta|<3)",
                           xStart=xStart,
                           yStart=yStart,
                           size=0.04,
                           color=ROOT.kRed)
        yStart = yStart - 0.05
        eta3text = getText("DeepJet (|#eta|>3)",
                           xStart=xStart,
                           yStart=yStart,
                           size=0.04,
                           color=ROOT.kGreen + 2)
        eta1text.Draw("same")
        eta2text.Draw("same")
        eta3text.Draw("same")
    can.SaveAs(o.outDir + "/roc_" + name + ".pdf")
    can.SaveAs(o.outDir + "/roc_" + name + ".png")
Ejemplo n.º 2
0
def plotSame(name,
             graphs,
             colors,
             styles,
             plotCaloJet=False,
             plotPFJet=False,
             plotOffJet=False,
             plotPuppiJet=False,
             plotCSV=False,
             plotDeepCSV=False,
             workingPts=None,
             rocType=None,
             plotDeepJet=False):

    can = ROOT.TCanvas(name, name)
    can.cd().SetLogy(1)
    for gItr, g in enumerate(graphs):
        g.SetLineColor(colors[gItr])
        g.SetLineStyle(styles[gItr])
        if not gItr:
            g.Draw("AL")
        else:
            g.Draw("L")

    if not workingPts == None:
        g_wrkPts = ROOT.TGraph(len(workingPts))
        g_wrkPts.SetMarkerSize(2)
        g_wrkPts.SetMarkerColor(colors[1])
        g_wrkPts.SetMarkerStyle(34)
        for wpItr, wp in enumerate(workingPts):
            print wpItr, wp

            g_wrkPts.SetPoint(wpItr, wp[0], wp[1])

        g_wrkPts.Draw("P")

    cmsLine1, cmsLine2 = getCMSText(xStart=0.2,
                                    yStart=0.875,
                                    subtext=o.cmsText)
    cmsLine1.Draw("same")
    cmsLine2.Draw("same")

    yStart = 0.75
    xStart = 0.2
    if rocType == "Rej":
        xStart = 0.5
        yStart = 0.875

    if plotOffJet:
        offJetText = getText("Offline Jets  ",
                             xStart=xStart,
                             yStart=yStart,
                             size=0.04,
                             color=ROOT.kBlack)
        yStart = yStart - 0.05
        offJetText.Draw("same")

    if plotCaloJet:
        caloJetText = getText("HLT Calo Jets",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.04,
                              color=ROOT.kRed)
        yStart = yStart - 0.05
        caloJetText.Draw("same")
    if plotPFJet:
        pfJetText = getText("HLT PFCHS Jets  ",
                            xStart=xStart,
                            yStart=yStart,
                            size=0.04,
                            color=ROOT.kBlue)
        pfJetText.Draw("same")
    if plotPuppiJet:
        puppiJetText = getText("HLT Puppi Jets  ",
                               xStart=xStart,
                               yStart=yStart,
                               size=0.04,
                               color=ROOT.kBlue)
        puppiJetText.Draw("same")

        #offJetTextDeep  = getText("Offline DeepCSV (Dashed)  ",xStart=0.6,yStart=0.36,size=0.03,color=ROOT.kBlack)

        #offJetText  = getText("Offline Jet  ",xStart=0.6,yStart=0.4,size=0.03,color=ROOT.kBlack)

    yStart = 0.3
    xStart = 0.6
    if rocType == "Rej":
        xStart = 0.2

    if plotDeepCSV:
        if plotCSV:
            deepCSVText = getText("DeepCSV (solid)  ",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.04,
                                  color=ROOT.kBlack)
        elif plotDeepJet:
            deepCSVText = getText("DeepJet (dotted)  ",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.04,
                                  color=ROOT.kBlack)
        else:
            deepCSVText = getText("DeepCSV",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.04,
                                  color=ROOT.kBlack)
        deepCSVText.Draw("same")
        yStart = yStart - 0.05

    if plotDeepJet:
        if plotCSV:
            deepJetText = getText("DeepJet (solid)  ",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.04,
                                  color=ROOT.kBlack)
        elif plotDeepCSV:
            deepJetText = getText("DeepCSV (solid)  ",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.04,
                                  color=ROOT.kBlack)
        else:
            deepJetText = getText("DeepJet",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.04,
                                  color=ROOT.kBlack)
        deepJetText.Draw("same")
        yStart = yStart - 0.05

    if plotCSV:
        if plotDeepCSV:
            # CSVText   = getText("CSV      (dashed)  ",xStart=xStart,yStart=yStart,size=0.04,color=ROOT.kBlack)
            CSVText = getText("JetBProb      (dashed)  ",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.04,
                              color=ROOT.kBlack)
        else:
            # CSVText   = getText("CSV",xStart=xStart,yStart=yStart,size=0.04,color=ROOT.kBlack)
            CSVText = getText("JetBProb",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.04,
                              color=ROOT.kBlack)
        CSVText.Draw("same")

    #offJetTextDeep.Draw("same")

    can.SaveAs(o.outDir + "/roc_" + name + ".pdf")
    can.SaveAs(o.outDir + "/roc_" + name + ".png")
def plotSame(name,
             graphs,
             colors,
             styles,
             plotCaloJet=False,
             plotPFJet=False,
             plotOffJet=False,
             plotCSV=False,
             plotDeepCSV=False,
             plotDeepJet=False,
             workingPts=None,
             rocType=None):

    can = ROOT.TCanvas(name, name)
    can.cd().SetLogy(1)
    for gItr, g in enumerate(graphs):
        g.SetLineColor(colors[gItr])
        g.SetLineStyle(styles[gItr])
        if not gItr:
            g.Draw("AL")
        else:
            g.Draw("L")

    if not workingPts == None:
        g_wrkPts = ROOT.TGraph(len(workingPts))
        g_wrkPts.SetMarkerSize(2)
        g_wrkPts.SetMarkerColor(colors[1])
        g_wrkPts.SetMarkerStyle(34)
        for wpItr, wp in enumerate(workingPts):
            print wpItr, wp

            g_wrkPts.SetPoint(wpItr, wp[0], wp[1])

        g_wrkPts.Draw("P")

    cmsLine1, cmsLine2 = getCMSText(xStart=0.2,
                                    yStart=0.875,
                                    subtext=o.cmsText)
    cmsLine1.Draw("same")
    cmsLine2.Draw("same")

    yStart = 0.75
    # xStart = 0.225
    xStart = 0.185
    if rocType == "Rej":
        xStart = 0.5
        yStart = 0.875

    if plotOffJet:
        offJetText = getText("Offline Jets  ",
                             xStart=xStart,
                             yStart=yStart,
                             size=0.03,
                             color=ROOT.kBlack)
        yStart = yStart - 0.04
        offJetText.Draw("same")

    if plotPFJet:
        pfJetText = getText("HLT PF Jets TRK Run 2",
                            xStart=xStart,
                            yStart=yStart,
                            size=0.03,
                            color=ROOT.kRed)
        pfJetText.Draw("same")
        yStart = yStart - 0.04
        # pfJetText3   = getText("HLT PF Jets TRKRun3",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kGreen)
        # pfJetText3   = getText("HLT PF Jets TRKRun2+PatatrackQuadruplets",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kGreen)
        pfJetText3 = getText("HLT PF Jets TRK Run 3",
                             xStart=xStart,
                             yStart=yStart,
                             size=0.03,
                             color=ROOT.kBlue)
        pfJetText3.Draw("same")
        # yStart = yStart - 0.04
        # pfJetText6   = getText("HLT PF Jets TRKRun3PU",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kCyan)
        # pfJetText6.Draw("same")
        # yStart = yStart - 0.04
        # # pfJetText7   = getText("HLT PF Jets ROI",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kCyan)
        # pfJetText7   = getText("HLT PF Jets TRKRun2+PatatrackTriplets",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kCyan)
        # # pfJetText7   = getText("HLT PF Jets PixelOnly",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kCyan)
        # pfJetText7.Draw("same")
        # yStart = yStart - 0.04
        # # # pfJetText7   = getText("HLT PF Jets BtagROI",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kCyan)
        # # pfJetText8   = getText("HLT PF Jets PixelOnlyTuned",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kOrange)
        # pfJetText8   = getText("HLT PF Jets TRKRun3",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kOrange)
        # pfJetText8.Draw("same")
        # yStart = yStart - 0.04
        # # pfJetText9   = getText("HLT PF Jets TRKRun3PixelOnlyCleaned",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.Blue+1)
        # pfJetText9   = getText("HLT PF Jets TRKRun3 Quadruplets",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kBlue+1)
        # pfJetText9.Draw("same")

    yStart = 0.25
    xStart = 0.6
    if rocType == "Rej":
        xStart = 0.2

    if plotDeepCSV:
        if plotCSV or plotDeepJet:
            deepCSVText = getText("DeepCSV (solid)  ",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.03,
                                  color=ROOT.kBlack)
        else:
            deepCSVText = getText("DeepCSV",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.03,
                                  color=ROOT.kBlack)
        deepCSVText.Draw("same")
        yStart = yStart - 0.04
        calodeepCSVText = getText("CaloJets (dotted)",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.03,
                                  color=ROOT.kBlack)
        calodeepCSVText.Draw("same")
        yStart = yStart - 0.04
    if plotDeepJet:
        if plotDeepCSV:
            deepJetText = getText("DeepJet (dashed)  ",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.03,
                                  color=ROOT.kBlack)
        else:
            deepJetText = getText("DeepJet",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.03,
                                  color=ROOT.kBlack)
        deepJetText.Draw("same")
        yStart = yStart - 0.04

    if plotCSV:
        if plotDeepCSV:
            CSVText = getText("CSV      (dashed)  ",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.03,
                              color=ROOT.kBlack)
        else:
            CSVText = getText("CSV",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.03,
                              color=ROOT.kBlack)
        CSVText.Draw("same")

    #offJetTextDeep.Draw("same")

    can.SaveAs(o.outDir + "/roc_" + name + ".pdf")
    can.SaveAs(o.outDir + "/roc_" + name + ".png")
def plotSame(name,
             graphs,
             colors,
             styles,
             plotCaloJet=False,
             plotPFJet=False,
             plotOffJet=False,
             plotCSV=False,
             plotDeepCSV=False,
             plotDeepJet=False,
             workingPts=None,
             rocType=None):

    can = ROOT.TCanvas(name, name)
    can.cd().SetLogy(1)
    for gItr, g in enumerate(graphs):
        g.SetLineColor(colors[gItr])
        g.SetLineStyle(styles[gItr])
        if not gItr:
            g.Draw("AL")
        else:
            g.Draw("L")

    if not workingPts == None:
        g_wrkPts = ROOT.TGraph(len(workingPts))
        g_wrkPts.SetMarkerSize(2)
        g_wrkPts.SetMarkerColor(colors[1])
        g_wrkPts.SetMarkerStyle(34)
        for wpItr, wp in enumerate(workingPts):
            print wpItr, wp

            g_wrkPts.SetPoint(wpItr, wp[0], wp[1])

        g_wrkPts.Draw("P")

    cmsLine1, cmsLine2 = getCMSText(xStart=0.2,
                                    yStart=0.875,
                                    subtext=o.cmsText)
    cmsLine1.Draw("same")
    cmsLine2.Draw("same")

    yStart = 0.75
    # xStart = 0.225
    xStart = 0.185
    if rocType == "Rej":
        xStart = 0.5
        yStart = 0.875

    if plotOffJet:
        offJetText = getText("Offline PUPPI Jets  ",
                             xStart=xStart,
                             yStart=yStart,
                             size=0.03,
                             color=ROOT.kBlack)
        yStart = yStart - 0.04
        offJetText.Draw("same")

    if plotPFJet:
        pfJetText = getText("HLT PUPPI Jets" + " TRKv6p1",
                            xStart=xStart,
                            yStart=yStart,
                            size=0.03,
                            color=ROOT.kRed)
        pfJetText.Draw("same")
        # yStart = yStart - 0.04
        # pfJetText3   = getText("HLT PUPPI Jets"+" TRKv6p1+TICL",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kGreen+2)
        # pfJetText3.Draw("same")
        yStart = yStart - 0.04
        pfJetText6 = getText("HLT PUPPI Jets" + " TRKv7p2",
                             xStart=xStart,
                             yStart=yStart,
                             size=0.03,
                             color=ROOT.kBlue + 1)
        pfJetText6.Draw("same")
        # yStart = yStart - 0.04
        # pfJetText8   = getText("HLT PUPPI Jets"+" TRKv7p2+TICL",xStart=xStart,yStart=yStart,size=0.03,color=ROOT.kOrange+1)
        # pfJetText8.Draw("same")
        yStart = yStart - 0.04
        pfJetText7 = getText("(+TICL) dotted",
                             xStart=xStart,
                             yStart=yStart,
                             size=0.03,
                             color=ROOT.kBlack)
        pfJetText7.Draw("same")

    yStart = 0.25
    xStart = 0.6
    if rocType == "Rej":
        xStart = 0.2

    if plotDeepCSV:
        if plotCSV:
            deepCSVText = getText("DeepCSV (solid)  ",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.03,
                                  color=ROOT.kBlack)
        else:
            deepCSVText = getText("DeepCSV",
                                  xStart=xStart,
                                  yStart=yStart,
                                  size=0.03,
                                  color=ROOT.kBlack)
        deepCSVText.Draw("same")
        yStart = yStart - 0.04
    if plotDeepJet:

        deepJetText = getText("DeepJet",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.03,
                              color=ROOT.kBlack)
        deepJetText.Draw("same")
        yStart = yStart - 0.04

    if plotCSV:
        if plotDeepCSV:
            CSVText = getText("CSV      (dashed)  ",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.03,
                              color=ROOT.kBlack)
        else:
            CSVText = getText("CSV",
                              xStart=xStart,
                              yStart=yStart,
                              size=0.03,
                              color=ROOT.kBlack)
        CSVText.Draw("same")

    #offJetTextDeep.Draw("same")

    can.SaveAs(o.outDir + "/roc_" + name + ".pdf")
    can.SaveAs(o.outDir + "/roc_" + name + ".png")
Ejemplo n.º 5
0
def doVarRatio(var,
               binning,
               xTitle,
               setLogy=1,
               minX=None,
               maxX=None,
               minY=None,
               etaRange=None):
    if o.doCaloJets:
        offLF = getHist(inFile, "offJets_matchedCalo_L", var, binning,
                        ROOT.kBlack)
        hltLF = getHist(inFile, "offJets_matchedCaloJet_L", var, binning,
                        ROOT.kBlack)
        offBQ = getHist(inFile, "offJets_matchedCalo_B", var, binning,
                        ROOT.kRed)
        hltBQ = getHist(inFile, "offJets_matchedCaloJet_B", var, binning,
                        ROOT.kRed)
    elif o.doPuppiJets:
        if etaRange:
            offLF = getHist(inFile, "offJets_matchedPuppi_L" + etaRange, var,
                            binning, ROOT.kBlack)
            hltLF = getHist(inFile, "offJets_matchedPuppiJet_L" + etaRange,
                            var, binning, ROOT.kBlack)
            offBQ = getHist(inFile, "offJets_matchedPuppi_B" + etaRange, var,
                            binning, ROOT.kRed)
            hltBQ = getHist(inFile, "offJets_matchedPuppiJet_B" + etaRange,
                            var, binning, ROOT.kRed)
        else:
            offLF = getHist(inFile, "offJets_matchedPuppi_L", var, binning,
                            ROOT.kBlack)
            hltLF = getHist(inFile, "offJets_matchedPuppiJet_L", var, binning,
                            ROOT.kBlack)
            offBQ = getHist(inFile, "offJets_matchedPuppi_B", var, binning,
                            ROOT.kRed)
            hltBQ = getHist(inFile, "offJets_matchedPuppiJet_B", var, binning,
                            ROOT.kRed)
    else:
        if etaRange:
            offLF = getHist(inFile, "offJets_matched_L" + etaRange, var,
                            binning, ROOT.kBlack)
            hltLF = getHist(inFile, "offJets_matchedJet_L" + etaRange, var,
                            binning, ROOT.kBlack)
            offBQ = getHist(inFile, "offJets_matched_B" + etaRange, var,
                            binning, ROOT.kRed)
            hltBQ = getHist(inFile, "offJets_matchedJet_B" + etaRange, var,
                            binning, ROOT.kRed)
        else:
            offLF = getHist(inFile, "offJets_matched_L", var, binning,
                            ROOT.kBlack)
            hltLF = getHist(inFile, "offJets_matchedJet_L", var, binning,
                            ROOT.kBlack)
            offBQ = getHist(inFile, "offJets_matched_B", var, binning,
                            ROOT.kRed)
            hltBQ = getHist(inFile, "offJets_matchedJet_B", var, binning,
                            ROOT.kRed)

    maxY = max(offLF.GetMaximum(), offBQ.GetMaximum(), hltLF.GetMaximum(),
               hltBQ.GetMaximum())
    if setLogy:
        offLF.SetMaximum(4e0 * maxY)
        offLF.SetMinimum(1.01e-5)
    else:
        offLF.SetMaximum(1.2 * maxY)

    if not minY == None:
        offLF.SetMinimum(minY)

    offLF.GetYaxis().SetTitle("Simulated Tracks")
    offLF.GetXaxis().SetTitle(xTitle)

    if maxX:
        offLF.GetXaxis().SetRangeUser(minX, maxX)
        offBQ.GetXaxis().SetRangeUser(minX, maxX)
        hltLF.GetXaxis().SetRangeUser(minX, maxX)
        hltBQ.GetXaxis().SetRangeUser(minX, maxX)

    LFRatio = makeRatio(num=hltLF.Clone(), den=offLF.Clone())
    BQRatio = makeRatio(num=hltBQ.Clone(), den=offBQ.Clone())

    xpos = 0.2
    ypos = 0.07
    xwidth = 0.7
    ywidth = 0.1

    leg = ROOT.TLegend(xpos, ypos, xpos + xwidth, ypos + ywidth)
    leg.SetNColumns(2)
    leg.AddEntry(offBQ, "Offline tracks b-quark jets", "L")
    leg.AddEntry(offLF, "Offline tracks light-flavor jets", "L")
    leg.AddEntry(hltBQ, "HLT tracks b-quark jets", "PEL")
    leg.AddEntry(hltLF, "HLT tracks light-flavor jets", "PEL")

    canvas = makeCanvas(var, var, width=600, height=600)
    split = 0.3
    top_pad = ROOT.TPad("pad1", "The pad 80% of the height", 0, split, 1, 1, 0)
    bottom_pad = ROOT.TPad("pad2", "The pad 20% of the height", 0, 0, 1, split,
                           0)
    top_pad.Draw()
    bottom_pad.Draw()

    axissep = 0.02
    top_pad.cd()
    top_pad.SetLogy(setLogy)
    top_pad.SetTopMargin(canvas.GetTopMargin() * 1.0 / (1.0 - split))
    top_pad.SetBottomMargin(0.5 * axissep)
    top_pad.SetRightMargin(canvas.GetRightMargin())
    top_pad.SetLeftMargin(canvas.GetLeftMargin())
    top_pad.SetFillStyle(0)  # transparent
    top_pad.SetBorderSize(0)

    if var in maxDict.keys():
        offLF.GetXaxis().SetRangeUser(offLF.GetXaxis().GetXmin(), maxDict[var])

    offLF.Draw("hist")
    # hltLF.SetMarkerSize(0.75)
    hltLF.SetMarkerSize(0.5)
    #hltLF.SetMarkerStyle(21)
    hltLF.Draw("same pe")
    offBQ.Draw("hist same")
    hltBQ.SetMarkerSize(0.5)
    #hltBQ.SetMarkerStyle(21)
    hltBQ.Draw("same pe")
    leg.Draw("same")

    cmsLines = getCMSText(xStart=0.2, yStart=0.85, subtext=o.cmsText)
    for cmsl in cmsLines:
        cmsl.Draw("same")

    bottom_pad.cd()
    bottom_pad.SetTopMargin(2 * axissep)
    bottom_pad.SetBottomMargin(canvas.GetBottomMargin() * 1.0 / split)
    bottom_pad.SetRightMargin(canvas.GetRightMargin())
    bottom_pad.SetLeftMargin(canvas.GetLeftMargin())
    bottom_pad.SetFillStyle(0)  # transparent
    bottom_pad.SetBorderSize(0)
    ratio_axis = offLF.Clone()
    #ratio_axis.GetYaxis().SetTitle("PF to Calo")
    ratio_axis.GetYaxis().SetTitle("HLT to Offline")
    ratio_axis.GetXaxis().SetTitle(offLF.GetXaxis().GetTitle())
    ratio_axis.GetYaxis().SetNdivisions(507)
    rMin = 0
    rMax = 2

    if var in maxDict.keys():
        LFRatio.GetXaxis().SetRangeUser(LFRatio.GetXaxis().GetXmin(),
                                        maxDict[var])

    ratio_axis.GetYaxis().SetRangeUser(rMin, rMax)
    LFRatio.GetYaxis().SetRangeUser(rMin, rMax)
    #LFRatio.GetYaxis().SetTitle("Calo to Offline")
    #LFRatio.GetYaxis().SetTitle("PF to Calo")
    LFRatio.GetYaxis().SetTitle("HLT to Offline")

    LFRatio.Draw("PE")
    LFRatio.Draw("PE same")
    # oldSize = LFRatio.GetMarkerSize()
    oldSize = hltLF.GetMarkerSize()
    LFRatio.SetMarkerSize(0)
    LFRatio.DrawCopy("same e0")
    LFRatio.SetMarkerSize(oldSize)
    LFRatio.Draw("PE same")

    BQRatio.Draw("PE same")
    BQRatio.Draw("PE same")
    # oldSize = BQRatio.GetMarkerSize()
    oldSize = hltBQ.GetMarkerSize()
    BQRatio.SetMarkerSize(0)
    BQRatio.DrawCopy("same e0")
    BQRatio.SetMarkerSize(oldSize)
    BQRatio.Draw("PE same")

    line = ROOT.TLine()
    line.DrawLine(offLF.GetXaxis().GetXmin(), 1.0,
                  offLF.GetXaxis().GetXmax(), 1.0)

    ndivs = [505, 503]

    pads = [top_pad, bottom_pad]
    factors = [0.8 / (1.0 - split), 0.7 / split]
    for i_pad, pad in enumerate(pads):

        factor = factors[i_pad]
        ndiv = ndivs[i_pad]

        prims = [p.GetName() for p in pad.GetListOfPrimitives()]

        #
        #  Protection for scaling hists multiple times
        #
        procedHist = []

        for name in prims:

            if name in procedHist: continue
            procedHist.append(name)

            h = pad.GetPrimitive(name)
            if isinstance(
                    h, ROOT.TH1) or isinstance(h, ROOT.THStack) or isinstance(
                        h, ROOT.TGraph) or isinstance(
                            h, ROOT.TGraphErrors) or isinstance(
                                h, ROOT.TGraphAsymmErrors):
                if isinstance(h, ROOT.TGraph) or isinstance(
                        h, ROOT.THStack) or isinstance(
                            h, ROOT.TGraphErrors) or isinstance(
                                h, ROOT.TGraphAsymmErrors):
                    h = h.GetHistogram()
                #print "factor is",factor,h.GetName(),split

                if i_pad == 1:
                    h.SetLabelSize(h.GetLabelSize('Y') * factor, 'Y')
                    h.SetTitleSize(h.GetTitleSize('X') * factor, 'X')
                    h.SetTitleSize(h.GetTitleSize('Y') * factor, 'Y')
                    h.SetTitleOffset(h.GetTitleOffset('Y') / factor, 'Y')

                if i_pad == 1:
                    h.GetYaxis().SetNdivisions(ndiv)
                h.GetXaxis().SetNdivisions()
                if i_pad == 0:
                    h.SetLabelSize(0.0, 'X')
                    h.GetXaxis().SetTitle("")
                else:
                    h.SetLabelSize(h.GetLabelSize('X') * factor, 'X')
                    ## Trying to remove overlapping y-axis labels.  Doesn't work.
                    # h.GetYaxis().Set(4, h.GetYaxis().GetXmin(), h.GetYaxis().GetXmax())
                    # h.GetYaxis().SetBinLabel( h.GetYaxis().GetLast(), '')

    ##xatlas, yatlas = 0.18, 0.88
    ##atlas   = ROOT.TLatex(xatlas+0.01,   yatlas, "ATLAS")
    ###simulation = ROOT.TLatex(xatlas+0.11,   yatlas, "Simulation Internal")
    ##simulation = ROOT.TLatex(xatlas+0.11,   yatlas, "Simulation Preliminary")
    ##lumi    = ROOT.TLatex(xatlas+0.01,    yatlas-0.05, "#sqrt{s}=13 TeV, t#bar{t}")
    ##jetText = ROOT.TLatex(xatlas+0.02,   yatlas-0.1, "p_{T}^{jet} > 40 GeV, |#eta^{jet}| < 2.5" )
    ##wm      = [atlas, simulation, lumi, jetText]

    #watermarks = drawWaterMarks(wm)

    #varName = var.replace("tracks/","").replace("btags/","btags_")
    varName = var.replace("tracks/",
                          "track_").replace("btags/", "btag_").replace(
                              "btags_noV0/", "btag_noV0_")
    if etaRange:
        canvas.SaveAs(o.outDir + etaRange + "/" + varName + ".pdf")
        canvas.SaveAs(o.outDir + etaRange + "/" + varName + ".png")
    else:
        canvas.SaveAs(o.outDir + "/" + varName + ".pdf")
        canvas.SaveAs(o.outDir + "/" + varName + ".png")