ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/batch_qsub.py
Revision: 1.4
Committed: Tue Dec 21 15:25:39 2010 UTC (14 years, 4 months ago) by jueugste
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +12 -11 lines
Log Message:
Added generated PU info

File Contents

# User Rev Content
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.4 ##output = "Data_PromptReco"
21     output = "WenuD6T_PU"
22     ##inputlist = "config/input_PromptReco.txt"
23     inputlist = "config/input_WenuD6T_PU.txt"
24 jueugste 1.1 ## the cut file (still needed...)
25     settingfile = "config/cutFileExample.txt"
26     ## number of max jobs
27 jueugste 1.4 ##ijobmax = 578
28     ijobmax = 33
29     numfiles = 99
30 jueugste 1.1
31     ################################################
32     # to write on local disks
33     ################################################
34    
35     ## name of the directory where the *.root file is stored
36     outputmain = output
37     ## make some directories
38     os.system("mkdir "+output)
39     os.system("mkdir "+output+"/log/")
40     os.system("mkdir "+output+"/input/")
41     os.system("mkdir "+output+"/src/")
42     outputroot = outputmain+"/root/"
43     os.system("mkdir "+outputroot)
44    
45     ################################################
46     #look for the current directory
47     ################################################
48     os.system("\\rm tmp.log")
49     os.system("echo $PWD > tmp.log")
50     tmp = open("tmp.log")
51     pwd = tmp.readline()
52     tmp.close()
53     os.system("\\rm tmp.log")
54     #################################################
55 jueugste 1.4 ##numfiles = reduce(lambda x,y: x+1, file(inputlist).xreadlines(), 0)
56 jueugste 1.1 filesperjob = numfiles/ijobmax
57 jueugste 1.4 ##filesperjob = filesperjob
58 jueugste 1.1 extrafiles = numfiles%ijobmax
59     input = open(inputlist)
60     #################################################
61     for ijob in range(ijobmax):
62     # prepare the list file
63     inputfilename = output+"/input/input_"+str(ijob)+".list"
64     inputfile = open(inputfilename,'w')
65     # if it is a normal job get filesperjob lines
66     if ijob != (ijobmax-1):
67     for line in range(filesperjob):
68     ntpfile = input.readline()
69     if ntpfile != '':
70     inputfile.write(ntpfile)
71     continue
72     else:
73     # if it is the last job get ALL remaining lines
74     ntpfile = input.readline()
75     while ntpfile != '':
76     inputfile.write(ntpfile)
77     ntpfile = input.readline()
78     continue
79     inputfile.close()
80    
81     # prepare the script to run
82     outputname = output+"/src/submit_"+str(ijob)+".src"
83     outputfile = open(outputname,'w')
84     outputfile.write('#!/bin/bash\n')
85     outputfile.write('#$ -N '+output+'_'+str(ijob)+'\n')
86 jueugste 1.2 outputfile.write('#$ -l s_rt=01:30:00,h_rt=04:00:00\n')
87 jueugste 1.1 outputfile.write('#$ -q all.q\n')
88     outputfile.write('#$ -cwd\n')
89 jueugste 1.4 outputfile.write('#$ -o /shome/jueugste/CMSSW/CMSSW_3_6_1_patch2_diff/src/DiLeptonAnalysis/NTupleProducer/test/rootEWKanalyzer/'+output+'/log/\n')
90     outputfile.write('#$ -e /shome/jueugste/CMSSW/CMSSW_3_6_1_patch2_diff/src/DiLeptonAnalysis/NTupleProducer/test/rootEWKanalyzer/'+output+'/log/\n')
91 jueugste 1.1
92     outputfile.write('source /swshare/cms/cmsset_default.sh\n')
93 jueugste 1.4 outputfile.write('cd /shome/jueugste/CMSSW/CMSSW_3_6_1_patch2_diff/src/DiLeptonAnalysis/NTupleProducer/test/rootEWKanalyzer\n')
94 jueugste 1.1 outputfile.write('eval `scramv1 runtime -sh`\n')
95     outputfile.write('export LD_LIBRARY_PATH=/swshare/glite/d-cache/dcap/lib:$LD_LIBRARY_PATH\n')
96     outputfile.write('./main '+inputfilename+' '+settingfile+' analyze/Analysis '+outputroot+output+'_'+str(ijob)+' '+output+"/log/cutEfficiencyFile_"+str(ijob)+"\n")
97     outputfile.close
98     ##os.system('echo qsub '+outputname)
99     ##os.system('qsub '+outputname)
100     ijob = ijob+1
101     continue
102    
103     ## now submit the jobs...
104     for ijob in range(ijobmax):
105 jueugste 1.2 os.system('echo qsub '+output+'/src/submit_'+str(ijob)+'.src')
106 jueugste 1.1 os.system('qsub '+output+'/src/submit_'+str(ijob)+'.src')