import ROOT,math,argparse parser=argparse.ArgumentParser(description="plot the drift path of an electroon") parser.add_argument('filename',help='file wit the coordinates') parser.add_argument('--mean',help="plot the mean",action="store_true") args=parser.parse_args() dfile=open(args.filename,'r') zbin=0 rbin=0 x=0 y=0 z=0 xbins=106*20 zbins=723*10 hrz=ROOT.TH2D("hrz","rz position",xbins,17.249,17.251,zbins,5.048,5.056) hxy=ROOT.TH2D("hxy","xy position",xbins,5.0494,5.054,xbins,0,.0022) c=ROOT.TCanvas() c.Divide(1,2) counter=0 for line in dfile: words=line.split(";") if words[0]=='position': # hrz.Reset() # hxy.Reset() if args.mean: x=float(words[4])*100 y=float(words[5])*100 z=float(words[6])*100 hrz.Fill(z,math.sqrt(x*x+y*y),-1) hxy.Fill(x,y,-1) # else: x=float(words[1])*100 y=float(words[2])*100 z=float(words[3])*100 hrz.Fill(z,math.sqrt(x*x+y*y)) hxy.Fill(x,y) if line.find('rPos')!=-1: counter+=1 c.cd(1) # mean=hrz.GetMean(1) # hrz.GetXaxis().SetRangeUser(mean-mean*0.1,mean+mean*1.1) # mean=hrz.GetMean(2) # hrz.GetYaxis().SetRangeUser(mean-mean*0.1,mean+mean*1.1) hrz.Draw("col") c.cd(2) # mean=hxy.GetMean(1) # hxy.GetXaxis().SetRangeUser(mean-mean*0.1,mean+mean*1.1) # mean=hxy.GetMean(2) # hxy.GetYaxis().SetRangeUser(mean-mean*0.1,mean+mean*1.1) hxy.Draw("col") print "waiting for update" c.Update() u=raw_input("updated "+str(counter)) hrz.Reset() hxy.Reset() c.cd(1) hrz.Draw("col") c.cd(2) hxy.Draw("col") c.Update() u=raw_input()