canvas1 = ROOT.TCanvas("c1"+str(njetcut),"c1"+str(njetcut),600, 600) canvas1.SetRightMargin(0.13); canvas1.cd() canvas1.SetLogz() leg = ROOT.TLegend(.2, .2, .5, .5) leg.AddEntry(mDeltaR_allVsTen[njetcut]) leg.Draw() mDeltaR_allVsTen[njetcut].SetTitle("") mDeltaR_allVsTen[njetcut].Draw("colz") mDeltaR_allVsTen[njetcut].GetXaxis().SetTitle("Offline M_{#Delta}^{R}(all jets) (GeV)") mDeltaR_allVsTen[njetcut].GetXaxis().SetNdivisions(505) mDeltaR_allVsTen[njetcut].GetYaxis().SetNdivisions(505) mDeltaR_allVsTen[njetcut].GetYaxis().SetTitle("Offline M_{#Delta}^{R}(ten jets) (GeV)") AtlasUtils.myText(.3,.85,ROOT.kBlack, "N HLT Jets > " + str(njetcut)) canvas1.SetGrid(1,1) canvas1.SaveAs("plots/2d_alljet_tenjet_njetcut"+str(njetcut)+".eps") canvas2 = ROOT.TCanvas("c2"+str(njetcut),"c2"+str(njetcut),600,600) canvas2.SetRightMargin(0.13); canvas2.cd() canvas2.SetLogy() alljet = mDeltaR_allVsTen[njetcut].ProjectionX() tenjet = mDeltaR_allVsTen[njetcut].ProjectionY() alljet.Draw() alljet.GetYaxis().SetTitle("Entries") tenjet.SetMarkerColor(ROOT.kRed) tenjet.Draw("same")
def mp(filename,show=False): #filename = filename[0] tree = ET.parse(filename) root = tree.getroot() plot = atlas_root_multi_graph.plot() plot.build(root) #print "plot.get_filename()",plot.get_filename() #print "plot.get_title()",plot.get_title() title = plot.get_title() saveFile = plot.get_filename() axes = plot.get_axe() if (len(axes) != 2): print "\nThere must be 2 and only 2 axes, named X and Y.\nExiting...\n" exit(len(axes)) for axe in axes: #print "axe.get_name()",axe.get_name() if ( axe.get_name() == 'X' ): Xaxe = axe else: Yaxe = axe minX = 0 maxX = 0 minY = 0 maxY = 0 # here starts the ROOT part tstring_title = TString(title) mgr = TMultiGraph('mgr',tstring_title.Data()) if ( plot.get_legend() ): leg = plot.get_legend() x1 = leg.get_x1() x2 = leg.get_x2() y1 = leg.get_y1() y2 = leg.get_y2() leg = TLegend(x1,y1,x2,y2) else: leg = TLegend(.6,.65,.89,.89) #leg.SetHeader(tstring_title.Data()) curves = plot.get_curve() for curve in curves: file=curve.get_data() input_file = open(file,'r') lines = input_file.readlines() Y = [] X = [] for line in lines: tmp = line.split() X.append(float(tmp[0])) Y.append(float(tmp[1])) input_file.close() X=array('d',X) Y=array('d',Y) gr = TGraph(len(X),X,Y) gr.SetTitle(curve.get_label()) try: gr.SetMarkerStyle(curve.get_marker().get_style()) except TypeError: gr.SetMarkerStyle(defaultMarkerStyle) try: gr.SetMarkerSize(curve.get_marker().get_size()) except TypeError: gr.SetMarkerSize(defaultMarkerSize) try: gr.SetMarkerColor(curve.get_marker().get_color()) except TypeError: gr.SetMarkerColor(defaultMarkerColor) try: gr.SetLineStyle(curve.get_line().get_style()) except TypeError: gr.SetLineStyle(defaultLineStyle) try: int(curve.get_line().get_size()) except TypeError: gr.SetLineWidth(defaultLineSize) try: gr.SetLineWidth(int(curve.get_line().get_size())) except TypeError: gr.SetLineWidth(defaultLineSize) gr.SetLineColor(curve.get_line().get_color()) mgr.Add(gr) leg.AddEntry(gr,gr.GetTitle(),'lp') # real design part minX = Xaxe.get_min() maxX = Xaxe.get_max() print 'X range',minX,maxX minY = Yaxe.get_min() maxY = Yaxe.get_max() print 'Y range',minY,maxY c1 = TCanvas('c1',title) c1.cd() gPad.Range(minX,maxX,minY,maxY) gPad.Draw() mgr.Draw('ALP') mgr.GetXaxis().SetRangeUser(minX,maxX) mgr.GetXaxis().SetTitle(Xaxe.get_label()) mgr.GetYaxis().SetRangeUser(minY,maxY) mgr.GetYaxis().SetTitle(Yaxe.get_label()) mgr.GetYaxis().SetTitleOffset(1.5) hmg = TH1F() hmg = mgr.GetHistogram(); hmg.SetBins(100000000,hmg.GetXaxis().GetXmin(),hmg.GetXaxis().GetXmax()); gPad.SetLogx(Xaxe.get_log()) gPad.SetLogy(Yaxe.get_log()) gPad.Modified() gPad.Update() mgr.GetXaxis().SetRangeUser(minX,maxX) mgr.GetYaxis().SetRangeUser(minY,maxY) try: atlaslabel = plot.get_atlasl() except: pass try: xatlaslabel = atlaslabel.get_x() except: pass try: yatlaslabel = atlaslabel.get_y() except: pass try: coloratlaslabel = atlaslabel.get_color() except: pass try: AtlasUtils.ATLAS_LABEL(xatlaslabel,yatlaslabel) except: pass try: mytext = plot.get_mytext() for mt in mytext: AtlasUtils.myText(mt.get_x(),mt.get_y(),mt.get_color(),mt.get_label()) except: pass #c1.SetGrid(1,1) c1.SetTicks(1) leg.SetBorderSize(0) leg.SetTextSize(0.04) leg.Draw() #leg.SetFillColor(10) save_pic = saveFile + '.png' print "Results will be saved in:\n\t",save_pic c1.SaveAs(save_pic) save_pic = saveFile + '.pdf' print "Results will be saved in:\n\t",save_pic, c1.SaveAs(save_pic) save_pic = saveFile + '.C' print "Results will be saved in:\n\t",save_pic, c1.SaveAs(save_pic) mgr.DrawClone() leg.DrawClone() return c1
"alljet" : files['alljet'].eff_xe10_razor170_off_metcut, } ROOT.SetAtlasStyle() ROOT.gStyle.SetOptStat(0) canvas1 = ROOT.TCanvas("tenjet2d", "tenjet2d", 600, 600) canvas1.SetRightMargin(0.13); onlineMDR_vs_offlineMDR["tenjet"].Draw("colz") onlineMDR_vs_offlineMDR["tenjet"].SetTitle("") onlineMDR_vs_offlineMDR["tenjet"].GetYaxis().SetTitleOffset(1.4) onlineMDR_vs_offlineMDR["tenjet"].GetXaxis().SetTitle("Offline M_{#Delta}^{R} (GeV)") onlineMDR_vs_offlineMDR["tenjet"].GetYaxis().SetTitle("HLT M_{#Delta}^{R} (GeV) ") onlineMDR_vs_offlineMDR["tenjet"].Draw("colz") AtlasUtils.myText(.3,.85,ROOT.kBlack, "Ten Jets") AtlasUtils.ATLAS_LABELInternal(.3,.75, ROOT.kBlack) canvas1.SetGrid(1,1) canvas2 = ROOT.TCanvas("alljet2d", "alljet2d", 600, 600) canvas2.SetRightMargin(0.13); onlineMDR_vs_offlineMDR["alljet"].Draw("colz") onlineMDR_vs_offlineMDR["alljet"].SetTitle("") onlineMDR_vs_offlineMDR["alljet"].GetXaxis().SetTitle("Offline M_{#Delta}^{R} (GeV)") onlineMDR_vs_offlineMDR["alljet"].GetYaxis().SetTitleOffset(1.4) onlineMDR_vs_offlineMDR["alljet"].GetYaxis().SetTitle("HLT M_{#Delta}^{R} (GeV) ") onlineMDR_vs_offlineMDR["alljet"].Draw("colz") AtlasUtils.myText(.3,.85,ROOT.kBlack, "All Jets") AtlasUtils.ATLAS_LABELInternal(.3,.75, ROOT.kBlack) canvas2.SetGrid(1,1)