Beispiel #1
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 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))
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 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 Background, {} PAT association (36.3 fb^{{-1}})'.format(
            hkey.replace('LxySig-', '').replace('Lxy-', '')),
        logy=True,
        cWidth=600 if ARGS.SQUARE else 800)

    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='Event Yield')
    canvas.makeLegend(lWidth=.3, 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.)

    if ARGS.SQUARE:
        canvas.firstPlot.scaleTitleOffsets(1.1, 'X')

    z = PLOTS['stack'].plot.GetStack().Last()
    print 'MC', hkey, z.Integral(0, z.GetNbinsX() + 1)
    canvas.cleanup('pdfs/REPEFF_MC_{}.pdf'.format(hkey), mode='LUMI')
def makeIntegratedSEQMC(hkey='SEQ'):
    if DODATA:
        HISTS, PConfig = HG.getBackgroundHistograms(FILES['MC'],
                                                    hkey,
                                                    extraScale=DATASCALE)
        DATAHISTS, DataPConfig = HG.getDataHistograms(FILES['Data'], hkey)
    else:
        HISTS, PConfig = HG.getBackgroundHistograms(FILES['MC'], hkey)

    HISTS = HISTS[hkey]
    PConfig = PConfig[hkey]

    if DODATA:
        DATAHISTS = DATAHISTS[hkey]
        PConfig['data'] = DataPConfig[hkey]['data']

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

    if DODATA:
        PLOTS['data'] = Plotter.Plot(DATAHISTS['data'], *PConfig['data'])

    canvas = Plotter.Canvas(
        lumi='MC' if not DODATA else 'MC + Data',
        logy=True,
        cWidth=1600,
    )
    #       ratioFactor=0. if not DODATA else 1./3., fontscale=1. if not DODATA else 1.+1./3.)

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

    canvas.addMainPlot(PLOTS['stack'])

    if DODATA:
        canvas.addMainPlot(PLOTS['data'])

    setBinLabels(canvas)

    canvas.makeLegend(lWidth=.27, pos='tr', autoOrder=False,
                      fontscale=0.8)  # if not DODATA else 1.)
    if DODATA:
        canvas.addLegendEntry(PLOTS['data'])
    for ref in reversed(HG.BGORDER):
        canvas.addLegendEntry(PLOTS[ref])
    canvas.legend.resizeHeight()
    canvas.legend.moveLegend(X=.1)

    canvas.firstPlot.setTitles(X='Cut', Y='Normalized Counts')
    canvas.firstPlot.SetMaximum(2.e7)
    canvas.firstPlot.SetMinimum(1.e4 if 'DSA' not in hkey else 1.e-1)

    canvas.scaleMargins(.5, 'L')
    canvas.firstPlot.scaleTitleOffsets(.5, 'Y')
    R.TGaxis.SetExponentOffset(0., 0.02, "y")

    #    if DODATA:
    #        canvas.makeRatioPlot(PLOTS['data'].plot, PLOTS['stack'].plot.GetStack().Last())
    #        canvas.firstPlot.scaleTitleOffsets(0.8, axes='Y')
    #        canvas.rat      .scaleTitleOffsets(0.8, axes='Y')
    #        canvas.rat.setTitles(X='', copy=canvas.firstPlot.plot)
    #        setBinLabels(canvas, '')

    #canvas.cleanup('pdfs/NM1_{}_MC.pdf'.format(hkey))
    #canvas.finishCanvas(extrascale=1. if not DODATA else 1.+1./3.)
    #canvas.save('pdfs/NM1_{}{}_MC.pdf'.format(hkey, BUMPSTRING))
    #canvas.deleteCanvas()
    canvas.cleanup('pdfs/NM1_{}{}{}_MC.pdf'.format(hkey, BUMPSTRING,
                                                   IDPHISTRING))
def makeMCPlots():
    quantities = {
        'DSA': [],
        'PAT': [],
        'HYB': [],
        'HYB-DSA': [],
        'HYB-PAT': []
    }
    dimQuantities = [
        'Lxy', 'LxySig', 'LxyErr', 'vtxChi2', 'mind0Sig', 'mass', 'deltaPhi',
        'deltaR', 'cosAlpha', 'cosAlpha-O', 'DCA', 'pTOverM', 'minNHits',
        'qsum'
    ]
    for recoType in quantities:
        if 'HYB-' in recoType: continue
        quantities[recoType].extend(dimQuantities)

    quantities['HYB-DSA'].extend(
        ['pT', 'eta', 'phi', 'd0', 'FPTE', 'd0Sig', 'trkChi2', 'nStations'])
    quantities['HYB-PAT'].extend(
        ['pT', 'eta', 'phi', 'd0', 'relTrkIso', 'd0Sig', 'trkChi2'])

    for recoType in ('DSA', 'PAT'):
        quantities[recoType].extend(quantities['HYB-' + recoType])

    quantities['REF-DSA'] = ['FPTE']
    quantities[''] = ['nDimuon', 'nDSA', 'nDSA12', 'nDSA12-pT', 'nDSA-DT']

    # consider making deltaPhi not log scale. If so, then uncomment the maximum commands at the bottom

    def rebinVeto(key):
        if 'Lxy' in key and 'Sig' not in key and 'Err' not in key and 'DSA' not in key:
            return True
        if 'deltaPhi' in key or 'phi' in key: return True
        if 'mass' in key and MASSZOOMED: return True
        if 'nStations' in key: return True
        if 'cosAlpha' in key: return True
        if 'LxySig' in key and 'DSA' in key: return True
        if 'mind0Sig' in key and 'DSA' in key: return True
        if 'd0' in key and 'Sig' not in key and 'DSA' in key: return True
        if 'trkChi2' in key: return True
        if 'nDimuon' in key: return True
        if 'nDSA' in key: return True
        if 'REF-DSA-FPTE' in key: return True
        if 'minNHits' in key: return True
        if 'qsum' in key: return True
        return False

    for recoType in quantities:
        for quantity in quantities[recoType]:
            hkey = recoType + '-' + quantity
            if hkey[0] == '-' or recoType == 'DSAPlus':
                hkey = quantity
                recoType = 'DSAPlus'

            DODATA = recoType == 'DSA' or recoType == 'REF-DSA' or (
                recoType == 'DSAPlus' and 'nDSA' in quantity)

            if DODATA:
                HISTS, PConfig = HG.getBackgroundHistograms(
                    FILES['MC'],
                    hkey,
                    addFlows=True,
                    rebin=10,
                    rebinVeto=rebinVeto,
                    extraScale=DATASCALE)
                DATAHISTS, DataPConfig = HG.getDataHistograms(
                    FILES['Data'],
                    hkey,
                    addFlows=True,
                    rebin=10,
                    rebinVeto=rebinVeto)
            else:
                HISTS, PConfig = HG.getBackgroundHistograms(
                    FILES['MC'],
                    hkey,
                    addFlows=True,
                    rebin=10,
                    rebinVeto=rebinVeto)

            HISTS = HISTS[hkey]
            PConfig = PConfig[hkey]

            if DODATA:
                DATAHISTS = DATAHISTS[hkey]
                PConfig['data'] = DataPConfig[hkey]['data']

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

            if DODATA:
                PLOTS['data'] = Plotter.Plot(DATAHISTS['data'],
                                             *PConfig['data'])

            canvas = Plotter.Canvas(
                lumi=('MC' if not DODATA else 'MC + Data') +
                lumiExtra.get(CUTSTRING) + ' ({})'.format(recoType),
                logy=True,
                ratioFactor=0. if not DODATA else 1. / 3.,
                fontscale=1. if not DODATA else 1. + 1. / 3.)

            if hkey == 'REF-DSA-FPTE':
                canvas.mainPad.SetLogx()

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

            canvas.addMainPlot(PLOTS['stack'])

            if DODATA:
                canvas.addMainPlot(PLOTS['data'])

            # this has to be here because it has to be drawn first
            if 'vtxChi2' in hkey:
                canvas.firstPlot.GetXaxis().SetRangeUser(0., 50.)

            if 'mass' in hkey:
                if MASSZOOMED:
                    canvas.firstPlot.GetXaxis().SetRangeUser(0., 100.)

            if 'mind0Sig' in hkey and 'DSA' in hkey:
                pass
                #canvas.firstPlot.GetXaxis().SetRangeUser(0., 5.)

            canvas.firstPlot.setTitles(X='', copy=PLOTS[HG.BGORDER[0]])
            canvas.firstPlot.setTitles(Y='Normalized Counts')
            canvas.makeLegend(lWidth=.27,
                              pos='tr' if hkey != 'REF-DSA-FPTE' else 'tl',
                              autoOrder=False,
                              fontscale=0.8 if not DODATA else 1.)
            if DODATA:
                canvas.addLegendEntry(PLOTS['data'])
            for ref in reversed(HG.BGORDER):
                canvas.addLegendEntry(PLOTS[ref])
            canvas.legend.resizeHeight()
            RT.addBinWidth(canvas.firstPlot)

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

            val = None
            if 'LxySig' in hkey:
                val = 100.
            if 'vtxChi2' in hkey:
                val = 50.
            if 'LxyErr' in hkey:
                val = 10.
            if 'mind0Sig' in hkey:
                val = 3.
            if 'Lxy' == quantity:
                val = 100.

            if val is not None:
                print '{} Mean         : {}'.format(hkey,
                                                    HISTS['sum'].GetMean())
                print '{} Overflow   % : {}'.format(
                    hkey, HISTS['sum'].GetBinContent(nBins) /
                    HISTS['sum'].Integral(1, nBins) * 100.)
                print '{} > {:<8.0f} % : {}'.format(
                    hkey, val,
                    HISTS['sum'].Integral(HISTS['sum'].FindBin(val), nBins) /
                    HISTS['sum'].Integral(1, nBins) * 100.)

            if hkey == 'PAT-LxySig':
                h = HG.getHistogram(FILES['MC'], 'DY50toInf', hkey).Clone()
                print '{} DY50toInf    : {}'.format(
                    hkey, h.Integral(h.FindBin(100.), h.GetNbinsX()))

            if DODATA:
                canvas.makeRatioPlot(PLOTS['data'].plot,
                                     PLOTS['stack'].plot.GetStack().Last())
                canvas.firstPlot.scaleTitleOffsets(0.8, axes='Y')
                canvas.rat.scaleTitleOffsets(0.8, axes='Y')

                if 'mass' in hkey:
                    if MASSZOOMED:
                        canvas.rat.GetXaxis().SetRangeUser(0., 100.)

                if 'REF-DSA-FPTE' in hkey:
                    canvas.ratPad.SetLogx()

            doNotMaximize = True
            canvas.firstPlot.SetMaximum({
                'DSA': 1000.,
                'PAT': 10.**7.,
                'HYB': 2. * 10.**5.,
                'HYB-DSA': 2. * 10.**5.,
                'HYB-PAT': 2. * 10.**5.,
                'REF-DSA': 1000.,
                'DSAPlus': 1000.
            }[recoType])

            if recoType == 'DSA' and quantity in [
                    'pT', 'eta', 'phi', 'FPTE', 'd0Sig', 'trkChi2', 'nStations'
            ]:
                canvas.firstPlot.SetMaximum(10.**5.)

            #if recoType == 'PAT' and 'deltaPhi' in quantity:
            #    canvas.firstPlot.SetMaximum(11.**5.)

            if not doNotMaximize:
                canvas.firstPlot.SetMaximum(HISTS['sum'].GetMaximum() * 1.05)
            canvas.firstPlot.SetMinimum(1.)
            #canvas.cleanup('pdfs/ZEP_{}_{}_{}_MC.pdf'.format(quantity, recoType, CUTSTRING))
            canvas.finishCanvas(extrascale=1. if not DODATA else 1. + 1. / 3.)
            canvas.save('pdfs/ZEP_{}_{}_{}_MC.pdf'.format(
                quantity +
                ('Zoomed' if 'mass' in quantity and MASSZOOMED else ''),
                recoType, CUTSTRING))
            canvas.deleteCanvas()
import ROOT as R
import DisplacedDimuons.Analysis.HistogramGetter as HG
import DisplacedDimuons.Analysis.Plotter as Plotter

f = R.TFile.Open('roots/HPPlots_Trig_Combined_NS_NH_FPTE_HLT_REP_PT_PC_LXYE_MASS_2Mu2J.root')
h = HG.getAddedSignalHistograms(f, '2Mu2J', ('pT', 'GM-pT', 'pT-HP', 'GM-pT-HP'))

for key in ('', 'GM-'):
    h[key+'pT-HP'].Rebin(5)
    h[key+'pT'   ].Rebin(5)
    g = R.TGraphAsymmErrors(h[key+'pT-HP'], h[key+'pT'], 'cp')
    p = Plotter.Plot(g, '', '', 'pe')
    c = Plotter.Canvas()
    c.addMainPlot(p)
    p.setTitles(X='pre-refit PAT muon p_{T} [GeV]', Y='High purity fraction')
    p.setColor(R.kBlue, which='LM')
    c.cleanup('pdfs/HP_2Mu2J_'+key+'HPFrac.pdf')

f = R.TFile.Open('roots/HPPlots_Combined_NS_NH_FPTE_HLT_REP_PT_PC_LXYE_MASS_MC.root')
h, pc = HG.getBackgroundHistograms(f, ('pT', 'pT-HP'), stack=False, rebin=5)

for key in ('stack', 'DY50toInf'):
    g = R.TGraphAsymmErrors(h['pT-HP'][key], h['pT'][key], 'cp')
    p = Plotter.Plot(g, '', '', 'pe')
    c = Plotter.Canvas(lumi=key.title() if key == 'stack' else key)
    c.addMainPlot(p)
    p.setTitles(X='pre-refit PAT muon p_{T} [GeV]', Y='High purity fraction')
    p.setColor(R.kBlue, which='LM')
    c.cleanup('pdfs/HP_MC_'+key+'_HPFrac.pdf')
keyList = {
    'hLessLxySig': 'LxySig-SplitDPhi',
    'hMoreLxySig': 'LxySig-SplitDPhi',
    'hLessLxySigBig': 'LxySig-SplitDPhi-Big',
    'hMoreLxySigBig': 'LxySig-SplitDPhi-Big',
    'hLessLxySigEdges': 'LxySig-SplitDPhi-Edges',
    'hMoreLxySigEdges': 'LxySig-SplitDPhi-Edges',
    'hLessDeltaPhi': 'deltaPhi-SplitLxySig',
    'hMoreDeltaPhi': 'deltaPhi-SplitLxySig',
    'hLessDeltaPhiBig': 'deltaPhi-SplitLxySig-Big',
    'hMoreDeltaPhiBig': 'deltaPhi-SplitLxySig-Big',
    'hDeltaPhi': 'deltaPhi',
    'hDeltaPhiBig': 'deltaPhi-Big',
}

HISTS, PConfig = HG.getBackgroundHistograms(f, keyList.keys(), addFlows=False)
DHists = {}
for key in keyList:
    DHists[key] = HG.getHistogram(f, 'Data', key).Clone()


def makeSinglePlots(hkey, logy=True):
    PLOTS = {}
    for key in HG.BGORDER + ('stack', ):
        PLOTS[key] = Plotter.Plot(HISTS[hkey][key], *PConfig[hkey][key])
    PLOTS['Data'] = Plotter.Plot(DHists[hkey], 'DoubleMuon2016', 'pe', 'pe')

    canvas = Plotter.Canvas(lumi='36.3 fb^{-1} (13 TeV)',
                            logy=logy,
                            cWidth=800 if not ARGS.SQUARE else 600)
Beispiel #9
0
def makeMCPlot(hkey, DODATA=False, TENP=False):

    if DODATA:
        if not TENP:
            HISTS, PConfig = HG.getBackgroundHistograms(FILES['MC_I'], hkey)
            DATAHISTS, DataPConfig = HG.getDataHistograms(
                FILES['Data_I'], hkey)
            lumi = 'MC + Data, |#Delta#Phi| > #pi/2'
        else:
            HISTS, PConfig = HG.getBackgroundHistograms(FILES['MC'],
                                                        hkey,
                                                        extraScale=DATASCALE)
            DATAHISTS, DataPConfig = HG.getDataHistograms(FILES['Data'], hkey)
            lumi = 'MC + 10% Data'
    else:
        HISTS, PConfig = HG.getBackgroundHistograms(FILES['MC'], hkey)
        lumi = 'MC'

    HISTS = HISTS[hkey]
    PConfig = PConfig[hkey]

    if DODATA:
        DATAHISTS = DATAHISTS[hkey]
        PConfig['data'] = DataPConfig[hkey]['data']

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

    if DODATA:
        PLOTS['data'] = Plotter.Plot(DATAHISTS['data'], *PConfig['data'])

    canvas = Plotter.Canvas(
        lumi=lumi,
        logy=True if hkey != 'nDTHits' else False
        #ratioFactor=0. if not DODATA else 1./3., fontscale=1. if not DODATA else 1.+1./3.)
    )

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

    canvas.addMainPlot(PLOTS['stack'])

    if DODATA:
        canvas.addMainPlot(PLOTS['data'])

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

    if canvas.logy:
        canvas.firstPlot.SetMinimum(1.)
        canvas.firstPlot.SetMaximum(500.)
    else:
        canvas.firstPlot.SetMinimum(0.)
        canvas.firstPlot.SetMaximum(10.)

    #if DODATA:
    #    canvas.makeRatioPlot(PLOTS['data'].plot, PLOTS['stack'].plot.GetStack().Last())
    #    canvas.firstPlot.scaleTitleOffsets(0.8, axes='Y')
    #    canvas.rat      .scaleTitleOffsets(0.8, axes='Y')
    #    canvas.rat.setTitles(X='', copy=canvas.firstPlot.plot)

    if canvas.logy:
        line = R.TLine(CONFIG[hkey]['val'], 0.45, CONFIG[hkey]['val'],
                       10.**(R.TMath.Log10(500.) * 1.06))
    else:
        line = R.TLine(CONFIG[hkey]['val'], 0., CONFIG[hkey]['val'],
                       10. * 1.05)
    line.Draw()
    line.SetLineStyle(2)
    if DODATA:
        if not TENP:
            DATAHISTS_NO, DataPConfig_NO = HG.getDataHistograms(
                FILES['Data_I'], hkey, addFlows=False)
        else:
            DATAHISTS_NO, DataPConfig_NO = HG.getDataHistograms(FILES['Data'],
                                                                hkey,
                                                                addFlows=False)
        print '\033[32m{:6s} {:8s} {:5.0f} {:5.0f} {:7.2%}\033[m'.format(
            'Data' + ('' if not TENP else '10'), hkey,
            *fractionCut(hkey, DATAHISTS_NO[hkey]['data']))

    canvas.cleanup('pdfs/NM1D_{}_MC{}{}.pdf'.format(
        hkey, '' if not DODATA else 'Data', '' if not TENP else '-10'))