예제 #1
0
파일: compute.py 프로젝트: blallen/MitMonoX
    weight = 'weight'

    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)
예제 #2
0
파일: sf_compute.py 프로젝트: sraman2/MonoX
### Visualize

lumi = sum(allsamples[s].lumi for s in lumiSamples)

# scaleFactor.SetMaximum(1.05)

canvas = SimpleCanvas(lumi = lumi)
canvas.SetGrid(False, True)
canvas.legend.setPosition(0.7, 0.8, 0.9, 0.9)

canvas.legend.add('sf', 'Scale Factor', opt = 'LP', color = ROOT.kBlack, mstyle = 8)
canvas.legend.add('sf_truth', 'MC truth', opt = 'LP', color = ROOT.kGreen, mstyle = 4)
canvas.ylimits = (0.9, 1.10)

canvas.legend.apply('sf_truth', sfTruth)
canvas.addHistogram(sfTruth, drawOpt = 'EP')

canvas.legend.apply('sf', scaleFactor)
canvas.addHistogram(scaleFactor, drawOpt = 'EP')

if ADDFIT:
    flat = ROOT.TF1('flat', '[0]', scaleFactor.GetXaxis().GetXmin(), scaleFactor.GetXaxis().GetXmax())
    flat.SetParameter(0, 1.)
    flat.SetParLimits(0, 0.95, 1.05)

    sfTruth.Fit(flat)
    canvas.addObject(flat)

    linear = ROOT.TF1('linear', '[0] + [1] * x', scaleFactor.GetXaxis().GetXmin(), scaleFactor.GetXaxis().GetXmax())
    linear.SetParameters(1., 0.01)
    linear.SetParLimits(0, 0.95, 1.05)
예제 #3
0
                purityFile.write(r"\\")
                purityFile.write("\n")

                purityFile.write(r"\hline")
                purityFile.write("\n")
                purityFile.write(r"\end{tabular}")
                purityFile.write("\n")
                purityFile.write(r"\end{document}")
                purityFile.close()


                suffix = [ "central", "error" ] 
                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()
예제 #4
0
                    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.kBlue + iMod,
                                  lcolor=r.kBlue + iMod,
                                  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)
예제 #5
0
파일: eff.py 프로젝트: yiiyama/MonoX
            canvas.Clear()
            canvas.SetGrid()

            canvas.legend.Clear()
            if title:
                canvas.legend.add('eff',
                                  title=title,
                                  opt='LP',
                                  color=ROOT.kBlack,
                                  mstyle=8)
                canvas.legend.apply('eff', eff)
            else:
                eff.SetMarkerColor(ROOT.kBlack)
                eff.SetMarkerStyle(8)

            canvas.addHistogram(eff, drawOpt='EP', clone=False)

            canvas.xtitle = vtitle
            canvas.ylimits = (0., 1.1)

            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)
예제 #6
0
    mcMonoph.Draw(expr + '>>' + monophDist.GetName(), weight, 'goff')
    monophDist.Scale(1. / monophDist.GetSumOfWeights(), scaleopt)

    # 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)
예제 #7
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)
예제 #8
0
outputFile.cd()
frate.Write()
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)
예제 #9
0
                    dataEff.SetPoint(iB, center, eff)
                    dataEff.SetPointError(iB, exl, exh, effError, effError)

                    sf = eff / mceffs[0]
                    sfErrLow = effError / mceffs[0]
                    sfErrHigh = effError / mceffs[0]
                    gSF.SetPoint(iB, center, sf)
                    gSF.SetPointError(iB, exl, exh, sfErrLow, sfErrHigh)

                    # print sf, sfErrLow, sfErrLow / sf

                if not 'max' in mod:
                    rcanvas.legend.add("mc"+mod, title = base+mod, mcolor = r.kRed+iMod, lcolor = r.kRed+iMod, lwidth = 2)
                    rcanvas.legend.apply("mc"+mod, mcEff)
                    rcanvas.addHistogram(mcEff, drawOpt = 'EP')

                # rcanvas.legend.add("data"+mod, title = "Data"+mod, mcolor = r.Blue+iMod, lcolor = r.kBlue+iMod, lwidth = 2)
                # rcanvas.legend.apply("data"+mod, dataEff)
                # rcanvas.addHistogram(dataEff, drawOpt = 'EP')

                canvas.legend.add(loc+'-'+base+mod, title = loc+'-'+base+mod, color = r.kBlack+iMod, lwidth = 2)
                canvas.legend.apply(loc+'-'+base+mod, gSF)
                canvas.addHistogram(gSF, drawOpt = 'EP')

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

            plotName = "efficiency_"+str(loc)+"_"+str(base)
예제 #10
0
파일: plot2D.py 프로젝트: yiiyama/MonoX
    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')
예제 #11
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()
예제 #12
0
파일: phifit.py 프로젝트: dabercro/MonoX
# Canvas
from plotstyle import SimpleCanvas
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)
예제 #13
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)
예제 #14
0
파일: calcSF.py 프로젝트: dabercro/MonoX
                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)
예제 #15
0
for sample in sphs:
    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()
예제 #16
0
        tfact.Write()

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

        canvas.legend.add(gname, title = '#gamma + jet', lcolor = ROOT.kBlack, lwidth = 2)
        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)
예제 #17
0
                  title='Halo template',
                  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)
예제 #18
0
                      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(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':
예제 #19
0
파일: plotDPhi.py 프로젝트: DylanHsu/MonoX
           }


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)


예제 #20
0
                gSF.SetPoint(iB, center, sf)
                gSF.SetPointError(iB, exl, exh, sfErrLow, sfErrHigh)

            outFile.cd()
            gMcEff.Write()
            gDataEff.Write()
            gSF.Write()

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

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

            canvas.legend.add(loc + '-' + base,
                              title=loc + ' ' + base,
                              color=r.kBlack,
                              lwidth=2)
            canvas.legend.apply(loc + '-' + base, gSF)
            canvas.addHistogram(gSF, drawOpt='EP')
예제 #21
0
파일: efake_fit.py 프로젝트: DylanHsu/MonoX
    
                hmcbkg = generator.makeTemplate(ROOT.kEG, hmcbkgName, 'TMath::Abs(probes.matchedGen) != 11 && ({cut})'.format(cut = cut))
                
                hmcbkg.SetDirectory(outputFile)
                outputFile.cd()
                hmcbkg.Write()

            # 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)
예제 #22
0
파일: compare.py 프로젝트: blallen/MitMonoX
rawMass = 'TMath::Sqrt(TMath::Power(' + rawE + ' + tags.pt * TMath::CosH(tags.eta), 2.)'
rawMass += ' - TMath::Power(' + rawPx + ' + tags.pt * TMath::Cos(tags.phi), 2.)'
rawMass += ' - TMath::Power(' + rawPy + ' + tags.pt * TMath::Sin(tags.phi), 2.)'
rawMass += ' - TMath::Power(' + rawPz + ' + tags.pt * TMath::SinH(tags.eta), 2.))'

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)
예제 #23
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)
예제 #24
0
        print "Purity diff is:", purityDiff
        toyPlot.Fill(purityDiff)

        yieldDiff = toyResult.nReal - nominalResult.nReal
        print "Yield diff is:", yieldDiff
        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'
    
예제 #25
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)
예제 #26
0
파일: plotDPhi.py 프로젝트: yiiyama/MonoX
                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)
예제 #27
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)
예제 #28
0
    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.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)
예제 #29
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)
예제 #30
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()
예제 #31
0
        canvas.Clear()
        canvas.legend.Clear()

        canvas.legend.add(gname, title = '#gamma + jet', lcolor = ROOT.kBlack, lwidth = 2)
        canvas.legend.add(fname, title = '#gamma + jet #times impurity', lcolor = ROOT.kRed, lwidth = 2)
        canvas.legend.add(fname+'Syst', title = 'impurity #pm 1#sigma', 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(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 = (0.1, 250000.)
        canvas.SetLogy(True)

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

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

        if samp == 'Down':
            canvas.ylimits = (0., -1.)
예제 #32
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)
        
    

예제 #33
0
        canvas.Clear()
        canvas.SetGrid()

        canvas.legend.Clear()
        if title:
            canvas.legend.add('sf',
                              title=title,
                              opt='LP',
                              color=ROOT.kBlack,
                              mstyle=8)
            canvas.legend.apply('sf', sf)
        else:
            sf.SetMarkerColor(ROOT.kBlack)
            sf.SetMarkerStyle(8)

        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()
예제 #34
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)
예제 #35
0
else:
    canvas.legend.add(PRODUCT,
                      '#epsilon_{e}',
                      opt='LP',
                      color=ROOT.kBlack,
                      mstyle=8)
    canvas.ylimits = (0.75, 1.)

if dataType == 'mc':
    canvas.legend.add(PRODUCT + '_truth',
                      'MC truth',
                      opt='LP',
                      color=ROOT.kGreen,
                      mstyle=4)
    canvas.legend.apply(PRODUCT + '_truth', trueResult)
    canvas.addHistogram(trueResult, drawOpt='EP')

canvas.legend.apply(PRODUCT, result)
canvas.addHistogram(result, drawOpt='EP')

if ADDFIT:
    # exclude bins 42 < pT < 48
    errors = {}
    ibin = result.FindFixBin(42.)
    while ibin <= result.FindFixBin(48.):
        errors[ibin] = result.GetBinError(ibin)
        result.SetBinError(ibin, 1.e+6)
        ibin += 1

    power = ROOT.TF1('power', '[0] + [1] / ((x - [3])- [2])',
                     result.GetXaxis().GetXmin(),
예제 #36
0
파일: compute.py 프로젝트: dabercro/MonoX
    weight = "weight"

    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)
예제 #37
0
else:
    canvas.legend.add(PRODUCT,
                      '#epsilon_{e}',
                      opt='LP',
                      color=ROOT.kBlack,
                      mstyle=8)
    canvas.ylimits = (0.75, 1.)

if dataType == 'mc':
    canvas.legend.add(PRODUCT + '_truth',
                      'MC truth',
                      opt='LP',
                      color=ROOT.kGreen,
                      mstyle=4)
    canvas.legend.apply(PRODUCT + '_truth', trueResult)
    canvas.addHistogram(trueResult, drawOpt='EP')

canvas.legend.apply(PRODUCT, result)
canvas.addHistogram(result, drawOpt='EP')

if ADDFIT:
    contents = {}

    print result.GetBinContent(1), result.GetBinError(1)

    # exclude bins 42 < pT < 48
    ibin = result.FindFixBin(42.)
    while ibin <= result.FindFixBin(48.):
        contents[ibin] = (result.GetBinContent(ibin), result.GetBinError(ibin))
        #        result.SetBinContent(ibin, 0.)
        result.SetBinError(ibin, 1.e+6)
예제 #38
0
파일: eff.py 프로젝트: dabercro/MonoX
if outname:
    outputFile.cd()
    eff.Write(vname + '_' + tname + '_' + sname)

canvas.SetGrid()

canvas.legend.Clear()
if title:
    canvas.legend.add('eff', title = title, opt = 'LP', color = ROOT.kBlack, mstyle = 8)
    canvas.legend.apply('eff', eff)
else:
    eff.SetMarkerColor(ROOT.kBlack)
    eff.SetMarkerStyle(8)

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

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)
예제 #39
0
    outputFile.cd()
    tfact.Write()
    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)
예제 #40
0
파일: plot2D.py 프로젝트: blallen/MitMonoX
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')
예제 #41
0
파일: compare.py 프로젝트: yiiyama/MonoX
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)