1 |
jueugste |
1.1 |
#! /usr/bin/python
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
# this is a python script to submit the analysis* as
|
6 |
|
|
# batch jobs on the tier-3
|
7 |
|
|
#
|
8 |
|
|
# * this means jobs in the jet met prompt analysis
|
9 |
|
|
# framework which I adapted to the ewk analysis
|
10 |
|
|
#
|
11 |
|
|
# the following variables should be changed/checked
|
12 |
|
|
# before job submission:
|
13 |
|
|
# - output
|
14 |
|
|
# - inputlist
|
15 |
|
|
# - ijobmax
|
16 |
|
|
|
17 |
|
|
import os
|
18 |
|
|
|
19 |
|
|
## setup the output dir and input files
|
20 |
jueugste |
1.2 |
output = "Data_Run2010A-PromptReco_JSON_140183-140399"
|
21 |
|
|
inputlist = "config/input_140183-140399.txt"
|
22 |
jueugste |
1.1 |
## the cut file (still needed...)
|
23 |
|
|
settingfile = "config/cutFileExample.txt"
|
24 |
|
|
## number of max jobs
|
25 |
jueugste |
1.2 |
ijobmax = 8
|
26 |
jueugste |
1.1 |
|
27 |
|
|
################################################
|
28 |
|
|
# to write on local disks
|
29 |
|
|
################################################
|
30 |
|
|
|
31 |
|
|
## name of the directory where the *.root file is stored
|
32 |
|
|
outputmain = output
|
33 |
|
|
## make some directories
|
34 |
|
|
os.system("mkdir "+output)
|
35 |
|
|
os.system("mkdir "+output+"/log/")
|
36 |
|
|
os.system("mkdir "+output+"/input/")
|
37 |
|
|
os.system("mkdir "+output+"/src/")
|
38 |
|
|
outputroot = outputmain+"/root/"
|
39 |
|
|
os.system("mkdir "+outputroot)
|
40 |
|
|
|
41 |
|
|
################################################
|
42 |
|
|
#look for the current directory
|
43 |
|
|
################################################
|
44 |
|
|
os.system("\\rm tmp.log")
|
45 |
|
|
os.system("echo $PWD > tmp.log")
|
46 |
|
|
tmp = open("tmp.log")
|
47 |
|
|
pwd = tmp.readline()
|
48 |
|
|
tmp.close()
|
49 |
|
|
os.system("\\rm tmp.log")
|
50 |
|
|
#################################################
|
51 |
|
|
numfiles = reduce(lambda x,y: x+1, file(inputlist).xreadlines(), 0)
|
52 |
|
|
filesperjob = numfiles/ijobmax
|
53 |
|
|
filesperjob = filesperjob
|
54 |
|
|
extrafiles = numfiles%ijobmax
|
55 |
|
|
input = open(inputlist)
|
56 |
|
|
#################################################
|
57 |
|
|
for ijob in range(ijobmax):
|
58 |
|
|
# prepare the list file
|
59 |
|
|
inputfilename = output+"/input/input_"+str(ijob)+".list"
|
60 |
|
|
inputfile = open(inputfilename,'w')
|
61 |
|
|
# if it is a normal job get filesperjob lines
|
62 |
|
|
if ijob != (ijobmax-1):
|
63 |
|
|
for line in range(filesperjob):
|
64 |
|
|
ntpfile = input.readline()
|
65 |
|
|
if ntpfile != '':
|
66 |
|
|
inputfile.write(ntpfile)
|
67 |
|
|
continue
|
68 |
|
|
else:
|
69 |
|
|
# if it is the last job get ALL remaining lines
|
70 |
|
|
ntpfile = input.readline()
|
71 |
|
|
while ntpfile != '':
|
72 |
|
|
inputfile.write(ntpfile)
|
73 |
|
|
ntpfile = input.readline()
|
74 |
|
|
continue
|
75 |
|
|
inputfile.close()
|
76 |
|
|
|
77 |
|
|
# prepare the script to run
|
78 |
|
|
outputname = output+"/src/submit_"+str(ijob)+".src"
|
79 |
|
|
outputfile = open(outputname,'w')
|
80 |
|
|
outputfile.write('#!/bin/bash\n')
|
81 |
|
|
outputfile.write('#$ -N '+output+'_'+str(ijob)+'\n')
|
82 |
jueugste |
1.2 |
outputfile.write('#$ -l s_rt=01:30:00,h_rt=04:00:00\n')
|
83 |
jueugste |
1.1 |
outputfile.write('#$ -q all.q\n')
|
84 |
|
|
outputfile.write('#$ -cwd\n')
|
85 |
jueugste |
1.2 |
outputfile.write('#$ -o /shome/jueugste/CMSSW/CMSSW_3_6_1_patch2/src/DiLeptonAnalysis/NTupleProducer/test/rootEWKanalyzer/'+output+'/log/\n')
|
86 |
|
|
outputfile.write('#$ -e /shome/jueugste/CMSSW/CMSSW_3_6_1_patch2/src/DiLeptonAnalysis/NTupleProducer/test/rootEWKanalyzer/'+output+'/log/\n')
|
87 |
jueugste |
1.1 |
|
88 |
|
|
outputfile.write('source /swshare/cms/cmsset_default.sh\n')
|
89 |
jueugste |
1.2 |
outputfile.write('cd /shome/jueugste/CMSSW/CMSSW_3_6_1_patch2/src/DiLeptonAnalysis/NTupleProducer/test/rootEWKanalyzer\n')
|
90 |
jueugste |
1.1 |
outputfile.write('eval `scramv1 runtime -sh`\n')
|
91 |
|
|
outputfile.write('export LD_LIBRARY_PATH=/swshare/glite/d-cache/dcap/lib:$LD_LIBRARY_PATH\n')
|
92 |
|
|
outputfile.write('./main '+inputfilename+' '+settingfile+' analyze/Analysis '+outputroot+output+'_'+str(ijob)+' '+output+"/log/cutEfficiencyFile_"+str(ijob)+"\n")
|
93 |
|
|
outputfile.close
|
94 |
|
|
##os.system('echo qsub '+outputname)
|
95 |
|
|
##os.system('qsub '+outputname)
|
96 |
|
|
ijob = ijob+1
|
97 |
|
|
continue
|
98 |
|
|
|
99 |
|
|
## now submit the jobs...
|
100 |
|
|
for ijob in range(ijobmax):
|
101 |
jueugste |
1.2 |
os.system('echo qsub '+output+'/src/submit_'+str(ijob)+'.src')
|
102 |
jueugste |
1.1 |
os.system('qsub '+output+'/src/submit_'+str(ijob)+'.src')
|