#!/usr/bin/python import sys,getopt,os; opts, args = getopt.getopt(sys.argv[1:],"hr:R:d:D:aA") Disk = "1" where = "volatile" for opt,arg in opts: if opt in ("-r","-R"): RunNumber = arg if opt in ("-d","-D"): Disk = arg if opt in ("-a","-A"): where = "active" print "RunNumber is ",RunNumber period = "RunPeriod-2017-01" #period = "RunPeriod-2016-02" #period = "RunPeriod-2015-03" #period = "RunPeriod-2014-10" #location = "/gluonraid"+Disk+"/rawdata/"+where+"/"+period+"/rawdata" #location = "/cache/halld/"+period+"/rawdata" #location = "/gluonraid3/data3/rawdata/volatile/RunPeriod-2017-01/rawdata/" #location = "/gluonraid2/rawdata/volatile/RunPeriod-2017-01/rawdata" location = "/cache/halld/"+period+"/recon/ver01/REST" RunDir = RunNumber.zfill(6) loc = location+"/"+RunDir R = int(RunNumber) files = [] for k in range(0,1): RunDir = (str(R+k)).zfill(6) #loc = location+"/Run"+RunDir for f in os.listdir(loc): if f.endswith(".hddm"): print f files.append(loc+'/'+f) files.sort() scriptlines = [] scriptlines.append("#!/bin/csh") scriptlines.append("cd localdir") mdir = "mkdir run"+RunNumber scriptlines.append(mdir) godir = "cd run"+RunNumber scriptlines.append(godir) # make sure: setenv JANA_CALIB_CONTEXT "variation=beni" theline = "hd_ana --nthreads=6 -PPLUGINS=pi0,monitoring_hists -PTHREAD_TIMEOUT=100 -PJANA:MAX_RELAUNCH_THREADS=10 -PEVENTS_TO_KEEP=10000" max = len(files) if max>1: max = 1 for k in range(0,max): theline += (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 print print cmd print os.system(cmd)