import ROOT,glob,math,argparse,sys sys.path.append('$PANDAPATH/macro/tpc/FOPI/mberger') from anaFile import anaFile from functions import * def drawPull(hists,name,same=False,legok=False): print "doing canvas:",name maximum=[] minimum=[] if same: canv.append(ROOT.TCanvas("c"+name.replace(" ","_"),name,700,1000)) canv[-1].Divide(1,3) else: canv.append(ROOT.TCanvas("c"+name.replace(" ","_"),name)) canv[-1].Divide(3,3) ccounter=0 fcounter=-1 #find min and max for f in hists: fcounter+=1 hcounter=-1 for h in f: hcounter+=1 if fcounter==0: maximum.append(-99999) minimum.append( 99999) maximum[hcounter]=max(maximum[hcounter],h.GetBinContent(h.GetMaximumBin())) minimum[hcounter]=min(minimum[hcounter],h.GetBinContent(h.GetMinimumBin())) fcounter=-1 colcounter=-1 for f in hists: fcounter+=1 colcounter+=1 f.sort() if same: ccounter=0 hcounter=-1 for h in f: ccounter+=1 hcounter+=1 canv[-1].cd(ccounter) h.SetTitle(h.GetName()) if args.titles!=None: h.SetTitle(h.GetName()+" "+args.titles[fcounter]) if type(h)==ROOT.TH2D: h.Draw("colz") else: h.SetStats(0) h.GetYaxis().SetTitle("Pull Value") h.GetYaxis().SetTitleSize(.05) h.GetXaxis().SetTitle("Z-pos (cm)") h.GetXaxis().SetTitleSize(.05) h.GetYaxis().SetRangeUser(minimum[hcounter]*0.8,maximum[hcounter]*1.2) print "setting plot range to:",minimum[hcounter],maximum[hcounter],hcounter if same and colcounter>0: if colcounter+1==10 or colcounter+1==5: colcounter+=1 h.SetLineColor(colcounter+1) h.Draw("same") else: h.Draw() if same and args.titles!=None and ccounter==1 and legok: leg.AddEntry(h,args.titles[fcounter],"L") # if same: # leg.Draw() canv[-1].Update() return def drawPullGraph(hist,graph,canv): canv.Divide(3,3) i=0 for h in hist: i+=1 canv.cd(i) h.Draw('colz') for i in range(len(graph)): canv.cd(i+4) graph[i]['Mean'].Draw('AP') canv.cd(i+7) if graph[i].get('Sigma',None)!=None: graph[i]['Sigma'].Draw('AP') elif graph[i].get('RMS',None)!=None: graph[i]['RMS'].Draw('AP') def drawGraphMulti(graphs,canv): opt='AP' counter=-1 for gset in graphs: counter+=1 canv.cd(1+counter) gset['Mean'].Draw(opt) canv.cd(4+counter) if gset.get('Sigma',None)!=None: gset['Sigma'].Draw(opt) elif gset.get('RMS',None)!=None: gset['RMS'].Draw(opt) def drawGraphComp(canv,g_set,leg=None): mini=[{},{},{}] maxi=[{},{},{}] for i in range(len(rfiles)): for j in range(len(g_set[i])): for g in g_set[i][j]: #print i,j,g setGraph(g_set[i][j][g],g_set[i][j][g].GetTitle(),20,1,colors[i],'Z (cm)','Pull') x,y=ROOT.Double(0),ROOT.Double(0) for ip in range(g_set[i][j][g].GetN()): g_set[i][j][g].GetPoint(ip,x,y) # print 'j={0}, g={1}, y={2}'.format(j,g,y) mini[j][g]=min(mini[j].get(g,9999),float(y)) maxi[j][g]=max(maxi[j].get(g,0),float(y)) #print 'mini:',mini[j][g] #print 'maxi:',maxi[j][g] opt='AP' for i in range(len(rfiles)): if leg!=None: leg.AddEntry(g_set[i][0]['Mean'],args.titles[i],'p') for j in range(len(g_set[i])): canv.cd(j*2+1) if mini[j]['Mean']<0: mini[j]['Mean']*=1.1 else: mini[j]['Mean']*=0.9 if maxi[j]['Mean']>0: maxi[j]['Mean']*=1.1 else: maxi[j]['Mean']*=0.9 g_set[i][j]['Mean'].SetMinimum(mini[j]['Mean']) g_set[i][j]['Mean'].SetMaximum(maxi[j]['Mean']) g_set[i][j]['Mean'].Draw(opt) canv.cd(j*2+2) if g_set[i][j].get('Sigma',None)!=None: g_set[i][j]['Sigma'].SetMinimum(mini[j]['Sigma']*0.9) g_set[i][j]['Sigma'].SetMaximum(maxi[j]['Sigma']*1.1) g_set[i][j]['Sigma'].Draw(opt) elif g_set[i][j].get('RMS',None)!=None: g_set[i][j]['RMS'].SetMinimum(mini[j]['RMS']*0.9) g_set[i][j]['RMS'].SetMaximum(maxi[j]['RMS']*1.1) g_set[i][j]['RMS'].Draw(opt) opt='P' def getNameAdd(info,i): if info[i].get('generator','')=='data': if args.titles!=None: return args.titles[i] else: return str(i) else: if info[i].get('generator','')=='cyl': retname='theta {0}'.format(info[i]['angle']) if args.titles!=None and len(args.titles)>i: retname+=' {0}'.format(args.titles[i]) return retname return str(i) def fitprojection(glist,flist,graphP,tofit): gcounter=-1 #print glist #print for graph in glist: gcounter+=1 for j in range(3): flist.append(ROOT.TF1("fitfunc{0}".format(graph[j][tofit].GetName()),"pol1",25,60)) flist[-1].SetLineColor(graph[j][tofit].GetLineColor()) graph[j][tofit].Fit(flist[-1],"QRN+") print args.titles[gcounter],gcounter theta=float(args.titles[gcounter].split('_')[-1]) graphP[j][0].SetPoint(graphP[j][0].GetN(),theta,flist[-1].GetParameter(0)) graphP[j][0].SetPointError(graphP[j][0].GetN()-1,0,flist[-1].GetParError(0)) graphP[j][1].SetPoint(graphP[j][1].GetN(),theta,flist[-1].GetParameter(1)) graphP[j][1].SetPointError(graphP[j][1].GetN()-1,0,flist[-1].GetParError(1)) #return graphP parser=argparse.ArgumentParser(description="plot the residual vs z graph") parser.add_argument('anafiles',help='the list of ana files to process',type=str,nargs='+') parser.add_argument('--hlp',help='print help',action='store_true') parser.add_argument('--pdir',help='the picture print directory',type=str,default="not") parser.add_argument('--titles',help='the titles to plot in legend and canvas for the files',type=str,nargs='+',default=None) parser.add_argument('--list',help='use anafiles and titles listed in file',action='store_true') parser.add_argument('--redo',help='force recreation of graphs',action='store_true') parser.add_argument('--noMC',help='dont plot MC',action='store_true') parser.add_argument('--extra',help='some extra plots',action='store_true') parser.add_argument('--singles',help='plot every pull distribution',action='store_true') parser.add_argument('--compare',help='plot the comparison between distributions',action='store_true') args=parser.parse_args() ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') set_palette() colors=getColors2() if args.hlp: parser.print_help() exit(0) if args.list: infile=open(args.anafiles[0],'r') args.anafiles=[] args.titles=[] for line in infile: line=line.replace("\n","") if line=="\n": continue if line[0] == '#': continue words=line.split(';') print words args.anafiles.append(words[0]) args.titles.append(words[1]) hpulls=[] cluster_track_pulls=[] cluster_track_pulls_graph=[] cluster_track_pullsT=[] cluster_MC_pulls=[] cluster_MC_pulls_graph=[] cluster_errors=[] cluster_errors_graph=[] track_errors=[] track_MC_pulls=[] track_MC_res=[] track_MC_res_graph=[] track_MC_pullsA=[] track_MC_resA=[] track_MC_resA_graph=[] cluster_track_res=[] cluster_track_res_graph=[] cluster_MC_res=[] cluster_MC_res_graph=[] cluster_MC_pullsA=[] cluster_MC_pullsA_graph=[] cluster_MC_resA=[] cluster_MC_resA_graph=[] cluster_ErrA=[] cluster_ErrA_graph=[] cluster_MC_pullcovCut=[] cluster_MC_pullcovCut_graph=[] cluster_MC_covresErr=[] cluster_MC_covresErr_graph=[] cluster_resMagMC=[] cluster_resMag=[] cluster_pullsA=[] cluster_pullsA_graph=[] cluster_resA=[] cluster_resA_graph=[] cluster_pullsUV=[] cluster_pullsUV_graph=[] cluster_resUV=[] cluster_resUV_graph=[] cluster_MC_pullsUV=[] cluster_MC_pullsUV_graph=[] cluster_MC_resUV=[] cluster_MC_resUV_graph=[] track_MC_resUV=[] track_MC_resUV_graph=[] cluster_pullcovCut=[] cluster_pullcovCut_graph=[] cluster_covresErr=[] rfiles=[] fileinfos=[] canv=[] maximas={} minimas={} for ifile in range(len(args.anafiles)): print 'at file: ',args.anafiles[ifile] rfiles.append(anaFile(args.anafiles[ifile])) fileinfos.append(rfiles[-1].getInfos()) fitopt='t' if fileinfos[-1]['error']=='-1' or fileinfos[-1]['error'].find('stdErr')!=-1: fitopt='c' hpulls.append(rfiles[-1].getHistsByPattern("pull",'pulls')) cluster_track_pulls.append( rfiles[-1].getHistGroup("hpull_cl_","x;y;z","VSz")) cluster_track_pulls_graph.append(rfiles[-1].getSliceGraphGroup("hpull_cl_","x;y;z","VSz",0,0,args.redo,fitopt)) cluster_track_pullsT.append(rfiles[-1].getHistGroup("hpull_clt_","x;y;y","VSz")) cluster_errors.append(rfiles[-1].getHistGroup("herr_cl_err","X;Y;Z","vsZ")) cluster_errors_graph.append(rfiles[-1].getSliceGraphGroup("herr_cl_err","X;Y;Z","vsZ",1,0,args.redo)) cluster_track_res.append(rfiles[-1].getHistGroup("hClusterRes","X;Y;Z","vsZ")) cluster_track_res_graph.append(rfiles[-1].getSliceGraphGroup("hClusterRes","X;Y;Z","vsZ",0,0,args.redo,fitopt,2)) track_errors.append(rfiles[-1].getHistGroup("herr_tr_err","X;Y;Z","vsZ")) cluster_ErrA.append(rfiles[-1].getHistGroup('herr_cl_errA','0;1;2','vsZ')) cluster_ErrA_graph.append(rfiles[-1].getSliceGraphGroup('herr_cl_errA','0;1;2','vsZ',1,0,args.redo)) cluster_resMag.append(rfiles[-1].getHist('hResMagVsZ')) cluster_pullsA.append(rfiles[-1].getHistGroup('hpull_cl_a','0;1;2','VSz')) cluster_pullsA_graph.append(rfiles[-1].getSliceGraphGroup('hpull_cl_a','0;1;2','VSz',0,0,args.redo,fitopt,2)) cluster_resA.append(rfiles[-1].getHistGroup('hClusterResA','0;1;2','vsZ')) cluster_resA_graph.append(rfiles[-1].getSliceGraphGroup('hClusterResA','0;1;2','vsZ',0,0,args.redo,fitopt)) cluster_pullcovCut.append(rfiles[-1].getHist('hpull_covCutPull')) cluster_pullcovCut_graph.append(rfiles[-1].getSliceGraph('hpull_covCutPull',0,1,args.redo)) cluster_covresErr.append(rfiles[-1].getHist('herr_covResCut')) cluster_pullsUV.append(rfiles[-1].getHistGroup('hpull_cl_','u;v','Vsz')) cluster_pullsUV_graph.append(rfiles[-1].getSliceGraphGroup('hpull_cl_','u;v','Vsz',0,0,args.redo,fitopt)) cluster_resUV.append(rfiles[-1].getHistGroup('hClusterRes','U;V','vsZ')) cluster_resUV_graph.append(rfiles[-1].getSliceGraphGroup('hClusterRes','U;V','vsZ',0,0,args.redo,fitopt)) if not args.noMC: cluster_MC_pullsUV.append(rfiles[-1].getHistGroup('hpull_clMC_','u;v','Vsz')) cluster_MC_pullsUV_graph.append(rfiles[-1].getSliceGraphGroup('hpull_clMC_','u;v','Vsz',0,0,args.redo,fitopt)) cluster_MC_resUV.append(rfiles[-1].getHistGroup('hClusterMCRes','U;V','vsZ')) cluster_MC_resUV_graph.append(rfiles[-1].getSliceGraphGroup('hClusterMCRes','U;V','vsZ',0,0,args.redo,fitopt)) track_MC_resUV.append(rfiles[-1].getHistGroup('hTrackMCRes','U;V','vsZ')) track_MC_resUV_graph.append(rfiles[-1].getSliceGraphGroup('hTrackMCRes','U;V','vsZ',0,0,args.redo,fitopt)) cluster_resMagMC.append(rfiles[-1].getHist('hResMagVsZMC')) cluster_MC_pullcovCut.append(rfiles[-1].getHist('hpull_covCutPullMC')) cluster_MC_pullcovCut_graph.append(rfiles[-1].getSliceGraph('hpull_covCutPullMC',0,1,args.redo)) cluster_MC_covresErr.append(rfiles[-1].getHist('herr_covResCutMC')) cluster_MC_res.append(rfiles[-1].getHistGroup('hClusterMCRes','X;Y;Z','vsZ')) cluster_MC_res_graph.append(rfiles[-1].getSliceGraphGroup('hClusterMCRes','X;Y;Z','vsZ',0,0,args.redo,fitopt)) cluster_MC_pullsA.append(rfiles[-1].getHistGroup('hpull_clMC_a','0;1;2','VSz')) cluster_MC_pullsA_graph.append(rfiles[-1].getSliceGraphGroup('hpull_clMC_a','0;1;2','VSz',0,0,args.redo,fitopt)) cluster_MC_resA.append(rfiles[-1].getHistGroup('hClusterMCResA','0;1;2','vsZ')) cluster_MC_resA_graph.append(rfiles[-1].getSliceGraphGroup('hClusterMCResA','0;1;2','vsZ',0,0,args.redo,fitopt)) track_MC_pulls.append(rfiles[-1].getHistGroup("hpull_trp_","x;y;z","VSz")) cluster_MC_pulls.append(rfiles[-1].getHistGroup("hpull_clMC_","x;y;z","VSz")) cluster_MC_pulls_graph.append(rfiles[-1].getSliceGraphGroup("hpull_clMC_","x;y;z","VSz",0,0,args.redo,fitopt)) track_MC_res.append(rfiles[-1].getHistGroup("hTrackMCRes","X;Y;Z","vsZ")) track_MC_res_graph.append(rfiles[-1].getSliceGraphGroup("hTrackMCRes","X;Y;Z","vsZ",0,0,args.redo,fitopt)) track_MC_resA.append(rfiles[-1].getHistGroup("hTrackMCResA","0;1;2","vsZ")) track_MC_resA_graph.append(rfiles[-1].getSliceGraphGroup("hTrackMCResA","0;1;2","vsZ",0,0,args.redo,fitopt)) hpulls[-1].sort() hcounter=-1 leg=ROOT.TLegend(0,0,1,1) leg.SetFillColor(0) leg.SetTextSize(0.1) u=raw_input("start plotting?") if args.singles: if not args.noMC: c_cluster_MC_pulls=[] for i in range(len(rfiles)): c_cluster_MC_pulls.append(ROOT.TCanvas('c_cluster_MC_pulls'+str(i),'cluster pulls A '+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_MC_pullsA[i],cluster_MC_pullsA_graph[i],c_cluster_MC_pulls[i]) c_cluster_MC_pulls[i].Update() c_cluster_MC_resA=[] for i in range(len(rfiles)): c_cluster_MC_resA.append(ROOT.TCanvas('c_cluster_MC_resA'+str(i),'Cluster MC Residuals A '+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_MC_resA[i],cluster_MC_resA_graph[i],c_cluster_MC_resA[i]) c_cluster_MC_resA[i].Update() c_track_MC_res=[] for i in range(len(rfiles)): c_track_MC_res.append(ROOT.TCanvas('c_track_MC_res'+str(i),'Track MC Residuals '+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(track_MC_res[i],track_MC_res_graph[i],c_track_MC_res[i]) c_track_MC_res[i].Update() c_track_MC_resA=[] for i in range(len(rfiles)): c_track_MC_resA.append(ROOT.TCanvas('c_track_MC_resA'+str(i),'Track MC Residuals A '+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(track_MC_resA[i],track_MC_resA_graph[i],c_track_MC_resA[i]) c_track_MC_resA[i].Update() c_cluster_MC_pullsUV=[] for i in range(len(rfiles)): c_cluster_MC_pullsUV.append(ROOT.TCanvas('c_cluster_MC_pullsUV'+str(i),'cluster pulls MC UV'+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_MC_pullsUV[i],cluster_MC_pullsUV_graph[i],c_cluster_MC_pullsUV[i]) c_cluster_MC_pullsUV[i].Update() c_cluster_MC_resUV=[] for i in range(len(rfiles)): c_cluster_MC_resUV.append(ROOT.TCanvas('c_cluster_MC_resUV'+str(i),'cluster Residuals MC UV'+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_MC_resUV[i],cluster_MC_resUV_graph[i],c_cluster_MC_resUV[i]) c_cluster_MC_resUV[i].Update() c_track_MC_resUV=[] for i in range(len(rfiles)): c_track_MC_resUV.append(ROOT.TCanvas('c_track_MC_resUV'+str(i),'track Residuals MC UV'+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(track_MC_resUV[i],track_MC_resUV_graph[i],c_track_MC_resUV[i]) c_track_MC_resUV[i].Update() c_cluster_pullsXYZ=[] for i in range(len(rfiles)): c_cluster_pullsXYZ.append(ROOT.TCanvas('c_cluster_pullsXYZ'+str(i),'cluster pulls xyz '+getNameAdd(fileinfos, i),1200,1000)) drawPullGraph(cluster_track_pulls[i],cluster_track_pulls_graph[i],c_cluster_pullsXYZ[i]) c_cluster_pullsXYZ[i].Update() c_cluster_track_res=[] for i in range(len(rfiles)): c_cluster_track_res.append(ROOT.TCanvas('c_cluster_resXYZ'+str(i),'cluster res xyz '+getNameAdd(fileinfos, i),1200,1000)) drawPullGraph(cluster_track_res[i],cluster_track_res_graph[i],c_cluster_track_res[i]) c_cluster_track_res[i].Update() c_cluster_errXYZ=[] for i in range(len(rfiles)): c_cluster_errXYZ.append(ROOT.TCanvas('c_cluster_errXYZ'+str(i),'cluster errors XYZ '+getNameAdd(fileinfos, i),1200,1000)) drawPullGraph(cluster_errors[i],cluster_errors_graph[i],c_cluster_errXYZ[i]) c_cluster_errXYZ[i].Update() c_cluster_pullsA=[] for i in range(len(rfiles)): c_cluster_pullsA.append(ROOT.TCanvas('c_cluster_pulls'+str(i),'cluster pulls A '+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_pullsA[i],cluster_pullsA_graph[i],c_cluster_pullsA[i]) c_cluster_pullsA[i].Update() c_cluster_resA=[] for i in range(len(rfiles)): c_cluster_resA.append(ROOT.TCanvas('c_cluster_resA'+str(i),'Cluster Residuals A '+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_resA[i],cluster_resA_graph[i],c_cluster_resA[i]) c_cluster_resA[i].Update() c_cluster_ErrA=[] for i in range(len(rfiles)): c_cluster_ErrA.append(ROOT.TCanvas('c_cluster_ErrA'+str(i),'Cluster Error A '+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_ErrA[i],cluster_ErrA_graph[i],c_cluster_ErrA[i]) c_cluster_ErrA[i].Update() c_cluster_pullsUV=[] for i in range(len(rfiles)): c_cluster_pullsUV.append(ROOT.TCanvas('c_cluster_pullsUV'+str(i),'cluster pulls UV'+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_pullsUV[i],cluster_pullsUV_graph[i],c_cluster_pullsUV[i]) c_cluster_pullsUV[i].Update() c_cluster_resUV=[] for i in range(len(rfiles)): c_cluster_resUV.append(ROOT.TCanvas('c_cluster_resUV'+str(i),'cluster Residuals UV'+getNameAdd(fileinfos,i),1200,1000)) drawPullGraph(cluster_resUV[i],cluster_resUV_graph[i],c_cluster_resUV[i]) c_cluster_resUV[i].Update() if not args.noMC: c_covCut_MC=[] for i in range(len(rfiles)): c_covCut_MC.append(ROOT.TCanvas('c_covCut_MC'+str(i),'Cluster Cov Cut A '+getNameAdd(fileinfos,i),1200,1000)) c_covCut_MC[i].Divide(3,3) c_covCut_MC[i].cd(1) cluster_MC_covresErr[i].Draw('colz') c_covCut_MC[i].cd(2) cluster_resMagMC[i].Draw('colz') c_covCut_MC[i].cd(3) cluster_MC_pullcovCut[i].Draw('colz') c_covCut_MC[i].cd(6) cluster_MC_pullcovCut_graph[i]['Mean'].Draw('AP') c_covCut_MC[i].cd(9) cluster_MC_pullcovCut_graph[i]['Sigma'].Draw('AP') c_covCut_MC[i].Update() c_covCut=[] for i in range(len(rfiles)): c_covCut.append(ROOT.TCanvas('c_covCut'+str(i),'Cluster Cov Cut A '+getNameAdd(fileinfos,i),1200,1000)) c_covCut[i].Divide(3,3) c_covCut[i].cd(1) cluster_covresErr[i].Draw('colz') c_covCut[i].cd(2) cluster_resMag[i].Draw('colz') c_covCut[i].cd(3) cluster_pullcovCut[i].Draw('colz') c_covCut[i].cd(6) cluster_pullcovCut_graph[i]['Mean'].Draw('AP') c_covCut[i].cd(9) cluster_pullcovCut_graph[i]['Sigma'].Draw('AP') c_covCut[i].Update() if args.compare: c_cluster_pullsA_comp=ROOT.TCanvas("c_cluster_pullsA_comp",'All cluster pulls A',1000,1000) c_cluster_pullsA_comp.Divide(2,3) drawGraphComp(c_cluster_pullsA_comp,cluster_pullsA_graph,leg) c_cluster_pullsA_comp.Update() c_cluster_pullsA_fit=ROOT.TCanvas("c_cluster_pullsA_fit","linear pull fit",1000,1000) c_cluster_pullsA_fit.Divide(2,3) fitgraph_cluster_pullsA=[] for j in range(3): fitgraph_cluster_pullsA.append([ROOT.TGraphErrors(),ROOT.TGraphErrors()]) fits_cluster_pullsA=[] fitprojection(cluster_pullsA_graph, fits_cluster_pullsA, fitgraph_cluster_pullsA,'Sigma') for j in range(3): c_cluster_pullsA_fit.cd(2*j+1) fitgraph_cluster_pullsA[j][0].Draw('AP') c_cluster_pullsA_fit.cd(2*j+2) fitgraph_cluster_pullsA[j][1].Draw('AP') c_cluster_resA_comp=ROOT.TCanvas("c_cluster_resA_comp",'All cluster residuals A',1000,1000) c_cluster_resA_comp.Divide(2,3) drawGraphComp(c_cluster_resA_comp,cluster_resA_graph) c_cluster_resA_comp.Update() c_cluster_ErrA_comp=ROOT.TCanvas("c_cluster_errA_comp","All cluster errors A",1000,1000) c_cluster_ErrA_comp.Divide(2,3) drawGraphComp(c_cluster_ErrA_comp,cluster_ErrA_graph) c_cluster_ErrA_comp.Update() c_cluster_pullsUV_comp=ROOT.TCanvas("c_cluster_pullUV_comp","All cluster pulls UV",1000,1000) c_cluster_pullsUV_comp.Divide(2,3) drawGraphComp(c_cluster_pullsUV_comp, cluster_pullsUV_graph) c_cluster_pullsUV_comp.Update() c_cluster_resUV_comp=ROOT.TCanvas("c_cluster_resUV_comp","All cluster residuals UV",1000,1000) c_cluster_resUV_comp.Divide(2,3) drawGraphComp(c_cluster_resUV_comp, cluster_resUV_graph) c_cluster_resUV_comp.Update() c_cluster_pulls_comp=ROOT.TCanvas("c_cluster_pulls_comp",'All cluster pulls',1000,1000) c_cluster_pulls_comp.Divide(2,3) drawGraphComp(c_cluster_pulls_comp,cluster_track_pulls_graph) c_cluster_pulls_comp.Update() c_cluster_res_comp=ROOT.TCanvas("c_cluster_res_comp",'All cluster residuals',1000,1000) c_cluster_res_comp.Divide(2,3) drawGraphComp(c_cluster_res_comp,cluster_track_res_graph) c_cluster_res_comp.Update() if not args.noMC: c_cluster_pullsUV_MC_comp=ROOT.TCanvas("c_cluster_pullUV_MC_comp","All cluster pulls MC UV",1000,1000) c_cluster_pullsUV_MC_comp.Divide(2,3) drawGraphComp(c_cluster_pullsUV_MC_comp, cluster_MC_pullsUV_graph) c_cluster_pullsUV_MC_comp.Update() c_cluster_resUV_MC_comp=ROOT.TCanvas("c_cluster_resUV_MC_comp","All cluster res MC UV",1000,1000) c_cluster_resUV_MC_comp.Divide(2,3) drawGraphComp(c_cluster_resUV_MC_comp, cluster_MC_resUV_graph) c_cluster_resUV_MC_comp.Update() c_track_resUV_MC_comp=ROOT.TCanvas("c_track_pullUV_MC_comp","All track res MC UV",1000,1000) c_track_resUV_MC_comp.Divide(2,3) drawGraphComp(c_track_resUV_MC_comp, track_MC_resUV_graph) c_track_resUV_MC_comp.Update() c_cluster_res_MC_comp=ROOT.TCanvas("c_cluster_res_MC_comp","All cluster MC residuals",1000,1000) c_cluster_res_MC_comp.Divide(2,3) drawGraphComp(c_cluster_res_MC_comp,cluster_MC_res_graph) c_cluster_res_MC_comp.Update() c_track_res_MC_comp=ROOT.TCanvas("c_track_res_MC_comp","All track MC residuals",1000,1000) c_track_res_MC_comp.Divide(2,3) drawGraphComp(c_track_res_MC_comp,track_MC_res_graph) c_track_res_MC_comp.Update() c_track_resA_MC_comp=ROOT.TCanvas("c_track_resA_MC_comp","All track MC residuals A",1000,1000) c_track_resA_MC_comp.Divide(2,3) drawGraphComp(c_track_resA_MC_comp,track_MC_resA_graph) c_track_resA_MC_comp.Update() c_cluster_MC_resA_comp=ROOT.TCanvas("c_cluster_MC_resA_comp",'All cluster MC residuals A',1000,1000) c_cluster_MC_resA_comp.Divide(2,3) drawGraphComp(c_cluster_MC_resA_comp,cluster_MC_resA_graph) c_cluster_MC_resA_comp.Update() #leg=ROOT.TLegend(0.7,0.75,0.9,0.9) if args.extra: excanv1=ROOT.TCanvas('extra','extra',500,1000) excanv1.Divide(1,3) for h in cluster_pullsA[0]: h.GetXaxis().SetTitle("Z (cm)") #h.GetXaxis().SetTitleOffset(1.2) h.GetYaxis().SetTitle("pull") h.SetTitle('') h.SetStats(0) excanv1.cd(1) cluster_pullsA[0][1].Draw('colz') excanv1.cd(2) g=cluster_pullsA_graph[0][1]['Mean'] g.GetXaxis().SetTitle('Z (cm)') g.GetXaxis().SetRangeUser(0,75) #g.GetXaxis().SetTitleOffset(1.2) g.GetYaxis().SetTitle('Mean position') g.SetMarkerStyle(20) g.SetTitle('') g.Draw('AP') excanv1.cd(3) g=cluster_pullsA_graph[0][1]['Sigma'] g.GetXaxis().SetTitle('Z (cm)') g.GetXaxis().SetRangeUser(0,75) #g.GetXaxis().SetTitleOffset(1.2) g.GetYaxis().SetTitle('Width') g.SetMarkerStyle(20) g.SetTitle('') g.Draw('AP') u=raw_input('next') excanv1.cd(1) cluster_pullsA[0][2].Draw('colz') excanv1.cd(2) g=cluster_pullsA_graph[0][2]['Mean'] g.GetXaxis().SetTitle('Z (cm)') g.GetXaxis().SetRangeUser(0,75) #g.GetXaxis().SetTitleOffset(1.2) g.GetYaxis().SetTitle('Mean position') g.SetTitle('') g.SetMarkerStyle(20) g.Draw('AP') excanv1.cd(3) g=cluster_pullsA_graph[0][2]['Sigma'] g.GetXaxis().SetTitle('Z (cm)') g.GetXaxis().SetRangeUser(0,75) #g.GetXaxis().SetTitleOffset(1.2) g.GetYaxis().SetTitle('Width') g.SetTitle('') g.SetMarkerStyle(20) g.Draw('AP') u=raw_input('next') excanv2=ROOT.TCanvas('extra2','extra2') cluster_pullsA_graph[0][1]['Sigma'].GetYaxis().SetRangeUser(0,1.6) cluster_pullsA_graph[0][1]['Sigma'].Draw('AP') cluster_pullsA_graph[0][2]['Sigma'].SetMarkerColor(2) cluster_pullsA_graph[0][2]['Sigma'].Draw('P') cleg=ROOT.TCanvas("legend","legend",200,1000) leg.Draw() if args.pdir!="not": for c in canv: ctitle=c.GetTitle() ctitle=ctitle.replace(" ","_") ctitle=ctitle.replace("(","") ctitle=ctitle.replace(")","") c.SaveAs(args.pdir+"/"+ctitle+".eps") u='' while u!='q': u=raw_input("Done?")