import ROOT,argparse,sys,math,os pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/mberger/') sys.path.append(pandapath+'/macro/tpc/FOPI/') from functions import * from cosmic_histos import * from parseFiles import PyFileParser parser=argparse.ArgumentParser(description='plot track residual stuff from plot_reclcomp.py output') parser.add_argument('file',help='the input files',type=str,default=[],nargs='+') parser.add_argument('--svgpath',help='the path to save them as svg',type=str,default='none') parser.add_argument('--pdfpath',help='the path to save them as pdf',type=str,default='none') parser.add_argument('--mergepdf',help='create only one pdf file',action='store_true') args=parser.parse_args() ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') set_palette() rfiles=[] hists={} fcounter=-1 titles=[] for f in args.file: fcounter+=1 print 'doing',f rfiles.append(ROOT.TFile(f,'read')) tits=rfiles[-1].Get("Titles").GetTitle() tits=tits.split(';') titles=titles+tits for tit in tits: if tit=='': continue hists[tit]={} hists[tit]['theta']={} hists[tit]['phi']={} hists[tit]['mom']={} hists[tit]['theta']['first']=rfiles[-1].Get('dtheta {0}FirstPoint'.format(tit)) hists[tit]['phi']['first']=rfiles[-1].Get('dphi {0}FirstPoint'.format(tit)) hists[tit]['mom']['first']=rfiles[-1].Get('dmom {0}FirstPoint'.format(tit)) hists[tit]['theta']['first_pull']=rfiles[-1].Get('pullTheta_{0}FirstPoint'.format(tit)) hists[tit]['phi']['first_pull']=rfiles[-1].Get('pullPhi_{0}FirstPoint'.format(tit)) hists[tit]['mom']['first_pull']=rfiles[-1].Get('pullMom_{0}FirstPoint'.format(tit)) hists[tit]['phi']['first_resZ']=rfiles[-1].Get('resPhi_z_{0}FirstPoint'.format(tit)) hists[tit]['theta']['first_resZ']=rfiles[-1].Get('resTheta_z_{0}FirstPoint'.format(tit)) hists[tit]['mom']['first_resZ']=rfiles[-1].Get('resMom_z_{0}FirstPoint'.format(tit)) canvases=[] data={} for tit in hists: data[tit]={} for val in hists[tit]: data[tit][val]={} for pos in hists[tit][val]: h=hists[tit][val][pos] canvases.append(ROOT.TCanvas(h.GetName().replace(' ','_'),h.GetTitle())) if type(h)==ROOT.TH1D: h=h.Rebin(4) print tit,val,pos data[tit][val][pos]=fitres(h)#,False,0,[h.GetMaximum(),h.GetMean(),h.GetRMS()],[binlow,binhigh]) h.GetYaxis().UnZoom() h.Draw() drawresdata(data[tit][val][pos],"sigma mean chi/ndf S/B ngaus bgaus cgaus","#circ",3) drawGaussians(data[tit][val][pos]) else: h.Draw('colz') canvases[-1].Update() if args.pdfpath!='none': if args.mergepdf: canvases[0].SaveAs('{0}['.format(args.pdfpath)) for c in canvases: c.SaveAs('{0}'.format(args.pdfpath)) canvases[0].SaveAs('{0}]'.format(args.pdfpath)) else: for c in canvases: c.SaveAs('{0}/{1}.pdf'.format(args.pdfpath,c.GetName().replace(' ','_') )) u='w' while u!='q': u=raw_input('done?')