ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/batch_qsub.py
Revision: 1.3
Committed: Mon Sep 20 14:23:15 2010 UTC (14 years, 7 months ago) by jueugste
Content type: text/x-python
Branch: MAIN
Changes since 1.2: +6 -3 lines
Log Message:
Update (plus EWK and HWW analysis added)

File Contents

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