def makeLxyPlot():
    hkeys = ['Lxy_{}'.format(tag) for tag in TAGS]
    HISTS = HG.getAddedSignalHistograms(FILES['Signal'], '2Mu2J', hkeys)

    for key in hkeys:
        HISTS[key].Rebin(10)

    g = {}
    for tag in TAGS:
        g[tag] = R.TGraphAsymmErrors(HISTS['Lxy_{}'.format(tag)], HISTS['Lxy_1'], 'cp')

    p = {tag:Plotter.Plot(g[tag], TAGS[tag]['leg'], 'lp', 'p') for tag in TAGS}

    c = Plotter.Canvas()
    for tag in ('1', '34', '23', '12'):
        c.addMainPlot(p[tag])
        p[tag].setColor(TAGS[tag]['col'])

    c.makeLegend(lWidth=0.2, pos='bl')

    c.firstPlot.setTitles(X='', Y='', copy=HISTS[hkeys[0]])
    c.firstPlot.SetMinimum(0.8)
    c.firstPlot.SetMaximum(1.01)

    c.cleanup('Lxy_deltaR.pdf')
def makeLxyPlot():
    hkeys = ['Lxy_{}'.format(tag) for tag in TAGS]
    HISTS = HG.getAddedSignalHistograms(FILES['Signal'], '2Mu2J', hkeys)

    for key in hkeys:
        HISTS[key].Rebin(20)

    print HISTS['Lxy_before'].Integral(HISTS['Lxy_before'].GetXaxis().FindBin(100.), HISTS['Lxy_before'].GetNbinsX()+1), \
          HISTS['Lxy_after' ].Integral(HISTS['Lxy_after' ].GetXaxis().FindBin(100.), HISTS['Lxy_after' ].GetNbinsX()+1)

    g = {}
    g['plot'] = R.TGraphAsymmErrors(HISTS['Lxy_after'], HISTS['Lxy_before'], 'cp')

    p = {}
    p['plot'] = Plotter.Plot(g['plot'], '', '', 'p')

    #p = {tag:Plotter.Plot(g[tag], TAGS[tag]['leg'], 'lp', 'hist p') for tag in TAGS}

    c = Plotter.Canvas()
    c.addMainPlot(p['plot'])
    p['plot'].setColor(R.kBlue)

    c.firstPlot.setTitles(X='', Y='', copy=HISTS[hkeys[0]])
    c.firstPlot.SetMinimum(0.95)
    c.firstPlot.SetMaximum(1.01)

    c.firstPlot.GetXaxis().SetRangeUser(0., 400.)

    c.cleanup('Lxy_globalDeltaR.pdf')
def makeEffPlot(fs, sp):
    hNum = HG.getHistogram(FILES[fs], (fs, sp), 'LxyEff').Clone()
    hDen = HG.getHistogram(FILES[fs], (fs, sp), 'LxyDen').Clone()

    hNum.Rebin(10)
    hDen.Rebin(10)

    g = R.TGraphAsymmErrors(hNum, hDen, 'cp')

    p = Plotter.Plot(g, '', '', 'p')

    prettyFS = '2#mu' if '2Mu' in fs else '4#mu'
    c = Plotter.Canvas(
        lumi='H#rightarrow2X#rightarrow{} ({} GeV, {} GeV, {} mm)'.format(
            prettyFS, *sp),
        cWidth=600 if ARGS.SQUARE else 800)

    c.addMainPlot(p)
    p.setColor(R.kBlue, which='LM')

    c.firstPlot.SetMinimum(0.)
    c.firstPlot.SetMaximum(1.)
    c.firstPlot.setTitles(X='', Y='', copy=hNum)

    if ARGS.SQUARE:
        c.firstPlot.scaleTitleOffsets(1.1, 'X')
    c.cleanup('pdfs/VFE_Lxy_{}_{}_{}_{}.pdf'.format(fs, *sp), mode='LUMI')
예제 #4
0
def makeLxyResVSLxyPlot(recoType):
    key = recoType + '-LxyResVSgenLxy'
    HISTS = HG.getAddedSignalHistograms(FILE, fs, (key,))

    upperEdge = 35
    xPoints = map(lambda z: float(z)+0.5, range(upperEdge))
    xError = [0.5] * len(xPoints)

    yPoints = []
    yError = []
    for ibin in xrange(1,upperEdge+1):
        h = HISTS[key].ProjectionY('h'+str(ibin), ibin, ibin)
        #lims = .01
        lims = 5. if recoType == 'DSA' else .05
        if recoType == 'PAT' and ibin > 10:
            lims = lims/5.
        func = R.TF1('f', 'gaus', -lims, lims)
        h.Fit('f', 'R')
        yPoints.append(func.GetParameter(2))
        yError.append(func.GetParError(2))

    g = R.TGraphErrors(len(xPoints), np.array(xPoints), np.array(yPoints), np.array(xError), np.array(yError))
    p = Plotter.Plot(g, '', '', 'pe')
    p.setTitles(X='gen L_{xy} [cm]', Y='Fitted #sigma L_{xy} Res. [cm]')

    canvas = Plotter.Canvas(lumi=fs)
    canvas.addMainPlot(p)
    if recoType == 'PAT':
        canvas.firstPlot.SetMaximum(0.020)
        canvas.firstPlot.SetMinimum(0.000)
    canvas.cleanup('pdfs/ResVSLxy_{}.pdf'.format(recoType))
예제 #5
0
def makeBinnedResPlot(MUON, fs, sp, quantity, q2):
    h = HistogramGetter.getHistogram(f, (fs, sp), '{M}_{Q}ResVS{Q2}'.format(M=MUON, Q=quantity, Q2=q2)).Clone()

    fname = 'pdfs/SRR_{}_{}_{}-Binned_{}HTo2XTo{}_{}.pdf'.format(MUON, quantity+'Res', q2, 'Trig-' if TRIGGER else '', fs, SPStr(sp))

    pretty, binranges, values, colors, colors2, legName = getBinningValues(q2)

    projections = {key:h.ProjectionY('_'+str(i), key[0], key[1]) for i,key in enumerate(binranges)}
    plots       = {key:Plotter.Plot(projections[key], legName.format(Q2=pretty, V1=values[key][0], V2=values[key][1]), 'l', 'hist') for key in binranges}

    canvas = Plotter.Canvas(lumi=SPLumiStr(fs, *sp))
    for key in binranges:
        RT.addFlows(plots[key])
        plots[key].Rebin(10)
        if plots[key].Integral() != 0:
            plots[key].Scale(1./plots[key].Integral())
        canvas.addMainPlot(plots[key])

    canvas.makeLegend(lWidth=.25, pos='tr')
    canvas.legend.moveLegend(X=-.08)
    canvas.legend.resizeHeight()
    canvas.setMaximum(recompute=True)

    for i, key in enumerate(binranges):
        plots[key].SetLineColor(colors[key])
        plots[key].setTitles(X=plots[key].GetXaxis().GetTitle(), Y='Normalized Counts')
        canvas.drawText('#color[{}]{{'.format(colors2[key]) + 'RMS = {:.4f}'.format(plots[key].GetStdDev()) + '}',
                        (canvas.legend.GetX1NDC()+.01, canvas.legend.GetY1NDC()-(i*0.04)-.04)
        )

    RT.addBinWidth(canvas.firstPlot)
    canvas.cleanup(fname)
예제 #6
0
def makeColorPlot(MUON, fs, quantity, sp=None, q2=None):
    if q2 is None:
        fstring = '{M}_{Q}VS{Q}'.format(M=MUON, Q=quantity)
    else:
        fstring = '{M}_{Q}ResVS{Q2}'.format(M=MUON, Q=quantity, Q2=q2)

    if sp is None:
        for i, SP in enumerate(SIGNALPOINTS):
            if i == 0:
                h = HistogramGetter.getHistogram(f, (fs, SP), fstring).Clone()
            else:
                h.Add(HistogramGetter.getHistogram(f, (fs, SP), fstring).Clone())
        fname = 'pdfs/SRR_{}_{}HTo2XTo{}_Global.pdf'.format(fstring, 'Trig-' if TRIGGER else '', fs)
    else:
        h = HistogramGetter.getHistogram(f, (fs, sp), fstring).Clone()
        fname = 'pdfs/SRR_{}_{}HTo2XTo{}_{}.pdf'.format(fstring, 'Trig-' if TRIGGER else '', fs, SPStr(sp))

    h.Rebin2D(10, 10)
    p = Plotter.Plot(h, '', '', 'colz')
    canvas = Plotter.Canvas(lumi=SPLumiStr(fs, *sp) if sp is not None else fs)
    canvas.mainPad.SetLogz(True)
    canvas.addMainPlot(p)
    canvas.scaleMargins(1.75, edges='R')
    canvas.scaleMargins(0.8, edges='L')
    canvas.cleanup(fname)
def makeDSAMC2DPlots():
    for quantity in ('pT', 'eta', 'trkChi2'):

        hkey = 'DSA-12-' + quantity
        HISTS, PConfig = HG.getBackgroundHistograms(
            FILES['MC'],
            hkey,
            stack=False,
            addFlows=False,
            rebin=(10, 10),
            rebinVeto=lambda key: 'trkChi2' in key)
        HISTS = HISTS[hkey]
        PConfig = PConfig[hkey]

        R.gStyle.SetPalette(56)
        PConfig['stack'] = ('', '', 'colz')
        #PConfig['stack'] = ('', '', 'scat=0.2')

        PLOTS = {}
        for key in ('stack', ):
            PLOTS[key] = Plotter.Plot(HISTS[key], *PConfig[key])
        canvas = Plotter.Canvas(lumi='MC' + lumiExtra.get(CUTSTRING))
        canvas.addMainPlot(PLOTS['stack'])
        canvas.mainPad.SetLogz()

        if quantity == 'trkChi2':
            canvas.firstPlot.GetXaxis().SetRangeUser(0., 10.)
            canvas.firstPlot.GetYaxis().SetRangeUser(0., 10.)

        canvas.scaleMargins(1.75, edges='R')
        canvas.scaleMargins(0.8, edges='L')
        canvas.cleanup('pdfs/ZEP_2D_{}_{}_MC.pdf'.format(quantity, CUTSTRING))
예제 #8
0
def makeSignalPlot(hkey):
    HISTS = HG.getAddedSignalHistograms(FILES['2Mu2J'], '2Mu2J', hkey)
    h = HISTS[hkey]
    p = Plotter.Plot(h, '', '', 'hist')
    canvas = Plotter.Canvas(lumi='Signal: H#rightarrow2X#rightarrow2#mu + *',
                            logy=True if hkey != 'nDTHits' else False)
    canvas.addMainPlot(p)
    p.SetLineColor(R.kBlue)
    canvas.firstPlot.SetMinimum(0.9)
    pave = canvas.makeStatsBox(p, color=R.kBlue)
    if hkey in ('nHits', 'LxySig'):
        Plotter.MOVE_OBJECT(pave, Y=-.3)
    canvas.mainPad.Update()
    if canvas.logy:
        line = R.TLine(
            CONFIG[hkey]['val'], canvas.firstPlot.GetMinimum(),
            CONFIG[hkey]['val'],
            10.**(R.TMath.Log10(canvas.firstPlot.GetMaximum()) * 1.06))
    else:
        line = R.TLine(CONFIG[hkey]['val'], canvas.firstPlot.GetMinimum(),
                       CONFIG[hkey]['val'],
                       canvas.firstPlot.GetMaximum() * 1.05)
    line.Draw()
    line.SetLineStyle(2)
    print '\033[31m{:6s} {:8s} {:5.0f} {:5.0f} {:7.2%}\033[m'.format(
        'Signal', hkey, *fractionCut(hkey, canvas.firstPlot.plot))
    RT.addBinWidth(canvas.firstPlot)
    canvas.cleanup('pdfs/NM1D_{}_2Mu2J.pdf'.format(hkey))
def makeColorPlots(key):
    for ref in HISTS:
        if not type(ref) == tuple: continue
        if type(ref) == tuple:
            if ref[0] == '4Mu':
                name = 'HTo2XTo4Mu_'
                latexFS = '4#mu'
            elif ref[0] == '2Mu2J':
                name = 'HTo2XTo2Mu2J_'
                latexFS = '2#mu2j'
            if TRIGGER:
                name = 'Trig-' + name
            name += SPStr(ref[1])
            lumi = SPLumiStr(ref[0], *ref[1])
        else:
            name = ref
            lumi = HistogramGetter.PLOTCONFIG[ref]['LATEX']
            if '_Matched' in key: continue

        h = HISTS[ref][key].Clone()
        h.Rebin2D(10, 10)
        p = Plotter.Plot(h, '', '', 'colz')
        canvas = Plotter.Canvas(lumi=lumi)
        #canvas.mainPad.SetLogz(True)
        canvas.addMainPlot(p)
        canvas.scaleMargins(1.75, edges='R')
        canvas.scaleMargins(0.8, edges='L')

        fname = 'pdfs/{}{}_{}.pdf'.format(key, CUTSTRING, name)
        canvas.cleanup(fname)
def makeIndividualPlots(obj, dtype, key):
    if type(key) == tuple:
        fs, sp = key
        lumi = SPLumiStr(fs, *sp)
        fname = 'pdfs/CutTable_{}-{}_{}HTo2XTo{}_{}.pdf'.format(obj, dtype, 'Trig-' if TRIGGER else '', fs, SPStr(sp))
    else:
        sample = key
        lumi = sample
        fname = 'pdfs/CutTable_{}-{}_{}.pdf'.format(obj, dtype, sample)

    p = Plotter.Plot(HISTS[obj][dtype][key], '', '', 'hist')
    canvas = Plotter.Canvas(lumi=lumi)
    canvas.addMainPlot(p)
    canvas.firstPlot.SetMaximum(1.)
    canvas.firstPlot.SetMinimum(0.)

    #canvas.firstPlot.SetMarkerColor(R.kBlue)
    #canvas.firstPlot.SetLineColor(R.kBlue)

    canvas.firstPlot.SetLineColor(4000)
    canvas.firstPlot.SetFillColor(R.kOrange)

    for ibin in xrange(1, p.GetNbinsX()+1):
        canvas.drawText(text='{:.2f}'.format(p.GetBinContent(ibin)), pos=(ibin-0.5, 0.1), align='cc', NDC=False)
    canvas.cleanup(fname)
예제 #11
0
def makeTestPlot():
    hkey = 'DSA-deltaPhi'
    HISTS = HG.getAddedSignalHistograms(FILES['2Mu2J'], '2Mu2J',
                                        ('deltaPhi', ))
    DATAHISTS, DataPConfig = HG.getDataHistograms(FILES['Data'], hkey)

    HISTS[hkey] = HISTS['deltaPhi']

    pS = Plotter.Plot(HISTS[hkey], 'H#rightarrow2X#rightarrow2#mu signal', 'l',
                      'hist')
    pD = Plotter.Plot(DATAHISTS[hkey]['data'], *DataPConfig[hkey]['data'])

    canvas = Plotter.Canvas(lumi='2#mu signal + 10% of 2016 data', logy=True)

    canvas.addMainPlot(pS)
    canvas.addMainPlot(pD)

    pS.setColor(R.kBlue, which='L')

    canvas.makeLegend(lWidth=.25)
    canvas.legend.resizeHeight()
    canvas.legend.moveLegend(X=-.1)

    canvas.firstPlot.SetMinimum(0.5)
    canvas.firstPlot.SetMaximum(50000.)
    canvas.firstPlot.setTitles(Y='Long-Lived Candidates')

    line = R.TLine(R.TMath.Pi() / 2., 0.5, R.TMath.Pi() / 2., 50000.)
    line.Draw()
    line.SetLineStyle(2)

    RT.addBinWidth(canvas.firstPlot)
    canvas.cleanup('deltaPhi.pdf')
예제 #12
0
def makePlot(config, order, fname, lumi):
    g = {}
    p = {}
    for key in config:
        hNum = getHist(config[key]['numer'])
        hDen = getHist(config[key]['denom'])
        hNum.Rebin(5)
        hDen.Rebin(5)
        g[key] = R.TGraphAsymmErrors(hNum, hDen, 'cp')
        p[key] = Plotter.Plot(g[key], config[key]['leg'], 'lp', 'pe')

    c = Plotter.Canvas(lumi=lumi)
    for key in order:
        c.addMainPlot(p[key])
        p[key].setColor(config[key]['col'], which='LM')

    if False:
        c.makeLegend(lWidth=.125, pos='tl')
        c.legend.resizeHeight()
        c.legend.moveLegend(X=.06, Y=-.4)

    if True:
        c.makeLegend(lWidth=.125, pos='tr')
        c.legend.resizeHeight()
        #c.legend.moveLegend(X=-.3)

    c.firstPlot.SetMinimum(0.)
    c.firstPlot.SetMaximum(1.)
    c.firstPlot.setTitles(X='gen L_{xy} [cm]', Y='Efficiency')

    #c.firstPlot.GetXaxis().SetRangeUser(0., 250.)

    c.cleanup('{}.pdf'.format(fname))
def makeOverlaidPlot():
    REFLIST = (('2Mu2J', (1000, 20, 2)), ('2Mu2J', (200, 50, 200)))
    key = 'Dim_deltaPhi_Matched'

    h = {
        REFLIST[0]: HISTS[REFLIST[0]][key].Clone(),
        REFLIST[1]: HISTS[REFLIST[1]][key].Clone(),
    }

    p = {}
    for ref in h:
        RT.addFlows(h[ref])
        if h[ref].GetNbinsX() > 100: h[ref].Rebin(10)
        p[ref] = Plotter.Plot(h[ref], '2#mu2j ({}, {}, {})'.format(*ref[1]),
                              'l', 'hist')

    fname = 'pdfs/{}{}_Overlaid.pdf'.format(key, CUTSTRING)

    canvas = Plotter.Canvas()
    canvas.addMainPlot(p[REFLIST[1]])
    canvas.addMainPlot(p[REFLIST[0]])
    canvas.makeLegend(lWidth=.25, pos='tl')
    #canvas.legend.moveLegend(Y=-.3)
    canvas.legend.resizeHeight()
    p[REFLIST[1]].SetLineColor(R.kBlue)
    p[REFLIST[0]].SetLineColor(R.kRed)
    RT.addBinWidth(canvas.firstPlot)

    pave1 = canvas.makeStatsBox(p[REFLIST[1]], color=R.kBlue)
    pave2 = canvas.makeStatsBox(p[REFLIST[0]], color=R.kRed)
    Plotter.MOVE_OBJECT(pave2, Y=-.22, NDC=False)
    canvas.cleanup(fname)
예제 #14
0
def makeGlobal(quantity):
    dummyX, dummyY = np.array([.1, 1000.]), np.array([0., 25.])
    dummyG = R.TGraph(2, dummyX, dummyY)
    d = Plotter.Plot(dummyG, '', '', 'p')

    n, x, y, g, p = {}, {}, {}, {}, {}
    for masses in DATA:
        n[masses] = len(DATA[masses][quantity]['x'])
        x[masses] = np.array(DATA[masses][quantity]['x'])
        y[masses] = np.array(DATA[masses][quantity]['y'])

        g[masses] = R.TGraph(n[masses], x[masses], y[masses])
        p[masses] = Plotter.Plot(g[masses], '', '', 'pl')

    c = Plotter.Canvas(lumi='{}'.format(PRETTY_LEG))
    c.addMainPlot(d)
    for masses in p:
        c.addMainPlot(p[masses])
    c.mainPad.SetLogx()

    colors = {1000:R.kRed, 400:R.kBlue, 200:R.kGreen, 125:R.kMagenta}

    d.setColor(R.kWhite, which='M')
    for masses in p:
        #p[masses].setColor(R.kBlue, which='LM')
        p[masses].setColor(colors[masses[0]], which='LM')
    c.firstPlot.setTitles(X='c#tau [cm]', Y=CONFIG[quantity]['pretty']+' Cut Value')

    c.cleanup('pdfs/RW_{}_Global_{}.pdf'.format(quantity, FIGURE_OF_MERIT))
예제 #15
0
def makeRepEffectPlots(hkey):
    HISTS, PConfig = HG.getBackgroundHistograms(FILES['MC'], hkey)
    HISTS = HISTS[hkey]
    PConfig = PConfig[hkey]

    PLOTS = {}
    for key in HG.BGORDER + ('stack', ):
        PLOTS[key] = Plotter.Plot(HISTS[key], *PConfig[key])

    canvas = Plotter.Canvas(lumi='MC, {} replacement'.format(
        hkey.replace('LxySig-', '').replace('Lxy-', '')),
                            logy=True)

    for key in HG.BGORDER:
        PLOTS[key].setColor(HG.PLOTCONFIG[key]['COLOR'], which='LF')

    canvas.addMainPlot(PLOTS['stack'])

    canvas.firstPlot.setTitles(X='', copy=PLOTS[HG.BGORDER[0]])
    canvas.firstPlot.setTitles(Y='Normalized Counts')
    canvas.makeLegend(lWidth=.27, pos='tr', autoOrder=False, fontscale=0.8)
    for ref in reversed(HG.BGORDER):
        canvas.addLegendEntry(PLOTS[ref])
    canvas.legend.resizeHeight()
    RT.addBinWidth(canvas.firstPlot)

    canvas.firstPlot.SetMaximum(10.**7.)
    canvas.firstPlot.SetMinimum(10.**0.)
    canvas.cleanup('RepEffect_MC_{}.pdf'.format(hkey))
def makeDSASignal2DPlots():
    for quantity in ('pT', 'eta', 'trkChi2'):

        hkey = 'DSA-12-' + quantity
        HISTS = HG.getAddedSignalHistograms(FILES[fs], fs, (hkey, ))
        if 'trkChi2' not in hkey: HISTS[hkey].Rebin2D(10, 10)
        for sp in SIGNALPOINTS:
            HISTS[sp] = HG.getHistogram(FILES[fs], (fs, sp), hkey).Clone()
            if 'trkChi2' not in hkey: HISTS[sp].Rebin2D(10, 10)

        opt = 'colz'
        #opt = 'scat=0.2'
        PLOTS = {hkey: Plotter.Plot(HISTS[hkey], '', '', opt)}
        for sp in SIGNALPOINTS:
            PLOTS[sp] = Plotter.Plot(HISTS[sp], '', '', opt)

        for sp in [
                hkey,
        ] + SIGNALPOINTS:
            canvas = Plotter.Canvas(lumi=fs + lumiExtra.get(CUTSTRING) if
                                    type(sp) != tuple else SPLumiStr(fs, *sp))
            canvas.addMainPlot(PLOTS[sp])
            canvas.mainPad.SetLogz()

            if quantity == 'trkChi2':
                canvas.firstPlot.GetXaxis().SetRangeUser(0., 10.)
                canvas.firstPlot.GetYaxis().SetRangeUser(0., 10.)

            canvas.scaleMargins(1.75, edges='R')
            canvas.scaleMargins(0.8, edges='L')
            canvas.cleanup('pdfs/ZEP_2D_{}_{}_{}_{}.pdf'.format(
                quantity, CUTSTRING, fs,
                'Global' if type(sp) != tuple else SPStr(sp)))
예제 #17
0
def makeLxyEffPlot(key, colorAxis, fs, sp, pTCut=''):

    config = {
        'Correct': ('Correct', 'Matches'),
    }
    if colorAxis == 'nMuons':
        num, den = config[key]

        nums = ['Lxy' + pTCut + '_n' + num + '_' + m for m in mnames]
        dens = ['Lxy' + pTCut + '_n' + den + '_' + m for m in mnames]
        tags = list(set(nums + dens))
        legs = {
            num: m if 'All' in m else m + ' #mu'
            for num, m in zip(nums, mnames)
        }
        cols = {num: c for num, c in zip(nums, colors)}

    if sp is None:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, SIGNALPOINTS[0]),
                                                  tag).Clone()
        for SP in SIGNALPOINTS[1:]:
            for tag in tags:
                h[tag].Add(HistogramGetter.getHistogram(f, (fs, SP), tag))
    else:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, sp), tag).Clone()

    for z in h:
        h[z].Rebin(10)

    p = {}
    graphs = {}
    for num, den in zip(nums, dens):
        realDen = h[den].Clone()
        graphs[num] = R.TGraphAsymmErrors(h[num], realDen, 'cp')
        p[num] = Plotter.Plot(graphs[num], legs[num], 'l', 'px')

    canvas = Plotter.Canvas(lumi=SPLumiStr(fs, sp) if sp is not None else fs)
    for tag in nums:
        canvas.addMainPlot(p[tag])
    canvas.firstPlot.SetMaximum(1.01)
    canvas.firstPlot.SetMinimum(0.)
    canvas.firstPlot.setTitles(X=h[tags[0]].GetXaxis().GetTitle(),
                               Y='Efficiency')
    for tag in p:
        p[tag].setColor(cols[tag], which='LM')

    canvas.makeLegend(lWidth=.275, pos='tr')
    canvas.legend.resizeHeight()

    canvas.cleanup('pdfs/RA_{}-Lxy{}-{}{}_HTo2XTo{}_{}.pdf'.format(
        'ComboMu' if colorAxis == 'nMuons' else 'ComboEff', pTCut, key,
        ARGS.CUTSTRING, fs,
        SPStr(sp) if sp is not None else 'Global'))
예제 #18
0
def makeMCPlots():
    f = R.TFile.Open('roots/PATMuonStudyPlots_Combined_BS8_MC.root')
    #f = R.TFile.Open('roots/PATMuonStudyPlots_Combined_BS8_MC_OldPATMatch.root')
    BGORDER = ('WJets', 'WW', 'WZ', 'ZZ', 'tW', 'tbarW', 'ttbar', 'QCD20toInf-ME', 'DY10to50', 'DY50toInf')
    PC = HG.PLOTCONFIG
    for hkey in ('PAT-LxySig', 'DSA-LxySig', 'PAT-vtxChi2', 'DSA-vtxChi2'):
        HISTS = {}
        HISTS['stack'] = R.THStack('hStack', '')
        PConfig = {'stack':('', '', 'hist')}
        for ref in BGORDER:
           HISTS[ref] = HG.getHistogram(f, ref, hkey).Clone()
           #RT.addFlows(HISTS[ref])
           HISTS[ref].Scale(PC[ref]['WEIGHT'])
           HISTS[ref].Rebin(10)
           HISTS['stack'].Add(HISTS[ref])
           PConfig[ref] = (PC[ref]['LATEX'], 'f', 'hist')

        PLOTS = {}
        for key in BGORDER + ('stack',):
            PLOTS[key] = Plotter.Plot(HISTS[key], *PConfig[key])
        canvas = Plotter.Canvas(logy=True)
        for key in BGORDER:
            PLOTS[key].setColor(PC[key]['COLOR'], which='LF')
        canvas.addMainPlot(PLOTS['stack'])
        # this has to be here because it has to be drawn first
        if 'LxySig' in hkey:
            canvas.firstPlot.GetXaxis().SetRangeUser(0., 1000.)
            pass
        if 'vtxChi2' in hkey:
            #canvas.firstPlot.GetXaxis().SetRangeUser(0., 200.)
            pass
        canvas.firstPlot.setTitles(X='', copy=PLOTS[BGORDER[0]])
        canvas.firstPlot.setTitles(Y='Normalized Counts')
        canvas.makeLegend(lWidth=.27, pos='tr', autoOrder=False, fontscale=0.8)
        for ref in reversed(BGORDER):
            canvas.addLegendEntry(PLOTS[ref])
        canvas.legend.resizeHeight()
        RT.addBinWidth(canvas.firstPlot)

        HISTS['sum'] = HISTS['stack'].GetStack().Last()
        nBins = HISTS['sum'].GetNbinsX()

        if 'LxySig' in hkey:
            val = 100.
        if 'vtxChi2' in hkey:
            val = 50.
        print '{} Mean         : {}'.format(hkey,      HISTS['sum'].GetMean())
        print '{} Overflow   % : {}'.format(hkey,      HISTS['sum'].GetBinContent(                           nBins+1)/HISTS['sum'].Integral(0, nBins+1)*100.)
        print '{} > {:<8.0f} % : {}'.format(hkey, val, HISTS['sum'].Integral     (HISTS['sum'].FindBin(val), nBins+1)/HISTS['sum'].Integral(0, nBins+1)*100.)

        if hkey == 'PAT-LxySig':
            h = HG.getHistogram(f, 'DY50toInf', hkey).Clone()
            print '{} DY50toInf    : {}'.format(hkey, h.Integral(h.FindBin(100.), h.GetNbinsX()+1))

        canvas.firstPlot.SetMaximum(HISTS['sum'].GetMaximum()*1.05)
        canvas.firstPlot.SetMinimum(1.)
        canvas.cleanup('pdfs/MC_'+hkey+'.pdf')
예제 #19
0
def makeDistPlot(quantity, criteria, fs, sp=None):
    # configy type stuff
    legs = ('All', 'Matched', 'NotMatched')
    tags = [
        quantity + '_' + ('All' + ('-4' if '-4' in criteria else '')
                          if 'All' in leg else criteria + '_' + leg)
        for leg in legs
    ]
    cols = (R.kBlack, R.kBlue, R.kRed)

    # get/add histograms
    if sp is None:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, SIGNALPOINTS[0]),
                                                  tag).Clone()
        for SP in SIGNALPOINTS[1:]:
            for tag in tags:
                h[tag].Add(HistogramGetter.getHistogram(f, (fs, SP), tag))
    else:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, sp), tag).Clone()

    # make plots
    p = {}
    for i, tag in enumerate(tags):
        p[tag] = Plotter.Plot(h[tag], legs[i], 'l', 'hist')

    # canvas, plots, min max
    logy = True
    canvas = Plotter.Canvas(lumi=SPLumiStr(fs, sp) if sp is not None else fs,
                            logy=logy)
    for tag in tags:
        canvas.addMainPlot(p[tag])
    canvas.setMaximum()
    if not logy:
        canvas.firstPlot.SetMinimum(0)
    else:
        canvas.firstPlot.SetMinimum(1.)
    if 'Lxy' in quantity:
        canvas.firstPlot.GetXaxis().SetRangeUser(0., 330.)

    # colors
    for i, tag in enumerate(tags):
        p[tag].SetLineColor(cols[i])

    # legend, cleanup
    canvas.makeLegend(lWidth=.2, pos='tr')
    canvas.legend.resizeHeight()

    canvas.cleanup('pdfs/LCD_{}Dist_{}{}_HTo2XTo{}_{}.pdf'.format(
        quantity, criteria, ARGS.CUTSTRING, fs,
        SPStr(sp) if sp is not None else 'Global'))
예제 #20
0
def makeStackPlot(key, colorAxis, fs, sp):

    if colorAxis == 'nMuons':
        tags = ['n' + key + '_' + m for m in mnames[1:]]
        legs = {tag: m + ' #mu' for tag, m in zip(tags, mnames[1:])}
        cols = {tag: R.kRed + i for i, tag in enumerate(tags)}

    elif colorAxis == 'Eff':
        tags = ['n' + k + '_' + key for k in hnames[1:]]
        legs = {tag: k for tag, k in zip(tags, hnames[1:])}
        cols = {tag: c for tag, c in zip(tags, colors[1:])}

    if sp is None:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, SIGNALPOINTS[0]),
                                                  tag).Clone()
        for SP in SIGNALPOINTS[1:]:
            for tag in tags:
                h[tag].Add(HistogramGetter.getHistogram(f, (fs, SP), tag))
    else:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, sp), tag).Clone()

    h['stack'] = R.THStack('hBG' + key, '')
    p = {}
    for tag in tags:
        if fs == '4Mu' and 'Event' in tag and colorAxis == 'Eff':
            h[tag].Scale(2.)
        h['stack'].Add(h[tag])
    p['stack'] = Plotter.Plot(h['stack'], '', '',
                              'hist' if colorAxis == 'nMuons' else 'nostack')
    for tag in tags:
        p[tag] = Plotter.Plot(h[tag], legs[tag], 'f', 'hist')

    for tag in tags:
        p[tag].setColor(cols[tag], which='LMF')

    canvas = Plotter.Canvas(lumi=SPLumiStr(fs, sp) if sp is not None else fs)
    for tag in ('stack', ):
        canvas.addMainPlot(p[tag])
    if colorAxis == 'nMuons':
        canvas.setMaximum(recompute=True)
    canvas.firstPlot.SetMinimum(0.)
    canvas.makeLegend(lWidth=.2, pos='tr', autoOrder=False)
    canvas.firstPlot.setTitles(X=h[tags[0]].GetXaxis().GetTitle(), Y='Counts')
    for tag in tags:
        canvas.addLegendEntry(p[tag])
    canvas.legend.resizeHeight()

    canvas.cleanup('pdfs/RA_{}-{}{}_HTo2XTo{}_{}.pdf'.format(
        'StackMu' if colorAxis == 'nMuons' else 'StackEff', key,
        ARGS.CUTSTRING, fs, sp if sp is not None else 'Global'))
def makeLessMorePlot(fs, sp, quantity):
    h = {
        'Less':
        HG.getHistogram(FILES[fs], (fs, sp),
                        '{}-Less'.format(quantity)).Clone(),
        'More':
        HG.getHistogram(FILES[fs], (fs, sp),
                        '{}-More'.format(quantity)).Clone(),
    }

    for key in h:
        try:
            h[key].Scale(1. / h[key].Integral())
        except:
            return

    pretty = {
        'Less': {
            'leg': 'L_{xy} < 320 cm',
            'col': R.kBlue
        },
        'More': {
            'leg': 'L_{xy} > 320 cm',
            'col': R.kRed
        },
    }

    p = {
        key: Plotter.Plot(h[key], pretty[key]['leg'], 'l', 'hist')
        for key in h
    }

    prettyFS = '2#mu' if '2Mu' in fs else '4#mu'
    c = Plotter.Canvas(
        lumi='H#rightarrow2X#rightarrow{} ({} GeV, {} GeV, {} mm)'.format(
            prettyFS, *sp),
        cWidth=600 if ARGS.SQUARE else 800)

    for key in p:
        c.addMainPlot(p[key])
        p[key].setColor(pretty[key]['col'], which='LM')

    RT.addBinWidth(c.firstPlot)
    c.makeLegend(lWidth=0.125, pos='tr')
    c.legend.resizeHeight()
    c.legend.moveLegend(X=-.4)
    c.setMaximum()

    if ARGS.SQUARE:
        c.firstPlot.scaleTitleOffsets(1.1, 'X')
    c.cleanup('pdfs/LESSMORE_{}_{}_{}_{}_{}.pdf'.format(quantity, fs, *sp),
              mode='LUMI')
예제 #22
0
def makePerSignalPlots(fs):
    for sp in SIGNALPOINTS:
        for key in HISTS[(fs, sp)]:
            h = HISTS[(fs, sp)][key]
            RT.addFlows(h)
            p = Plotter.Plot(h, '', 'p', 'hist')
            canvas = Plotter.Canvas(lumi=SPLumiStr(fs, *sp))
            canvas.addMainPlot(p)
            p.SetLineColor(R.kBlue)
            RT.addBinWidth(p)
            pave = canvas.makeStatsBox(p, color=R.kBlue)
            canvas.cleanup('pdfs/Gen_{}_{}HTo2XTo{}_{}.pdf'.format(
                key, 'Trig-' if TRIGGER else '', fs, SPStr(sp)))
def makeLxyResVSLxyPlot(recoType):
    key = recoType + '-LxyResVSGEN-Lxy'
    HISTS = HG.getAddedSignalHistograms(FILES[fs], fs, (key, ))

    config = {
        'PAT': (35, 1),
        'HYB': (70, 2),
        'DSA': (350, 10),
    }

    upperEdge = config[recoType][0]
    step = config[recoType][1]
    xPoints = map(lambda z: float(z) + float(step) / 2.,
                  range(0, upperEdge, step))
    xError = [float(step) / 2.] * len(xPoints)

    yPoints = []
    yError = []
    for ibin in xrange(1, upperEdge + 1):
        if (ibin + step / 2) % step != 0: continue
        binRange = (ibin - int(step / 2. - 1), ibin + int(step / 2.))
        h = HISTS[key].ProjectionY('h' + str(ibin), *binRange)
        #lims = .01
        #lims = 5. if recoType == 'DSA' else .05
        lims = {'DSA': 15., 'PAT': .05, 'HYB': 5.}
        lims = lims[recoType]
        if recoType == 'PAT' and ibin > 10:
            lims = lims / 5.
        func = R.TF1('f', 'gaus', -lims, lims)
        h.Fit('f', 'Rq')
        yPoints.append(func.GetParameter(2))
        yError.append(func.GetParError(2))

    g = R.TGraphErrors(len(xPoints), np.array(xPoints), np.array(yPoints),
                       np.array(xError), np.array(yError))
    p = Plotter.Plot(g, '', '', 'pe')
    p.setTitles(X='gen L_{xy} [cm]', Y='Fitted #sigma L_{xy} Res. [cm]')

    canvas = Plotter.Canvas(lumi=fs + lumiExtra.get(CUTSTRING) +
                            ' ({})'.format(recoType))
    canvas.addMainPlot(p)
    canvas.firstPlot.SetMinimum(0.)
    if recoType == 'PAT':
        canvas.firstPlot.SetMaximum(0.02)
    if recoType == 'HYB':
        canvas.firstPlot.SetMaximum(5.)
    if recoType == 'DSA':
        canvas.firstPlot.SetMaximum(10.)
    canvas.cleanup('pdfs/ZEP_ResVSLxy_{}_{}_{}.pdf'.format(
        recoType, CUTSTRING, fs))
def makeEffPlot(fs, sp):
    if sp is None:
        hNum = HG.getAddedSignalHistograms(FILES[fs], fs, 'Lxy-Num')['Lxy-Num']
        hDen = HG.getAddedSignalHistograms(FILES[fs], fs, 'Lxy-Den')['Lxy-Den']
    else:
        hNum = HG.getHistogram(FILES[fs], (fs, sp), 'Lxy-Num').Clone()
        hDen = HG.getHistogram(FILES[fs], (fs, sp), 'Lxy-Den').Clone()

        hNumInt = hNum.Integral(hNum.GetXaxis().FindBin(65.),
                                hNum.GetNbinsX() + 1)
        hDenInt = hDen.Integral(hDen.GetXaxis().FindBin(65.),
                                hDen.GetNbinsX() + 1)

        #if sp == (sp[0], sp[1], SIGNALS[sp[0]][sp[1]][0]): return
        print '{:5s} {:4d} {:3d} {:4d} ::: {:5.0f} {:5.0f} {:7.2%}'.format(
            fs, sp[0], sp[1], sp[2], hNumInt, hDenInt,
            hNumInt / hDenInt if hDenInt != 0. else 0.)

        return

    hNum.Rebin(2)
    hDen.Rebin(2)

    g = R.TGraphAsymmErrors(hNum, hDen, 'cp')

    p = Plotter.Plot(g, '', '', 'p')

    prettyFS = '2#mu' if '2Mu' in fs else '4#mu'
    if sp is not None:
        lumi = 'H#rightarrow2X#rightarrow{} ({} GeV, {} GeV, {} mm)'.format(
            prettyFS, *sp)
    else:
        lumi = 'H#rightarrow2X#rightarrow{}, all samples combined'.format(
            prettyFS)
    c = Plotter.Canvas(lumi=lumi, cWidth=600 if ARGS.SQUARE else 800)

    c.addMainPlot(p)
    p.setColor(R.kBlue, which='LM')

    c.firstPlot.SetMinimum(0.)
    c.firstPlot.SetMaximum(1.)
    c.firstPlot.setTitles(X='', copy=hNum)
    c.firstPlot.setTitles(
        Y='Efficiency for pairing criteria to select correct dimuons')

    if ARGS.SQUARE:
        c.firstPlot.scaleTitleOffsets(1.1, 'X')
    c.cleanup('pdfs/PC_Lxy_{}_{}.pdf'.format(
        fs, 'Global' if sp is None else SPStr(sp)),
              mode='LUMI')
예제 #25
0
def makePTCutPlot(fs, sp=None):
    # configy type stuff
    legs = ('All', 'Matched', 'Wrong', 'Right', 'Hopeless', 'Lost')
    tags = ['pT_' + tag for tag in legs]
    cols = (R.kBlack, R.kGreen, R.kOrange, R.kBlue, R.kRed, R.kMagenta)

    # get/add histograms
    if sp is None:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, SIGNALPOINTS[0]),
                                                  tag).Clone()
        for SP in SIGNALPOINTS[1:]:
            for tag in tags:
                h[tag].Add(HistogramGetter.getHistogram(f, (fs, SP), tag))
    else:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, sp), tag).Clone()

    # make plots
    p = {}
    for i, tag in enumerate(tags):
        p[tag] = Plotter.Plot(h[tag], legs[i], 'l', 'hist')

    # canvas, plots, min max
    logy = True
    canvas = Plotter.Canvas(lumi=SPLumiStr(fs, sp) if sp is not None else fs,
                            logy=logy)
    for tag in tags:
        canvas.addMainPlot(p[tag])
    canvas.setMaximum()
    if not logy:
        canvas.firstPlot.SetMinimum(0)
    else:
        canvas.firstPlot.SetMinimum(1.)
    #canvas.firstPlot.GetXaxis().SetRangeUser(0., 200.)
    canvas.firstPlot.GetXaxis().SetRangeUser(0., 30.)

    # colors
    for i, tag in enumerate(tags):
        p[tag].SetLineColor(cols[i])

    # legend, cleanup
    canvas.makeLegend(lWidth=.2, pos='tr')
    canvas.legend.resizeHeight()

    canvas.cleanup('pdfs/HPD_pTDist_HTo2XTo{}_{}.pdf'.format(
        fs,
        SPStr(sp) if sp is not None else 'Global'))
def makePerSamplePlots():
    for ref in HISTS:
        for key in HISTS[ref]:
            if 'DenVS' in key: continue

            matches = re.match(r'(.*)EffVS(.*)', key)

            cut = matches.group(1)
            val = matches.group(2)

            if cut in Selections.CutLists['MuonCutList'] and val == 'Lxy':
                continue
            if cut in Selections.CutLists['DimuonCutList'] and val in ('pT',
                                                                       'eta',
                                                                       'd0'):
                continue

            if type(ref) == tuple:
                if ref[0] == '4Mu': name = 'HTo2XTo4Mu_'
                elif ref[0] == '2Mu2J': name = 'HTo2XTo2Mu2J_'
                name += SPStr(ref[1])
                if TRIGGER:
                    name = 'Trig-' + name
                lumi = SPLumiStr(ref[0], *ref[1])
                legName = HistogramGetter.PLOTCONFIG['HTo2XTo' +
                                                     ref[0]]['LATEX']
            else:
                name = ref
                lumi = HistogramGetter.PLOTCONFIG[ref]['LATEX']
                legName = HistogramGetter.PLOTCONFIG[ref]['LATEX']

            h = HISTS[ref][key].Clone()
            RT.addFlows(h)
            d = HISTS[ref][key.replace('Eff', 'Den')].Clone()
            RT.addFlows(d)
            g = R.TGraphAsymmErrors(h, d, 'cp')
            g.SetNameTitle(
                'g_' + key,
                ';' + h.GetXaxis().GetTitle() + ';' + h.GetYaxis().GetTitle())
            p = Plotter.Plot(g, '', 'pe', 'pe')

            canvas = Plotter.Canvas(lumi=lumi)
            canvas.addMainPlot(p)
            p.setColor(R.kBlue)
            canvas.firstPlot.SetMinimum(0.)
            canvas.firstPlot.SetMaximum(1.)

            fname = 'pdfs/NM1E_{}_{}.pdf'.format(key, name)
            canvas.cleanup(fname)
def makeMC2DPlots(BGList=None, SUFFIX=None):
    if BGList is None:
        BGORDER = ('WJets', 'WW', 'WZ', 'ZZ', 'tW', 'tbarW', 'ttbar',
                   'QCD20toInf-ME', 'DY10to50', 'DY50toInf')
        SUFFIX = 'Full'
    else:
        BGORDER = BGList
        if SUFFIX is None:
            SUFFIX = BGList[0]
    for quantity in ('normChi2', 'nTrkLay', 'nPxlHit', 'highPurity',
                     'isGlobal', 'isMedium', 'hitsBeforeVtx',
                     'missingHitsAfterVtx'):
        if quantity == 'nTrkLay':
            R.gStyle.SetPaintTextFormat('.1f')
        else:
            R.gStyle.SetPaintTextFormat('g')

        hkey = 'PAT-12-' + quantity
        HG.BGORDER = BGORDER  # don't do this, normally
        HISTS, PConfig = HG.getBackgroundHistograms(FILES['MC'],
                                                    hkey,
                                                    stack=False,
                                                    addFlows=False)
        HG.BGORDER = BGORDER_REAL
        HISTS = HISTS[hkey]
        PConfig = PConfig[hkey]

        if quantity != 'normChi2':
            R.gStyle.SetPalette(55)
            PConfig['stack'] = ('', '', 'colz text')
        else:
            R.gStyle.SetPalette(56)
            PConfig['stack'] = ('', '', 'colz')

        PLOTS = {}
        for key in ('stack', ):
            PLOTS[key] = Plotter.Plot(HISTS[key], *PConfig[key])
        canvas = Plotter.Canvas(lumi=SUFFIX + lumiExtra.get(CUTSTRING))
        canvas.addMainPlot(PLOTS['stack'])
        canvas.firstPlot.SetMarkerColor(R.kWhite)

        if quantity == 'normChi2':
            canvas.firstPlot.GetXaxis().SetRangeUser(0., 10.)
            canvas.firstPlot.GetYaxis().SetRangeUser(0., 10.)

        canvas.scaleMargins(1.75, edges='R')
        canvas.scaleMargins(0.8, edges='L')
        canvas.cleanup('pdfs/ZEP_2D_{}_{}_{}_MC.pdf'.format(
            quantity, SUFFIX, CUTSTRING))
def savePlot(data, filename, extList=[".pdf", ".root"], lumi="", x_range=None):
    c = Plotter.Canvas(lumi=lumi)
    if isinstance(data, Plotter.Plot):
        plot = data.Clone()
    else:
        plot = Plotter.Plot(data, "", "elp", "pe")

    c.addMainPlot(plot)

    if x_range:
        c.firstPlot.GetXaxis().SetRangeUser(x_range[0], x_range[1])

    c.finishCanvas()
    c.save(filename, extList=extList)
    c.deleteCanvas()
def makeGenRecoPlots():
    for ref in HISTS:
        if not type(ref) == tuple: continue
        if ref[0] == '4Mu':
            name = 'HTo2XTo4Mu_'
            latexFS = '4#mu'
        elif ref[0] == '2Mu2J':
            name = 'HTo2XTo2Mu2J_'
            latexFS = '2#mu2j'
        if TRIGGER:
            name = 'Trig-' + name
        name += SPStr(ref[1])
        lumi = SPLumiStr(ref[0], *ref[1])

        colors = {'Matched': R.kRed, 'Closest': R.kBlue}
        KEYS = ('Matched', 'Closest')

        for MUON in ('DSA', 'REF'):
            h, p = {}, {}
            for key in KEYS:
                h[key] = HISTS[ref]['{}_{}_{}'.format(MUON, 'deltaRGR',
                                                      key)].Clone()
                RT.addFlows(h[key])
                if h[key].GetNbinsX() > 100: h.Rebin(10)
                p[key] = Plotter.Plot(h[key], key, 'l', 'hist')
            fname = 'pdfs/{}{}_{}_{}_{}.pdf'.format(MUON, CUTSTRING,
                                                    'deltaRGR', 'Matched',
                                                    name)

            canvas = Plotter.Canvas(lumi=lumi)
            for key in KEYS:
                canvas.addMainPlot(p[key])
                p[key].SetLineColor(colors[key])

            canvas.makeLegend(lWidth=.25, pos='tr')
            canvas.legend.resizeHeight()
            canvas.setMaximum()
            RT.addBinWidth(canvas.firstPlot)

            LPOS = (canvas.legend.GetX1NDC() + .01,
                    canvas.legend.GetY1NDC() - .04)

            for i, key in enumerate(KEYS):
                canvas.drawText(text='#color[{}]{{n = {:d}}}'.format(
                    colors[key], int(p[key].GetEntries())),
                                pos=(LPOS[0], LPOS[1] - i * 0.04))

            canvas.cleanup(fname)
예제 #30
0
def makeEffPlot(quantity, den, fs, sp=None):
    tags = (quantity + '_MSD', quantity + '_LCD', quantity + '_CID')

    effTag = quantity + '_CID'

    # get/add histograms
    if sp is None:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, SIGNALPOINTS[0]),
                                                  tag).Clone()
        for SP in SIGNALPOINTS[1:]:
            for tag in tags:
                h[tag].Add(HistogramGetter.getHistogram(f, (fs, SP), tag))
    else:
        h = {}
        for tag in tags:
            h[tag] = HistogramGetter.getHistogram(f, (fs, sp), tag).Clone()

    hNum = h[quantity + '_CID']
    h[quantity + '_' + den].Add(h[quantity + '_CID'])
    hDen = h[quantity + '_' + den]

    graph = R.TGraphAsymmErrors(hNum, hDen, 'cp')

    # make plots
    p = Plotter.Plot(graph, '', 'l', 'px')

    # canvas, plots, min max
    canvas = Plotter.Canvas(lumi=SPLumiStr(fs, sp) if sp is not None else fs)
    canvas.addMainPlot(p)
    canvas.setMaximum()
    canvas.firstPlot.SetMinimum(0)

    # set titles
    canvas.firstPlot.setTitles(X=hNum.GetXaxis().GetTitle(), Y='Efficiency')

    # colors
    p.setColor(R.kBlue, which='M')

    # legend, cleanup
    #canvas.makeLegend(lWidth=.2, pos='tr')
    #canvas.legend.resizeHeight()

    canvas.cleanup('pdfs/3Mu_{}Eff-{}{}_HTo2XTo{}_{}.pdf'.format(
        quantity, den, ARGS.CUTSTRING, fs,
        SPStr(sp) if sp is not None else 'Global'))