#!/usr/bin/python import sys,getopt,os; opts, args = getopt.getopt(sys.argv[1:],"r:R:l:L:") Disk = "1" loc1 = 'ver02' for opt,arg in opts: if opt in ("-r","-R"): RunNumber = arg if opt in ("-l","-L"): loc1 = arg #print "RunNumber is ",RunNumber #period = "RunPeriod-2016-02" #period = "RunPeriod-2015-03" #period = "RunPeriod-2014-10" #location = "/gluonraid"+Disk+"/rawdata/volatile/"+period+"/rawdata" location = '/cache/halld/RunPeriod-2017-01/calib/'+loc1+'/PS' RunDir = RunNumber.zfill(6) loc = location+"/Run"+RunDir print loc if not os.path.isdir(loc): sys.exit(0) dest = 'localdir/run'+RunNumber #if os.path.isdir(dest): # sys.exit(0) files = [] for f in os.listdir(loc): if f.endswith(".evio"): #print f files.append(f) files.sort() scriptlines = [] scriptlines.append("#!/bin/csh") #scriptlines.append("mkdir localdir") scriptlines.append("cd localdir") mdir = "mkdir run"+RunNumber scriptlines.append(mdir) godir = "cd run"+RunNumber scriptlines.append(godir) scriptlines.append("setenv JANA_CALIB_CONTEXT \"variation=beni\"\n") # theline = "hd_ana --nthreads=10 -PPLUGINS=TOF_calib -PTHREAD_TIMEOUT=500 -PEVIO:ENABLE_DISENTANGLING=0 -PJANA:MAX_RELAUNCH_THREADS=10 -PBFIELD_TYPE=NoField " theline = "hd_root --nthreads=24 -PPLUGINS=tagg -PTHREAD_TIMEOUT=500 -PEVIO:ENABLE_DISENTANGLING=0 -PJANA:MAX_RELAUNCH_THREADS=10 " #theline = "hd_ana --nthreads=10 -PPLUGINS=TOF_calib -PTHREAD_TIMEOUT=500 -PEVIO:ENABLE_DISENTANGLING=0 -PJANA:MAX_RELAUNCH_THREADS=10 -PBFIELD_MAP=Magnets/Solenoid/solenoid_1200A_poisson_20140520 " #theline = "hd_ana -PPLUGINS=cdc_basics -PJANA:MAX_RELAUNCH_THREADS=10 -PBFIELD_MAP=\'Magnets/Solenoid/solenoid_1000A_poisson_20141104\' " max = len(files) #if max>25: # max = 25 for k in range(0,max): theline += (loc+"/"+files[k]+" ") scriptlines.append(theline) scriptlines.append("") fnam2 = "j"+RunNumber+".csh" fscript = open(fnam2,'w') for k in range(0,len(scriptlines)): fscript.write(scriptlines[k]+"\n") fscript.close() os.system("chmod +x "+fnam2) cmd = "./"+fnam2 os.system(cmd)