babymaker  e95a6a9342d4604277fe7cc6149b6b5b24447d89
send_merge_glu_stop.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 ###### Script to send 40 jobs to the batch changing weights to the signal scan
4 import os, sys, subprocess
5 import pprint
6 import glob
7 import json
8 import string
9 import time
10 
11 # Setting folders
12 infolder = "/net/cms2/cms2r0/babymaker/babies/2016_02_09/mc/T5tttt/"
13 outfolder = "mergedGluStop/"
14 runfolder = outfolder+"run/"
15 if not os.path.exists(runfolder):
16  os.system("mkdir -p "+runfolder)
17 
18 #input datasets
19 inputfiles = [i for i in os.listdir(infolder) if "SMS" in i]
20 
21 os.system("JobSetup.csh")
22 njobs = 50
23 files_job = (len(inputfiles)+njobs-1)/njobs
24 ifile = 0
25 ijob = 0
26 for file in inputfiles:
27  ifile += 1
28  # Creating executable
29  if ifile % files_job == 1:
30  ijob += 1
31  exename = runfolder+"/merge_glu_stop_"+str(ijob)+".sh"
32  fexe = open(exename,"w")
33  os.system("chmod u+x "+exename)
34  fexe.write("#!/bin/bash\n\n")
35  fexe.write("./run/merge_glu_stop.exe "+infolder+'/'+file+' '+outfolder+' \n')
36  if ifile % files_job == 0 or ifile == len(inputfiles):
37  fexe.close()
38  cmd = "JobSubmit.csh ./run/wrapper.sh ./"+exename
39  #print cmd
40  os.system(cmd)
41  #sys.exit(0)
42 
43 print "\nSubmitted "+str(ifile)+" files in "+str(ijob)+" jobs. Output goes to "+outfolder+"\n"
44 sys.exit(0)