import glob, sys, os, string, io, ROOT, math, commands pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/python/argparse-1.2.1') import argparse def getValues(str): vals=[] str=str.split() vals=str[1:len(str)] return vals def submit(ampstart,ampstop): print 'at offxy=',offxy,'offz=',offz,'diffXY=',diffXY,'diffZ=',diffZ os.environ['XYStart']=str(offxy) os.environ['XYStop']=str(offxy) os.environ['XYStep']=str(xyScan[2]) os.environ['ZStart']=str(offz) os.environ['ZStop']=str(offz) os.environ['ZStep']=str(zScan[2]) os.environ['DIFFXYStart']=str(diffXY) os.environ['DIFFXYStop']=str(diffXY) os.environ['DIFFXYStep']=str(diffScanXY[2]) os.environ['DIFFZStart']=str(diffZ) os.environ['DIFFZStop']=str(diffZ) os.environ['DIFFZStep']=str(diffScanZ[2]) os.environ['AMPStart']=str(ampstart) os.environ['AMPStop']=str(ampstop) os.environ['AMPStep']=str(ampScan[2]) os.environ['filename']='{0}/bat_parameterscan_{1:010d}.root'.format(args.outpath,offset+counter) os.environ['NTHREADS']='1' sbatch='sbatch -J batPar{0} --time=120 --mem-per-cpu=2000 -p farmq -o ~/sgeout/batPar{0} -e ~/sgeout/batPar{0} FOPI/BatchTools/submit_clusterErrorScan.sh'.format(offset+counter) print sbatch #os.system('./FOPI/BatchTools/submit_clusterErrorScan.sh') status,jobid=commands.getstatusoutput(sbatch) print status print jobid print 'submitted amp from {0} to {1}'.format(ampstart,ampstop) print parser=argparse.ArgumentParser(description='submit cluster error parameter scan') #parser.add_argument('infile',help='the recofile to read the evetns from',type=str) parser.add_argument('outpath',help='path to folder to store outfiles',type=str) parser.add_argument('--events',help='number of events to process',type=int,default=2500) parser.add_argument('--readDefect',help='read info from defect sgeout files',type=str,default='NONE') args=parser.parse_args() 2.92777 xyScan=[.1,.2,0.01] zScan=[0.15,.25,0.025] diffScanXY=[3.,6.,0.05] diffScanZ=[0.,0.,1] ampScan=[0.01,.2,0.01] nsteps=50 offset=len([item for item in os.listdir(args.outpath) if os.path.isfile(os.path.join(args.outpath,item))]) counter=0 istep=-1 if args.readDefect!='NONE': outfiles=glob.glob(args.readDefect+'/batPar*') for ifile in outfiles: good=False data = [line.strip() for line in open(ifile, 'r')] index=0 for d in data: if d.find('xy:')!=-1: break index+=1 xyScan=getValues(data[index]) zScan=getValues(data[index+1]) diffScanXY=getValues(data[index+2]) diffScanZ=getValues(data[index+3]) ampScan=getValues(data[index+4]) offxy=xyScan[0] offz=zScan[0] diffXY=diffScanXY[0] diffZ=diffScanZ[0] print xyScan print zScan print diffScanZ print ampScan submit(ampScan[0], ampScan[1]) counter+=1 print 'submitted',counter,'jobs' exit() offxy=xyScan[0] while offxy<=xyScan[1]: offz=zScan[0] while offz<=zScan[1]: diffXY=diffScanXY[0] while diffXY<=diffScanXY[1]: diffZ=diffScanZ[0] while diffZ<=diffScanZ[1]: amp=ampScan[0] lastamp=amp istep=-1 while amp<=ampScan[1]: istep+=1 if istep==nsteps: counter+=1 submit(lastamp,amp) lastamp=amp istep=-1 amp+=ampScan[2] if round(lastamp,4)!=round(ampScan[1],4): counter+=1 submit(lastamp,ampScan[1]) diffZ+=diffScanZ[2] diffXY+=diffScanXY[2] offz+=zScan[2] offxy+=xyScan[2] print 'submitted',counter,'jobs'