import ROOT,glob,math,argparse,sys, os from anaFile import anaFile from functions import * parser=argparse.ArgumentParser(description="plot the McResX vs z graph") parser.add_argument('path',help='path to the hisos',type=str) parser.add_argument('name',help='cause of distortion',type=str) parser.add_argument('value',help='value it starts',type=float) parser.add_argument('step',help='step it goes',type=float) 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) args=parser.parse_args() ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gStyle->SetPalette(1)') ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') if args.hlp: parser.print_help() exit(0) c1 = ROOT.TCanvas("c1", "reldiff1d", 700,1000) #c2 = ROOT.TCanvas("c2", "reldiff1d", 1000,700) c1.Divide(1,2) c3 = ROOT.TCanvas("c3", "reldiff1dP", 700,1000) #c4 = ROOT.TCanvas("c4", "reldiff1dP", 1000,700) c3.Divide(1,2) c5 = ROOT.TCanvas("c5", "reldiff1dR", 700,1000) #c6 = ROOT.TCanvas("c6", "reldiff1dR", 1000,700) c5.Divide(1,2) HistList = os.listdir(args.path) HistList.sort() print HistList mean=[] RMS=[] meanP=[] RMSP=[] meanR=[] RMSR=[] for his in range(len(HistList)-1): if HistList[his]==".svn": del(HistList[his]) hfile=args.path + HistList[his] print hfile try: infile = ROOT.TFile(hfile) except: print "No histos found" sys.exit(0) infile.cd() histo=infile.Get("reldiff1d") me = histo.GetMean() rms=histo.GetRMS() mean.append(me) RMS.append(rms) histoP=infile.Get("reldiff1dP") meP = histoP.GetMean() rmsP=histoP.GetRMS() meanP.append(meP) RMSP.append(rmsP) histoR=infile.Get("reldiff1dR") meR = histoR.GetMean() rmsR=histoR.GetRMS() meanR.append(meR) RMSR.append(rmsR) #x-Residuals Graph=ROOT.TGraph() Graph.SetMarkerColor(1) Graph.SetMarkerSize(1) Graph.SetMarkerStyle(20) GraphRMS=ROOT.TGraph() GraphRMS.SetMarkerColor(2) GraphRMS.SetMarkerSize(1) GraphRMS.SetMarkerStyle(20) bins=0 His=ROOT.TH1D("His", "force",30,2.5,5.5) count = args.value for me in range(len(mean)): Graph.SetPoint(bins, count, mean[me]) GraphRMS.SetPoint(bins, count, RMS[me]) if count == 0.0050 or count == 0.0055: count += 0.0005 else: count += args.step bins+=1 Graph.SetTitle(args.name) Graph.GetXaxis().SetTitle("force") Graph.GetYaxis().SetTitle("Mean") GraphRMS.SetTitle(args.name) GraphRMS.GetXaxis().SetTitle("force") GraphRMS.GetYaxis().SetTitle("RMS") c1.cd(1) Graph.Draw("AP") #c1.Update() c1.cd(2) GraphRMS.Draw("AP") c1.Update() #P-Residuals GraphP=ROOT.TGraph() GraphP.SetMarkerColor(1) GraphP.SetMarkerSize(1) GraphP.SetMarkerStyle(20) GraphRMSP=ROOT.TGraph() GraphRMSP.SetMarkerColor(2) GraphRMSP.SetMarkerSize(1) GraphRMSP.SetMarkerStyle(20) bins=0 countP=args.value for meP in range(len(meanP)): GraphP.SetPoint(bins, countP, meanP[meP]) GraphRMSP.SetPoint(bins, countP, RMS[meP]) if countP == 0.0050 or count == 0.0055: countP += 0.0005 else: countP += args.step #if countP >= 4.9: # countP += 0.5 #else: # countP += args.step bins+=1 GraphP.SetTitle(args.name + " P") GraphP.GetXaxis().SetTitle("force") GraphP.GetYaxis().SetTitle("MeanP") GraphRMSP.SetTitle(args.name + " P") GraphRMSP.GetXaxis().SetTitle("force") GraphRMSP.GetYaxis().SetTitle("RMSP") c3.cd(1) GraphP.Draw("AP") #c3.Update() c3.cd(2) GraphRMSP.Draw("AP") c3.Update() #R-Residuals GraphR=ROOT.TGraph() GraphR.SetMarkerColor(1) GraphR.SetMarkerSize(1) GraphR.SetMarkerStyle(20) GraphRMSR=ROOT.TGraph() GraphRMSR.SetMarkerColor(2) GraphRMSR.SetMarkerSize(1) GraphRMSR.SetMarkerStyle(20) bins=0 countR=args.value for meR in range(len(meanR)): GraphR.SetPoint(bins, countR, meanR[meR]) GraphRMSR.SetPoint(bins, countR, RMSR[meR]) if countR == 0.0050 or count == 0.0055: countR += 0.0005 else: countR += args.step #if countR >= 4.9: # countR += 0.5 #else: # countR += args.step bins+=1 GraphR.SetTitle(args.name + " R") GraphR.GetXaxis().SetTitle("force") GraphR.GetYaxis().SetTitle("MeanR") GraphRMSR.SetTitle(args.name + " R") GraphRMSR.GetXaxis().SetTitle("force") GraphRMSR.GetYaxis().SetTitle("RMSR") c5.cd(1) GraphR.Draw("AP") #c5.Update() c5.cd(2) GraphRMSR.Draw("AP") c5.Update() x = raw_input()