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) outFile.Close() for loc in s.Locations[:1]: for base in bases: for metCut in MetSels:
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) canvas.printWeb('trigger', vname + '_' + tname + '_' + sname + '_' + oname, logy = False) func = None
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()
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) canvas.legend.apply(tname, tfact) canvas.addHistogram(tfact, drawOpt = 'EP')
mcMonoph = ROOT.TChain("skim") mcMonoph.Add(config.histDir + "/veto_eff/monoph_znng-130.root") distCanvas = SimpleCanvas("cdist") distCanvas.legend.add("data", title="2#mu data", opt="L", color=ROOT.kBlack, fstyle=0) distCanvas.legend.add("dimu", title="2#mu MC", opt="L", color=ROOT.kRed, fstyle=0) distCanvas.legend.add("monoph", title="Z#gamma MC", opt="L", color=ROOT.kBlue, fstyle=0) distCanvas.legend.setPosition(0.7, 0.7, 0.9, 0.9) effCanvas = SimpleCanvas("ceff") effCanvas.legend.add("data", title="2#mu data", opt="LP", color=ROOT.kBlack, mstyle=8) effCanvas.legend.add("dimu", title="2#mu MC", opt="LP", color=ROOT.kRed, mstyle=8) effCanvas.legend.add("monoph", title="Z#gamma MC", opt="LP", color=ROOT.kBlue, mstyle=4) effCanvas.legend.add("sf", title="2#mu data/MC", opt="LP", color=ROOT.kBlack, mstyle=25, lwidth=2) effCanvas.legend.setPosition(0.7, 0.7, 0.9, 0.9) effCanvas.ylimits = (0.9, 1.05) effCanvas.SetGrid(True) configs = { "incl": ("0.5", "", (1, 0.0, 1.0)), "njet": ("njet", "N_{jet}", (8, 0.0, 8.0)), "ht": ("ht", "H_{T} (GeV)", [100.0 * x for x in range(5)] + [500.0, 700.0, 900.0, 1200.0, 2000.0]), "npv": ("npv", "N_{vtx}", (20, 0.0, 40.0)), } outputFile = ROOT.TFile.Open(config.histDir + "/veto_eff/veto_eff.root", "recreate") for name, config in configs.items(): expr, title, binning = config if type(binning) is tuple:
mcEff.Write('mcEff') mcTruthEff.Write('mcTruthEff') ### 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)
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)
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)
dataTreeAll = ROOT.TChain("events") 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)
# 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) rcanvas.printWeb('purity/'+s.Version+'/ScaleFactors', era+'_'+plotName, logy = False) # canvas.ylimits = (0.0, 2.0) canvas.ytitle = 'Photon Scale Factor' canvas.xtitle = 'E_{T}^{#gamma} (GeV)' plotName = "scalefactor_"+str(loc)+"_"+str(base) # canvas.printWeb('purity/'+s.Version+'/ScaleFactors', plotName, logy = False)
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', 'distributions'+samp) rcanvas.Clear() rcanvas.legend.Clear() if samp == 'Down': rcanvas.ylimits = (0., -1.) else: rcanvas.ylimits = (0., 0.15) rcanvas.SetLogy(False) rcanvas.legend.add(tname, title = 'transfer factor', lcolor = ROOT.kBlack, lwidth = 2)
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()
lcolor=r.kBlack, lwidth=1) 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()
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') 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.addObs(dataHist, title = 'Data') canvas.legend.add('data', title = '#Delta#phi(tag,probe) > 3. && '+varDef.cut, mcolor = r.kBlack, lcolor = r.kBlack, lwidth = 1) 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()
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)
tfact = hists[1].Clone(tname) tfact.Divide(hists[0]) tfact.GetYaxis().SetTitle("") tfact.SetMarkerStyle(8) tfact.SetMarkerSize(0.8) 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.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.) else: canvas.ylimits = (0., 0.15) canvas.SetLogy(False) canvas.legend.add(tname, title = 'transfer factor', lcolor = ROOT.kBlack, lwidth = 2)
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()
if dataType == 'mc': trueResult.Write() trueYields[meas[0]].Write() trueYields[meas[1]].Write() ### Visualize lumi = sum(allsamples[s].lumi for s in lumiSamples) canvas = SimpleCanvas(lumi=lumi, sim=(dataType == 'mc')) canvas.SetGrid(False, True) canvas.legend.setPosition(0.7, 0.8, 0.9, 0.9) if PRODUCT == 'frate': result.SetMaximum(0.05) canvas.legend.add(PRODUCT, 'R_{e}', opt='LP', color=ROOT.kBlack, mstyle=8) canvas.ylimits = (0., 0.05) 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)
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: canvas.printWeb(plotDir, vardef.name) if addLinear:
tfact = hists[1].Clone(tname) tfact.Divide(hists[0]) tfact.GetYaxis().SetTitle("") tfact.SetMarkerStyle(8) tfact.SetMarkerSize(0.8) 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)
mctruth.append(ratio) 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)
opt='LP', color=ROOT.kRed, mstyle=8) effCanvas.legend.add('monoph', title='Z#gamma MC', opt='LP', color=ROOT.kBlue, mstyle=4) effCanvas.legend.add('sf', title='2#mu data/MC', opt='LP', color=ROOT.kBlack, mstyle=34, lwidth=2) effCanvas.legend.setPosition(0.7, 0.7, 0.9, 0.9) effCanvas.ylimits = (0.9, 1.05) effCanvas.SetGrid(True) # plot configs configs = { 'incl': ('0.5', '', (1, 0., 1.)), 'njet': ('jets.size', 'N_{jet}', (8, 0., 8.)), 'ht': ('Sum$(jets.pt_)', 'H_{T} (GeV)', [100. * x for x in range(5)] + [500., 700., 900., 1200., 2000.]), 'npv': ('npv', 'N_{vtx}', (20, 0., 40.)) } outputFile = ROOT.TFile.Open(config.histDir + '/veto_eff/veto_eff.root', 'recreate') for name, config in configs.items():
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': rcanvas.ylimits = (0., -1.) # else: # rcanvas.ylimits = (0., 0.05) rcanvas.SetLogy(False)
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() 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.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) # 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)
if dataType == 'mc': trueResult.Write() trueYields[meas[0]].Write() trueYields[meas[1]].Write() ### Visualize lumi = sum(allsamples[s].lumi for s in lumiSamples) canvas = SimpleCanvas(lumi=lumi, sim=(dataType == 'mc')) canvas.SetGrid(False, True) canvas.legend.setPosition(0.7, 0.8, 0.9, 0.9) if PRODUCT == 'frate': result.SetMaximum(0.05) canvas.legend.add(PRODUCT, 'R_{e}', opt='LP', color=ROOT.kBlack, mstyle=8) canvas.ylimits = (0., .1) 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)