#!/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) 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) ## __________ 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) hs[0].GetXaxis().SetDecimals() hs[0].GetXaxis().SetTitle('z (cm)') hs[0].GetXaxis().SetTitleOffset(1.1) 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) c.SetLeftMargin(0.15) hs[0].Draw('cont1') hs[1].Draw('cont3 same') 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 psleg = TPaveText(0.09278894,0.1132813,0.2066918,0.139974,"br") psleg.SetFillColor(10) psleg.Draw() psleg_line = TLine(0.1028392,0.1263021,0.1215997,0.1263021) 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() ##hs[0].Draw('surf') au = raw_input('>')