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 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 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 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 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 plotMultiGraph(dataReadings, vals, title, xTitle, yTitle, outF): """ Plots several TGraphs using TMultiGraph """ mg = TMultiGraph() cv = TCanvas(outF, "cv", 1200, 1200) l = TLegend(0.9, 0.7, 1.0, 0.9) pad = TPad("p", "p", 0.05, 0.05, 1.0, 1.0) pad.cd() for a in xrange(len(vals)): print "vals[a] = {0}".format(vals[a]) l.AddEntry(vals[a], "Value %d" % (a + 1), "pl") mg.Add(vals[a]) mg.Draw("alp") pad.Update() mg.SetTitle(title + ";" + xTitle + ";" + yTitle) l.Draw() cv.cd() pad.Draw() mg.GetXaxis().SetNdivisions(len(dataReadings)) date = "" nReadings = len(dataReadings) divisor = nReadings / 10 + 1 # use to label no more than 10 bins, include first and last bins always for i in xrange(nReadings): if i % divisor == 0 or i == nReadings - 1: # If new date, print date and time if date != dataReadings[i]["date"]: date = dataReadings[i]["date"] mg.GetXaxis().SetBinLabel( mg.GetXaxis().FindBin(i), "#splitline{%s}{%s}" % (date, dataReadings[i]["time"])) else: mg.GetXaxis().SetBinLabel(mg.GetXaxis().FindBin(i), dataReadings[i]["time"]) mg.GetXaxis().SetTitleOffset(2.1) mg.GetYaxis().SetTitleOffset(2.1) pad.Update() cv.SaveAs(outF)
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 plotMultiGraph(dataReadings, vals, title, xTitle, yTitle, outF): """ Plots several TGraphs using TMultiGraph """ mg = TMultiGraph() cv = TCanvas(outF, "cv", 1200, 1200) l = TLegend(0.9, 0.7, 1.0, 0.9) pad = TPad("p", "p", 0.05, 0.05, 1.0, 1.0) pad.cd() for rm in range(len(vals)): l.AddEntry(vals[rm], "RM%d" % (rm + 1), "pl") mg.Add(vals[rm]) mg.Draw("alp") pad.Update() mg.SetTitle(title + ";" + xTitle + ";" + yTitle) l.Draw() cv.cd() pad.Draw() mg.GetXaxis().SetNdivisions(len(dataReadings)) date = "" for i in range(len(dataReadings)): # If new date, print date and time if date != dataReadings[i]["date"]: date = dataReadings[i]["date"] mg.GetXaxis().SetBinLabel( mg.GetXaxis().FindBin(i), "#splitline{%s}{%s}" % (date, dataReadings[i]["time"])) else: mg.GetXaxis().SetBinLabel(mg.GetXaxis().FindBin(i), dataReadings[i]["time"]) mg.GetXaxis().SetTitleOffset(2.1) mg.GetYaxis().SetTitleOffset(2.1) pad.Update() cv.SaveAs(outF)
def main(): filename = read_file_name( "OUTPUT_TWITTER_TXT_generator/NY_OUTPUT_week1n2n3n4.txt") ##FIXME can = TCanvas("can", "can") can.SetGrid() mg = TMultiGraph() nn = 7 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) % 7) py.append(float(Neg) / float(Total)) if ((indicator) % 7 == 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.75, 0.82, 0.95, 0.95) 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("Negative words propotion at NY(week 1&2&3&4)") ##FIXME 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(20, "Tue") mg.GetHistogram().GetXaxis().SetBinLabel(35, "Wed") mg.GetHistogram().GetXaxis().SetBinLabel(51, "Thu") mg.GetHistogram().GetXaxis().SetBinLabel(66, "Fri") mg.GetHistogram().GetXaxis().SetBinLabel(81, "Sat") mg.GetHistogram().GetXaxis().SetBinLabel(96, "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("NEG_NY_week1n2n3n4.pdf") ##FIXME
def produceRatioPlot(param1, dicts1, label1, param2, dicts2, label2, fname, ptmax): print '' print 'Preparing ratio plots ...' # uncertainty scenarios (theory+lumi, signal_eff, background) # signal eff uncertainty is computed later based on object pT, here specifiy only multiplicative factor # prepare yield plots mg_dr = TMultiGraph() titley = "#delta ( BR({}) / BR({}) ) (%)".format(label1, label2) ratiolabel = '#frac{{BR({})}}{{BR({})}}'.format(label1, label2) mg_dr.SetTitle(";p_{T,min}^{H} [GeV];" + titley) grs_dr = {} # do 3 scenarios only: stat only, stat+ syst (agg), stat+ syst (cons) uncertainties = [] uncertainties.append((1., 2.)) # syst (cons) + stat uncertainties.append((1., 1.)) # syst (agg) + stat uncertainties.append((1., 0.)) # stat only uncs = collections.OrderedDict() uncs[(1., 2.)] = 'stat + syst (cons.)' # syst (cons) + stat uncs[(1., 1.)] = 'stat + syst (optim.)' # syst (agg) + stat uncs[(1., 0.)] = 'stat. only' # stat only index = 0 for unc in uncertainties: gr_dr = TGraph() gr_dr.SetLineColor(colors[index]) gr_dr.SetLineWidth(3) gr_dr.SetMarkerSize(0.0001) gr_dr.SetFillColor(0) grs_dr[index] = gr_dr index += 1 # fill yield graphs nsel = 0 maxdr = -999 mindr = 999 ele_errors1 = dicts1[0] muo_errors1 = dicts1[1] pho_errors1 = dicts1[2] s_yields1 = dicts1[3] b_yields1 = dicts1[4] ele_errors2 = dicts2[0] muo_errors2 = dicts2[1] pho_errors2 = dicts2[2] s_yields2 = dicts2[3] b_yields2 = dicts2[4] minpt = dict() minss = dict() for unc in uncertainties: minpt[unc] = 999. minss[unc] = 999. nsel = 0 for cut in dicts1[0].keys(): nsel += 1 index = 0 s1 = s_yields1[cut] b1 = b_yields1[cut] s2 = s_yields2[cut] b2 = b_yields2[cut] args = options() if args.sqrts == 37: s1 *= ratio[cut] b1 *= ratio[cut] s2 *= ratio[cut] b2 *= ratio[cut] de1 = ele_errors1[cut] de2 = ele_errors2[cut] dm1 = muo_errors1[cut] dm2 = muo_errors2[cut] da1 = pho_errors1[cut] da2 = pho_errors2[cut] # in ratio take difference of correlated uncertaintites, and quad. sum or uncorr. ones #delta_eff_tot = 100.*(math.sqrt((de1-de2)**2 + (da1-da2)**2 + (dm1-dm2)**2)) delta_eff_tot = 100. * (math.sqrt((de1 + da1 - de2 - da2)**2 + (dm1 - dm2)**2)) # compute stat. uncertainties (TBC!!!) delta_stat1 = dMuOverMu(s1, 0., b1, 0.) delta_stat2 = dMuOverMu(s2, 0., b2, 0.) # add in quadrature efficiency and stat. uncertainty #toterr = math.sqrt(delta_eff_tot**2 + delta_stat1**2 + delta_stat2**2) #print cut, s1, b1, s2, b2 for unc in uncertainties: if index == 2: title = 'stat. only' if index == 1: title = 'stat + syst (optim.)' if index == 0: title = 'stat + syst (cons.)' toterr = math.sqrt((unc[1] * delta_eff_tot)**2 + delta_stat1**2 + delta_stat2**2) grs_dr[index].SetPoint(nsel, cut, toterr) if toterr < minss[unc]: minss[unc] = toterr minpt[unc] = cut if toterr < mindr: mindr = toterr if toterr > maxdr: maxdr = toterr grs_dr[index].SetTitle(title) index += 1 index = 0 for unc in uncertainties: mg_dr.Add(grs_dr[index]) index += 1 intLumiab = param1.intLumi / 1e+06 #ratiolabel = ratiolabel.replace('#','\\') args = options() if args.sqrts == 100: collabel = 'FCC-hh' sqrtslabel = args.sqrts if args.sqrts == 27: collabel = 'HE-LHC' sqrtslabel = args.sqrts if args.sqrts == 37: collabel = 'VHE-LHC' sqrtslabel = 37.5 lt = "{} Simulation (Delphes)".format(collabel) rt = "#sqrt{{s}} = {} TeV, L = {:.0f} ab^{{-1}}".format( sqrtslabel, intLumiab) rt += ', {}'.format(ratiolabel) drawMultiGraph(mg_dr, 'ratio', lt, rt, fname, mindr / 10., maxdr * 10., ptmax, True) print 'DONE' # print summary for unc in uncertainties: print '{}: {:.2f}'.format(uncs[unc], minss[unc])
purGraph = TGraphErrors(len(_NumberOfProtons), _NumberOfProtons, _Purity, _NumberOfProtonsErr, _PurityErr) purGraph.SetMarkerStyle(5) purGraph.SetLineColor(2) purGraph.SetMarkerColor(2) purGraph.SetMarkerSize(2) purGraph.GetXaxis().SetTitle("Mean N Proton") purGraph.GetYaxis().SetTitle("Purity") purGraph.SetTitle("Purity") MyFile = TFile( "effVsPurity_bs" + (str)(beamSpread) + "mrad_geo" + geoName + "_RestrictTracks" + (str)(restrictNTracks) + "_pitch" + (str)(pitch) + ".root", "RECREATE") mg = TMultiGraph() mg.SetTitle("Efficiency and Purity vs nProtons;Mean N Protons; (%)") mg.Add(effGraph, "lp") mg.Add(purGraph, "lp") mg.Draw("a") effGraph.Write() purGraph.Write() mg.Write() legend = TLegend(0.1, 0.7, 0.48, 0.9) legend.AddEntry(effGraph, "Efficiency", "lp") legend.AddEntry(purGraph, "Purity", "lp") legend.Draw("SAME") canvas1.Write("EffVsPurity")
def plot(tgr, n): #(List, layer, tgrDict): H = 1600 W = 800 #print "----- Creating Third TCanvas -----" c = TCanvas("c", "Canvas", W, H) ymax = 0.0 c.SetLeftMargin(0.15) c.SetRightMargin(0.06) c.SetTopMargin(0.09) c.SetBottomMargin(0.14) #gPad.SetGrid() gPad.SetTicks() #gPad.SetLogy() mg = TMultiGraph() tgr.SetMarkerColor(kGreen + 3) tgr.SetMarkerStyle(21) tgr.SetMarkerSize(1.5) mg.Add(tgr, 'AP') mg.Draw("a") l = TLegend(0.42, 0.15, 0.82, 0.35) l.SetFillColor(0) l.SetBorderSize(0) l.SetTextSize(0.03) l.SetNColumns(1) l.AddEntry(tgr, "CMS (13TeV)", "p") mg.SetTitle('') #mg.SetMaximum(ymax*1.1) mg.GetXaxis().SetTitle('Instantaneous Luminosity 10^{34} cm^{-2} s^{-1}') mg.GetXaxis().SetLabelFont(42) mg.GetXaxis().SetLabelOffset(0.007) mg.GetXaxis().SetLabelSize(0.043) mg.GetXaxis().SetTitleSize(0.03) mg.GetXaxis().SetTitleOffset(1.56) mg.GetXaxis().SetTitleFont(42) mg.GetYaxis().SetTitle('rate (Hz/cm^{2})') mg.GetYaxis().SetLabelFont(42) mg.GetYaxis().SetLabelOffset(0.008) mg.GetYaxis().SetLabelSize(0.02) mg.GetYaxis().SetTitleSize(0.03) mg.GetYaxis().SetTitleOffset(1.37) mg.GetYaxis().SetTitleFont(42) pv = TPaveText(.08, 0.94, .45, 0.94, "NDC") pv.AddText('CMS Preliminary Rack {}'.format(n)) pv.SetFillStyle(0) pv.SetBorderSize(0) pv.SetTextSize(0.04) pv.Draw() fun1 = TF1("fun1", "pol1", 6000, 16000) fit1 = tgr.Fit("fun1", "R") # "FQ") offset1 = fun1.GetParameter(0) slope1 = fun1.GetParameter(1) l.AddEntry(tgr, 'The p0 value is {0:.6f}'.format(offset1)) l.AddEntry(tgr, 'The p1 value is {0:.6f}'.format(slope1)) l.Draw("a") c.SaveAs("rack{}.png".format(n)) c.SaveAs("rack{}.pdf".format(n)) c.SaveAs("rack{}.C".format(n)) return
def SED(flist): gStyle.SetOptLogx() gStyle.SetOptLogy() gStyle.SetPadGridX(True) gStyle.SetPadGridY(True) gStyle.SetEndErrorSize(10) l = TLegend(.65, .6, .96, .95) g = [] gUL = [] pubdir = "/home/smasuda/storage/.Fermi2/Data/DataPoint/GammaCygni/" # g.append(GetPubData(pubdir+"GCyg_FermiLande_data.csv", # pubdir+"GCyg_FermiLande_error.csv")) # g[-1].SetName('gLande12') # g[-1].SetLineColor(kCyan) # g[-1].SetMarkerColor(g[-1].GetLineColor()) # g[-1].SetMarkerStyle(21) # gUL.append(TGraph(0)) # l.AddEntry(g[-1],'Lande+ \'12','p') g.append( GetPubData(pubdir + "GCyg_FermiFraija_data.csv", pubdir + "GCyg_FermiFraija_error.csv")) g[-1].SetName('gFraija16') g[-1].SetLineColor(kPink + 1) g[-1].SetLineColor(kCyan) g[-1].SetMarkerColor(g[-1].GetLineColor()) g[-1].SetMarkerStyle(22) gUL1 = GetPubData(pubdir + "GCyg_FermiFraija_UL.csv") gUL1.SetName('gFraija16UL') gUL1.SetLineColor(g[-1].GetLineColor()) gUL1.SetMarkerColor(g[-1].GetLineColor()) gUL.append(gUL1) l.AddEntry(g[-1], 'Fraija+ \'16', 'p') # g.append(GetPubData(pubdir+"GCyg_MAGIC_data.csv", # pubdir+"GCyg_MAGIC_error.csv")) # g[-1].SetLineColor(kMagenta) # g[-1].SetMarkerColor(kMagenta) # g[-1].SetMarkerStyle(29) # gUL.append(TGraph(0)) def ConvertFluxUnit(glist): g = glist[-1] n = g.GetN() x = g.GetX() y = g.GetY() ey = g.GetEY() for i in range(n): y[i] *= x[i] * x[i] * 1e-6 * 1e-4 if g.ClassName() == "TGraphErrors": ey[i] *= x[i] * x[i] * 1e-6 * 1e-4 rfile = TFile( "/home/smasuda/storage/Fermi/Data/GammaCygni2017/VERJ2019p407_spec.root" ) gVER = rfile.Get("gVER") gVERUL = rfile.Get("gVERUL") fVER = rfile.Get("fVER") rfile.Close() g.append(gVER) gUL.append(gVERUL) fVER.SetParameter(0, fVER.GetParameter(0) * 1e-4) fVER.SetParameter(1, fVER.GetParameter(1) - 2.) ConvertFluxUnit(g) ConvertFluxUnit(gUL) colV = kGreen gVER.SetMarkerColor(colV) gVER.SetLineColor(colV) gVERUL.SetMarkerColor(colV) gVERUL.SetLineColor(colV) fVER.SetLineColor(colV) l.AddEntry(g[-1], 'VER J2019+407', 'p') rfile = TFile( '/home/smasuda/storage/MAGIC/GammaCygni2017_ST7/analysis/flute/CombAll/Unfolding_Output_combunfold_2-Tikhonov.root' ) g.append(rfile.Get("fGraph1E2")) rfile.Close() g[-1].SetMarkerStyle(21) g[-1].SetMarkerColor(kMagenta + 1) g[-1].SetLineColor(g[-1].GetMarkerColor()) gUL.append(TGraph(0)) l.AddEntry(g[-1], 'MAGIC this work', 'lp') rfile = TFile( "/home/smasuda/storage/Fermi/Data/GammaCygni2017/MarcelFermi.root") gtmp = [] for key in rfile.GetListOfKeys(): obj = key.ReadObj() if obj.InheritsFrom(TGraph.Class()): gtmp.append(obj) # g.append(gtmp[0]) # gUL.append(TGraph(0)) # g.append(gtmp[1]) # gUL.append(TGraph(0)) # l.AddEntry(g[-1],'Marcel disk','lp') # g.append(gtmp[2]) # gUL.append(gtmp[3]) # l.AddEntry(g[-1],'Marcel gaus','lp') # g.append(TGraph(0)) # gUL.append(gtmp[4]) # l.AddEntry(gUL[-1],'Marcel arc','lp') # arr1=rfile.Get("aGausUL") # arr2=rfile.Get("aArcUL") rfile.Close() # XX=np.array([1.]) # YY=np.array([1.e-10]) # g.append(TGraph(1,XX,YY)) # gUL.append(TGraph(0)) for f in flist: tmpg, tmpgUL = GetData(f.file, f.scale, title=f.title) tmpg.SetLineColor(f.col) tmpg.SetMarkerColor(f.col) tmpg.SetMarkerStyle(f.sty) tmpgUL.SetLineColor(f.col) if f.leg != '': l.AddEntry(tmpg, f.leg, 'p') g.append(tmpg) gUL.append(tmpgUL) # l.AddEntry('p') ng = len(g) mg = TMultiGraph() for i in range(ng): if g[i].GetName() == 'gLP': mg.Add(g[i], '3') else: mg.Add(g[i], 'pz') if gUL[i].GetN() > 0: if gUL[i].GetName() == 'gGausUL' or gUL[i].GetName() == 'gArcUL': mg.Add(gUL[i], 'pz') else: mg.Add(gUL[i], 'p') xbin = np.logspace(np.log10(0.9), np.log10(8079.765852892145), 101) # ybin=np.logspace(np.log10(1.565210892602076e-14),np.log10(1.675199606589398e-10),101) ybin = np.logspace(np.log10(3.786556805899183e-14), np.log10(1.05e-10), 101) frame = TH2F("frame", "SED;Energy [GeV];E^{2}dN/dE [TeV cm^{-2} s^{-1}]", 100, xbin, 100, ybin) frame.SetStats(False) frame.SetDirectory(0) frame.Draw("0") mg.SetTitle("SED;Energy [GeV];E^{2}dN/dE [TeV cm^{-2} s^{-1}]") mg.Draw() fVER.Draw("same") arr = [] for i in range(len(gUL)): if gUL[i].GetN() > 0: arr.append(DrawUL(gUL[i])) # arr.append(arr1) # arr.append(arr2) # arr1.Draw() # arr2.Draw() l.Draw() gROOT.frame = frame gROOT.mg = mg gROOT.arr = arr gROOT.l = l gROOT.fVER = fVER gStyle.SetOptLogx(False) gStyle.SetOptLogy(False)
gr2.GetYaxis().SetNdivisions(505) gr2.GetYaxis().SetLabelOffset(1.4) gr2.GetXaxis().SetTitleOffset(4.0) gr2.SetLineColor(3) gr2.SetLineWidth(5) gr2.SetMarkerStyle(21) gr3 = TGraph(n, MH3name, PS_M2_list) gr3.SetTitle("Medium2 (FJetCSV > 0.89)") gr3.GetYaxis().SetNdivisions(505) gr3.GetYaxis().SetLabelOffset(1.4) gr3.GetXaxis().SetTitleOffset(4.0) gr3.SetLineColor(4) gr3.SetLineWidth(5) gr3.SetMarkerStyle(22) mg = TMultiGraph("mg", "") mg.SetTitle("QCD Background; MH3 (GeV); Punzi Significance") mg.GetYaxis().SetNdivisions(505) mg.GetYaxis().SetLabelOffset(1.4) mg.GetXaxis().SetTitleOffset(4.0) mg.Add(gr1, "ALP") mg.Add(gr2, "ALP") mg.Add(gr3, "ALP") mg.Draw("ALP") c1.BuildLegend() c1.cd() c1.Update() c1.SaveAs("PS_test.pdf")
def make_time_rod_evo(error_dict, rod_dict, results, doLock): c2 = TCanvas( 'c2', 'c2', 1000, 600) leg = TLegend(0.18,0.85,0.45,0.55) leg.SetLineColor(0) leg.SetFillStyle(0) leg.SetShadowColor(0) leg.SetBorderSize(0) leg.SetNColumns(2) R15 = TLine(431,0,431,60) R15.SetLineColorAlpha(kPink+10,0.4) R15.SetLineWidth(4) R16 = TLine(1820,0,1820,60) R16.SetLineColorAlpha(kMagenta+10,0.4) R16.SetLineWidth(4) R17 = TLine(3376,0,3376,60) R17.SetLineColorAlpha(kGreen-3,0.4) R17.SetLineWidth(4) TS1 = TLine(431,0,432,60) TS1.SetLineColorAlpha(kPink+10,0.5) TS1.SetLineWidth(5) TS2 = TLine(1415,0,1415,60) TS2.SetLineColorAlpha(kMagenta+3,0.5) TS2.SetLineWidth(5) leg2 = TLegend(0.18,0.45,0.35,0.55) leg2.SetLineColor(0) leg2.SetFillStyle(0) leg2.SetShadowColor(0) leg2.SetBorderSize(0) gStyle.SetLegendTextSize(0.030) leg2.AddEntry(R15, "End of 2015", 'lf') leg2.AddEntry(R16, "End of 2016", 'lf') leg2.AddEntry(R17, "End of 2017", 'lf') #leg2.AddEntry(TS2, "TS2", 'lf') for key,val in rod_dict.items(): TS1.SetY2(val*0.5) TS2.SetY2(val+1) R15.SetY2(val*0.3) R16.SetY2(val*0.5) R17.SetY2(val*0.8) times = {} times.clear() for e in error_bits: times['0x'+e] = [0] for error in results: pos_rod = error.text.find("ROD") + 4 pos_lock = error.text.find("Lock") + 15 pos_buff = error.text.find("buffer") + 17 if error.msgID == 'TRT::ROD05Module': rod = '0x'+str(error.text[pos_rod:pos_rod+6]) else: rod = str(error.text[pos_rod:pos_rod+8]) lock = str(error.text[pos_lock:pos_lock+3]) buff = str(error.text[pos_buff:pos_buff+3]) if key == rod and doLock and lock != '0xf': times[lock].append(error.sb_total_time) leg.Clear() mg = TMultiGraph() for e in error_bits: errs = [] for i,x in enumerate(times['0x'+e]): errs.append(i+0.0) errs.append(errs[-1]) #times['0x'+e].append(1800.0) times['0x'+e].append(results[-1].sb_total_time) gr = TGraph(len(times['0x'+e]), array(times['0x'+e]), array(errs)) gr.SetMarkerSize(0.7) if bin(int('0x'+e, 16))[2:].zfill(4) == '0111': leg.AddEntry(gr,'GOL 3',"lp"); elif bin(int('0x'+e, 16))[2:].zfill(4) == '1011': leg.AddEntry(gr,'GOL 2',"lp"); elif bin(int('0x'+e, 16))[2:].zfill(4) == '1101': leg.AddEntry(gr,'GOL 1',"lp"); elif bin(int('0x'+e, 16))[2:].zfill(4) == '1110': leg.AddEntry(gr,'GOL 0',"lp"); else: leg.AddEntry(gr,bin(int('0x'+e, 16))[2:].zfill(4),"lp"); mg.Add(gr,"pl"); mg.SetTitle("; Hours of stable beams; # of rocketio io lock errors"); mg.Draw("PMC PLC a"); R15.Draw() R16.Draw() R17.Draw() #TS1.Draw() #TS2.Draw() AtlasStyle.ATLAS_LABEL(0.19,.88, 1, "Internal") leg.Draw() leg2.Draw() AtlasStyle.myText(0.4, 0.88, kBlack, "ROD: " + key) leg.SetMargin(0.5) gPad.Modified() mg.GetXaxis().SetLimits(0,results[-1].sb_total_time) mg.SetMinimum(0.) mg.SetMaximum(val+1) c2.Update() c2.Print("plots/time_"+key+".pdf") c2.Clear()
def getGraph(self,dset): 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 lst = [] for inc in range (0,n): d={} d['run']=self.__runs[inc] d['x']=self.__x[inc] d['y']=self.__y[inc] d['yErr']=self.__yErrLow[inc] d['yTitle']=self.__yTitle if self.__config.has_option(self.__section,"yMin") and self.__config.has_option(self.__section,"yMax") : d['ymin']=float(self.__config.get(self.__section,"yMin")) d['ymax']=float(self.__config.get(self.__section,"yMax")) else: d['ymin']=0 d['ymax']=0 lst.append(d) obj ={} obj[self.__title]=lst #finalObj[self.__title]=lst #finalList.append(finalObj) # save_path = './JSON_A/' #completeName = os.path.join(save_path, self.__title+".json") if not os.path.exists("JSON_RECO"): os.makedirs("JSON_RECO") if not os.path.exists("JSON_RECO/"+dset): os.makedirs("JSON_RECO/"+dset) with open("./JSON_RECO/"+dset+"/"+self.__title+".json", 'w') as outfile: json.dump(obj, outfile,indent=4) print json.dumps(obj,indent=2) 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"))) #TOMAS removed sys error from the plot #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)
gr6 = dumb.Clone() gr6.GetYaxis().SetRangeUser(0.,3.) gr5.Draw("p, same") mg.Add(gr6) colorset(gr = gr6, color = 1) leg.AddEntry(gr6, options.label6, 'Lp') entries += 1 #canv.Update() #mg.GetXaxis().SetTitle("#kappa_t (no kinematics)") #mg.GetYaxis().SetTitle("-2#Delta lnL") #gPad.Modified() #mg.GetYaxis().SetRangeUser(0.,3.) mg.SetTitle("Multi-graph Title; X-axis Title; Y-axis Title"); mg.Draw('apl, same') canv.Update() mg.GetXaxis().SetTitle("#kappa_t (no kinematics)") mg.GetYaxis().SetTitle("-2#Delta lnL") gPad.Modified() mg.GetYaxis().SetRangeUser(0.,55.) xmin = mg.GetXaxis().GetXmin() xmax = mg.GetXaxis().GetXmax() mg.GetXaxis().SetRangeUser(xmin,xmax) #mg.Draw('ap') lat = TLatex()
def printmultigraph(grs, sortk, plotoptions, outn, title, year, doext, ploterror, ymax): import CMS_lumi, tdrstyle import array #set the tdr style tdrstyle.setTDRStyle() #change the CMS_lumi variables (see CMS_lumi.py) CMS_lumi.writeExtraText = 1 CMS_lumi.extraText = "Preliminary" if year == 2018: CMS_lumi.extraText2 = "2018 pp data" if year == 2017: CMS_lumi.extraText2 = "2017 pp data" if year == 2016: CMS_lumi.extraText2 = "2016 pp data" CMS_lumi.lumi_sqrtS = "13 TeV" # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string) CMS_lumi.writeTitle = 1 CMS_lumi.textTitle = title iPos = 11 if (iPos == 0): CMS_lumi.relPosX = 0.12 H_ref = 600 W_ref = 800 W = W_ref H = H_ref iPeriod = 0 # references for T, B, L, R T = 0.08 * H_ref B = 0.12 * H_ref L = 0.12 * W_ref R = 0.04 * W_ref c = TCanvas("c", "c", 50, 50, W, H) #gStyle.SetOptStat(0) c.SetFillColor(0) c.SetBorderMode(0) c.SetFrameFillStyle(0) c.SetFrameBorderMode(0) c.SetLeftMargin(L / W) c.SetRightMargin(R / W) c.SetTopMargin(T / H) c.SetBottomMargin(B / H) c.SetTickx(0) c.SetTicky(0) #canvassettings(c) mg = TMultiGraph() #mg = grs['main'] mg.SetTitle(title) #gStyle.SetTitleAlign(33) #gStyle.SetTitleX(0.99) leg = TLegend( 0.345, 0.68, 0.645, 0.88 ) #TLegend(1. - c.GetRightMargin() - 0.8, 1. - c.GetTopMargin() - 0.40,1. - c.GetRightMargin()- 0.60, 1. - c.GetTopMargin() -0.02) leg.SetFillStyle(0) leg.SetBorderSize(0) leg.SetMargin(0.1) #ymax = 0; ratesFromFit = {} evVal = 15000 if doext: evVal = 50000 #f=TFile.Open(outn+".root","RECREATE") # for name,value in plotoptions.iteritems(): for name in sortk: if name != 'main': continue value = plotoptions[name] #print grs gr = grs[name] #print gr gr.SetName(title) #extrate = fitGraph(gr,evVal) #ratesFromFit[name] = extrate if doext: #print name, extrate[0], extrate[1] NN = gr.GetN() gr.Set(NN + 1) gr.SetPoint(NN + 1, 50000.0, extrate["rate"][0]) yErr = extrate["rate"][1] if not ploterror: yErr = 0.0 gr.SetPointError(NN + 1, 0.0, yErr) gr.SetMarkerColor(value['color']) gr.SetMarkerStyle(value['markst']) gr.SetLineColor(value['color']) gr.SetMarkerSize(1.15) #1.05 gr.SetMinimum(0.1) #gr.Write() mg.Add(gr) text = title #name #+plotoptions[name]['leg'] leg.AddEntry(gr, text, "p") continue mg.SetName(outn) mg.SetMinimum(0.1) mg.SetMaximum(ymax) #1.6*ymax mg.Draw("AP") mg.GetXaxis().SetRangeUser(2000, 20000) c.Update() graphAxis(mg) CMS_lumi.CMS_lumi(c, iPeriod, iPos) c.cd() c.Update() frame = c.GetFrame() frame.Draw() leg.Draw() c.SaveAs(outn + ".png") #c.SaveAs(outn+".C") del c return ratesFromFit
def eta_plot(X0W, Y0W, X1W, Y1W, X2W, Y2W, X3W, Y3W, X4W, Y4W, X5W, Y5W, X6W, Y6W, X7W, Y7W, X8W, Y8W, X9W, Y9W, X10W, Y10W, X11W, Y11W, X12W, Y12W, X13W, Y13W, X0E, Y0E, X1E, Y1E, X2E, Y2E, X3E, Y3E, X4E, Y4E, X5E, Y5E, X6E, Y6E, X7E, Y7E, X8E, Y8E, X9E, Y9E, X10E, Y10E, X11E, Y11E, X12E, Y12E, X13E, Y13E): print "------ Setting Up Format ----------" tdrstyle.setTDRStyle() #change the CMS_lumi variables (see CMS_lumi.py) CMS_lumi.writeExtraText = 1 CMS_lumi.extraText = "Preliminary" CMS_lumi.extraText2 = "2018 pp data" CMS_lumi.lumi_sqrtS = "13 TeV" # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string) CMS_lumi.writeTitle = 1 CMS_lumi.textTitle = 'title' iPos = 11 if (iPos == 0): CMS_lumi.relPosX = 0.12 H_ref = 600 W_ref = 800 W = W_ref H = H_ref iPeriod = 0 # references for T, B, L, R T = 0.08 * H_ref B = 0.12 * H_ref L = 0.12 * W_ref R = 0.04 * W_ref print "------ Creating Wheel TGraph ----------" n0W = len(X0W) gr0W = TGraph(n0W, X0W, Y0W) gr0W.SetMarkerColor(kRed) gr0W.SetMarkerStyle(20) gr0W.SetMarkerSize(1.5) gr0W.SetTitle('RB1 in') gr0W.GetXaxis().SetTitle('#eta') gr0W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n1W = len(X1W) gr1W = TGraph(n1W, X1W, Y1W) gr1W.SetLineColor(2) gr1W.SetLineWidth(4) gr1W.SetMarkerColor(kBlue) gr1W.SetMarkerStyle(29) gr1W.SetMarkerSize(1.7) gr1W.SetTitle('Layer 1 Wheel') gr1W.GetXaxis().SetTitle('#eta') gr1W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n2W = len(X2W) gr2W = TGraph(n2W, X2W, Y2W) gr2W.SetLineColor(3) gr2W.SetLineWidth(5) gr2W.SetMarkerColor(kRed + 2) gr2W.SetMarkerStyle(21) gr2W.SetMarkerSize(1.5) gr2W.SetTitle('Layer 2 Wheel') gr2W.GetXaxis().SetTitle('#eta') gr2W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n3W = len(X3W) gr3W = TGraph(n3W, X3W, Y3W) gr3W.SetLineColor(4) gr3W.SetLineWidth(6) gr3W.SetMarkerColor(kRed) gr3W.SetMarkerStyle(21) gr3W.SetMarkerSize(1.5) gr3W.SetTitle('Layer 3 Wheel') gr3W.GetXaxis().SetTitle('#eta') gr3W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n4W = len(X4W) gr4W = TGraph(n4W, X4W, Y4W) gr4W.SetLineColor(5) gr4W.SetLineWidth(7) gr4W.SetMarkerColor(kBlue) gr4W.SetMarkerStyle(23) gr4W.SetMarkerSize(1.5) gr4W.SetTitle('Layer 4 Wheel') gr4W.GetXaxis().SetTitle('#eta') gr4W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') print "------ Creating Endcap TGraph ----------" n0E = len(X0E) gr0E = TGraph(n0E, X0E, Y0E) gr0E.SetLineColor(2) gr0E.SetLineWidth(4) gr0E.SetMarkerColor(kRed) gr0E.SetMarkerStyle(24) gr0E.SetMarkerSize(1.5) gr0E.SetTitle('Layer 1 Endcap') gr0E.GetXaxis().SetTitle('#eta') gr0E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n1E = len(X1E) gr1E = TGraph(n1E, X1E, Y1E) gr1E.SetLineColor(2) gr1E.SetLineWidth(4) gr1E.SetMarkerColor(kBlue) gr1E.SetMarkerStyle(30) gr1E.SetMarkerSize(1.5) gr1E.SetTitle('Layer 1 Endcap') gr1E.GetXaxis().SetTitle('#eta') gr1E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n2E = len(X2E) gr2E = TGraph(n2E, X2E, Y2E) gr2E.SetLineColor(3) gr2E.SetLineWidth(5) gr2E.SetMarkerColor(kRed + 2) gr2E.SetMarkerStyle(25) gr2E.SetMarkerSize(1.5) gr2E.SetTitle('Layer 2 Endcap') gr2E.GetXaxis().SetTitle('#eta') gr2E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n3E = len(X3E) gr3E = TGraph(n3E, X3E, Y3E) gr3E.SetLineColor(4) gr3E.SetLineWidth(6) gr3E.SetMarkerColor(kRed) gr3E.SetMarkerStyle(25) gr3E.SetMarkerSize(1.5) gr3E.SetTitle('Layer 3 Endcap') gr3E.GetXaxis().SetTitle('#eta') gr3E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n4E = len(X4E) gr4E = TGraph(n4E, X4E, Y4E) gr4E.SetLineColor(5) gr4E.SetLineWidth(7) gr4E.SetMarkerColor(kBlue) gr4E.SetMarkerStyle(32) gr4E.SetMarkerSize(1.5) gr4E.SetTitle('Layer 4 Endcap') gr4E.GetXaxis().SetTitle('#eta') gr4E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') print "------ Creating Wheel TGraph ----------" n5W = len(X5W) gr5W = TGraph(n5W, X5W, Y5W) gr5W.SetLineColor(2) gr5W.SetLineWidth(4) gr5W.SetMarkerColor(6) gr5W.SetMarkerStyle(22) gr5W.SetMarkerSize(1.5) gr5W.SetTitle('Layer 1 Wheel') gr5W.GetXaxis().SetTitle('#eta') gr5W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n6W = len(X6W) gr6W = TGraph(n6W, X6W, Y6W) gr6W.SetLineColor(3) gr6W.SetLineWidth(5) gr6W.SetMarkerColor(28) gr6W.SetMarkerStyle(23) gr6W.SetMarkerSize(1.7) gr6W.SetTitle('Layer 2 Wheel') gr6W.GetXaxis().SetTitle('#eta') gr6W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n7W = len(X7W) gr7W = TGraph(n7W, X7W, Y7W) gr7W.SetLineColor(4) gr7W.SetLineWidth(6) gr7W.SetMarkerColor(kRed) gr7W.SetMarkerStyle(20) gr7W.SetMarkerSize(1.5) gr7W.SetTitle('Layer 3 Wheel') gr7W.GetXaxis().SetTitle('#eta') gr7W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n8W = len(X8W) gr8W = TGraph(n8W, X8W, Y8W) gr8W.SetLineColor(5) gr8W.SetLineWidth(7) gr8W.SetMarkerColor(kBlue) gr8W.SetMarkerStyle(29) gr8W.SetMarkerSize(1.5) gr8W.SetTitle('Layer 4 Wheel') gr8W.GetXaxis().SetTitle('#eta') gr8W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n9W = len(X9W) gr9W = TGraph(n9W, X9W, Y9W) gr9W.SetLineColor(5) gr9W.SetLineWidth(7) gr9W.SetMarkerColor(kRed + 2) gr9W.SetMarkerStyle(21) gr9W.SetMarkerSize(1.5) gr9W.SetTitle('Layer 4 Wheel') gr9W.GetXaxis().SetTitle('#eta') gr9W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n10W = len(X10W) gr10W = TGraph(n10W, X10W, Y10W) gr10W.SetLineColor(5) gr10W.SetLineWidth(7) gr10W.SetMarkerColor(kRed) gr10W.SetMarkerStyle(21) gr10W.SetMarkerSize(1.5) gr10W.SetTitle('Layer 4 Wheel') gr10W.GetXaxis().SetTitle('#eta') gr10W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n11W = len(X11W) gr11W = TGraph(n11W, X11W, Y11W) gr11W.SetLineColor(5) gr11W.SetLineWidth(7) gr11W.SetMarkerColor(kBlue) gr11W.SetMarkerStyle(23) gr11W.SetMarkerSize(1.5) gr11W.SetTitle('Layer 4 Wheel') gr11W.GetXaxis().SetTitle('#eta') gr11W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n12W = len(X12W) gr12W = TGraph(n12W, X12W, Y12W) gr12W.SetLineColor(5) gr12W.SetLineWidth(7) gr12W.SetMarkerColor(6) gr12W.SetMarkerStyle(22) gr12W.SetMarkerSize(1.5) gr12W.SetTitle('Layer 4 Wheel') gr12W.GetXaxis().SetTitle('#eta') gr12W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n13W = len(X13W) gr13W = TGraph(n13W, X13W, Y13W) gr13W.SetLineColor(5) gr13W.SetLineWidth(7) gr13W.SetMarkerColor(28) gr13W.SetMarkerStyle(23) gr13W.SetMarkerSize(1.5) gr13W.SetTitle('Layer 4 Wheel') gr13W.GetXaxis().SetTitle('#eta') gr13W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') print "------ Creating Endcap TGraph ----------" n5E = len(X5E) gr5E = TGraph(n5E, X5E, Y5E) gr5E.SetLineColor(2) gr5E.SetLineWidth(4) gr5E.SetMarkerColor(6) gr5E.SetMarkerStyle(26) gr5E.SetMarkerSize(1.5) gr5E.SetTitle('Layer 1 Endcap') gr5E.GetXaxis().SetTitle('#eta') gr5E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n6E = len(X6E) gr6E = TGraph(n6E, X6E, Y6E) gr6E.SetLineColor(3) gr6E.SetLineWidth(5) gr6E.SetMarkerColor(28) gr6E.SetMarkerStyle(32) gr6E.SetMarkerSize(1.5) gr6E.SetTitle('Layer 2 Endcap') gr6E.GetXaxis().SetTitle('#eta') gr6E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n7E = len(X7E) gr7E = TGraph(n7E, X7E, Y7E) gr7E.SetLineColor(4) gr7E.SetLineWidth(6) gr7E.SetMarkerColor(kRed) gr7E.SetMarkerStyle(24) gr7E.SetMarkerSize(1.5) gr7E.SetTitle('Layer 3 Endcap') gr7E.GetXaxis().SetTitle('#eta') gr7E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n8E = len(X8E) gr8E = TGraph(n8E, X8E, Y8E) gr8E.SetLineColor(5) gr8E.SetLineWidth(7) gr8E.SetMarkerColor(kBlue) gr8E.SetMarkerStyle(30) gr8E.SetMarkerSize(1.5) gr8E.SetTitle('Layer 4 Endcap') gr8E.GetXaxis().SetTitle('#eta') gr8E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n9E = len(X9E) gr9E = TGraph(n9E, X9E, Y9E) gr9E.SetLineColor(5) gr9E.SetLineWidth(7) gr9E.SetMarkerColor(kRed + 2) gr9E.SetMarkerStyle(25) gr9E.SetMarkerSize(1.5) gr9E.SetTitle('Layer 4 Endcap') gr9E.GetXaxis().SetTitle('#eta') gr9E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n10E = len(X10E) gr10E = TGraph(n10E, X10E, Y10E) gr10E.SetLineColor(5) gr10E.SetLineWidth(7) gr10E.SetMarkerColor(kRed) gr10E.SetMarkerStyle(25) gr10E.SetMarkerSize(1.5) gr10E.SetTitle('Layer 4 Endcap') gr10E.GetXaxis().SetTitle('#eta') gr10E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n11E = len(X11E) gr11E = TGraph(n11E, X11E, Y11E) gr11E.SetLineColor(5) gr11E.SetLineWidth(7) gr11E.SetMarkerColor(kBlue) gr11E.SetMarkerStyle(32) gr11E.SetMarkerSize(1.5) gr11E.SetTitle('Layer 4 Endcap') gr11E.GetXaxis().SetTitle('#eta') gr11E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n12E = len(X12E) gr12E = TGraph(n12E, X12E, Y12E) gr12E.SetLineColor(5) gr12E.SetLineWidth(7) gr12E.SetMarkerColor(6) gr12E.SetMarkerStyle(26) gr12E.SetMarkerSize(1.5) gr12E.SetTitle('Layer 4 Endcap') gr12E.GetXaxis().SetTitle('#eta') gr12E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') n13E = len(X13E) gr13E = TGraph(n13E, X13E, Y13E) gr13E.SetLineColor(5) gr13E.SetLineWidth(7) gr13E.SetMarkerColor(28) gr13E.SetMarkerStyle(32) gr13E.SetMarkerSize(1.5) gr13E.SetTitle('Layer 4 Endcap') gr13E.GetXaxis().SetTitle('#eta') gr13E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') print "----- Reading Fluka Info -----" f = TFile.Open("../FlukaEta.root") flukaRB1 = f.RB1 flukaRB1.SetMarkerColor(2) flukaRB1.SetMarkerStyle(20) flukaRB2 = f.RB2 flukaRB2.SetMarkerColor(2) flukaRB2.SetMarkerStyle(20) flukaRB3 = f.RB3 flukaRB3.SetMarkerColor(2) flukaRB3.SetMarkerStyle(20) flukaRB4 = f.RB4 flukaRB4.SetMarkerColor(2) flukaRB4.SetMarkerStyle(20) flukaRE1 = f.RE1 flukaRE1.SetMarkerColor(2) flukaRE1.SetMarkerStyle(4) flukaRE2 = f.RE2 flukaRE2.SetMarkerColor(2) flukaRE2.SetMarkerStyle(4) flukaRE3 = f.RE3 flukaRE3.SetMarkerColor(2) flukaRE3.SetMarkerStyle(4) flukaRE4 = f.RE4 flukaRE4.SetMarkerColor(2) flukaRE4.SetMarkerStyle(4) print "I did open the file" print flukaRB1, flukaRE4 print "----- Creating TCanvas -----" H = 800 W = 1600 canv = TCanvas("c1", "Canvas", 50, 50, W, H) canv.SetFillColor(0) canv.SetBorderMode(0) canv.SetFrameFillStyle(0) canv.SetFrameBorderMode(0) canv.SetLeftMargin(L / W) canv.SetRightMargin(R / W) canv.SetTopMargin(T / H) canv.SetBottomMargin(B / H) canv.SetTickx(0) canv.SetTicky(0) canv.Divide(3, 2, 0.001, 0.001) CMS_lumi.CMS_lumi(canv, iPeriod, iPos) canv.cd() canv.Update() maxY = 1000 canv.cd(1) gPad.SetLogy() print " ------------ Creating TMultiGraph -----------" mg1 = TMultiGraph() gr0E.SetMarkerColor(4) gr0W.SetMarkerColor(4) gr7E.SetMarkerColor(4) gr7W.SetMarkerColor(4) mg1.Add(gr0E, "AP") mg1.Add(gr0W, "AP") mg1.Add(gr7E, "AP") mg1.Add(gr7W, "AP") mg1.Add(flukaRB1, "AP") mg1.Add(flukaRE1, "AP") mg1.Draw("a") mg1.SetTitle('RB1in') mg1.GetXaxis().SetTitle('#eta') mg1.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') mg1.SetMaximum(maxY) mg1.GetXaxis().SetLabelFont(42) mg1.GetXaxis().SetLabelOffset(0.007) mg1.GetXaxis().SetLabelSize(0.043) mg1.GetXaxis().SetTitleSize(0.05) mg1.GetXaxis().SetTitleOffset(1.06) mg1.GetXaxis().SetTitleFont(42) mg1.GetYaxis().SetLabelFont(42) mg1.GetYaxis().SetLabelOffset(0.008) mg1.GetYaxis().SetLabelSize(0.05) mg1.GetYaxis().SetTitleSize(0.06) mg1.GetYaxis().SetTitleOffset(0.87) mg1.GetYaxis().SetTitleFont(42) pvtxt = TPaveText(.1, 0.97, .55, 0.97, "NDC") #(.06,.4,.55,.73) pvtxt.AddText('CMS Preliminary') pvtxt.SetFillStyle(0) pvtxt.SetBorderSize(0) pvtxt.SetTextSize(0.03) pvtxt.Draw() pvtxt100 = TPaveText(.7, 0.97, .9, 0.97, "NDC") pvtxt100.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)') pvtxt100.SetFillStyle(0) pvtxt100.SetBorderSize(0) pvtxt100.SetTextSize(0.03) pvtxt100.Draw() canv.cd(2) gPad.SetLogy() gr00 = TGraph() gr00.SetMarkerColor(kBlack) gr00.SetMarkerStyle(20) gr00.SetMarkerSize(1.5) gr01 = TGraph() gr01.SetMarkerColor(kBlack) gr01.SetMarkerStyle(24) gr01.SetMarkerSize(1.5) legend0 = TLegend(0.2, 0.75, .8, .95) legend0.SetNColumns(1) legend0.AddEntry(gr00, "Barrel", "p") legend0.AddEntry(gr01, "Endcaps", "p") legend0.Draw("a same") legendi = TLegend(0.2, 0.15, .8, .69) legendi.SetNColumns(1) legendi.AddEntry(gr7W, "RB1in + RE1", "p") legendi.AddEntry(gr8W, "RB1out + RE1", "p") legendi.AddEntry(gr9W, "RB2 + RE2", "p") # legendi.AddEntry(gr10W, "RB2in + RE2" , "p") # legendi.AddEntry(gr11W, "RB2out + RE2" , "p") legendi.AddEntry(gr12W, "RB3 + RE3", "p") legendi.AddEntry(gr13W, "RB4 + RE4", "p") legendi.AddEntry(flukaRB1, "Fluka Simulation", "p") legendi.SetTextSize(0.05) legendi.Draw("a") canv.cd(3) gPad.SetLogy() mg2 = TMultiGraph() gr1E.SetMarkerColor(4) gr1W.SetMarkerColor(4) gr8E.SetMarkerColor(4) gr8W.SetMarkerColor(4) mg2.Add(gr1E, "AP") mg2.Add(gr1W, "AP") mg2.Add(gr8E, "AP") mg2.Add(gr8W, "AP") mg2.Add(flukaRB1, "AP") mg2.Add(flukaRE1, "AP") mg2.Draw("a") mg2.SetTitle('RB1out') mg2.GetXaxis().SetTitle('#eta') mg2.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') mg2.SetMaximum(maxY) mg2.GetXaxis().SetLabelFont(42) mg2.GetXaxis().SetLabelOffset(0.007) mg2.GetXaxis().SetLabelSize(0.043) mg2.GetXaxis().SetTitleSize(0.05) mg2.GetXaxis().SetTitleOffset(1.06) mg2.GetXaxis().SetTitleFont(42) mg2.GetYaxis().SetLabelFont(42) mg2.GetYaxis().SetLabelOffset(0.008) mg2.GetYaxis().SetLabelSize(0.05) mg2.GetYaxis().SetTitleSize(0.06) mg2.GetYaxis().SetTitleOffset(0.87) mg2.GetYaxis().SetTitleFont(42) pvtxt3 = TPaveText(.1, 0.97, .55, 0.97, "NDC") #(.06,.4,.55,.73) pvtxt3.AddText('CMS Preliminary') pvtxt3.SetFillStyle(0) pvtxt3.SetBorderSize(0) pvtxt3.SetTextSize(0.03) pvtxt3.Draw() pvtxt4 = TPaveText(.7, 0.97, .9, 0.97, "NDC") pvtxt4.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)') pvtxt4.SetFillStyle(0) pvtxt4.SetBorderSize(0) pvtxt4.SetTextSize(0.03) pvtxt4.Draw() canv.cd(4) gPad.SetLogy() mg3 = TMultiGraph() #graphAxis(mg3) gr2E.SetMarkerColor(4) gr2W.SetMarkerColor(4) gr9E.SetMarkerColor(4) gr9W.SetMarkerColor(4) mg3.Add(gr2E, "AP") mg3.Add(gr2W, "AP") mg3.Add(gr9E, "AP") mg3.Add(gr9W, "AP") mg3.Add(flukaRB2, "AP") mg3.Add(flukaRE2, "AP") mg3.Draw("a") mg3.SetTitle('RB2') mg3.GetXaxis().SetTitle('#eta') mg3.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') mg3.SetMaximum(maxY) mg3.GetXaxis().SetLabelFont(42) mg3.GetXaxis().SetLabelOffset(0.007) mg3.GetXaxis().SetLabelSize(0.043) mg3.GetXaxis().SetTitleSize(0.05) mg3.GetXaxis().SetTitleOffset(1.06) mg3.GetXaxis().SetTitleFont(42) mg3.GetYaxis().SetLabelFont(42) mg3.GetYaxis().SetLabelOffset(0.008) mg3.GetYaxis().SetLabelSize(0.05) mg3.GetYaxis().SetTitleSize(0.06) mg3.GetYaxis().SetTitleOffset(0.87) mg3.GetYaxis().SetTitleFont(42) pvtxt5 = TPaveText(.1, 0.97, .55, 0.97, "NDC") #(.06,.4,.55,.73) pvtxt5.AddText('CMS Preliminary') pvtxt5.SetFillStyle(0) pvtxt5.SetBorderSize(0) pvtxt5.SetTextSize(0.03) pvtxt5.Draw() pvtxt6 = TPaveText(.7, 0.97, .9, 0.97, "NDC") pvtxt6.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)') pvtxt6.SetFillStyle(0) pvtxt6.SetBorderSize(0) pvtxt6.SetTextSize(0.03) pvtxt6.Draw() canv.cd(5) gPad.SetLogy() mg4 = TMultiGraph() #graphAxis(mg4) gr5E.SetMarkerColor(4) gr5W.SetMarkerColor(4) gr12E.SetMarkerColor(4) gr12W.SetMarkerColor(4) mg4.Add(gr5E, "AP") mg4.Add(gr5W, "AP") mg4.Add(gr12E, "AP") mg4.Add(gr12W, "AP") mg4.Add(flukaRB3, "AP") mg4.Add(flukaRE3, "AP") mg4.Draw("a") mg4.SetTitle('RB3') mg4.GetXaxis().SetTitle('#eta') mg4.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') mg4.SetMaximum(maxY) mg4.GetXaxis().SetLabelFont(42) mg4.GetXaxis().SetLabelOffset(0.007) mg4.GetXaxis().SetLabelSize(0.043) mg4.GetXaxis().SetTitleSize(0.05) mg4.GetXaxis().SetTitleOffset(1.06) mg4.GetXaxis().SetTitleFont(42) mg4.GetYaxis().SetLabelFont(42) mg4.GetYaxis().SetLabelOffset(0.008) mg4.GetYaxis().SetLabelSize(0.05) mg4.GetYaxis().SetTitleSize(0.06) mg4.GetYaxis().SetTitleOffset(0.87) mg4.GetYaxis().SetTitleFont(42) pvtxt7 = TPaveText(.1, 0.97, .55, 0.97, "NDC") #(.06,.4,.55,.73) pvtxt7.AddText('CMS Preliminary') pvtxt7.SetFillStyle(0) pvtxt7.SetBorderSize(0) pvtxt7.SetTextSize(0.03) pvtxt7.Draw() pvtxt8 = TPaveText(.7, 0.97, .9, 0.97, "NDC") pvtxt8.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)') pvtxt8.SetFillStyle(0) pvtxt8.SetBorderSize(0) pvtxt8.SetTextSize(0.03) pvtxt8.Draw() canv.cd(6) gPad.SetLogy() mg5 = TMultiGraph() #graphAxis(mg5) gr6E.SetMarkerColor(4) gr6W.SetMarkerColor(4) gr13E.SetMarkerColor(4) gr13W.SetMarkerColor(4) mg5.Add(gr6E, "AP") mg5.Add(gr6W, "AP") mg5.Add(gr13E, "AP") mg5.Add(gr13W, "AP") mg5.Add(flukaRB4, "AP") mg5.Add(flukaRE4, "AP") mg5.Draw("a") mg5.SetTitle('RB4') mg5.GetXaxis().SetTitle('#eta') mg5.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') mg5.SetMaximum(maxY) mg5.GetXaxis().SetLabelFont(42) mg5.GetXaxis().SetLabelOffset(0.007) mg5.GetXaxis().SetLabelSize(0.043) mg5.GetXaxis().SetTitleSize(0.05) mg5.GetXaxis().SetTitleOffset(1.06) mg5.GetXaxis().SetTitleFont(42) mg5.GetYaxis().SetLabelFont(42) mg5.GetYaxis().SetLabelOffset(0.008) mg5.GetYaxis().SetLabelSize(0.05) mg5.GetYaxis().SetTitleSize(0.06) mg5.GetYaxis().SetTitleOffset(0.87) mg5.GetYaxis().SetTitleFont(42) pvtxt10 = TPaveText(.1, 0.97, .55, 0.97, "NDC") #(.06,.4,.55,.73) pvtxt10.AddText('CMS Preliminary') pvtxt10.SetFillStyle(0) pvtxt10.SetBorderSize(0) pvtxt10.SetTextSize(0.03) pvtxt10.Draw() pvtxt9 = TPaveText(.7, 0.97, .9, 0.97, "NDC") pvtxt9.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)') pvtxt9.SetFillStyle(0) pvtxt9.SetBorderSize(0) pvtxt9.SetTextSize(0.03) pvtxt9.Draw() canv.SaveAs("etaDistro.gif") canv.SaveAs("etaDistro.png") canv.SaveAs("etaDistro.pdf") canv.SaveAs("etaDistro.C") canv.Close() print "----- Creating Second TCanvas -----" H = 800 W = 800 c = TCanvas("c1", "Canvas", 50, 50, W, H) c.SetFillColor(0) c.SetBorderMode(0) c.SetFrameFillStyle(0) c.SetFrameBorderMode(0) c.SetLeftMargin(L / W) c.SetRightMargin(R / W) c.SetTopMargin(T / H) c.SetBottomMargin(B / H) c.SetTickx(0) c.SetTicky(0) gPad.SetLogy() print " ------------ Creating TMultiGraph -----------" mg = TMultiGraph() mg.Add(gr0E, "AP") mg.Add(gr0W, "AP") mg.Add(gr7E, "AP") mg.Add(gr7W, "AP") mg.Add(gr1W, "AP") mg.Add(gr8W, "AP") mg.Add(flukaRB1, "AP") mg.Add(flukaRE1, "AP") mg.Draw("a") mg.SetTitle('RB1in') mg.GetXaxis().SetTitle('#eta') mg.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') mg.SetMaximum(maxY) mg.GetXaxis().SetLabelFont(42) mg.GetXaxis().SetLabelOffset(0.007) mg.GetXaxis().SetLabelSize(0.043) mg.GetXaxis().SetTitleSize(0.05) mg.GetXaxis().SetTitleOffset(1.06) mg.GetXaxis().SetTitleFont(42) mg.GetYaxis().SetLabelFont(42) mg.GetYaxis().SetLabelOffset(0.008) mg.GetYaxis().SetLabelSize(0.05) mg.GetYaxis().SetTitleSize(0.06) mg.GetYaxis().SetTitleOffset(0.87) mg.GetYaxis().SetTitleFont(42) pvt = TPaveText(.1, 0.97, .55, 0.97, "NDC") #(.06,.4,.55,.73) pvt.AddText('CMS Preliminary') pvt.SetFillStyle(0) pvt.SetBorderSize(0) pvt.SetTextSize(0.03) pvt.Draw() pvt1 = TPaveText(.7, 0.97, .9, 0.97, "NDC") pvt1.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)') pvt1.SetFillStyle(0) pvt1.SetBorderSize(0) pvt1.SetTextSize(0.03) pvt1.Draw() legenda = TLegend(0.4, 0.7, .7, .9) legenda.SetNColumns(1) legenda.AddEntry(gr0E, "RE1", "p") legenda.AddEntry(gr0W, "RB1in", "p") legenda.AddEntry(gr1W, "RB1out", "p") legenda.AddEntry(flukaRB1, "Fluka Simulation", "p") legenda.SetTextSize(0.05) legenda.Draw("a") c.SaveAs("etaDistroDetailRB1.png") c.SaveAs("etaDistroDetailRB1.gif") c.SaveAs("etaDistroDetailRB1.pdf") c.SaveAs("etaDistroDetailRB1.C") c.Close() print "----- Creating Second TCanvas -----" c1 = TCanvas("c1", "Canvas", 50, 50, W, H) c1.SetFillColor(0) c1.SetBorderMode(0) c1.SetFrameFillStyle(0) c1.SetFrameBorderMode(0) c1.SetLeftMargin(L / W) c1.SetRightMargin(R / W) c1.SetTopMargin(T / H) c1.SetBottomMargin(B / H) c1.SetTickx(0) c1.SetTicky(0) gPad.SetLogy() print " ------------ Creating TMultiGraph -----------" mgd2 = TMultiGraph() gr3E.SetMarkerColor(4) gr3W.SetMarkerColor(4) gr10E.SetMarkerColor(4) gr10W.SetMarkerColor(4) gr4W.SetMarkerColor(4) gr11W.SetMarkerColor(4) mgd2.Add(gr3E, "AP") mgd2.Add(gr3W, "AP") mgd2.Add(gr10E, "AP") mgd2.Add(gr10W, "AP") mgd2.Add(gr4W, "AP") mgd2.Add(gr11W, "AP") mgd2.Add(flukaRB2, "AP") mgd2.Add(flukaRE2, "AP") mgd2.Draw("a") mgd2.SetTitle('RB1in') mgd2.GetXaxis().SetTitle('#eta') mgd2.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})') mgd2.SetMaximum(maxY) mgd2.GetXaxis().SetLabelFont(42) mgd2.GetXaxis().SetLabelOffset(0.007) mgd2.GetXaxis().SetLabelSize(0.043) mgd2.GetXaxis().SetTitleSize(0.05) mgd2.GetXaxis().SetTitleOffset(1.06) mgd2.GetXaxis().SetTitleFont(42) mgd2.GetYaxis().SetLabelFont(42) mgd2.GetYaxis().SetLabelOffset(0.008) mgd2.GetYaxis().SetLabelSize(0.05) mgd2.GetYaxis().SetTitleSize(0.06) mgd2.GetYaxis().SetTitleOffset(0.87) mgd2.GetYaxis().SetTitleFont(42) pv = TPaveText(.1, 0.97, .55, 0.97, "NDC") #(.06,.4,.55,.73) pv.AddText('CMS Preliminary') pv.SetFillStyle(0) pv.SetBorderSize(0) pv.SetTextSize(0.03) pv.Draw() pv1 = TPaveText(.7, 0.97, .9, 0.97, "NDC") pv1.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)') pv1.SetFillStyle(0) pv1.SetBorderSize(0) pv1.SetTextSize(0.03) pv1.Draw() legendd2 = TLegend(0.4, 0.6, .7, .8) legendd2.SetNColumns(1) legendd2.AddEntry(gr3E, "RE2", "p") legendd2.AddEntry(gr3W, "RB2in", "p") legendd2.AddEntry(gr4W, "RB2out", "p") legendd2.AddEntry(flukaRB2, "Fluka Simulation", "p") legendd2.SetTextSize(0.05) legendd2.Draw("a") c1.SaveAs("etaDistroDetailRB2.png") c1.SaveAs("etaDistroDetailRB2.pdf") c1.SaveAs("etaDistroDetailRB2.gif") c1.SaveAs("etaDistroDetailRB2.C")
rawfitresultList.At(i).getError()) tageffVsEtaGraph.SetLineColor(currentColor) linFunc.SetLineColor(currentColor) tageffVsEtaGraph.Fit(linFunc) graphHolder.Add(tageffVsEtaGraph) currentColor += 1 #tageffVsEtaGraph = TGraph(rawfitresultList.GetSize(),etaAvgValList,tageffValVList)#,etaAvgErrorList,tageffErrorList); #tageffVsEtaGraph. #ROOT.gSystem.ProcessEvents(); #img.FromPad(theCanvas); os.chdir("..") theCanvas = TCanvas() if (graphHolder.GetListOfGraphs().GetSize() == 1): graphHolder.SetTitle( "Tagging efficiency vs. Eta;Eta;Tagging Efficiency (omega)") else: graphHolder.SetTitle( "Tagging efficiency vs. Eta (multiple eta sets);Eta;Tagging Efficiency (omega)" ) graphHolder.Draw("AP") #raw_input("Press Enter to continue"); theCanvas.Print("tageffVsEtaGraph_%f.pdf" % time.time(), "pdf") print "SHIT"
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) ISS_negative_plot.SetLineColor(4) ISS_chargeconfused_plot.SetLineColor(6) ISS_positive_plot.SetLineColor(8) ccratio_plot.SetMarkerStyle(20) ISS_negative_plot.SetMarkerStyle(21) ISS_chargeconfused_plot.SetMarkerStyle(22) ISS_positive_plot.SetMarkerStyle(23) mg.SetTitle("; Rigidity (GV); ") #mg.Add(ccratio_plot) mg.Add(ISS_negative_plot) mg.Add(ISS_positive_plot) mg.Add(ISS_chargeconfused_plot) mg.Draw("ACP") grshade.SetFillStyle(3004) grshade.SetFillColor(2) grshade.Draw("F") grshade2.SetFillStyle(3016) grshade2.SetFillColor(1) grshade2.Draw("F") leg =TLegend(.7,.7,.9,.9,) leg.SetFillColor(0)
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")
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)
ratePlot.Add(jetToElectronRatePlot, "A3") jetToElectronRatePlot.SetFillStyle(1001) jetToElectronRatePlot.SetLineWidth(2) jetToElectronRatePlot.SetLineStyle(1) # ratePlot.Add(jetToPhotonRatePlot, "A3") # jetToPhotonRatePlot.SetFillStyle(1001) # jetToPhotonRatePlot.SetLineWidth(2) # jetToPhotonRatePlot.SetLineStyle(1) ratePlot.Add(jetToMETRatePlot, "A3") jetToMETRatePlot.SetFillStyle(1001) jetToMETRatePlot.SetLineWidth(2) jetToMETRatePlot.SetLineStyle(1) ratePlot.Draw("A3") # Plot labels ratePlot.SetTitle("Zero pile-up event rate simulation") ratePlot.GetXaxis().SetTitle("p_{t} [GeV]") ratePlot.GetYaxis().SetTitle("Rate [Hz]") leg.Draw() # Plot ranges ratePlot.GetYaxis().SetRangeUser(1e2, 1e10) ratePlot.GetXaxis().SetRangeUser(30, 370) # Lumi and energy info text = TPaveText(0.2, 0.84, 0.6, 0.9, "NDC") text.AddText("L_{inst} = 3 #times 10^{35} cm^{-2} s^{-1} #sqrt{s} = 100 TeV") text.Draw() # Adding a reference line at 1 MHz
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 produceYieldPlots(param, dicts, uncertainties, fname, label, ptmax): print '' print 'Preparing yield plots ...' # uncertainty scenarios (theory+lumi, signal_eff, background) # signal eff uncertainty is computed later based on object pT, here specifiy only multiplicative factor # prepare yield plots gr_sb = TGraph() mg_sign = TMultiGraph() mg_dmu = TMultiGraph() gr_sb.SetTitle(";p_{T,min}^{H} [GeV]; S/B") mg_sign.SetTitle( ";p_{T,min}^{H} [GeV]; Significance = #frac{S}{#sqrt{S + #sigma_{S}^{2} + B + #sigma_{B}^{2}}}" ) mg_dmu.SetTitle(";p_{T,min}^{H} [GeV]; #delta #mu / #mu (%)") grs_sign = {} grs_dmu = {} index = 0 gr_sb.SetLineColor(ROOT.kBlack) gr_sb.SetLineWidth(3) for unc, tit in uncertainties.iteritems(): 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 title = tit grs_sign[index].SetTitle(title) grs_dmu[index].SetTitle(title) index += 1 # fill yield graphs nsel = 0 maxsb = -999 minsb = 999 maxsig = -999 minsig = 999 maxdmu = -999 mindmu = 999 nsel = 0 minpt = dict() minss = dict() for unc, tit in uncertainties.iteritems(): minpt[unc] = 999. minss[unc] = 999. for cut in dicts[0][0].keys(): #print s, b nsel += 1 index = 0 delta_eff_ele = 0 delta_eff_mu = 0 delta_eff_pho = 0 delta_eff_i = 0 # loop over all final states deltas_s = 0 deltas_s_2 = 0 deltab_b = 0 deltab_b_2 = 0 s = 0 b = 0 for i in xrange(len(dicts)): ele_errors = dicts[i][0] muo_errors = dicts[i][1] pho_errors = dicts[i][2] s_yields = dicts[i][3] b_yields = dicts[i][4] s_i = s_yields[cut] b_i = b_yields[cut] args = options() if args.sqrts == 37: s_i *= ratio[cut] b_i *= ratio[cut] #sigma_eff_i = unc[1]*delta_eff_i #sig_unc_i = math.sqrt(unc[0]**2 + sigma_eff_i**2) #bkg_unc_i = math.sqrt(unc[2]**2) sigma_eff_i = math.sqrt(ele_errors[cut]**2 + muo_errors[cut]**2 + pho_errors[cut]**2) sig_unc_i = math.sqrt(sigma_eff_i**2) bkg_unc_i = 0. s += s_i b += b_i deltas_s += sig_unc_i * s_i deltas_s_2 += (sig_unc_i * s_i)**2 #print '{:.0f}, {:.0f}, {:.3f}, {:.0f}'.format(s_i, b_i, sig_unc_i, sig_unc_i*s_i) deltab_b += bkg_unc_i * b_i deltab_b_2 += (bkg_unc_i * b_i)**2 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) index = 0 for unc, tit in uncertainties.iteritems(): sig_unc = 1.0 bkg_unc = 1.0 s_2 = s * s b_2 = b * b # conservative case, correlated sum --> sigma_s * s = Sum sigma_i * s_i if s > 0 and b > 0: sig_unc = deltas_s / s #bkg_unc = deltab_b/b bkg_unc = math.sqrt(deltab_b_2 / b_2) '''# aggro case, un-correlated sum --> sigma_s * s = sqrt( Sum (sigma_i * s_i)^2 if s > 0 and b > 0: sig_unc = math.sqrt(deltas_s_2/s_2) bkg_unc = math.sqrt(deltab_b_2/b_2)''' #print cut, s, b, unc, sig_unc # rescale by various uncertainty assumptions sig_unc = math.sqrt(unc[0]**2 + (unc[1] * sig_unc)**2) bkg_unc = math.sqrt(unc[2]**2) sign = significance(s, sig_unc, b, bkg_unc) rel_unc = dMuOverMu(s, sig_unc, b, bkg_unc) if float(cut) <= ptmax: if sign < minsig: minsig = sign if sign > maxsig: maxsig = sign if rel_unc < mindmu: mindmu = rel_unc if rel_unc > maxdmu: maxdmu = rel_unc if rel_unc < minss[unc]: minss[unc] = rel_unc minpt[unc] = cut #print unc, cut, rel_unc grs_sign[index].SetPoint(nsel, cut, sign) grs_dmu[index].SetPoint(nsel, cut, rel_unc) index += 1 index = 0 for unc, tit in uncertainties.iteritems(): mg_sign.Add(grs_sign[index]) mg_dmu.Add(grs_dmu[index]) index += 1 intLumiab = param[0].intLumi / 1e+06 args = options() if args.sqrts == 100: collabel = 'FCC-hh' sqrtslabel = args.sqrts if args.sqrts == 27: collabel = 'HE-LHC' sqrtslabel = args.sqrts if args.sqrts == 37: collabel = 'VHE-LHC' sqrtslabel = 37.5 lt = "{} Simulation (Delphes)".format(collabel) rt = "#sqrt{{s}} = {} TeV, L = {:.0f} ab^{{-1}}, {}".format( sqrtslabel, intLumiab, label) drawMultiGraph(mg_sign, 'sign', lt, rt, fname, minsig / 2., maxsig * 10., ptmax, True) #drawMultiGraph(mg_dmu, 'optim_dmu', lt, rt, fname , mindmu/2., maxdmu*4., ptmax, True) drawMultiGraph(mg_dmu, 'dmu', lt, rt, fname, mindmu / 4., maxdmu * 10., ptmax, True) drawMultiGraph(gr_sb, 'sb', lt, rt, fname, minsb / 2., maxsb * 2., ptmax, True, False) # print summary for unc, tit in uncertainties.iteritems(): print '{}: {:.2f}'.format(tit, minss[unc]) print 'DONE'