Ejemplo n.º 1
0
                                  lwidth=2)
                canvas.legend.apply(base + mod, pGraph)
                canvas.addHistogram(pGraph, drawOpt='EP')

                outFile.cd()
                pGraph.Write()

            canvas.ylimits = (0.0, 15.0)
            canvas.ytitle = 'Photon Impurity'
            canvas.xtitle = 'E_{T}^{#gamma} (GeV)'
            canvas.SetGridy(True)

            plotName = 'Plot_' + tune + '_impurity_' + str(metCut) + '_' + str(
                loc) + '_' + str(base)
            canvas.printWeb('purity/' + s.Version + '/Fitting',
                            plotName,
                            logy=False)

outFile.Close()

for loc in s.Locations[:1]:
    for base in bases:
        for metCut in MetSels:
            for iMod, mod in enumerate(mods):

                # start new table
                purityFileName = 'table_' + tune + '_impurity_' + str(
                    metCut) + '_' + str(loc) + '_' + str(base + mod) + '.tex'
                purityFilePath = outDir + '/' + purityFileName
                purityFile = open(purityFilePath, 'w')
Ejemplo n.º 2
0
                xString + ">>" + sample + region,
                str(lumi) +
                '* weight * (photons.pt[0] > 175. && !photons.pixelVeto[0] && t1Met.minJetDPhi > 0.5 && t1Met.met > 170.)',
                'goff')
        else:
            dataTree.Draw(
                xString + ">>" + sample + region,
                str(lumi) +
                '* weight * (photons.pt[0] > 175. && t1Met.minJetDPhi > 0.5 && t1Met.met > 170.)',
                'goff')

        print "Integrals for", sample, region
        print "Events in dPhi < 0.52:", dataHist.Integral(1, 5)
        print "Events in dPhi < 1.05:", dataHist.Integral(1, 10)
        print "Events in dPhi > 1.99:", dataHist.Integral(
            19,
            dataHist.GetNbinsX() + 1)
        print '\n'

        canvas.legend.add('data',
                          title=sample + region,
                          mcolor=ROOT.kRed,
                          msize=1,
                          lcolor=ROOT.kRed,
                          lwidth=4)
        canvas.legend.apply('data', dataHist)
        canvas.addHistogram(dataHist, drawOpt='HIST')
        canvas.printWeb('monophoton/phoMet',
                        'dPhi' + '_' + sample + '_' + region,
                        logy=False)
Ejemplo n.º 3
0
    # this distribution will be convoluted with mumug efficiency
    if name == 'ht':
        monophHt = monophDist

    # znng efficiency
    monophEff = eff.Clone('monoph_' + eff.GetName())
    effCanvas.legend.apply('monoph', monophEff)
    mcMonoph.Draw(
        'electrons.size == 0 && muons.size == 0:' + expr + '>>' +
        monophEff.GetName(), weight, 'prof goff')

    # print plots
    distCanvas.addHistogram(dataDist, drawOpt='HIST')
    distCanvas.addHistogram(mumugDist, drawOpt='HIST')
    distCanvas.addHistogram(monophDist, drawOpt='HIST')
    distCanvas.printWeb('veto_eff', 'dist_' + name)
    distCanvas.Clear()

    effCanvas.addHistogram(dataEff, drawOpt='EP')
    effCanvas.addHistogram(mumugEff, drawOpt='EP')
    if name == 'incl':
        effCanvas.addHistogram(datajetEff, drawOpt='EP')
        effCanvas.addHistogram(mumugjetEff, drawOpt='EP')
    effCanvas.addHistogram(monophEff, drawOpt='EP')
    effCanvas.addHistogram(sf, drawOpt='P')
    effCanvas.printWeb('veto_eff', 'eff_' + name, logy=False)
    effCanvas.Clear()
    effCanvas.SetGrid(True)

    # save histograms
    outputFile.cd()
Ejemplo n.º 4
0
                for iH, hList in enumerate(histograms):
                    canvas.Clear()

                    canvas.addHistogram(hList[0], drawOpt = 'HIST')
                    canvas.addHistogram(hList[2], drawOpt = 'HIST')
                    canvas.addHistogram(hList[1], drawOpt = 'HIST')
                    if iH:
                        canvas.ylimits = (0., 100.)
                    else:
                        if pid == 'none':
                            canvas.ylimits = (0., 30.)
                        else:
                            canvas.ylimits = (0., 10.)

                    plotName = "purity_data_"+str(loc)+"_"+str(pid)+"_ptbinned_"+suffix[iH] 
                    canvas.printWeb('purity/'+Version+'/Fitting', plotName, logy = False)

                canvas.Clear()
                canvas.legend.Clear()
                canvas.legend.add("final", title = str(loc)+" "+str(pid), lcolor = kBlack, lwidth = 2)
                canvas.legend.apply("final", finalHist)
                iH = canvas.addHistogram(finalHist, drawOpt = 'EP')
                if pid == 'none':
                    canvas.ylimits = (0., 30.)
                else:
                    canvas.ylimits = (0., 10.)
                plotName = "purity_data_"+str(loc)+"_"+str(pid)+"_ptbinned_final" 
                canvas.printWeb('purity/'+Version+'/Fitting', plotName, hList = [iH], logy = False)

                pdflatex = Popen( ["pdflatex",purityFilePath,"-interaction nonstopmode"]
                                  ,stdout=PIPE,stderr=PIPE,cwd=outDir)
Ejemplo n.º 5
0
yields['ee'].Write()
yields['eg'].Write()

lumi = 0.
for sname in lumiSamples:
    lumi += allsamples[sname].lumi

canvas = SimpleCanvas(lumi = lumi, sim = (dataType == 'mc'))
canvas.legend.setPosition(0.7, 0.8, 0.9, 0.9)
canvas.legend.add('frate', 'R_{e}', opt = 'LP', color = ROOT.kBlack, mstyle = 8)
canvas.legend.apply('frate', frate)
canvas.ylimits = (0., 0.03)
canvas.addHistogram(frate, drawOpt = 'EP')

canvas.xtitle = binningTitle
canvas.printWeb('efake', 'frate_' + dataType + '_' + binningName, logy = False)

for iBin, (binName, cut) in enumerate(fitBins):
    if dataType == 'mc':
        print '%15s [%.3f +- %.3f (stat.) +- %.3f (syst.)] x 10^{-2} (mc %.3f)' % (binName, contents[iBin] * 100., staterrs[iBin] * 100., systerrs[iBin] * 100., mctruth[iBin] * 100.)
    else:
        print '%15s [%.3f +- %.3f (stat.) +- %.3f (syst.)] x 10^{-2}' % (binName, contents[iBin] * 100., staterrs[iBin] * 100., systerrs[iBin] * 100.)

if toyUncert and binningName == 'pt':
    binName = 'pt_160_6500'
    for conf in ['ee', 'eg']:
        canvas.Clear(full = True)
        canvas.ylimits = (0., 0.05)
        canvas.xtitle = 'N_{Z}'

        toydist = toydists[binName][conf]
Ejemplo n.º 6
0
Archivo: eff.py Proyecto: yiiyama/MonoX
            canvas.Update()

            if type(binning) is tuple:
                eff.GetXaxis().SetLimits(binning[1], binning[2])
                eff.GetXaxis().SetRangeUser(binning[1], binning[2])
            else:
                eff.GetXaxis().SetLimits(binning[0], binning[-1])
                eff.GetXaxis().SetRangeUser(binning[0], binning[-1])

            eff.GetYaxis().SetRangeUser(0., 1.2)

            #            if tname == 'sph165abs' and vname.startswith('pt'):
            #                canvas.addLine(175., canvas.ylimits[0], 175., canvas.ylimits[1], color = ROOT.kRed, width = 2, style = ROOT.kDashed)

            canvas.printWeb(outName,
                            oname + '_' + mname + '_' + tname + '_' + vname,
                            logy=False)

    source.Close()

# TO BE FIXED
#    func = None
#    marker = 0.
#
#    if (vname, tname) in fitconfs[oname]:
#        func = work.factory('FormulaVar::func("(@0 < @1) * @2 * (1. + TMath::Erf((@3 - @2) * @4 / @2 * (@0 - @1))) + (@0 > @1) * (@2 + (@3 - @2) * TMath::Erf(@4 * (@0 - @1)))", {x, turn[170.,0.,300.], norm1[0.5,0.,1.], norm[0.9,0.,1.], rise2[0.1,0.,1.]})')
#        params = ROOT.RooArgList(work.arg('turn'), work.arg('norm1'), work.arg('norm'), work.arg('rise2'))
#        fitmin = 150.
#        fitmax = 250.
#
#        marker = 175.
Ejemplo n.º 7
0
            if y > 5.:
                y = 5.
            if y < -5.:
                y = -5.

            graph.SetPoint(ip, x, y)

        graph.SetTitle('')

        outputFile.cd()
        graph.Write('%s_%s' % (sigs, faken))

        graphs.append(graph)

        canvas.legend.apply('n%s' % faken, graph)
        canvas.addHistogram(graph, drawOpt='P')

    canvas.addLine(-5., 0., 5., 0., style=ROOT.kDashed)
    canvas.addLine(0., -5., 0., 5., style=ROOT.kDashed)
    canvas.xlimits = (-5., 5.)
    canvas.ylimits = (-5., 5.)

    canvas.title = '#sigma#timesBR = %.2f' % mu
    canvas.xtitle = 'Fake E_{T}^{miss}: (N_{fit} - N_{true})/#sigma_{fit}'
    canvas.ytitle = 'Signal: (N_{fit} - N_{true})/#sigma_{fit}'

    canvas.printWeb('monophoton/fakemet', sourceName + '_' + sigs, logy=False)
    canvas.Clear()

outputFile.Close()
Ejemplo n.º 8
0
        Xmin = min(xmin, Xmin)
        Xmax = max(xmax, Xmax)
        # sys.stdin.readline()

    print Xmin, Xmax
    hbase = r.TH1F("hbase"+weight, weight, 100, Xmin, Xmax)

    
    canvas.Clear()
    canvas.legend.Clear()

    hists = []
    for iS, (sample, tree) in enumerate(trees):
        hsample = hbase.Clone(sample+weight)
        tree.Draw(weight+" >> "+sample+weight, '', "goff")
        # if hsample.Integral():
        print tree.GetEntries()
        print hsample.Integral()
        hsample.Scale(1./tree.GetEntries())

        canvas.legend.add(sample+weight, title = sample, mcolor = iS+1, lcolor = iS+1, lwidth = 2)
        canvas.legend.apply(sample+weight, hsample)
        hists.append(hsample)
        
        canvas.addHistogram(hists[iS])

    canvas.printWeb('monophoton/compWeights', weight, logy = False)
        
    

Ejemplo n.º 9
0
canvas = SimpleCanvas(lumi = sum(t.lumi for t in targs))
plotName = 'fit'

### fit to halo distribution and parametrize

# draw
dataTree.Draw(phimpipi + '>>haloTemp(40,-{pi},{pi})'.format(pi = math.pi), 'photons.mipEnergy > 4.9 && photons.isEB && photons.scRawPt > 175. && t1Met.met > 140. && photons.chWorstIso < 1.37 && photons.nhIso < 1.06', 'goff')

haloTemp = ROOT.gDirectory.Get('haloTemp')
haloTemp.SetLineColor(ROOT.kBlack)
haloTemp.SetLineWidth(2)
haloTemp.SetTitle(';#phi\'')

canvas.addHistogram(haloTemp)
canvas.xtitle = '#phi\''
canvas.printWeb('monophoton/halo', 'haloTemp', logy = False)
canvas.Clear()

# first get the halo phi values
nHalo = dataTree.Draw(phivar + '>>haloTemp(40,-{pi},{pi})'.format(pi = math.pi), 'photons.mipEnergy > 4.9 && photons.isEB && photons.scRawPt > 175. && t1Met.met > 140. && photons.chWorstIso < 1.37 && photons.nhIso < 1.06', 'goff')
print nHalo, 'halo events'

# dump them into a RooDataSet
haloData = ROOT.RooDataSet('halo', 'halo', phiset)
haloPhi = dataTree.GetV1()
for iHalo in range(nHalo):
    phi.setVal(haloPhi[iHalo])
    haloData.add(phiset)

# then fit with gaus + gaus + uniform
base = work.factory('Uniform::base({phi})')
Ejemplo n.º 10
0
        canvas.legend.apply('data', dataHist)
        canvas.addHistogram(dataHist, drawOpt='EP')

        # sys.stdin.readline()
        """
        for sample, color, mcTree in mcTrees:
            mcName = sample+'_'+label
            mcHist = varDef.makeHist(mcName)
            mcTree.Draw(varDef.expr+'>>'+mcName, str(lumi)+' * weight * ('+cutString+')')

            canvas.addStacked(mcHist, title = sample, color = color)
        """

        canvas.ylimits = (0.5, -1.)

        canvas.printWeb('monophoton/phoMet/' + probeCut[1], label, logy=False)

    for var in vars2D:
        allCuts = list(probeCuts)
        if var[1] != '':
            allCuts.append(var[1])

        cutString = ' && '.join(['(%s)' % c for c in allCuts])
        print cutString

        label = var[0] + '_' + probeCut[1]

        canvas.Clear(xmax=0.90)
        canvas.legend.Clear()
        canvas.legend.setPosition(0.1, 0.7, 0.9, 0.9)
Ejemplo n.º 11
0
            # plot fit
            frame = mass.frame(ROOT.RooFit.Range('fitWindow'), ROOT.RooFit.Bins(mass.getBins('fitWindow')))
            targHist.plotOn(frame)
            model.plotOn(frame)
            model.plotOn(frame, ROOT.RooFit.Components(bkgModelName), ROOT.RooFit.LineStyle(ROOT.kDashed), ROOT.RooFit.LineColor(ROOT.kGreen))
            frame.SetTitle('')
            frame.SetMinimum(0.)
    
            canvas.Clear()
            canvas.addHistogram(frame)
            if dataType == 'mc':
                canvas.legend.apply('mcbkg', hmcbkg)
                canvas.addHistogram(hmcbkg)

            if pdf == 'altbkg':
                canvas.printWeb(plotDir, 'fit_' + dataType + '_altbkg_' + conf + '_' + binName, logy = False)
            elif pdf == 'altsig':
                canvas.printWeb(plotDir, 'fit_' + dataType + '_altsig_' + conf + '_' + binName, logy = False)
            else:
                canvas.printWeb(plotDir, 'fit_' + dataType + '_' + conf + '_' + binName, logy = False)

        # run toys
        nNominal = vals['nsignal'] + vals['nbkg']

        ROOT.RooMsgService.instance().setStreamStatus(1, False)

        iToy = 0
        while iToy < nToys:
            iToy += 1

            for param, val in vals.items():
Ejemplo n.º 12
0
        if matches.group(1) == 'a':
            dma.append((float(matches.group(2)), float(matches.group(3))))
        else:
            dmv.append((float(matches.group(2)), float(matches.group(3))))

canvas = SimpleCanvas(cms = False)
canvas.SetGrid(True)

gdma = ROOT.TGraph(len(dma))
for iP, (med, dm) in enumerate(dma):
    gdma.SetPoint(iP, med, dm)

gdma.SetTitle('DMA;M_{med} (GeV);M_{DM} (GeV)')
gdma.SetMarkerStyle(21)

canvas.addHistogram(gdma, drawOpt = 'P')
canvas.printWeb('signal_points', 'dma', logx = True)

canvas.Clear()
canvas.SetGrid(True)

gdmv = ROOT.TGraph(len(dmv))
for iP, (med, dm) in enumerate(dmv):
    gdmv.SetPoint(iP, med, dm)

gdmv.SetTitle('DMV;M_{med} (GeV);M_{DM} (GeV)')
gdmv.SetMarkerStyle(21)

canvas.addHistogram(gdmv, drawOpt = 'P')
canvas.printWeb('signal_points', 'dmv', logx = True)
Ejemplo n.º 13
0
                              lwidth=2)
            canvas.legend.apply(loc + '-' + base, gSF)
            canvas.addHistogram(gSF, drawOpt='EP')

            rcanvas.ylimits = (0.75, 1.0)
            # rcanvas.rlimits = (0.9, 1.1)
            rcanvas.ytitle = 'Pixel Veto Efficiency'
            rcanvas.xtitle = 'E_{T}^{#gamma} (GeV)'
            rcanvas.SetGridy(True)

            suffix = str(tune) + '_' + str(metCut) + '_' + str(
                loc) + '_' + str(base)

            plotName = 'efficiency_' + suffix
            rcanvas.printWeb('purity/' + s.Version + '/ScaleFactors',
                             plotName,
                             logy=False)

            canvas.ylimits = (0.95, 1.05)
            canvas.ytitle = 'Pixel Veto Scale Factor'
            canvas.xtitle = 'E_{T}^{#gamma} (GeV)'
            canvas.SetGridy(True)

            plotName = 'scalefactor_' + suffix
            canvas.printWeb('purity/' + s.Version + '/ScaleFactors',
                            plotName,
                            logy=False)

outFile.Close()

for loc in s.Locations[:1]:
Ejemplo n.º 14
0
    scanvas.legend.Clear()

    scanvas.ylimits = (0.01, 2.5)
    scanvas.SetLogy(True)

    scanvas.legend.setPosition(0.6, 0.7, 0.9, 0.9)
    scanvas.legend.add(tname,
                       title='Transfer factor',
                       lcolor=r.kBlack,
                       lwidth=1)

    scanvas.legend.apply(tname, tfact)

    scanvas.addHistogram(tfact, drawOpt='EP')

    scanvas.printWeb('monophoton/gjetsTFactor', 'tfactor' + method)

canvas.Clear()
canvas.legend.Clear()

canvas.SetLogy(True)
canvas.ylimits = (0.01, 2.5)

canvas.legend.setPosition(0.6, 0.7, 0.9, 0.9)

canvas.addObs(tfacts[0], 'Data')
canvas.addSignal(tfacts[1], title='MC', color=r.kRed, idx=-1)
canvas.addStacked(tfacts[1], title='MC', idx=-1)

canvas.printWeb('monophoton/gjetsTFactor', 'tfactorRatio', ymax=2.5)
Ejemplo n.º 15
0
    yString = "( ( (photons.e55[0] / TMath::CosH(photons.eta[0])) - photons.pt[0] ) / t1Met.met )"

    dataHist = ROOT.TH2D(sample, "", 30, 0., math.pi, 10, -1.0, 1.0)
    dataHist.GetXaxis().SetTitle('#Delta#phi(#gamma, E_{T}^{miss})')
    dataHist.GetYaxis().SetTitle(
        '(E_{55}^{#gamma} - E_{T}^{#gamma}) / E_{T}^{miss}')
    dataHist.Sumw2()
    dataTree.Draw(
        yString + ":" + xString + ">>" + sample,
        '(photons.pt[0] > 175. && t1Met.minJetDPhi > 0.5 && t1Met.met > 170.)',
        'goff')

    ColorGrad()
    canvas.addHistogram(dataHist, drawOpt='COLZ TEXT')
    canvas.printWeb('monophoton/phoMet',
                    'DiffVsPhi' + '_' + sample,
                    logy=False)

    canvas.Clear(xmax=0.90)

dataTree = ROOT.TChain('events')
dataTree.Add('/scratch5/ballen/hist/monophoton/skim/sph-d*_monoph.root')

xString = "photons.eta[0]"
yString = "photons.phi[0]"

dataHist = ROOT.TH2D("lego", "", 30, -1.5, 1.5, 30, -math.pi, math.pi)
dataHist.GetXaxis().SetTitle('#eta')
dataHist.GetYaxis().SetTitle('#phi')
dataHist.Sumw2()
dataTree.Draw(
Ejemplo n.º 16
0
        graph.SetPoint(iX - 1, cent.GetXaxis().GetBinCenter(iX), y)
        graph.SetPointError(iX - 1, binw * 0.5, binw * 0.5,
                            up.GetBinContent(iX) - y,
                            y - down.GetBinContent(iX))
        bars.SetPoint(iX - 1, cent.GetXaxis().GetBinCenter(iX), y)
        bars.SetPointError(iX - 1, binw * 0.5, 0.)

        cent.SetBinError(iX, 0.)

    canvas.legend.apply(hname, cent)
    canvas.legend.apply(hname, bars)
    canvas.legend.apply(hname, graph)

    cent.GetXaxis().SetTitle('p_{T}^{#gamma} (GeV)')
    cent.GetYaxis().SetTitle('#sigma_{QCD}^{NNLO} / #sigma^{LO}')

    canvas.addHistogram(cent, drawOpt='EP')
    canvas.addHistogram(graph, drawOpt='2')
    canvas.addHistogram(bars, drawOpt='EZ')

canvas.addLine(cent.GetXaxis().GetXmin(),
               1.,
               cent.GetXaxis().GetXmax(),
               1.,
               style=ROOT.kDashed)

canvas.ylimits = (0.8, 1.8)

canvas.printWeb('kfactor', 'zgwg', logy=False)
canvas.Clear()
Ejemplo n.º 17
0
noniso += ' && photons.chIsoMaxX[0][%d] < %f' % (itune, ROOT.cutvalue)
ROOT.gROOT.ProcessLine("cutvalue = panda::XPhoton::nhIsoCuts[%s][0][2];" %
                       tune)
noniso += ' && (photons.nhIsoX[0][%d] > %f' % (itune, ROOT.cutvalue)
ROOT.gROOT.ProcessLine("cutvalue = panda::XPhoton::phIsoCuts[%s][0][2];" %
                       tune)
noniso += ' || photons.phIsoX[0][%d] > %f)' % (itune, ROOT.cutvalue)

outputFile.cd()

addPlot(
    haloPlotter, 'phiHalo',
    'photons.sieie[0] > 0.015 && photons.mipEnergy[0] > 4.9 && metFilters.globalHalo16'
)
addPlot(emjetPlotter, 'phiCand', noniso)
addPlot(mcPlotter, 'phiZnng')

haloPlotter.fillPlots()
emjetPlotter.fillPlots()
mcPlotter.fillPlots()

canvas = SimpleCanvas()
canvas.legend.setPosition(0.4, 0.7, 0.92, 0.92)
canvas.legend.SetTextSize(0.03)

for plot in plots:
    canvas.Clear()
    canvas.ylimits = (0., plot.GetMaximum() * 1.5)
    canvas.addHistogram(plot)
    canvas.printWeb('monophoton/halo', plot.GetName(), logy=False)
Ejemplo n.º 18
0
        canvas.legend.add(fname, title = '#gamma + jet #times impurity', lcolor = ROOT.kRed, lwidth = 2, lstyle = ROOT.kDashed)
        canvas.legend.add(hname, title = 'EMobject + jet', lcolor = ROOT.kBlue, lwidth = 2)
        canvas.legend.setPosition(0.6, 0.7, 0.95, 0.9)

        canvas.legend.apply(gname, gpt)
        canvas.legend.apply(fname, fpt)
        canvas.legend.apply(hname, hpt)

        canvas.addHistogram(gpt, drawOpt = 'HIST')
        canvas.addHistogram(fpt, drawOpt = 'HIST')
        canvas.addHistogram(hpt, drawOpt = 'HIST')

        canvas.ylimits = (0.1, 2000.)
        canvas.SetLogy(True)

        canvas.printWeb('monophoton/hadronTFactor', 'distributions'+iso[0]+samp)

        canvas.Clear()
        canvas.legend.Clear()

        canvas.ylimits = (0., -1.)
        canvas.SetLogy(False)

        canvas.legend.add(tname, title = 'Transfer factor', lcolor = ROOT.kBlack, lwidth = 1)

        canvas.legend.apply(tname, tfact)

        canvas.addHistogram(tfact, drawOpt = 'EP')

        canvas.printWeb('monophoton/hadronTFactor', 'tfactor'+iso[0]+samp)
Ejemplo n.º 19
0
tree.Add('/scratch5/yiiyama/hist/triggertree/t2mit/filefi/042/' + allsamples['sph-d4'].directory + '/l1t_*.root')

binning = array.array('d', [30. + 5. * x for x in range(14)] + [100. + 10. * x for x in range(10)] + [200. + 20. * x for x in range(5)])

passing = ROOT.TH1D('passing', ';p_{T}^{#gamma} (GeV)', len(binning) - 1, binning)
denom = ROOT.TH1D('denom', ';p_{T}^{#gamma} (GeV)', len(binning) - 1, binning)

tree.Draw('pt>>denom')
tree.Draw('pt>>passing', 'l1dr2 < 0.25')

eff = ROOT.TGraphAsymmErrors(passing, denom)

canvas = SimpleCanvas(lumi = allsamples['sph-d3'].lumi + allsamples['sph-d4'].lumi)
canvas.legend.setPosition(0.7, 0.3, 0.9, 0.5)
canvas.legend.add('eff', title = 'L1 seed', opt = 'LP', color = ROOT.kBlack, mstyle = 8)

canvas.SetGrid()

canvas.legend.apply('eff', eff)

canvas.addHistogram(eff, drawOpt = 'EP')
canvas.addLine(0., 1., 300., 1.)
eff.GetXaxis().SetLimits(0., 300.)

canvas.xtitle = 'p_{T}^{#gamma} (GeV)'
canvas.ytitle = 'L1 seed eff.'

canvas.ylimits = (0., 1.2)

canvas.printWeb('trigger', 'l1seed', logy = False)
Ejemplo n.º 20
0
    canvas.legend.apply(gname, gpt)
    canvas.legend.apply(fname, fpt)
    canvas.legend.apply(fname + 'Syst', fptUp)
    canvas.legend.apply(fname + 'Syst', fptDown)
    canvas.legend.apply(hname, hpt)

    canvas.addHistogram(gpt, drawOpt='HIST')
    canvas.addHistogram(fpt, drawOpt='HIST')
    canvas.addHistogram(fptUp, drawOpt='HIST')
    canvas.addHistogram(fptDown, drawOpt='HIST')
    canvas.addHistogram(hpt, drawOpt='HIST')

    canvas.ylimits = (1.0, 2500000.)
    canvas.SetLogy(True)

    canvas.printWeb('monophoton/hadronTFactor' + suffix,
                    'distributions' + confName)

    rcanvas.Clear()
    rcanvas.legend.Clear()

    # if samp == 'Down':
    rcanvas.ylimits = (0., -1.)
    # else:
    # rcanvas.ylimits = (0., 0.05)

    rcanvas.SetLogy(False)

    rcanvas.legend.add(tname,
                       title='transfer factor',
                       lcolor=ROOT.kBlack,
                       lwidth=2)
Ejemplo n.º 21
0
    dataTreeAll.Add(config.ntuplesDir + "/" + sample.book + "/" + sample.fullname + "/*.root")

znngTree = ROOT.TChain("events")
znngTree.Add(config.photonSkimDir + "/znng-130.root")

## halo EB

phiHalo = makeFullPlot(dataTree, "phiHalo", "photons.mipEnergy > 4.9 && photons.isEB")
phiHalo.SetDirectory(outputFile)
outputFile.cd()
phiHalo.Write()

canvas.ylimits = (0.0, phiHalo.GetMaximum() * 1.5)

canvas.addHistogram(phiHalo)
canvas.printWeb("monophoton/halo", "phiHalo", logy=False)

canvas.Clear()

phiHalo = makeFoldedPlot(dataTree, "phiHaloFolded", "photons.mipEnergy > 4.9 && photons.isEB")
phiHalo.SetDirectory(outputFile)
outputFile.cd()
phiHalo.Write()

canvas.ylimits = (0.0, phiHalo.GetMaximum() * 1.5)

canvas.addHistogram(phiHalo)
canvas.printWeb("monophoton/halo", "phiHaloFolded", logy=False)

canvas.Clear()
Ejemplo n.º 22
0
            if x > 2.:
                x = 2.
            if y > 2.:
                y = 2.

            graph.SetPoint(ip, x, y)

        graph.SetTitle('')

        outputFile.cd()
        graph.Write('%s_%s' % (sigs, faken))

        graphs.append(graph)

        canvas.legend.apply('n%s' % faken, graph)
        canvas.addHistogram(graph, drawOpt='P')

    canvas.addLine(0., 1., 2., 1., style=ROOT.kDashed)
    canvas.addLine(1., 0., 1., 2., style=ROOT.kDashed)
    canvas.xlimits = (0., 2.)
    canvas.ylimits = (0., 2.)

    canvas.title = '#sigma#timesBR = %.2f' % mu
    canvas.xtitle = 'Fake E_{T}^{miss} extracted / injected'
    canvas.ytitle = 'Signal extracted / injected'

    canvas.printWeb('monophoton/fakemet', sigs, logy=False)
    canvas.Clear()

outputFile.Close()
Ejemplo n.º 23
0
def printCanvas(canvas, plotdef, plotConfig, plotDir):
    """
    Print the canvas content as pdf and png.
    """

    eil = ROOT.gErrorIgnoreLevel
    ROOT.gErrorIgnoreLevel = ROOT.kWarning

    canvas.xtitle = plotdef.xtitle()
    canvas.ytitle = plotdef.ytitle(binNorm=True)

    canvas.selection = plotdef.cutName

    if plotdef.logy is None:
        logy = True
        addLinear = True
    else:
        logy = plotdef.logy
        addLinear = False

    canvas.ylimits = (plotdef.ymin, plotdef.ymax)
    canvas.rlimits = (plotdef.rmin, plotdef.rmax)
    canvas.Update(logy=logy)

    if plotdef.fullyBlinded():
        # remove ratio pad. Hack to use SimpleCanvas interface
        simple = SimpleCanvas(lumi=canvas.lumi)

        garbage = []
        cnv = ROOT.TCanvas('tmp', 'tmp', 600, 600)
        cnv.cd()

        plotPad = canvas.plotPad.DrawClone()
        garbage.append(plotPad)
        plotPad.SetTopMargin(simple.canvas.GetTopMargin())
        plotPad.SetRightMargin(simple.canvas.GetRightMargin())
        plotPad.SetBottomMargin(simple.canvas.GetBottomMargin())
        plotPad.SetLeftMargin(simple.canvas.GetLeftMargin())

        xaxis = canvas.xaxis.DrawClone()
        garbage.append(xaxis)
        xaxis.SetX1(simple.canvas.GetLeftMargin())
        xaxis.SetX2(1. - simple.canvas.GetRightMargin())
        xaxis.SetY1(simple.canvas.GetBottomMargin())
        xaxis.SetY2(simple.canvas.GetBottomMargin())

        yaxis = canvas.yaxis.DrawClone()
        garbage.append(yaxis)
        yaxis.SetX1(simple.canvas.GetLeftMargin())
        yaxis.SetX2(simple.canvas.GetLeftMargin())
        yaxis.SetY1(simple.canvas.GetBottomMargin())
        yaxis.SetY2(1. - simple.canvas.GetTopMargin())

        simple.canvas.IsA().Destructor(simple.canvas)
        simple.canvas = cnv
        simple._needUpdate = False
        simple.printWeb(plotDir, plotdef.name)

        sys.stdout.write('    main')
        if logy:
            sys.stdout.write(' (log)')
        else:
            sys.stdout.write(' (lin)')

        if addLinear:
            plotPad.SetLogy(False)
            plotPad.Update()
            yaxis.SetOption('')
            yaxis.SetWmin(plotPad.GetUymin())
            yaxis.SetWmax(plotPad.GetUymax())
            simple.printWeb(plotDir, plotdef.name + 'Linear', logy=False)

            sys.stdout.write(' (lin)')

        sys.stdout.write('\n')
        sys.stdout.flush()

        # cleanup the mess
        for obj in garbage:
            obj.IsA().Destructor(obj)

        cnv.IsA().Destructor(cnv)

    else:
        # normal, (partially) unblinded distributions
        canvas.printWeb(plotDir, plotdef.name, drawLegend=False)

        sys.stdout.write('    main')
        if logy:
            sys.stdout.write(' (log)')
        else:
            sys.stdout.write(' (lin)')

        if addLinear:
            canvas.ylimits = (0., -1.)
            canvas.minimum = -1.
            plotdef.ymax = -1.
            plotdef.ymin = 0.
            canvas._needUpdate = True
            canvas.printWeb(plotDir, plotdef.name + 'Linear', logy=False)

            sys.stdout.write(' (lin)')

        sys.stdout.write('\n')
        sys.stdout.flush()

    ROOT.gErrorIgnoreLevel = eil
Ejemplo n.º 24
0
dataCorr = ROOT.TH1D('dataCorr', '', 60, 60., 120.)
dataRaw = ROOT.TH1D('dataRaw', '', 60, 60., 120.)
dataChain.Draw('tp.mass>>dataCorr', 'probes.pt > 100.', 'goff')
dataChain.Draw(rawMass + '>>dataRaw', 'probes.pt > 100.', 'goff')

canvas = SimpleCanvas()
canvas.legend.setPosition(0.7, 0.7, 0.9, 0.9)
canvas.legend.add('dataCorr', title = 'Corrected', opt = 'LF', color = ROOT.kBlue, fstyle = 3003, lwidth = 2)
canvas.legend.add('dataRaw', title = 'Raw', opt = 'LF', color = ROOT.kRed, fstyle = 3003, lwidth = 2)

canvas.addHistogram(dataCorr)
canvas.addHistogram(dataRaw)

canvas.applyStyles()

canvas.printWeb('rawEScale', 'data', logy = False)

canvas.Clear()

mcCorr = ROOT.TH1D('mcCorr', '', 60, 60., 120.)
mcRaw = ROOT.TH1D('mcRaw', '', 60, 60., 120.)
mcChain.Draw('tp.mass>>mcCorr', 'probes.pt > 100.', 'goff')
mcChain.Draw(rawMass + '>>mcRaw', 'probes.pt > 100.', 'goff')

canvas = SimpleCanvas()
canvas.legend.setPosition(0.7, 0.7, 0.9, 0.9)
canvas.legend.add('mcCorr', title = 'Corrected', opt = 'LF', color = ROOT.kBlue, fstyle = 3003, lwidth = 2)
canvas.legend.add('mcRaw', title = 'Raw', opt = 'LF', color = ROOT.kRed, fstyle = 3003, lwidth = 2)

canvas.addHistogram(mcCorr)
canvas.addHistogram(mcRaw)
Ejemplo n.º 25
0
                  lcolor=ROOT.kGreen,
                  lwidth=1,
                  opt='L')
canvas.legend.add('obs',
                  title='Data',
                  mcolor=ROOT.kBlack,
                  mstyle=8,
                  msize=1,
                  lcolor=ROOT.kBlack,
                  lwidth=1,
                  opt='LP')

canvas.ytitle = 'Events / (#pi/%d)' % nbins

canvas.addHistogram(frame)
canvas.printWeb('monophoton/halo', 'fit_' + fitName, logy=False)

if not FITPSEUDODATA:
    # generate 10 toy distributions - does your target distribution look "normal"?

    for iT in range(10):
        toyData = model.generate(phiset, nTarg)

        frame = phi.frame()
        frame.SetTitle('')
        toyData.plotOn(frame)

        canvas.Clear(full=True)
        canvas.ytitle = 'Events / (#pi/25)'
        canvas.addHistogram(frame)
        canvas.printWeb('monophoton/halo', 'toy%d' % iT, logy=False)
Ejemplo n.º 26
0
        toyPlotYield.Fill(yieldDiff)

    bkgdUncertainty = toyPlot.GetStdDev()
    bkgdUncYield = toyPlotYield.GetStdDev()

    tcanvas = SimpleCanvas(lumi = s.sphLumi, name = 'toys')
    toyPlot.SetTitle('')

    tcanvas.legend.add('toys', title = 'toys', opt = 'L', lcolor = ROOT.kBlue, lwidth = 2, lstyle = ROOT.kSolid)
    tcanvas.legend.apply('toys', toyPlot)
    tcanvas.addHistogram(toyPlot)

    tcanvas.xtitle = 'Impurity Difference (%)'
    tcanvas.ytitle = '# of Toys'
    
    tcanvas.printWeb(plotDir, 'ssfit_toy_dist', logy = False)
    
    tcanvas.Clear()
    toyPlotYield.SetTitle('')
    
    tcanvas.legend.apply('toys', toyPlotYield)
    tcanvas.addHistogram(toyPlotYield)

    tcanvas.xtitle = '#Delta(# of True Photons)'
    tcanvas.ytitle = '# of Toys'
    
    tcanvas.printWeb(plotDir, 'ssfit_toyyield_dist', logy = False)
    

else:
    bkgdUncertainty = 0.
Ejemplo n.º 27
0
           }


for sample in samples:
    for region in samples[sample]:
        canvas.Clear()
        canvas.legend.Clear()
        canvas.legend.setPosition(0.6, 0.7, 0.9, 0.9)

        dataTree = ROOT.TChain('events')
        dataTree.Add('/scratch5/ballen/hist/monophoton/skim/'+sample+'-*_'+region+'.root')

        xString = "t1Met.photonDPhi"

        dataHist = ROOT.TH1D(sample+region, "", 30, 0., math.pi)
        dataHist.GetXaxis().SetTitle('#Delta#phi(#gamma, E_{T}^{miss})')
        dataHist.GetYaxis().SetTitle('Events / 0.10')
        dataHist.Sumw2()
        if sample == 'sph':
            dataTree.Draw(xString+">>"+sample+region, '(photons.pt[0] > 175. && t1Met.minJetDPhi > 0.5 && t1Met.met > 170.)', 'goff')
        else:
            dataTree.Draw(xString+">>"+sample+region, str(lumi)+'* weight * (photons.pt[0] > 175. && t1Met.minJetDPhi > 0.5 && t1Met.met > 170.)', 'goff')


        canvas.legend.add('data', title = sample+region, mcolor = ROOT.kRed, msize = 1, lcolor = ROOT.kRed, lwidth = 4)
        canvas.legend.apply('data', dataHist)
        canvas.addHistogram(dataHist, drawOpt = 'HIST')
        canvas.printWeb('monophoton/phoMet', 'dPhi'+'_'+sample+'_'+region, logy = False)


Ejemplo n.º 28
0
        canvas.legend.apply('data', dataHist)
        canvas.addHistogram(dataHist, drawOpt = 'EP')

        # sys.stdin.readline()
        """
        for sample, color, mcTree in mcTrees:
            mcName = sample+'_'+label
            mcHist = varDef.makeHist(mcName)
            mcTree.Draw(varDef.expr+'>>'+mcName, str(lumi)+' * weight * ('+cutString+')')

            canvas.addStacked(mcHist, title = sample, color = color)
        """
        
        canvas.ylimits = (0.5, -1.)

        canvas.printWeb('monophoton/phoMet/'+probeCut[1], label, logy = False)

    for var in vars2D:
        allCuts = list(probeCuts)
        if var[1] != '':
            allCuts.append(var[1])
            
        cutString = ' && '.join(['(%s)' % c for c in allCuts])
        print cutString
            
        label = var[0]+'_'+probeCut[1]

        canvas.Clear(xmax = 0.90)
        canvas.legend.Clear()
        canvas.legend.setPosition(0.1, 0.7, 0.9, 0.9)
Ejemplo n.º 29
0
            # plot fit
            frame = mass.frame(ROOT.RooFit.Range('fitWindow'), ROOT.RooFit.Bins(mass.getBins('fitWindow')))
            targHist.plotOn(frame)
            model.plotOn(frame)
            model.plotOn(frame, ROOT.RooFit.Components(bkgModelName), ROOT.RooFit.LineStyle(ROOT.kDashed), ROOT.RooFit.LineColor(ROOT.kGreen))
            frame.SetTitle('')
            frame.SetMinimum(0.)
    
            canvas.addHistogram(frame)
            if dataType == 'mc':
                canvas.legend.apply('mcbkg', hmcbkg)
                canvas.addHistogram(hmcbkg)

            if pdf == 'altbkg':
                canvas.printWeb('efake', 'fit_' + dataType + '_altbkg_' + conf + '_' + binName, logy = False)
            elif pdf == 'altsig':
                canvas.printWeb('efake', 'fit_' + dataType + '_sigbkg_' + conf + '_' + binName, logy = False)
            else:
                canvas.printWeb('efake', 'fit_' + dataType + '_' + conf + '_' + binName, logy = False)

        # run toys
        nNominal = vals['nsignal'] + vals['nbkg']

        ROOT.RooMsgService.instance().setStreamStatus(1, False)

        iToy = 0
        while iToy < nToys:
            iToy += 1

            for param, val in vals.items():
Ejemplo n.º 30
0
    monophDist = dist.Clone('monoph_' + dist.GetName())
    distCanvas.legend.apply('monoph', monophDist)
    mcMonoph.Draw(expr + '>>' + monophDist.GetName(), weight, 'goff')
    monophDist.Scale(1. / monophDist.GetSumOfWeights(), scaleopt)

    if name == 'ht':
        monophHt = monophDist

    monophEff = eff.Clone('monoph_' + eff.GetName())
    effCanvas.legend.apply('monoph', monophEff)
    mcMonoph.Draw('1. - (eleveto || muveto):' + expr + '>>' + monophEff.GetName(), weight, 'prof goff')

    distCanvas.addHistogram(dataDist, drawOpt = 'HIST')
    distCanvas.addHistogram(mumugDist, drawOpt = 'HIST')
    distCanvas.addHistogram(monophDist, drawOpt = 'HIST')
    distCanvas.printWeb('veto_eff', 'dist_' + name)
    distCanvas.Clear()

    effCanvas.addHistogram(dataEff, drawOpt = 'EP')
    effCanvas.addHistogram(mumugEff, drawOpt = 'EP')
    if name == 'incl':
        effCanvas.addHistogram(datajetEff, drawOpt = 'EP')
        effCanvas.addHistogram(mumugjetEff, drawOpt = 'EP')
    effCanvas.addHistogram(monophEff, drawOpt = 'EP')
    effCanvas.addHistogram(sf, drawOpt = 'P')
    effCanvas.printWeb('veto_eff', 'eff_' + name, logy = False)
    effCanvas.Clear()
    effCanvas.SetGrid(True)

    outputFile.cd()
Ejemplo n.º 31
0
        for iX in range(hnominal.GetNbinsX() + 2):
            if ROOT.TMath.IsNaN(hnominal.GetBinContent(iX)) or ROOT.TMath.IsNaN(hnominal.GetBinError(iX)):
                print hnominal.GetName(), 'cannot be plotted because it contains NaN'
                plot = False
                break

            if huncert and (ROOT.TMath.IsNaN(huncert.GetBinContent(iX)) or ROOT.TMath.IsNaN(huncert.GetBinError(iX))):
                print huncert.GetName(), 'cannot be plotted because it contains NaN'
                plot = False
                break

        if not plot:
            continue
    
        canvas1.legend.apply('stat', hnominal)
    
        if huncert:
            canvas1.Clear()
            canvas1.legend.apply('total', huncert)
   
            canvas1.addHistogram(huncert, drawOpt = 'E2')
            canvas1.addHistogram(hnominal, drawOpt = 'EP')
            canvas1.printWeb(plotDir, hnominal.GetName(), logy = not proc.startswith('tf_'))
        else:
            canvas2.Clear()
            canvas2.addHistogram(hnominal, drawOpt = 'EP')
            canvas2.printWeb(plotDir, hnominal.GetName(), logy = not proc.startswith('tf_'))

rcanvas = RatioCanvas(name = 'datamc', lumi = 36400)
rcanvas.legend.setPosition(0.7, 0.7, 0.9, 0.9)
Ejemplo n.º 32
0
    linear.SetParLimits(0, 0.95, 1.05)
    linear.SetParLimits(1, -0.0001, 0.0001)

    sfTruth.Fit(linear)
    canvas.addObject(linear)

    text = 'flat = %.3f #pm %.3f' % (flat.GetParameter(0), flat.GetParError(0))
    canvas.addText(text, 0.3, 0.25, 0.5, 0.2)

    text = 'line = %.6f + %.6f * p_{T}' % (linear.GetParameter(0), linear.GetParameter(1))
    canvas.addText(text, 0.3, 0.35, 0.5, 0.25)



canvas.xtitle = binningTitle
canvas.printWeb(outputName, 'scaleFactor_' + binningName, logy = False)


print 'Fit Results:'
for iBin, (bin, _) in enumerate(fitBins):
    print '%15s [%.3f +- %.3f]' % (bin, scaleFactor.GetBinContent(iBin + 1), scaleFactor.GetBinError(iBin + 1))

print '\nTruth Results:'
for iBin, (bin, _) in enumerate(fitBins):
    print '%15s [%.3f +- %.3f]' % (bin, sfTruth.GetBinContent(iBin + 1), sfTruth.GetBinError(iBin + 1))

outFileName = 'table_' + binningName + '.tex'
outDir = WEBDIR + '/' + outputName
outFilePath = outDir + '/' + outFileName
outFile = open(outFilePath, 'w')
Ejemplo n.º 33
0
                        lowEdge = float(ptCut.split('t')[2])
                        highEdge = ptCut.split('to')[-1]
                        if highEdge == 'Inf':
                            highEdge = 500.
                        highEdge = float(highEdge)

                    center = (lowEdge + highEdge) / 2.
                    exl = center - lowEdge
                    exh = highEdge - center

                    purity = purities[loc][base+mod][ptCut][metCut]

                    pGraph.SetPoint(iB, center, purity[0])
                    pGraph.SetPointError(iB, exl, exh, purity[1], purity[1])

                if not 'max' in mod:
                    canvas.legend.add(base+mod, title = base+mod, mcolor = r.kOrange+iMod-1, lcolor = r.kOrange+iMod-1, lwidth = 2)
                    canvas.legend.apply(base+mod, pGraph)
                    canvas.addHistogram(pGraph, drawOpt = 'EP')

                outFile.cd()
                pGraph.Write()
                
            canvas.ylimits = (0.0, 15.0)
            canvas.ytitle = 'Photon Impurity'
            canvas.xtitle = 'E_{T}^{#gamma} (GeV)'
            canvas.SetGridy(True)

            plotName = "impurity_"+str(loc)+"_"+str(base)
            canvas.printWeb('purity/'+s.Version+'/Fitting', era+'_'+plotName, logy = False)
Ejemplo n.º 34
0
                gSF.SetPoint(iB, center, sf)
                gSF.SetPointError(iB, exl, exh, sfErrLow, sfErrHigh)

                print sf, sfErrLow, sfErrLow / sf

            rcanvas.legend.add("mc", title = "MC", mcolor = r.kRed, lcolor = r.kRed, lwidth = 2)
            rcanvas.legend.apply("mc", mcEff)
            rcanvas.addHistogram(mcEff, drawOpt = 'EP')

            rcanvas.legend.add("data", title = "Data", lcolor = r.kBlack, lwidth = 2)
            rcanvas.legend.apply("data", dataEff)
            rcanvas.addHistogram(dataEff, drawOpt = 'EP')

            rcanvas.ylimits = (0.0, 1.1)
            rcanvas.ytitle = 'Photon Efficiency'
            rcanvas.xtitle = 'E_{T}^{#gamma} (GeV)'

            plotName = "efficiency_"+str(loc)+"_"+str(pid)
            rcanvas.printWeb('purity/'+s.Version+'/ScaleFactors', plotName, logy = False)
                
            canvas.legend.add(loc+'-'+pid, title = loc+'-'+pid, color = r.kBlack, lwidth = 2)
            canvas.legend.apply(loc+'-'+pid, gSF)
            canvas.addHistogram(gSF, drawOpt = 'EP')
            
            canvas.ylimits = (0.0, 2.0)
            canvas.ytitle = 'Photon Scale Factor'
            canvas.xtitle = 'E_{T}^{#gamma} (GeV)'

            plotName = "scalefactor_"+str(loc)+"_"+str(pid)
            canvas.printWeb('purity/'+s.Version+'/ScaleFactors', plotName, logy = False)
Ejemplo n.º 35
0
stack.Add(sig)

bkgTrue.Scale(1., 'width')
bkgTrue.SetLineColor(ROOT.kGreen + 2)
bkgTrue.SetLineWidth(2)

fakeTrue.Scale(fakeNorm / fakeTrue.GetSumOfWeights(), 'width')
fakeTrue.SetLineColor(ROOT.kRed + 2)
fakeTrue.SetLineWidth(2)

sigTrue.Scale(sigScale, 'width')
sigTrue.SetLineColor(ROOT.kBlue + 2)
sigTrue.SetLineWidth(2)

data.SetMarkerStyle(8)
data.SetLineColor(ROOT.kBlack)
data.SetLineWidth(1)

canvas.title = '#sigma#timesBR = %.2f, N_{fake} = %.0f' % (originalMu *
                                                           sigScale, fakeNorm)
canvas.xtitle = 'm_{T} (GeV)'
canvas.ytitle = 'Events / GeV'

canvas.addHistogram(stack, drawOpt='HIST')
canvas.addHistogram(bkgTrue, drawOpt='HIST')
canvas.addHistogram(fakeTrue, drawOpt='HIST')
canvas.addHistogram(sigTrue, drawOpt='HIST')
canvas.addHistogram(data, drawOpt='EP')

canvas.printWeb('monophoton/fakemet', name, logy=False)
Ejemplo n.º 36
0
                xaxis.SetX1(simple.canvas.GetLeftMargin())
                xaxis.SetX2(1. - simple.canvas.GetRightMargin())
                xaxis.SetY1(simple.canvas.GetBottomMargin())
                xaxis.SetY2(simple.canvas.GetBottomMargin())

                yaxis = canvas.yaxis.DrawClone()
                garbage.append(yaxis)
                yaxis.SetX1(simple.canvas.GetLeftMargin())
                yaxis.SetX2(simple.canvas.GetLeftMargin())
                yaxis.SetY1(simple.canvas.GetBottomMargin())
                yaxis.SetY2(1. - simple.canvas.GetTopMargin())

                simple.canvas.IsA().Destructor(simple.canvas)
                simple.canvas = cnv
                simple._needUpdate = False
                simple.printWeb(plotDir, vardef.name)

                if addLinear:
                    simple.ylimits = (0., -1.)
                    simple.minimum = -1.
                    vardef.ymax = -1.
                    simple._needUpdate = True
                    simple.printWeb(plotDir, vardef.name + 'Linear', logy = False)

                # cleanup the mess
                for obj in garbage:
                    obj.IsA().Destructor(obj)

                cnv.IsA().Destructor(cnv)

            else:
Ejemplo n.º 37
0
        Xmin = min(xmin, Xmin)
        Xmax = max(xmax, Xmax)
        # sys.stdin.readline()

    print Xmin, Xmax
    hbase = r.TH1F("hbase" + weight, weight, 100, Xmin, Xmax)

    canvas.Clear()
    canvas.legend.Clear()

    hists = []
    for iS, (sample, tree) in enumerate(trees):
        hsample = hbase.Clone(sample + weight)
        tree.Draw(weight + " >> " + sample + weight, '', "goff")
        # if hsample.Integral():
        print tree.GetEntries()
        print hsample.Integral()
        hsample.Scale(1. / tree.GetEntries())

        canvas.legend.add(sample + weight,
                          title=sample,
                          mcolor=iS + 1,
                          lcolor=iS + 1,
                          lwidth=2)
        canvas.legend.apply(sample + weight, hsample)
        hists.append(hsample)

        canvas.addHistogram(hists[iS])

    canvas.printWeb('monophoton/compWeights', weight, logy=False)
Ejemplo n.º 38
0
    reweighted += efficiency.GetBinContent(iX) * nproxy

    tpDist.SetBinContent(iX, ntp)

original /= tpDist.GetSumOfWeights() # should in principle match the nominal pT > 40 GeV efficiency
reweighted /= proxyDist.GetSumOfWeights()

print 'Original fake rate =', 1. / original - 1.
print 'Reweighted fake rate =', 1. / reweighted - 1.

proxyDist.Scale(1., 'width')
tpDist.Scale(1., 'width')
proxyDist.Scale(8. / proxyDist.GetSumOfWeights())
tpDist.Scale(8. / tpDist.GetSumOfWeights())

canvas = SimpleCanvas()
canvas.legend.setPosition(0.6, 0.7, 0.9, 0.9)
canvas.legend.add('inefficiency', title = '1 - #epsilon_{e}', opt = 'LP', mstyle = 8, color = ROOT.kBlack)
canvas.legend.add('tp', title = 'T&P sample', opt = 'LF', color = ROOT.kRed - 7, fstyle = 3003, lwidth = 2)
canvas.legend.add('proxy', title = 'W#rightarrowe#nu', opt = 'LF', color = ROOT.kBlue - 7, fstyle = 3003, lwidth = 2)

canvas.addHistogram(inefficiency, drawOpt = 'EP')
canvas.addHistogram(tpDist)
canvas.addHistogram(proxyDist)
canvas.applyStyles()

canvas.ytitle = '1 - #epsilon (%)'
canvas.xtitle = title

canvas.printWeb('efake', 'convolution_' + variable, logy = False)
Ejemplo n.º 39
0
        canvas.addHistogram(sf, drawOpt='EP')

        if tname + '_' + vname == fit_targ:
            func = ROOT.TF1('fitfunc', formula, *fit_range)
            if len(params) > 1:
                func.SetParameters(*params)
            else:
                func.SetParameter(0, params[0])
            sf.Fit(func, "", "", *fit_range)
            canvas.addHistogram(func, drawOpt='')

        canvas.xtitle = vtitle
        canvas.ylimits = (0.8, 1.2)

        canvas.Update()

        if type(binning) is tuple:
            canvas.addLine(binning[0], 1., binning[2], 1., style=ROOT.kDashed)
            sf.GetXaxis().SetLimits(binning[1], binning[2])
        else:
            canvas.addLine(binning[0], 1., binning[-1], 1., style=ROOT.kDashed)
            sf.GetXaxis().SetLimits(binning[0], binning[-1])

        sf.GetYaxis().SetRangeUser(0.8, 1.2)

        canvas.printWeb(outName,
                        'sf_' + oname + '_' + mname1 + '_' + mname2 + '_' +
                        tname + '_' + vname,
                        logy=False)
Ejemplo n.º 40
0
    monophDist = dist.Clone("monoph_" + dist.GetName())
    distCanvas.legend.apply("monoph", monophDist)
    mcMonoph.Draw(expr + ">>" + monophDist.GetName(), weight, "goff")
    monophDist.Scale(1.0 / monophDist.GetSumOfWeights(), scaleopt)

    if name == "ht":
        monophHt = monophDist

    monophEff = eff.Clone("monoph_" + eff.GetName())
    effCanvas.legend.apply("monoph", monophEff)
    mcMonoph.Draw("1. - (eleveto || muveto):" + expr + ">>" + monophEff.GetName(), weight, "prof goff")

    distCanvas.addHistogram(dataDist, drawOpt="HIST")
    distCanvas.addHistogram(dimuDist, drawOpt="HIST")
    distCanvas.addHistogram(monophDist, drawOpt="HIST")
    distCanvas.printWeb("veto_eff", "dist_" + name)
    distCanvas.Clear()

    effCanvas.addHistogram(dataEff, drawOpt="EP")
    effCanvas.addHistogram(dimuEff, drawOpt="EP")
    if name == "incl":
        effCanvas.addHistogram(datajetEff, drawOpt="EP")
        effCanvas.addHistogram(dimujetEff, drawOpt="EP")
    effCanvas.addHistogram(monophEff, drawOpt="EP")
    effCanvas.addHistogram(sf, drawOpt="P")
    effCanvas.printWeb("veto_eff", "eff_" + name, logy=False)
    effCanvas.Clear()
    effCanvas.SetGrid(True)

    outputFile.cd()
Ejemplo n.º 41
0
    gup.SetLineColor(power.GetLineColor())
    gup.SetLineWidth(power.GetLineWidth())
    canvas.addHistogram(gup, drawOpt='CL')

    gdown.SetLineStyle(ROOT.kDashed)
    gdown.SetLineColor(power.GetLineColor())
    gdown.SetLineWidth(power.GetLineWidth())
    canvas.addHistogram(gdown, drawOpt='CL')

    outputFile.cd()
    gup.Write(PRODUCT + '_fitUp')
    gdown.Write(PRODUCT + '_fitDown')

canvas.xtitle = binningTitle
canvas.printWeb(outputName,
                PRODUCT + '_' + dataType + '_' + binningName,
                logy=False)

for iBin, (bin, _) in enumerate(fitBins):
    if dataType == 'mc':
        print '%15s [%.3f +- %.3f (stat.) +- %.3f (syst.)] x 10^{-2} (mc %.3f)' % (
            bin, result.GetBinContent(iBin + 1) * 100., staterrs[iBin] * 100.,
            systerrs[iBin] * 100., trueResult.GetBinContent(iBin + 1) * 100.)
    else:
        print '%15s [%.3f +- %.3f (stat.) +- %.3f (syst.)] x 10^{-2}' % (
            bin, result.GetBinContent(iBin + 1) * 100., staterrs[iBin] * 100.,
            systerrs[iBin] * 100.)

if uncSource:
    for conf in meas:
        for bin, _ in fitBins:
Ejemplo n.º 42
0
canvas.xtitle = vtitle
canvas.ylimits = (0., 1.2)

canvas.Update()

if type(binning) is tuple:
    canvas.addLine(binning[0], 1., binning[2], 1.)
    eff.GetXaxis().SetLimits(binning[1], binning[2])
else:
    canvas.addLine(binning[0], 1., binning[-1], 1.)
    eff.GetXaxis().SetLimits(binning[0], binning[-1])

eff.GetYaxis().SetRangeUser(0., 1.2)

canvas.printWeb('trigger', vname + '_' + tname + '_' + sname + '_' + oname, logy = False)

func = None
marker = None

if vname == 'pt' and (tname == 'l1' or tname == 'l1hlt') and sname == 'jht':
    func = work.factory('PolyVar::func(x, {intercept[1.04,0.,2.], slope[-0.001,-0.01,0.]})')
    params = ROOT.RooArgList(work.arg('intercept'), work.arg('slope'))
    fitmin = 300.
    fitmax = 1000.
    
elif vname == 'ptzoom' and tname == 'hlt' and sname == 'sel':
    func = work.factory('FormulaVar::func("(@0 < @1) * @2 * (1. + TMath::Erf((@3 - @2) * @4 / @2 * (@0 - @1))) + (@0 > @1) * (@2 + (@3 - @2) * TMath::Erf(@4 * (@0 - @1)))", {x, turn[170.,0.,300.], norm1[0.5,0.,1.], norm[0.9,0.,1.], rise2[0.1,0.,1.]})')
    params = ROOT.RooArgList(work.arg('turn'), work.arg('norm1'), work.arg('norm'), work.arg('rise2'))
    fitmin = 150.
    fitmax = 250.
Ejemplo n.º 43
0
    tfacts.append(tfact)

    scanvas.Clear()
    scanvas.legend.Clear()

    scanvas.ylimits = (0.01, 2.5)
    scanvas.SetLogy(True)

    scanvas.legend.setPosition(0.6, 0.7, 0.9, 0.9)
    scanvas.legend.add(tname, title = 'Transfer factor', lcolor = r.kBlack, lwidth = 1)

    scanvas.legend.apply(tname, tfact)

    scanvas.addHistogram(tfact, drawOpt = 'EP')

    scanvas.printWeb('monophoton/gjetsTFactor', 'tfactor'+method)

canvas.Clear()
canvas.legend.Clear()

canvas.ylimits = (0.01, 2.5)
canvas.SetLogy(True)

canvas.legend.setPosition(0.6, 0.7, 0.9, 0.9)

canvas.addObs(tfacts[0], 'Data')
canvas.addSignal(tfacts[1], title = 'MC', color = r.kRed, idx = -1)
canvas.addStacked(tfacts[1], title = 'MC', idx = -1)

canvas.printWeb('monophoton/gjetsTFactor', 'tfactorRatio')
Ejemplo n.º 44
0
for sample in samples:
    dataTree = ROOT.TChain('events')
    dataTree.Add('/scratch5/ballen/hist/monophoton/skim/sph-d*_'+sample+'.root')

    xString = "t1Met.photonDPhi"
    yString = "( ( (photons.e55[0] / TMath::CosH(photons.eta[0])) - photons.pt[0] ) / t1Met.met )"

    dataHist = ROOT.TH2D(sample, "", 30, 0., math.pi, 10, -1.0, 1.0)
    dataHist.GetXaxis().SetTitle('#Delta#phi(#gamma, E_{T}^{miss})')
    dataHist.GetYaxis().SetTitle('(E_{55}^{#gamma} - E_{T}^{#gamma}) / E_{T}^{miss}')
    dataHist.Sumw2()
    dataTree.Draw(yString+":"+xString+">>"+sample, '(photons.pt[0] > 175. && t1Met.minJetDPhi > 0.5 && t1Met.met > 170.)', 'goff')

    ColorGrad()
    canvas.addHistogram(dataHist, drawOpt = 'COLZ TEXT')
    canvas.printWeb('monophoton/phoMet', 'DiffVsPhi'+'_'+sample, logy = False)

    canvas.Clear(xmax = 0.90)

dataTree = ROOT.TChain('events')
dataTree.Add('/scratch5/ballen/hist/monophoton/skim/sph-d*_monoph.root')

xString = "photons.eta[0]"
yString = "photons.phi[0]"

dataHist = ROOT.TH2D("lego", "", 30, -1.5, 1.5, 30, -math.pi, math.pi)
dataHist.GetXaxis().SetTitle('#eta')
dataHist.GetYaxis().SetTitle('#phi')
dataHist.Sumw2()
dataTree.Draw(yString+":"+xString+">>lego", 'photons.pt[0] > 175. && t1Met.minJetDPhi > 0.5 && t1Met.met > 170. && t1Met.photonDPhi < 2.', 'goff')
Ejemplo n.º 45
0
                  color=ROOT.kBlue,
                  fstyle=3003,
                  lwidth=2)
canvas.legend.add('dataRaw',
                  title='Raw',
                  opt='LF',
                  color=ROOT.kRed,
                  fstyle=3003,
                  lwidth=2)

canvas.addHistogram(dataCorr)
canvas.addHistogram(dataRaw)

canvas.applyStyles()

canvas.printWeb('rawEScale', 'data', logy=False)

canvas.Clear()

mcCorr = ROOT.TH1D('mcCorr', '', 60, 60., 120.)
mcRaw = ROOT.TH1D('mcRaw', '', 60, 60., 120.)
mcChain.Draw('tp.mass>>mcCorr', 'probes.pt > 100.', 'goff')
mcChain.Draw(rawMass + '>>mcRaw', 'probes.pt > 100.', 'goff')

canvas = SimpleCanvas()
canvas.legend.setPosition(0.7, 0.7, 0.9, 0.9)
canvas.legend.add('mcCorr',
                  title='Corrected',
                  opt='LF',
                  color=ROOT.kBlue,
                  fstyle=3003,