import argparse import sys,os,glob import math, time pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/mberger') from functions import thisIsTheEnd, set_palette parser=argparse.ArgumentParser(description="get driftvel from david from config files and plot. also try to get driftvel from garfield") parser.add_argument('path',help='the path to the config files',type=str,nargs="+") parser.add_argument("--parfiles",help='the tpc.files file (default=%(default)s)',type=str,default="tpc/parfiles/tpc.files.par") #parser.add_argument args=parser.parse_args() import ROOT ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') ROOT.gROOT.LoadMacro("stlPYROOT.h+") set_palette("palette",99) filelist=[] for path in args.path: filelist+=glob.glob(path+"/tpc.run*") collection=[] for fname in filelist: found=False tmpset={} #print fname for line in open(fname,'r'): #print line if line[0]=="#": continue line=line.split("#")[0] #print line if line.find("TpcGasFile")!=-1: tmpset['gasfnum']=int(line.split()[-1]) if line.find("EField")!=-1: tmpset['field']=float(line.split()[-1]) if line.find("ManDriftVel")!=-1: try: tmpset['vd meas']=float(line.split()[-1]) found=True if tmpset['vd meas']==0: found=False except ValueError: found=False if found: collection.append(tmpset) tpcFiles=[ line.strip() for line in open(args.parfiles,"r") ] for coll in collection: coll['gasf']=tpcFiles[coll['gasfnum']] gvdMeas=ROOT.TGraph() gvdTheo=ROOT.TGraph() for i in range(len(collection)): gvdMeas.SetPoint(gvdMeas.GetN(),collection[i]['field'],collection[i]['vd meas']) gas=ROOT.TpcGas(collection[i]['gasf'],collection[i]['field']) gvdTheo.SetPoint(gvdTheo.GetN(),collection[i]['field'],gas.VDrift()) canv=ROOT.TCanvas() canv.SetLeftMargin(0.15) gvdMeas.SetMarkerStyle(20) gvdMeas.SetMarkerColor(ROOT.kGreen) gvdTheo.SetMarkerStyle(20) gvdTheo.SetMarkerColor(ROOT.kPink) gvdMeas.Draw("AP") gvdMeas.GetXaxis().SetTitle("Drift field (V/cm)") gvdMeas.GetYaxis().SetTitle('Drift velocity (cm/ns)') gvdMeas.GetYaxis().SetTitleOffset(1.6) gvdTheo.Draw("P") leg=ROOT.TLegend(0.2,0.7,0.5,0.89) leg.AddEntry(gvdMeas,"Measured","p") leg.AddEntry(gvdTheo,"Theoretical","p") leg.SetFillColor(4000) leg.SetLineWidth(0) leg.SetBorderSize(0) leg.Draw("same") thisIsTheEnd()