import sys,os pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/python/argparse-1.2.1') sys.path.append(pandapath+'/macro/tpc/FOPI/mberger') from functions import Divideh, set_palette import ROOT, argparse,math def setaxis(h): h.GetXaxis().SetTitleSize(0.05) h.GetXaxis().SetLabelSize(0.05) h.GetXaxis().SetTitle("Z (cm)") h.GetYaxis().SetTitleSize(0.05) h.GetYaxis().SetLabelSize(0.05) h.GetYaxis().SetTitleOffset(0.6) h.GetYaxis().SetTitle("R (cm)") h.GetZaxis().SetTitleSize(0.05) h.GetZaxis().SetLabelSize(0.05) h.GetZaxis().SetTitleOffset(0.6) h.GetZaxis().SetTitle("Deviation (cm)") return 0 def setRange(h,mini=0,maxi=0): for i in range(h.GetNbinsX()+1): for j in range(h.GetNbinsY()+1): if (maxi!=mini): cont=h.GetBinContent(i,j) if (cont>maxi): h.SetBinContent(i,j,maxi) if (cont=15: y+=ystep continue point=ROOT.TVector3(x,y,z) hxy.Fill(x,y) value=fdevMap.value(point) hxyxdev.Fill(x,y,value.X()) hxyydev.Fill(x,y,value.Y()) arrows.append(ROOT.TArrow()) absl=math.sqrt(value.X()**2+value.Y()**2) arrows[-1].SetX1(x) arrows[-1].SetY1(y) arrows[-1].SetX2(x+(value.X()))#/absl*xstep*2)) arrows[-1].SetY2(y+(value.Y()))#/absl*ystep*2)) arrows[-1].SetOption("|>") arrows[-1].SetArrowSize(0.005) arrows[-1].SetFillColor(1) rotval=value rotval.RotateZ(-point.Phi()) hxypdev.Fill(x,y,rotval.Y()) hxyrdev.Fill(x,y,rotval.X()) y+=ystep x+=xstep print "finished z-bin",z z+=1 if args.xdev: c2=ROOT.TCanvas("xdev",args.filename+"xdev",500,1000) c2.Divide(1,2) c2.cd(1) hxyxdevnorm=Divideh(hxyxdev,hxy,'hxyxdevnorm','xy projection of deviation x norm') hxyydevnorm=Divideh(hxyydev,hxy,'hxyydevnorm','xy projection of deviation y norm') hxyxdevnorm.SetStats(0) setRange(hxyxdevnorm,args.range[0],args.range[1]) hxyxdevnorm.Draw("colz") if args.arrows: for a in range(len(arrows)): if a%7==0: arrows[a].Draw() c2.cd(2) hxyydevnorm.SetStats(0) setRange(hxyydevnorm,args.range[0],args.range[1]) hxyydevnorm.Draw("colz") if args.phidev: c3=ROOT.TCanvas("rpdev",args.filename+"rpdev",500,1000) c3.Divide(1,2) c3.cd(1) hxypdevnorm=Divideh(hxypdev,hxy,'hxypdevnorm','xy projection of deviation phi norm') hxyrdevnorm=Divideh(hxyrdev,hxy,'hxyrdevnorm','xy projection of deviation rad norm') hxypdevnorm.SetStats(0) hxyrdevnorm.SetStats(0) setRange(hxyrdevnorm,args.range[0],args.range[1]) setRange(hxypdevnorm,args.range[0],args.range[1]) hxyrdevnorm.Draw("colz") c3.cd(2) hxypdevnorm.Draw("colz") if args.phidev or args.xdev: c4=ROOT.TCanvas("xy",args.filename+"xy",500,500) hxy.SetStats(0) hxy.Draw("colz") if args.pdir!='NO': c2.cd(1).SetRightMargin(0.15) hrdev.SetTitle("") hrdev.Draw("colz") if args.prelim: drawPrelim() c2.SaveAs(args.pdir+name[-1]+'_hrdev.eps') hpdev.SetTitle("") hpdev.Draw("colz") if args.prelim: drawPrelim() c2.SaveAs(args.pdir+name[-1]+'_hpdev.eps') hzdev.SetTitle("") hzdev.Draw("colz") if args.prelim: drawPrelim() c2.SaveAs(args.pdir+name[-1]+'_hzdev.eps') if args.rout!='': routfile=ROOT.TFile(args.rout,'recreate') hrdev.Write() hpdev.Write() hzdev.Write() if args.xdev: hxyxdev.Write() routfile.Close() #point=ROOT.TVector3(-10,-8,0) #value=fdevMap.value(point) #print "some vla:",value.X(),value.Y(),value.Z() if not args.batch: u='' while u!='q': u=raw_input("quit? (q)")