import ROOT,glob,math,argparse,sys sys.path.append('$PANDAPATH/macro/tpc/FOPI/vwalbre') from anaFile import anaFile from functions import * parser=argparse.ArgumentParser(description='Plot stuff along a track') parser.add_argument('anafiles',help='the list of ana files to process',type=str,nargs='+') parser.add_argument('--folder',help='if the recofile is in an outher folder then mc and digi, input: /folder', type=str, default="not") parser.add_argument('--ev',help='which event to go to',type=int) parser.add_argument('--pdir',help='the picture print directory',type=str,default="not") parser.add_argument('--name',help='name to save the picture',type=str,default="") parser.add_argument('--binwidth',help='width of bins',type=int,default=5) parser.add_argument('--titles',help='the titles to plot in legend and canvas for the files', type=str,nargs='+',default=None) args=parser.parse_args() if args.titles==None: args.titles=[] for i in range(len(args.anafiles)): args.titles.append("no title given") rfiles=[] chi=[] histos=[] graphs=[] color=0 for i in range(len(args.anafiles)): his=[] rfiles.append(anaFile(args.anafiles[i])) his.append(rfiles[-1].getHist('hpull_clMC_xVSz')) his.append(rfiles[-1].getHist("hpull_clMC_yVSz")) his.append(rfiles[-1].getHist("hpull_clMC_zVSz")) chi.append(rfiles[-1].getHist("hchi2cdf")) color+=1 #c1=ROOT.TCanvas("c1", "factor", 700, 1400) #c2=ROOT.TCanvas("c2", "factor", 700, 1400) #c1.Divide(1,3) #c2.Divide(1,3) RmsXvsZ=ROOT.TGraph() RmsYvsZ=ROOT.TGraph() RmsZvsZ=ROOT.TGraph() #his=[] gr=[RmsXvsZ,RmsYvsZ,RmsZvsZ] #graphs=[RmsXvsZ,RmsYvsZ,RmsZvsZ] name=["PullDisXvsZ","PullDisYvsZ","PullDisZvsZ"] counter=-63.0 points=0 while counter<12: for i in range(len(his)): his[i].GetXaxis().SetRangeUser(counter,counter+args.binwidth) gr[i].SetTitle("RMS"+str(name[i])) gr[i].SetMarkerStyle(20) gr[i].SetMarkerSize(1) gr[i].SetMarkerColor(color) xpoint=((counter)+(counter+args.binwidth))/2 gr[i].SetPoint(points,xpoint,his[i].GetRMS(2)) print points, "**", xpoint, "**", his[i].GetRMS(2) counter+=5 points+=1 histos.append(his) graphs.append(gr) legend_graphs=ROOT.TLegend(0.1,0.75,0.35,0.9) legend_chi=ROOT.TLegend(0.1,0.75,0.35,0.9) canvases1=[] canvases2=(ROOT.TCanvas()) canvases3=(ROOT.TCanvas()) for i in range(len(args.anafiles)): canvases1.append(ROOT.TCanvas()) for can in canvases1: can.Divide(1,3) canvases2.Divide(1,3) counter=1 for h in range(len(histos)): ROOT.gStyle.SetOptStat(1) canvases1[h].SetTitle(args.titles[h]) for j in histos[h]: j.GetXaxis().SetRangeUser(-70,20) canvases1[h].cd(counter) j.Draw("colz") counter+=1 counter=1 canvases1[h].Update() mg=[] for i in range(len(graphs[0])): mg.append(ROOT.TMultiGraph()) for h in range(len(graphs)): mg[0].Add(graphs[h][0]) mg[1].Add(graphs[h][1]) mg[2].Add(graphs[h][2]) legend_graphs.AddEntry(graphs[h][0], args.titles[h], "P") counter=1 canvases2.SetCanvasSize(700,1400) for m in mg: m.SetTitle("RMS") canvases2.SetTitle("RMS Y over Z") canvases2.cd(counter) m.Draw("AP") counter+=1 legend_graphs.Draw() canvases2.Update() color=1 for h in range(len(chi)): chi[h].SetLineColor(color) legend_chi.AddEntry(chi[h], args.titles[h], "L") color+=1 for h in range(len(chi)): ROOT.gStyle.SetOptStat(0) canvases3.SetTitle(args.titles[h]) chi[h].SetObjectStat(1) canvases3.cd() if h ==0: chi[h].Draw() else: chi[h].Draw("SAME") legend_chi.Draw() canvases3.Update() print args.titles if args.pdir!="not": c1.SaveAs(args.pdir+"PullDes2D_"+args.name+str(i)+".eps") c2.SaveAs(args.pdir+"RMS_"+args.name+str(i)+".eps") u = raw_input() if u == 'q': exit()