def main(): # print "reade ntuple for file ", sys.arg[1] # print "read geometry from file ", sys.argv[2] # ntuple = HGCalNtuple(sys.argv[1]) # planes = GeoUtils.read_planes(sys.argv[2]) # for plane in planes: # print_geo(ntuple, plane) print "read geometry from file: ", "fullgeometry_.txt" print "reading planes" planes = GeoUtils.read_planes("fullgeometry_.txt") c = TCanvas() mg = TMultiGraph() cells = planes[0].cells for cell in cells: x = array("d", cell.coordinates.vertices[:, 0]) x.append(x[0]) y = array("d", cell.coordinates.vertices[:, 1]) y.append(y[0]) gi = TGraph(len(x), x, y) gi.SetMarkerStyle(1) mg.Add(gi, "AL") # mg.Draw("AL") mg.Draw("A") c.Draw() c.SaveAs("hex0.png")
def __init__(self, models, bcids, values, fill=4954, workinprogress=False): """Initialize a summary plot of values per model and bcid.""" nbcid, nmodels = len(bcids), len(models) order = sorted(range(nbcid), key=lambda i: bcids[i]) mini, maxi = 1.0e99, -1.0e99 multi = TMultiGraph('summary', '') for i, mod in enumerate(models): xval = array( 'd', [c + 0.09 * (i - 0.5 * nmodels) for c in range(nbcid)]) xerr = array('d', [0.0] * nbcid) yval = array('d', [values[i][j][0] for j in order]) yerr = array('d', [values[i][j][1] for j in order]) #[0.0]*nbcid) mini = min(mini, min([v - e for v, e in zip(yval, yerr)])) maxi = max(maxi, max([v + e for v, e in zip(yval, yerr)])) graph = TGraphErrors(nbcid, xval, yval, xerr, yerr) graph.SetName('summary_{0}'.format(mod)) multi.Add(graph) self._multi = multi mini, maxi = mini - 0.08 * (maxi - mini), maxi + 0.25 * (maxi - mini) hist = TH2F('axishist', '', nbcid, -0.5, nbcid - 0.5, 100, mini, maxi) for i, j in enumerate(order): hist.GetXaxis().SetBinLabel(i + 1, str(bcids[j])) SingleGraphBase.__init__(self, hist, 'summary', fill, workinprogress) for gr in multi.GetListOfGraphs(): self.add(gr, draw=False) self._xtitle = 'bcid' self._drawoption = 'AXIS' self.markers = [markers(i) for i in range(nmodels)] self.colors = [colors(i) for i in range(nmodels)] self.xrange(-0.5, nbcid - 0.5) self.yrange(mini, maxi)
def E(b): tg1 = TGraph() tg2 = TGraph() tg3 = TGraph() tg4 = TGraph() tm = TMultiGraph() tm.Add(tg1, "L") tm.Add(tg2, "L") tm.Add(tg3, "L") #print len(b.KE()) for i in xrange(len(b.KE())): tg1.SetPoint(i, i, b.KE()[i]) tg2.SetPoint(i, i, b.PE()[i]) tg3.SetPoint(i, i, b.PE()[i] + b.KE()[i]) tg4.SetPoint(i, i, 1 - (b.PE()[i] + b.KE()[i]) / (b.PE()[0] + b.KE()[0])) tg1.SetLineWidth(2) tg2.SetLineWidth(2) tg3.SetLineWidth(2) tg4.SetLineWidth(2) return [tg1, tg2, tg3, tm, tg4]
def ROCMGDraw(TGraphArray, c1): c1.Clear() colorArray = [1, 2, 3, 4, 6, 7] AOC = 0 leg = TLegend(0.1, 0.7, 0.48, 0.9) mg = TMultiGraph() title_text = [] l_count = 0 for TGraphInstance, title in TGraphArray: print TGraphInstance, title TGraphInstance.SetLineColor(colorArray[l_count]) mg.Add(TGraphInstance) AOC = TGraphInstance.Integral(0, -1) + .5 leg.AddEntry(TGraphInstance, "{} AOC: {}".format(title, AOC)) title_text.append(title) l_count = l_count + 1 title_text = "_".join(title_text) yEqualsX = TLine(0, 0, 1, 1) yEqualsX.SetLineStyle(7) TH2F_range = TH2F("range_{}".format(title_text), "range_{}".format(title_text), 10, 0, 1, 10, 0, 1) TH2F_range.Draw() mg.Draw("AL") leg.Draw("L") yEqualsX.Draw() title_text = title_text.replace(" ", "_") c1.SaveAs("output/ROC_{}.png".format(title_text)) c1.Clear()
def FIT_XS(): is_fit = True gaexs_list_fit, geeff_list_fit, gexs_list_fit, func_list = fit_xs(label_list, iter_old, old_xs_list, tfunc_list, par_list, par_range_list, xmin_list, xmax_list, is_fit) for f, label, gaexs, geeff, gexs, xtitle, xs_ytitle, eff_ytitle in zip(func_list, label_list, gaexs_list_fit, geeff_list_fit, gexs_list_fit, xtitle_list, xs_ytitle_list, eff_ytitle_list): xs_mbc = TCanvas('xs_mbc_' + label + '_' + iter_old + '_fit', '', 700, 600) set_canvas_style(xs_mbc) xs_mbc.cd() if not label == 'DDPIPI': set_graph_style(gaexs, xtitle, xs_ytitle) gaexs.Draw('ap') else: set_graph_style(gaexs, xtitle, xs_ytitle) set_graph_style(gexs, xtitle, xs_ytitle) mg = TMultiGraph() mg.Add(gaexs) mg.Add(gexs) mg.Draw('ap') chi2 = f.GetChisquare() if label == 'DDPIPI': ndf = f.GetNDF() + 1 else: ndf = f.GetNDF() pt = TPaveText(0.15, 0.8, 0.55, 0.9, "BRNDC") set_pavetext(pt) pt.Draw() line = '#chi^{2}/ndf = ' + str(round(chi2, 3)) + '/' + str(round(ndf, 3)) + ' = ' + str(round(chi2/ndf, 3)) with open('./txts/likelihood_' + label + '.txt', 'w') as f: f.write(str(chi2) + '\n' + str(ndf)) pt.AddText(line) xs_mbc.SaveAs('./figs/xs_' + label + '_' + iter_old + '_fit.pdf') raw_input('Press <Enter> to end...') return func_list
def draw_bucket(self, show=True, t_corr=True): good = self.draw(1, show=False, t_corr=t_corr)[0] bucket = self.draw(1, cut=self.Cut.generate_custom(invert='bucket'), show=False, t_corr=t_corr)[0] bad_bucket = self.draw(1, cut=self.Cut.get_bad_bucket(), show=False, t_corr=t_corr)[0] mg = TMultiGraph('mg_bw', 'Bucket Waveforms') leg = Draw.make_legend(.85, .4, nentries=3) names = ['good wf', 'bucket wf', 'both wf'] for i, gr in enumerate([good, bucket, bad_bucket]): format_histo(gr, color=self.Draw.get_color(3), markersize=.5) mg.Add(gr, 'lp') leg.AddEntry(gr, names[i], 'lp') self.Draw(mg, show=show, draw_opt='A', w=1.5, h=0.75, lm=.07, rm=.045, bm=.2, leg=leg) format_histo(mg, x_range=ax_range( self.Ana.get_region(region='e') * self.BinWidth, None, 0, .3), y_off=.7, x_tit='Time [ns]', y_tit='Signal [mV]')
def evaluateResolutionVariation(model, bcid, prefix, suffix, vtxres, scaling, \ legend=False): from array import array from ROOT import TFile, TMultiGraph, TGraphErrors, gStyle, TCanvas, \ TLegend, TLatex names = [pre+'_'+model+'_'+bcid+'_'+suf for (pre, suf) in zip(prefix, \ suffix)] xVal = {name: array('d', [0.0]*len(vtxres)) for name in names} xErr = {name: array('d', [0.0]*len(vtxres)) for name in names} yVal = {name: array('d', [0.0]*len(vtxres)) for name in names} yErr = {name: array('d', [0.0]*len(vtxres)) for name in names} for name, scale in zip(names, scaling): for i, vr in enumerate(vtxres): f = TFile('results/'+name+'_'+vr+'.root') yVal[name][i] = f.Get('h_overlapInt').GetMean() * 100.0 yErr[name][i] = f.Get('h_integ').GetMeanError() * 100.0 xVal[name][i] = f.Get('h_vtxRes').GetMean() * scale * 1.0e4 multi = TMultiGraph('overlapIntegralBcid'+bcid, '') graphs = [] for i, name in enumerate(names): graph = TGraphErrors(len(vtxres), xVal[name], yVal[name], xErr[name], \ yErr[name]) graph.SetName(name) graph.SetMarkerStyle(20) graph.SetMarkerColor(1+i) multi.Add(graph) graphs.append(graph) gStyle.SetOptStat(0) canvas = TCanvas(model+'_'+bcid, '', 600, 600) multi.Draw('AP') canvas.Update() multi.GetXaxis().SetTitle('vertex resolution [#mum]') multi.GetXaxis().SetLabelSize(0.025) multi.GetXaxis().SetRangeUser(11, 69) multi.GetYaxis().SetTitle('overlap integral [a.u.]') multi.GetYaxis().SetLabelSize(0.025) multi.GetYaxis().SetRangeUser(0.77, 1.43) if legend: leg = TLegend(0.55, 0.15, 0.88, 0.3) leg.SetBorderSize(0) for i, name in enumerate(names): entry = leg.AddEntry(name, legend[i], 'P') entry.SetMarkerStyle(20) entry.SetMarkerColor(1+i) leg.Draw() drawCMS(wip=True) text = TLatex() text.SetNDC() text.SetTextFont(62) text.SetTextSize(0.04) text.SetTextAlign(21) text.DrawLatex(0.5, 0.92, 'Vertex Resolution Study: '+model+', BCID '+bcid) canvas.Modified() canvas.Update() canvas.SaveAs('plots/'+canvas.GetName()+'.pdf') canvas.SaveAs('plots/'+canvas.GetName()+'.C')
def getGraph(self): from array import array from ROOT import TMultiGraph, TLegend, TGraphAsymmErrors n = len(self.__x) if n != len(self.__y) or n != len(self.__yErrLow) or n != len(self.__yErrHigh): raise StandardError, "The length of the x(%s), y(%s) and y error(%s,%s) lists does not match"%(len(self.__x), len(self.__y), len(self.__yErrLow), len(self.__yErrHigh)) result = TMultiGraph() legendPosition = [float(i) for i in self.__getStyleOption("legendPosition").split()] legend = TLegend(*legendPosition) legend.SetFillColor(0) result.SetTitle("%s;%s;%s"%(self.__title,self.__xTitle,self.__yTitle)) xErr = array("d",[0 for i in range(n)]) graph = TGraphAsymmErrors(n, self.__x, self.__y, xErr, xErr, self.__yErrLow,self.__yErrHigh) graph.SetLineWidth(2) graph.SetFillColor(0) graph.SetLineColor(int(self.__getStyleOption("lineColor"))) graph.SetMarkerColor(int(self.__getStyleOption("markerColor"))) graph.SetMarkerStyle(int(self.__getStyleOption("markerStyle"))) graph.SetMarkerSize(float(self.__getStyleOption("markerSize"))) result.Add(graph,"P") result.SetName("MG_%s"%(self.__title)) legend.AddEntry(graph, self.__getStyleOption("name")) return (result, legend)
def makeTMultiGraph(self,name,tit=None): title = tit if tit is None:title = name.replace('_',' ') tmg = TMultiGraph() tmg.SetName(name) tmg.SetTitle(title) return tmg
def MakePlot(PlotList, Mode): colors = [ ROOT.kRed, ROOT.kBlue, ROOT.kGreen, ROOT.kOrange, ROOT.kCyan, ROOT.kMagenta ] MG = TMultiGraph() MG.SetTitle( "Varying {};Center of Mass Angle in Degrees;Cross Section in mb/sr". format(Mode)) MG.SetTitle("MG_{}".format(Mode)) MG.SetName("MG_{}".format(Mode)) legend = ROOT.TLegend(0.65, .65, .9, .9) Zipper = zip(PlotList, colors) for plot, color in Zipper: plot.SetMarkerColor(ROOT.kWhite) plot.SetLineColor(color) plot.SetFillColor(ROOT.kWhite) plot.SetLineWidth(2) MG.Add(plot, "L") legend.AddEntry(plot, plot.GetName()) MG.Draw("AL") canvas.SetLogy() MG.GetXaxis().SetTitle("Center of Mass Angle in Degrees") MG.GetYaxis().SetTitle("Cross Section in mb/sr") MG.Draw() legend.Draw() canvas.SaveAs("vary_{}.png".format(Mode))
def write_imposedattenuationgraphs(ordered_graphslinearity): if len(ordered_graphslinearity) == 40: sectors = [1, 2, 3, 4, 5] else: sectors = [6, 7, 8] colors = [1, 2, 3, 4, 5, 6, 7, 8, 9] for c, s in enumerate(sectors): plots = [x for x in ordered_graphslinearity if str(s) in x.filename[8]] mgraph = TMultiGraph() for counter, p in enumerate(plots): x = array('d', p.setattenvalues) y = array('d', p.normalizedsetmeancurrents) n = len(x) graph = TGraph(n, x, y) graph.SetMarkerColor(colors[counter]) graph.SetLineColor(colors[counter]) graph.SetMarkerStyle(20) graph.SetMarkerSize(1) mgraph.Add(graph) mgraph.SetTitle("PCBs type " + str(s)) mgraph.GetXaxis().SetRangeUser(0.0, 1.2) mgraph.GetXaxis().SetTitle("1/attenuation") mgraph.GetYaxis().SetTitle("i/area (uA/cm^{2})") mgraph.GetYaxis().SetTitleOffset(1.2) mgraph.Draw("APL") gPad.SaveAs("Overimposed_" + str(s) + ".pdf") gPad.Close()
def makeNoisePlot(outputdir, allgraphs, groups_to_plot, namegroups_to_plot, suffix, whats_to_plot, names_to_plot, xtitle): # gROOT.ProcessLine('.L ~/CMS_style/tdrstyle.C') # gROOT.ProcessLine('setTDRStyle()') c1=TCanvas('c1', 'c1', 600,600) leg=defaultLegend(x1=0.35,y1=0.6,x2=0.5,y2=0.90) mg=TMultiGraph() for k,group in enumerate(groups_to_plot): for i,what in enumerate(whats_to_plot): mg.Add(allgraphs[group][what], 'P') leg.AddEntry(allgraphs[group][what], namegroups_to_plot[k] + ' ' + names_to_plot[i], 'LP') mg.Draw('a') mg.GetXaxis().SetTitle(xtitle) mg.GetYaxis().SetTitle('Noise (GeV)') mg.GetXaxis().SetTitle(xtitle) if 'EB' in groups_to_plot[0]: mg.GetYaxis().SetRangeUser(0., 1.0) elif 'EE' in groups_to_plot[0]: mg.GetYaxis().SetRangeUser(0., 15.) leg.Draw('same') #c1.SetLogy() c1.SaveAs('{}/Noise_{}{}.pdf'.format(outputdir,groups_to_plot[0][:2],suffix)) c1.SaveAs('{}/Noise_{}{}.png'.format(outputdir,groups_to_plot[0][:2],suffix)) c1.SaveAs('{}/Noise_{}{}.C'.format(outputdir,groups_to_plot[0][:2],suffix)) c1.SaveAs('{}/Noise_{}{}.root'.format(outputdir,groups_to_plot[0][:2],suffix))
def correctedCrossSectionsPlot(crossings, shapes, overDiff): uncorrected = {41: (3.2575816286, 0.00514858611944), \ 281: (3.26316215713, 0.00468789412223), \ 872: (3.27340775031, 0.00484925398906), \ 1783: (3.24986926821, 0.00460908436455), \ 2063: (3.26363843728, 0.0044071069983)} multi = TMultiGraph('sigmavis', '') graphs = [] n = len(shapes) + 1 for i, shape in enumerate([''] + list(shapes)): xval = array('d', [a + 0.08 * (i - 0.5 * n) for a in range(len(crossings))]) xerr = array('d', len(crossings) * [0]) yval = array('d', [uncorrected[int(bx)][0] for bx in crossings]) yerr = array('d', [uncorrected[int(bx)][1] for bx in crossings]) if shape: for j, bx in enumerate(crossings): yval[j] *= 1 + overDiff[shape][bx] yerr[j] *= 1 + overDiff[shape][bx] graph = TGraphErrors(len(crossings), xval, yval, xerr, yerr) graph.SetName('ge' + shape) graph.SetMarkerStyle(20) graph.SetMarkerColor(1 + i) multi.Add(graph) graphs.append(graph) gStyle.SetOptStat(0) hist = TH2F('hist', '', len(crossings), -0.5, len(crossings) - 0.5, 100, 3.23, 3.33) for i, bx in enumerate(crossings): hist.GetXaxis().SetBinLabel(i + 1, bx) canvas = TCanvas('c_' + multi.GetName(), '', 600, 600) hist.Draw('AXIS') multi.Draw('P') canvas.Update() hist.GetXaxis().SetLabelSize(0.035) hist.GetXaxis().SetNdivisions(len(crossings), False) hist.GetYaxis().SetTitle('#sigma_{vis} [b]') hist.GetYaxis().SetLabelSize(0.025) hist.GetYaxis().SetTitleOffset(1.3) leg = TLegend(0.15, 0.82, 0.85, 0.85) leg.SetNColumns(len(shapes) + 1) leg.SetBorderSize(0) for i, shape in enumerate([''] + list(shapes)): entry = leg.AddEntry('ge' + shape, shapeNames[shape], 'P') entry.SetMarkerStyle(20) entry.SetMarkerColor(1 + i) leg.Draw() drawCMS() canvas.Modified() canvas.Update() canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.pdf') canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.C')
def DivideGraphs(self, g1, g2, interpolationMethod="lin"): """ Divide 2 graphs g1 and g2, by each other applying an interpolation between the points for the denominator @param g1: graph 1 @param g2: graph 2 @param interpolationMethod: method used for interpolation between the two graphs @return: The ratio graphs """ #calculate x range xmin = max(g1.GetX()[0], g2.GetX()[0]) xmax = min(g1.GetX()[g1.GetN() - 1], g2.GetX()[g2.GetN() - 1]) # create new TGraphErors for result1 result1 = self.MakeGraphDivision(g1, g2, xmin, xmax, interpolationMethod) result1.SetMarkerColor(1) result1.SetMarkerStyle(20) # create new TGraphErors for result2 result2 = self.MakeGraphDivision(g2, g1, xmin, xmax, interpolationMethod) result2.SetMarkerColor(2) result2.SetMarkerStyle(20) result = TMultiGraph("result", " ") result.Add(result1) result.Add(result2) result.Draw("AP") result.GetXaxis().SetRangeUser(xmin, xmax) result.GetXaxis().SetTitle("p_{T} [Gev/c]") result.GetXaxis().SetTitleOffset(1.2) result.GetYaxis().SetTitleOffset(1.2) return result
def gangGraphs(self, keywords=[], vetos=[]): ''' create multigraph containing all graphs with titles that match keywords and do not match vetos ''' debug = False if len(keywords) == 0: return # this bores me key = '' for k in keywords: key += k if keywords.index(k) < len(keywords) - 1: key += '__' n = 0 if debug: print 'gangGraphs: key', key, 'graphs:' for g in self.Graphs: title = g.GetTitle() OK = True for k in keywords: OK = OK and (k in title) for v in vetos: OK = OK and not (v in title) if OK: n += 1 if key not in self.MultiGraphs: self.MultiGraphs[key] = TMultiGraph() self.MultiGraphs[key].SetTitle(key) self.MultiGraphs[key].SetName(key) self.color(g, n, n, setMarkerColor=True) self.MultiGraphs[key].Add(g) if debug: print 'add graph', g.GetName() return
def draw_residuals_vs_chi2(self, show=True): mg = TMultiGraph('mgtr', 'Tracking Resolution') leg = Draw.make_legend(y2=.41, nentries=4) for roc, mode in zip([1, 1, 2, 2], ['x', 'y', 'x', 'y']): g = self.draw_residual_vs_chi2(roc, mode, show=False) format_histo(g, color=self.Draw.get_color(4)) mg.Add(g, 'pl') leg.AddEntry(g, 'ROC {} in {}'.format(roc, mode.title()), 'pl') y_range = [ 0, max(g.GetY()[i] for g in mg.GetListOfGraphs() for i in range(g.GetN())) * 1.1 ] format_histo(mg, x_tit='#chi^{2} [quantile]', y_tit='Residual Standard Deviation [#mum]', y_off=1.5, y_range=y_range, draw_first=True) self.Draw(mg, 'EventOffsets', show, draw_opt='ap', leg=leg, lm=.13)
def tgs(tgraphs, title): tmg = TMultiGraph() tle = TLegend(0.6, 0.4, 0.9, 0.8) tit = TPaveText(0.2988506, 0.934322, 0.6997126, 1, "nbNDC") # Make title tit.SetFillColor(0) tit.SetFillStyle(0) tit.SetLineColor(0) tit.AddText(title) for i in xrange(len(tgraphs)): tgraphs[i].SetLineWidth(2) tgraphs[i].SetLineColor(i + 1) tmg.Add(tgraphs[i]) tle.AddEntry(tgraphs[i], tgraphs[i].GetName(), "l") return [tmg, tle, tit]
def doSuperTGraph( data, canvas, obj): xmin=-1.8 xmax=1.8 gStyle.SetOptFit(0) gStyle.SetOptStat(0) gROOT.SetBatch(1) color=[601,417,920,633,910,433,400,619,1,922] mg = TMultiGraph(); leg = TLegend(0.58,0.75,0.89,0.89); i=0 for ivar in data['var']: if not os.path.exists(data['fold']+"/"+ivar+"_ll.root"): continue print '>>> Opening File :' , data['fold']+"/"+ivar+"_ll.root" inFile = TFile.Open ( data['fold']+"/"+ivar+"_ll.root" ," READ ") c1 = inFile.Get(canvas); gr = c1.GetListOfPrimitives().FindObject(obj) xaxis = gr.GetXaxis().GetTitle() yaxis = gr.GetYaxis().GetTitle() gr.SetLineColor(color[i]) mg.Add(gr) leg.AddEntry(gr,ivar,"l") i=i+1 print i c = TCanvas() c.cd() c.SetGrid() mg.Draw("al") line1 = TF1("line1","pol0",-100,100) line1.FixParameter(0,1.) line1.SetLineWidth(2) line1.SetLineStyle(2) line1.SetLineColor(2) line1.Draw("same") line2 = TF1("line2","pol0",-100,100) line2.FixParameter(0,3.84) line2.SetLineWidth(2) line2.SetLineStyle(2) line2.SetLineColor(2) line2.Draw("same") mg.SetTitle(";" +xaxis+";" +yaxis) mg.GetYaxis().SetRangeUser(0,10) leg.SetNColumns(2) leg.SetBorderSize(0) leg.Draw("same") c.SaveAs(data['fold']+"combined10.png") c.SaveAs(data['fold']+"combined10.pdf") c.SaveAs(data['fold']+"combined10.root")
def getGraph(self): from array import array from ROOT import TMultiGraph, TLegend, TGraphAsymmErrors n = len(self.__x) if n != len(self.__y) or n != len(self.__yErrLow) or n != len( self.__yErrHigh): raise StandardError, "The length of the x(%s), y(%s) and y error(%s,%s) lists does not match" % ( len(self.__x), len(self.__y), len( self.__yErrLow), len(self.__yErrHigh)) result = TMultiGraph() legendPosition = [ float(i) for i in self.__getStyleOption("legendPosition").split() ] legend = TLegend(*legendPosition) legend.SetFillColor(0) result.SetTitle("%s;%s;%s" % (self.__title, self.__xTitle, self.__yTitle)) #(refArrays, refLabel) = self.__getRefernceGraphArrays() #refGraph = TGraphAsymmErrors(*refArrays) #refGraph.SetLineWidth(2) #refGraph.SetLineColor(int(self.__config.get("reference","lineColor"))) #refGraph.SetFillColor(int(self.__config.get("reference","fillColor"))) #result.Add(refGraph,"L3") #legend.AddEntry(refGraph,self.__config.get("reference","name")) xErr = array("d", [0 for i in range(n)]) print "__x = ", self.__x print "__y = ", self.__y graph = TGraphAsymmErrors(n, self.__x, self.__y, xErr, xErr, self.__yErrLow, self.__yErrHigh) graph.SetLineWidth(2) graph.SetFillColor(0) graph.SetLineColor(int(self.__getStyleOption("lineColor"))) graph.SetMarkerColor(int(self.__getStyleOption("markerColor"))) graph.SetMarkerStyle(int(self.__getStyleOption("markerStyle"))) graph.SetMarkerSize(float(self.__getStyleOption("markerSize"))) sysGraph = TGraphAsymmErrors(n, self.__x, self.__y, xErr, xErr, self.__ySysErrLow, self.__ySysErrHigh) sysGraph.SetLineWidth(1) sysGraph.SetFillColor(0) sysGraph.SetLineColor(int(self.__getStyleOption("lineColor"))) sysGraph.SetMarkerColor(int(self.__getStyleOption("markerColor"))) sysGraph.SetMarkerStyle(int(self.__getStyleOption("markerStyle"))) sysGraph.SetMarkerSize(float(self.__getStyleOption("markerSize"))) result.Add(sysGraph, "[]") result.Add(graph, "P") # result.SetName("MultiPlots") # result.SetTitle("%s;%s;%s"%(self.__title,self.__xTitle,self.__yTitle)) result.SetName("MG_%s" % (self.__title)) legend.AddEntry(graph, self.__getStyleOption("name")) #for (x,y,yErr) in zip(self.__x, self.__y, zip(self.__yErrLow,self.__yErrHigh)): # self.__addAnnotaion("hallo",x,y,yErr) return (result, legend)
def print_to_pic(self): c = TCanvas() mg = TMultiGraph() for cell in self.cells: x = array("d", cell.coordinates.vertices[:, 0] / 10) x.append(x[0]) y = array("d", cell.coordinates.vertices[:, 1] / 10) y.append(y[0]) gi = TGraph(len(x), x, y) gi.SetMarkerStyle(1) mg.Add(gi, "AL") # mg.Draw("AL") mg.Draw("A") return mg
def doSuperTGraphAll( file_list, canvas, obj, output): gStyle.SetOptFit(0) gStyle.SetOptStat(0) gROOT.SetBatch(1) mg = TMultiGraph(); leg = TLegend(0.58,0.75,0.89,0.89); for iFile in file_list: if not os.path.exists(iFile['path']): print '>>> This File does not exist --> '+iFile['path']+'... check path ... ' continue print '>>> Opening File :' , iFile['path'] inFile = TFile.Open ( iFile['path'] ," READ ") c1 = inFile.Get(canvas); gr = c1.GetListOfPrimitives().FindObject(obj) xaxis = gr.GetXaxis().GetTitle() yaxis = gr.GetYaxis().GetTitle() gr.SetLineColor(iFile['color']) mg.Add(gr) leg.AddEntry(gr,iFile['legend'],"l") c = TCanvas() c.cd() c.SetGrid() mg.Draw("al") line1 = TF1("line1","pol0",-100,100) line1.FixParameter(0,1.) line1.SetLineWidth(2) line1.SetLineStyle(2) line1.SetLineColor(2) line1.Draw("same") line2 = TF1("line2","pol0",-100,100) line2.FixParameter(0,3.84) line2.SetLineWidth(2) line2.SetLineStyle(2) line2.SetLineColor(2) line2.Draw("same") mg.SetTitle(";" +xaxis+";" +yaxis) mg.GetYaxis().SetRangeUser(0,10) leg.SetNColumns(2) leg.SetBorderSize(0) leg.Draw("same") c.SaveAs(output+"10.png") c.SaveAs(output+"10.pdf") c.SaveAs(output+"10.root")
def plot_roc_curve(roc_b, roc_c, comp_roc_b, comp_roc_c, xlimits, ylimits, type, filename): canv = TCanvas("c1", "c1", 800, 600) mg = TMultiGraph() roc_b.SetLineColor(1) roc_c.SetLineColor(4) comp_roc_b.SetLineColor(1) comp_roc_c.SetLineColor(4) roc_b.SetMarkerColor(1) roc_c.SetMarkerColor(4) comp_roc_b.SetMarkerColor(1) comp_roc_c.SetMarkerColor(4) roc_b.SetMarkerStyle(20) roc_c.SetMarkerStyle(20) comp_roc_b.SetMarkerStyle(22) comp_roc_c.SetMarkerStyle(22) mg.Add(roc_b) mg.Add(roc_c) mg.Add(comp_roc_b) mg.Add(comp_roc_c) mg.SetTitle("; " + type + " efficiency; " + type + " fake rate") mg.Draw("ALP") mg.GetXaxis().SetLimits(xlimits[0], xlimits[1]) mg.SetMinimum(ylimits[0]) mg.SetMaximum(ylimits[1]) legend = TLegend(0.15, 0.88 - 0.08 * 4, 0.3, 0.88, '', 'NDC') legend.AddEntry(roc_b, "b-jets (GNN)", "lp") legend.AddEntry(roc_c, "c-jets (GNN)", "lp") legend.AddEntry(comp_roc_b, "b-jets (SV1)", "p") legend.AddEntry(comp_roc_c, "c-jets (SV1)", "p") legend.SetTextSize(0.025) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw("SAME") canv.SaveAs(filename) canv.Clear() del canv
def makeROC(fpr, tpr, thresholds,AUC,outfile,signal_label, background_label): c = TCanvas("c","c",700,600) gPad.SetMargin(0.15,0.07,0.15,0.05) gPad.SetLogy(0) gPad.SetGrid(1,1) gStyle.SetGridColor(15) mg = TMultiGraph() roc = TGraph(len(fpr),tpr,fpr) roc.SetLineColor(2) roc.SetLineWidth(3) roc.SetTitle(";Signal efficiency (%s); Background efficiency (%s)"%(signal_label, background_label)) roc.GetXaxis().SetTitleOffset(1.4) roc.GetXaxis().SetTitleSize(0.045) roc.GetYaxis().SetTitleOffset(1.4) roc.GetYaxis().SetTitleSize(0.045) roc.GetXaxis().SetRangeUser(0,1) roc.GetYaxis().SetRangeUser(0.000,1) mg.Add(roc) #roc.Draw("AL") tpr_diag = np.arange(0,1.09,0.1) fpr_diag = np.arange(0,1.09,0.1) roc_diag = TGraph(len(fpr_diag),tpr_diag,fpr_diag) roc_diag.SetLineStyle(2) roc_diag.SetLineWidth(3) roc_diag.SetLineColor(13) mg.Add(roc_diag) #roc_diag.Draw("AL same") mg.Draw("AL") mg.SetTitle(";Signal efficiency (%s); Background efficiency (%s)"%(signal_label, background_label)) latex = TLatex() latex.SetTextFont(42) latex.SetTextSize(0.05) latex.DrawLatexNDC(0.2,0.88,'AUC = %.3f'%AUC) c.SaveAs(outfile)
def produceYieldPlots(processes, seldict, variables, uncertainties, intLumi, pdir, delphesVersion, hfile): print '' print 'Preparing yield plots ...' # prepare yield plots gr_sb = TGraph() mg_sign = TMultiGraph() mg_dmu = TMultiGraph() gr_sb.SetTitle(";p_{T}^{H} (min) [GeV]; S/B") mg_sign.SetTitle( ";p_{T}^{H} (min) [GeV]; Significance = #frac{S}{#sqrt{S + #sigma_{S}^{2} + B + #sigma_{B}^{2}}}" ) mg_dmu.SetTitle(";p_{T}^{H} (min) [GeV]; #delta #mu / #mu (%)") grs_sign = {} grs_dmu = {} colors = [] colors.append(ROOT.kBlack) colors.append(ROOT.kRed - 9) colors.append(ROOT.kBlue - 3) colors.append(ROOT.kGreen + 2) colors.append(ROOT.kOrange - 3) colors.append(ROOT.kYellow + 2) colors.append(ROOT.kMagenta + 1) index = 0 gr_sb.SetLineColor(ROOT.kBlack) gr_sb.SetLineWidth(3) for unc in uncertainties: gr_sign = TGraph() gr_dmu = TGraph() gr_sign.SetLineColor(colors[index]) gr_dmu.SetLineColor(colors[index]) gr_sign.SetLineWidth(3) gr_dmu.SetLineWidth(3) gr_sign.SetMarkerSize(0.0001) gr_dmu.SetMarkerSize(0.0001) gr_sign.SetFillColor(0) gr_dmu.SetFillColor(0) grs_sign[index] = gr_sign grs_dmu[index] = gr_dmu index += 1 # fill yield graphs nsel = 0 maxsb = -999 minsb = 999 maxsig = -999 minsig = 999 maxdmu = -999 mindmu = 999 for cut in seldict.keys(): index = 0 v = variables.keys()[0] selstr = 'sel{}'.format(int(nsel)) nproc = 0 b = 0 for p in processes: hname = '{}_{}_{}'.format(p, selstr, v) h = hfile.Get(hname) err = ROOT.Double() yld = h.IntegralAndError(0, h.GetNbinsX() + 1, err) yld *= intLumi err *= intLumi if nproc == 0: s = yld else: b += yld nproc += 1 if b == 0: gr_sb.SetPoint(nsel, cut, 0.) if 0 < minsb: minsb = 0. if 0 > maxsb: maxsb = 0. else: if s / b < minsb: minsb = s / b if s / b > maxsb: maxsb = s / b gr_sb.SetPoint(nsel, cut, s / b) for unc in uncertainties: sign = significance(s, unc[0], b, unc[1]) rel_unc = dMuOverMu(s, unc[0], b, unc[1]) if sign < minsig: minsig = sign if sign > maxsig: maxsig = sign if rel_unc < mindmu: mindmu = rel_unc if rel_unc > maxdmu: maxdmu = rel_unc grs_sign[index].SetPoint(nsel, cut, sign) grs_dmu[index].SetPoint(nsel, cut, rel_unc) title = '#sigma_{{S}}/S = {}, #sigma_{{B}}/B = {}'.format( unc[0], unc[1]) grs_sign[index].SetTitle(title) grs_dmu[index].SetTitle(title) index += 1 nsel += 1 index = 0 for unc in uncertainties: mg_sign.Add(grs_sign[index]) mg_dmu.Add(grs_dmu[index]) index += 1 intLumiab = intLumi / 1e+06 rt = 'RECO: Delphes-{}'.format(delphesVersion) lt = '#sqrt{{s}} = 100 TeV, L = {} ab^{{-1}}'.format(intLumiab) drawMultiGraph(mg_sign, 'optim_sign', lt, rt, pdir, minsig / 10., maxsig * 10., True) drawMultiGraph(mg_dmu, 'optim_dmu', lt, rt, pdir, mindmu / 10., maxdmu * 10., True) drawMultiGraph(gr_sb, 'optim_sb', lt, rt, pdir, minsb / 10., maxsb * 10., True, False) print 'DONE'
def Draw_2D_Comp(rootfile_name, var_x, var_y, min, max, WP_list, leg, isTgraph=False): gStyle.SetErrorX(0.5) ## Creating a multigraph for the canvas if we are looking at TGraphs if isTgraph: stack = TMultiGraph() args = "AP" ## Creating a stack for the canvas if we are looking at TPofiles else: stack = THStack("stack", var_x.name + var_y.name) args = "nostack " stack.SetMinimum(min) stack.SetMaximum(max) for wp in WP_list: ## Generating the graph name graph_name = "{}_vs_{}_{}".format(var_x.name, var_y.name, wp.name) if isTgraph: graph_name += "_res" ## Loading the graph using its name and file location graph = GetGraphFromFile(rootfile_name, graph_name) if graph == -1: continue ## Setting the colors specific to the working point graph.SetLineColor(wp.colour) graph.SetMarkerColor(wp.colour) graph.SetMarkerStyle(wp.marker) ## Adding the legend entry leg.AddEntry(graph, wp.name, "p") ## Adding the object to the stack stack.Add(graph) del graph ## Checking to see if any graphs were found for this variable nhists = stack.GetListOfGraphs().GetSize( ) if isTgraph else stack.GetNhists() if nhists == 0: print("\n\n\nNo graphs found for working point {}\n\n\n".format( wp.name)) return -1 ## Drawing the stack on the currrent canvas stack.Draw(args) leg.Draw() ## Setting axis labels stack.GetXaxis().SetTitle(var_x.x_label + " " + var_x.units) stack.GetYaxis().SetTitle(var_y.x_label + " " + var_y.units) ## Moving axis tick marks stack.GetYaxis().SetMaxDigits(3) stack.GetXaxis().SetLabelOffset(0.017) return stack
def plotROCfromgraph(graphs, xlabel, ylabel, legendNames, destination, year, xlog=False, ylog=False, additionalInformation=None): GeneralSettings() #Make sure single curves also pass try: len(graphs) except: graphs = [graphs] #Create Canvas Canv = TCanvas("Canv" + destination, "Canv" + destination, 1000, 1000) tdr.setTDRStyle() #Create TGraph mgraph = TMultiGraph() for i, graph in enumerate(graphs): graph.SetMarkerSize(1.5) graph.SetLineColor(TColor.GetColor(GetLineColor(graphs.index(graph)))) graph.SetMarkerColor(TColor.GetColor(GetLineColor( graphs.index(graph)))) graph.SetMarkerStyle(GetMarker(graphs.index(graph))) mgraph.Add(graph) mgraph.Draw("APLine") mgraph.SetTitle(";" + xlabel + ";" + ylabel) cl.CMS_lumi(Canv, 4, 11, year, 'Simulation', False) xmax = GetXMax(graphs) xmin = GetXMin(graphs) ymax = GetYMax(graphs) ymin = GetYMin(graphs) if xlog: Canv.SetLogx() mgraph.GetXaxis().SetRangeUser(0.3 * xmin, 30 * xmax) else: mgraph.GetXaxis().SetRangeUser(0.7 * xmin, 1.3 * xmax) if ylog: Canv.SetLogy() mgraph.GetYaxis().SetRangeUser(0.3 * ymin, 10 * ymax) else: mgraph.GetYaxis().SetRangeUser(0.5 * ymin, 1.2 * ymax) #Write extra text if additionalInformation is not None: lastYpos = 0.8 lastCorrectedYpos = None extraText = TLatex() for info in additionalInformation: try: extraTextString = info[0] extraTextXpos = info[1] extraTextYpos = info[2] extraTextSize = info[3] except: print("Wrong Format for additionalInformation. Stopping") pass if extraTextSize is None: extraTextSize = 0.03 if extraTextXpos is None: extraTextXpos = 0.2 if extraTextYpos is None: if lastYpos is None: extraTextYpos = lastCorrectedYpos - 0.05 else: extraTextYpos = 0.8 extraText.SetNDC() extraText.SetTextAlign(12) extraText.SetTextSize(extraTextSize) extraText.DrawLatex(extraTextXpos, extraTextYpos, extraTextString) lastYpos = info[2] lastCorrectedYpos = extraTextYpos if legendNames: legend = TLegend(0.7, .7, .9, .9) for g, n in zip(graphs, legendNames): legend.AddEntry(g, n) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #Save everything savePlots(Canv, destination)
def plotROC(xdata, ydata, xlabel, ylabel, legendNames, destination, year, xerror=None, yerror=None, xlog=False, ylog=False, additionalInformation=None): GeneralSettings() #Make sure single curves also pass try: len(xdata[0]) except: xdata = [xdata] ydata = [ydata] legendNames = [legendNames] xerror = [xerror] yerror = [yerror] #Create Canvas Canv = TCanvas("Canv" + destination, "Canv" + destination, 1000, 1000) tdr.setTDRStyle() #Create TGraph graphs = [] for x, y, xe, ye in zip(xdata, ydata, xerror, yerror): tmpgraph = None if xe is None and ye is None: tmpgraph = TGraph(len(x), x, y) elif xe is None or ye is None: NullErrors = np.zeros(len(x)) if xe is not None: tmpgraph = TGraphErrors(len(x), x, y, xe, NullErrors) if ye is not None: tmpgraph = TGraphErrors(len(x), x, y, NullErrors, ye) else: tmpgraph = TGraphErrors(len(x), x, y, xe, ye) graphs.append(tmpgraph) mgraph = TMultiGraph() for i, graph in enumerate(graphs): graph.SetMarkerSize(1.5) graph.SetLineColor(TColor.GetColor(GetLineColor(graphs.index(graph)))) graph.SetMarkerColor(TColor.GetColor(GetLineColor( graphs.index(graph)))) graph.SetMarkerStyle(GetMarker(graphs.index(graph))) mgraph.Add(graph) mgraph.Draw("APLine") mgraph.SetTitle(";" + xlabel + ";" + ylabel) cl.CMS_lumi(Canv, 4, 11, 'Simulation', False) if xlog: Canv.SetLogx() mgraph.GetXaxis().SetRangeUser(0.3 * GetNestedMin(xdata), 30 * GetNestedMax(xdata)) else: mgraph.GetXaxis().SetRangeUser(0.7 * GetNestedMin(xdata[0]), 1.3 * GetNestedMax(xdata)) if ylog: Canv.SetLogy() mgraph.GetYaxis().SetRangeUser(0.3 * GetNestedMin(ydata), 10 * GetNestedMax(ydata)) else: mgraph.GetYaxis().SetRangeUser(0.5 * GetNestedMin(ydata), 1.2 * GetNestedMax(ydata)) #Write extra text if additionalInformation is not None: lastYpos = 0.8 lastCorrectedYpos = None extraText = TLatex() for info in additionalInformation: try: extraTextString = info[0] extraTextXpos = info[1] extraTextYpos = info[2] extraTextSize = info[3] except: print("Wrong Format for additionalInformation. Stopping") pass if extraTextSize is None: extraTextSize = 0.03 if extraTextXpos is None: extraTextXpos = 0.2 if extraTextYpos is None: if lastYpos is None: extraTextYpos = lastCorrectedYpos - 0.05 else: extraTextYpos = 0.8 extraText.SetNDC() extraText.SetTextAlign(12) extraText.SetTextSize(extraTextSize) extraText.DrawLatex(extraTextXpos, extraTextYpos, extraTextString) lastYpos = info[2] lastCorrectedYpos = extraTextYpos if legendNames: legend = TLegend(0.7, .7, .9, .9) for g, n in zip(graphs, legendNames): legend.AddEntry(g, n) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #Save everything savePlots(Canv, destination)
ISSpositive = np.array([16165878, 12455567, 8304814, 6352927, 4953535, 3823826, 2961983, 2367438, 1780154, 1500592, 1197313, 930211, 614647, 683018, 610281]).astype(np.float) ISSnegative = np.array([39986, 28817, 17690, 12754, 9576, 7191, 5572, 4624, 3988, 3950, 4469, 4905, 5066, 9397, 16391]).astype(np.float) ISS_chargeconfused = ISSpositive*ccratio ####################################################################################### c1 = TCanvas() gPad.SetGrid() gPad.SetFrameFillColor(0) gStyle.SetOptStat("00000000") c1.SetLogy() zeroline = [0]*rigidity.shape[0] mg = TMultiGraph("mg","mg") grshade = TGraph(2*rigidity.shape[0]) grshade2 = TGraph(2*rigidity.shape[0]) for i in range(rigidity.shape[0]): grshade.SetPoint(i,rigidity[i],ISSnegative[i]) grshade.SetPoint(rigidity.shape[0]+i,rigidity[rigidity.shape[0]-i-1],ISS_chargeconfused[rigidity.shape[0]-i-1]) for i in range(rigidity.shape[0]): grshade2.SetPoint(i,rigidity[i],ISS_chargeconfused[i]) grshade2.SetPoint(rigidity.shape[0]+i,rigidity[rigidity.shape[0]-i-1],zeroline[rigidity.shape[0]-i-1]) ccratio_plot = TGraph (rigidity.shape[0], rigidity,ccratio) ISS_negative_plot = TGraph (rigidity.shape[0], rigidity, ISSnegative) ISS_chargeconfused_plot = TGraph (rigidity.shape[0], rigidity, ISS_chargeconfused) ISS_positive_plot = TGraph (rigidity.shape[0], rigidity, ISSpositive) ccratio_plot.SetLineColor(1)
def main(): filename = read_file_name("NY_OUTPUT.txt") can = TCanvas("can","can") can.SetGrid() mg = TMultiGraph() nn = 9 GR = [] NAME = [] px,py = array('d'), array('d') f = open(filename[2],'r') indicator = 0 for line in f: if(indicator == 0): indicator = indicator + 1 continue Name, Total, Pos, Neg, TNum = line.split() name = Find_Loca(Name) name = Name.replace(Name[name:],"") # print(name) px.append((indicator-1)%9); py.append(float(TNum)) if((indicator)%9 == 0): NAME.append(name) gr = TGraph( nn, px, py ) GR.append(gr) px,py = array('d'), array('d') indicator = indicator + 1 # print(GR); print(len(GR)) for i in range(len(GR)): GR[i].SetLineWidth(2) if "water" in NAME[i]: GR[i].SetLineWidth(5); GR[i].SetLineColor(1) ;GR[i].SetMarkerColor(1) if "wine" in NAME[i]: GR[i].SetMarkerColor(2);GR[i].SetLineColor(2) if "beer" in NAME[i]: GR[i].SetMarkerColor(5);GR[i].SetLineColor(5) if "tea" in NAME[i]: GR[i].SetMarkerColor(4);GR[i].SetLineColor(4) if "coffee" in NAME[i]: GR[i].SetMarkerColor(3);GR[i].SetLineColor(3) if "juice" in NAME[i]: GR[i].SetMarkerColor(7);GR[i].SetLineColor(7) if "COLA" in NAME[i]: GR[i].SetMarkerColor(6);GR[i].SetLineColor(6) GR[i].GetXaxis().SetTitle("days") GR[i].SetMarkerStyle(20) # GR[i].Fit("pol4","q") mg.Add(GR[i]) mg.Draw("ALP") leg = TLegend(0.65, 0.65, 0.9, 0.8) leg.SetBorderSize(0) leg.SetFillColor(10) for i in range(len(GR)): leg_entry = leg.AddEntry(GR[i], NAME[i],"l") leg.Draw() mg.SetTitle("Total tweets counts at NY") mg.GetHistogram().GetXaxis().SetTitle("days") mg.GetHistogram().GetXaxis().SetTitleOffset(1) mg.GetHistogram().GetXaxis().SetLabelSize(0.03) mg.GetHistogram().GetYaxis().SetTitle("Counts") mg.GetHistogram().GetYaxis().SetTitleOffset(1.3) mg.GetHistogram().GetYaxis().SetLabelSize(0.03) mg.GetHistogram().GetXaxis().SetBinLabel(5,"Mon") mg.GetHistogram().GetXaxis().SetBinLabel(16,"Tue") mg.GetHistogram().GetXaxis().SetBinLabel(28,"Wed") mg.GetHistogram().GetXaxis().SetBinLabel(40,"Thu") mg.GetHistogram().GetXaxis().SetBinLabel(51,"Fri") mg.GetHistogram().GetXaxis().SetBinLabel(63,"Sat") mg.GetHistogram().GetXaxis().SetBinLabel(73,"Sun") mg.GetHistogram().GetXaxis().SetBinLabel(84,"Mon") mg.GetHistogram().GetXaxis().SetBinLabel(96,"Tue") # for i in range(len(GR)): # mg.GetHistogram().GetXaxis().SetBinLabel(i,DAYS) # mg.GetHistogram().GetXaxis().SetLabel("tt") can.Modified() can.Update() # can.GetFrame().SetBorderSize( 12 ) can.Print("Total_tweet_NY.pdf")
efficiencyPlotWithRate_ff_W_munu_1000events.SetMarkerColor(4) efficiencyPlotWithRate_ff_W_munu_1000events.SetLineColor(1) efficiencyPlotWithRate_ff_W_munu_1000events.SetMarkerStyle(21) efficiencyPlotWithRate_ff_W_munu_1000events.GetXaxis().SetTitle("Rate [Hz]") efficiencyPlotWithRate_ff_W_munu_1000events.GetXaxis().SetTitleOffset(1.2) efficiencyPlotWithRate_ff_W_munu_1000events.Draw("AP") efficiencyPlotWithRate_ff_W_munu_1000events.Write() line_200kHz.Draw() label_200kHz.Draw() text.Draw() canvas.Update() canvas.Print("metEfficiencyPlotWithRate_ff_W_munu_1000events.svg", "svg") canvas.Print("metEfficiencyPlotWithRate_ff_W_munu_1000events.png", "png") canvas.Print("metEfficiencyPlotWithRate_ff_W_munu_1000events.pdf", "pdf") metEfficiencyPlotWithRate = TMultiGraph("metEfficiencyPlotWithRate", "") metEfficiencyPlotWithRate.Add(efficiencyPlotWithRate_ff_H_WW_enuenu_1000events) efficiencyPlotWithRate_ff_H_WW_enuenu_1000events.SetMarkerColor(6) metEfficiencyPlotWithRate.Add(efficiencyPlotWithRate_ff_H_WW_munumunu_1000events) efficiencyPlotWithRate_ff_H_WW_munumunu_1000events.SetMarkerColor(2) metEfficiencyPlotWithRate.Add(efficiencyPlotWithRate_ff_W_enu_1000events) efficiencyPlotWithRate_ff_W_enu_1000events.SetMarkerColor(3) metEfficiencyPlotWithRate.Add(efficiencyPlotWithRate_ff_W_munu_1000events) efficiencyPlotWithRate_ff_W_munu_1000events.SetMarkerColor(4) efficiencyPlotWithRate_ff_W_munu_1000events.SetLineColor(1) metEfficiencyPlotWithRate.Draw("AP") metEfficiencyPlotWithRate.GetXaxis().SetTitle("Rate [Hz]") metEfficiencyPlotWithRate.GetXaxis().SetTitleOffset(1.2) metEfficiencyPlotWithRate.GetYaxis().SetTitle("% accepted events") metEfficiencyPlotWithRate.GetYaxis().SetTitleOffset(1.2) metEfficiencyPlotWithRate.GetYaxis().SetRangeUser(0, 1.1)