#!/usr/bin/python from ROOT import * from math import * import os,sys from clean_canvas import * ##plots a (less) sexy bfield, of course bfld = '/home/e614/e614soft/caldb_ascii/bfld_map.00016' ##current nominal ##bfld = '/home/e614/e614soft/caldb_ascii/field_map.0007-barnes' ##to reproduce Fig 4.2 from Sanaz gauss_to_tesla = 1E-5 ##script only plots Bz vs z, so you must choose (x,y) ##xy_coords = [ (0,0), (15,0), (30,0) ] ##(x,y) integer pairs xy_coords = [ (0,0), (5,0), (10,0) ] ##(x,y) integer pairs f = file(bfld,'r') fl = f.readlines() points = [] for i in range(len(xy_coords)): points.append([]) for l in fl[9:]: ls = l.split() x,y,z,bx,by,bz = ls[0],ls[1],ls[2],ls[3],ls[4],ls[5] for i,xycuts in enumerate(xy_coords): x_cut, y_cut = xycuts ## print 'i=',i,'; x_cut=',x_cut,'; y_cut=',y_cut if int(float(x)) == x_cut and int(float(y)) == y_cut: points[i].append( (float(z),1E-4*sqrt(float(bx)*float(bx)+float(by)*float(by)) ) ) ##print 'points=',points gStyle = makegstyle(gStyle) c = TCanvas() c.cd() grs = [] for pnts in points: grs.append(TGraph()) for i,p in enumerate(pnts): grs[-1].SetPoint(i,p[0],p[1]) ###gr.Draw('AP') grs[0].Draw('APL') for gr in grs[1:]: ## gr.Draw('same') gr.Draw('PL') myLegend = TLegend(0.8,0.8,0.9,0.9) myLegend.SetBorderSize(1) for gr,coords in zip(grs,xy_coords): myLegend.AddEntry( gr, str(coords), 'l') myLegend.Draw() insert = TPad("insert","insert",0.2,0.2,0.9,0.9) insert.Draw() insert.cd() grs[0].Clone().Draw('APL') for gr in grs[1:]: gr.Clone().Draw('PL') au = raw_input('>')