#!/usr/bin/python import os,sys ## __________ check usage __________ if len(sys.argv)!=3: print 'usage: ddstr_compare.py ddstr_file_from_alex_1 ddstr_file_from_alex_2' sys.exit(-1) fs = sys.argv[1:] ## __________ make TH2Ds __________ from ROOT import * # from clean_canvas import * # from nice_colours import * # gStyle = makegstyle(gStyle) # gStyle.SetOptTitle(0) # gStyle = nice_colours(gStyle) # ================ Display (Canvas, pads ...) =================== # # Canvas gStyle.SetCanvasColor ( 10 ) # Background color (white) # gStyle.SetCanvasDefH(500) # Default = 500 # gStyle.SetCanvasDefW(700) # Default = 700 # Output size gStyle.SetPaperSize ( 20., 24. ) # Default = 20.,26. # Pads gStyle.SetPadBorderMode ( 0 ) gStyle.SetPadColor ( 10 ) # Background color (white) gStyle.SetPadLeftMargin (0.14) gStyle.SetPadBottomMargin (0.12) gStyle.SetPadRightMargin (0.05) gStyle.SetPadTopMargin (0.05) # Miscellaneous gStyle.SetFillColor ( 10 ) # Background color (white) gStyle.SetFrameFillColor ( 10 ) # Background color (white) # ================ Fonts variable ================= # Font = 132 # Times roman FontSize = 0.05 # ================ Plots =================== # gStyle.SetOptTitle ( 1 ) # Display histogram titles. gStyle.SetOptTitle ( 0 ) # Display histogram titles. gStyle.SetMarkerStyle ( 5 ) # Cross gStyle.SetPalette ( 1 ) # Nicer colour scale for 2D histograms. gStyle.SetHistLineWidth ( 2 ) # ================ Stat Box =================== # # Display name of the histogram, entries, mean, RMS, underflow, overflow gStyle.SetOptStat ( 111111 ) # Good standard stats display. gStyle.SetOptStat ( 0 ) # Good standard stats display. gStyle.SetOptFit ( 1111 ) # Display fit info if available. gStyle.SetStatColor ( 10 ) # Background color (white) gStyle.SetStatX ( 0.95 ) # Statistic box X gStyle.SetStatY ( 0.9 ) # Statistic box Y gStyle.SetStatW ( 0.2 ) # Statistic box width # gStyle.SetStatH ( 0.2 ) # Statistic box height gStyle.SetStatBorderSize ( 1 ) gStyle.SetStatFont(Font) # No Stat box ! # gStyle.SetOptStat ( 0 ) # Good standard stats display. # gStyle.SetOptFit ( 0 ) # Display fit info if available. # ================ Title =================== # gStyle.SetTitleFillColor ( 10 ) # Background color (white) gStyle.SetTitleX ( 0.10 ) # Title box Y gStyle.SetTitleY ( 0.10 ) # Title box Y gStyle.SetTitleW ( 0.50 ) # Title box width gStyle.SetTitleH ( 0.09 ) # Title box height gStyle.SetTitleBorderSize ( 1 ) gStyle.SetTitleFont(Font) gStyle.SetTitleFont(Font, "X") gStyle.SetTitleFont(Font, "Y") gStyle.SetTitleFont(Font, "Z") gStyle.SetTitleFont(Font, "T") gStyle.SetTitleSize(FontSize ) gStyle.SetTitleSize(FontSize,"X") gStyle.SetTitleSize(FontSize,"Y") gStyle.SetTitleSize(FontSize,"Z") gStyle.SetTitleSize(FontSize,"T") # ================ Labels =================== # gStyle.SetLabelFont(Font) gStyle.SetLabelFont(Font, "X") gStyle.SetLabelFont(Font, "Y") gStyle.SetLabelFont(Font, "Z") gStyle.SetLabelFont(Font, "T") gStyle.SetLabelSize(FontSize) gStyle.SetLabelSize(FontSize,"X") gStyle.SetLabelSize(FontSize,"Y") gStyle.SetLabelSize(FontSize,"Z") gStyle.SetLabelSize(FontSize,"T") gStyle.SetNdivisions(505, "X") gStyle.SetNdivisions(505, "Y") gStyle.SetNdivisions(505, "Z") # =============== Text & Legends ================== # gStyle.SetTextFont(Font) gStyle.SetTextSize(FontSize) gStyle.SetTextSize(40) gStyle.SetLegendBorderSize ( 1 ) # ============================================= # # Do not display the canvas in a window, plot in a postscript gROOT.SetBatch(); # Needed to make sure that all the gStyle parameters are passed to the plots gROOT.ForceStyle() hs = [] for i,f in enumerate(fs): print 'reading in',f fi = file(f,'r') fil = fi.readlines() h = TH2D('f'+str(i),'f'+str(i), 401,-0.185,0.215, 401,-0.2,0.2) for ii,l in enumerate(fil): ls = l.split() if ls[1]!='-0.0': h.Fill(float(ls[0]),float(ls[1]),float(ls[2])) fi.close() hs.append(h) gStyle.SetPaperSize(10,15) ## __________ make contours __________ c = TCanvas('c1','c1',800,800) #### modified from http://root.cern.ch/root/roottalk/roottalk05/1010.html #n_contours = 30 #lowest_contour = 10. #highest_contour = 310. n_contours = 10 lowest_contour = 10. highest_contour = 260. for h in hs: h.SetContour(n_contours) for i in range(n_contours): c_level = lowest_contour+i*(highest_contour-lowest_contour)/n_contours print 'i=',i,'; counter_level=',c_level for h in hs: h.SetContourLevel(i,c_level) for h in hs: h.SetContourLevel(n_contours,1e6) hs[0].SetLineWidth(2) hs[1].SetLineWidth(2) ##hs[0].SetLineStyle(1) ##hs[1].SetLineStyle(7) ##hs[1].SetLineStyle(1) # c.SetLeftMargin(0.15) hs[0].Draw('cont1') hs[1].Draw('cont3 same') hs[0].SetTitle(';z (cm);u or v (cm)') hs[0].GetXaxis().SetDecimals() # hs[0].GetXaxis().SetTitle('z (cm)') hs[0].SetTitleOffset(1.2,'Y') # hs[0].GetXaxis().SetLabelSize(0.035) hs[0].GetYaxis().SetDecimals() # hs[0].GetYaxis().SetTitle('u or v (cm)') # hs[0].GetYaxis().SetTitleOffset(1.8) # hs[0].GetYaxis().SetLabelSize(0.035) e = TEllipse(0.,0.,0.003,0.003) e.SetFillColor(1) e.Draw() # wire_label = TPaveText(-0.0003,0,0.028,0.013,'br') # wire_label.AddText('wire') # wire_label.SetBorderSize(0) # wire_label.SetFillStyle(0) # wire_label.Draw() ##add legend Leg = TLegend(0.35, 0.88,0.90,0.98) Leg.AddEntry(hs[0], 'Data-driven STRs', 'l') Leg.Draw() # psleg = TPaveText(0.1,0.1,0.2,0.2,"br") # psleg.SetFillColor(10) # psleg.SetBorderSize(1) # psleg.Draw() # psleg_line = TLine(0.1,0.1,0.1,0.1) # psleg_line.SetLineWidth(3) # psleg_line.Draw() # psleg_label = TPaveText(0.1276298,0.1171875,0.2020017,0.1367188,"br") # psleg_label.SetBorderSize(0) # psleg_label.SetFillColor(10) # psleg_label.AddText("refined STRs") # psleg_label.Draw() # LowIso = TPaveText(0.3,0.3,0.3,0.3) # LowIso.SetBorderSize(0) # # LowIso.SetFillColor(10) # LowIso.AddText("10 ns") # LowIso.Draw() ##hs[0].Draw('surf') c.Update() c.Print("../../STR_Isochrons.eps") # au = raw_input('>')