-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalizeQGStudiesOnBatch.py
More file actions
77 lines (59 loc) · 2.46 KB
/
finalizeQGStudiesOnBatch.py
File metadata and controls
77 lines (59 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
import os
import sys
import re
import time
if len(sys.argv) != 3 :
print "usage finalizeQGStudiesOnBatch.py dataset nBlocks"
sys.exit(1)
dataset = sys.argv[1]
dataset_path = dataset
nBlocks = int(sys.argv[2])
analyzerType = "QGStudies"
queue = "8nh"
#application = "finalize_" + analyzerType
application = "finalize_QGStudies"
match_Fall11 = re.search( r'Fall11', dataset, re.M|re.I)
match_Summer12 = re.search( r'Summer12', dataset, re.M|re.I)
isDATA = re.search( r'Run201', dataset, re.M|re.I)
if isDATA:
diskoutputdir = "/shome/pandolf/FinalizedTrees/DATA/" + dataset_path
else:
if match_Fall11:
diskoutputdir = "/shome/pandolf/FinalizedTrees/MC/Fall11/" + dataset_path
elif match_Summer12:
diskoutputdir = "/shome/pandolf/FinalizedTrees/MC/Summer12/" + dataset_path
else:
diskoutputdir = "/shome/pandolf/FinalizedTrees/MC/Summer11/" + dataset_path
diskoutputmain = diskoutputdir
dir = "batch_" + analyzerType + "_" + dataset
os.system("mkdir -p "+dir)
os.system("mkdir -p "+dir+"/log/")
os.system("mkdir -p "+dir+"/input/")
os.system("mkdir -p "+dir+"/src/")
if diskoutputdir != "none":
os.system("mkdir -p "+diskoutputmain)
pwd = os.environ['PWD']
ijob=0
while (ijob<nBlocks):
print( str(ijob) + " / " + str(nBlocks) +"\n\n" )
WORKDIR=os.getenv("PWD")
outputname = dir+"/src/submit_"+str(ijob)+".src"
outputfile = open(outputname,'w')
outputfile.write('#!/bin/bash\n')
outputfile.write('source /swshare/cms/cmsset_default.sh\n')
outputfile.write('cd /shome/pandolf/CMSSW_4_2_8/src/ ; eval `scramv1 runtime -sh` ; cd -\n')
outputfile.write('cd '+WORKDIR+'\n')
outputfile.write(pwd+'/'+application+" "+dataset+" " + str(ijob)+" "+ str(nBlocks) + "\n")
# select this for GENJETS ntuples:
outputfile.write('mv ' + analyzerType + "_" + dataset + "_*_" + str(ijob) + '.root '+diskoutputmain+'\n')
outputfile.close()
#print "chmod +x "+outputname
os.popen("chmod +x "+outputname)
#os.system("echo bsub -q "+queue+" -o "+dir+"/log/"+dataset+"_"+str(ijob)+".log "+pwd+"/"+outputname)
#out = os.popen("echo bsub -q "+queue+" -o "+dir+"/log/"+dataset+"_"+str(ijob)+".log "+pwd+"/"+outputname+" -copyInput="+dataset+"_"+str(ijob))
os.system("ls -lah "+pwd+"/"+outputname)
command = "bsub -q "+queue+" -o "+pwd+"/"+dir+"/log/"+dataset+"_"+str(ijob)+".log -e "+pwd+"/"+dir+"/log/"+dataset+"_"+str(ijob)+".err "+pwd+"/"+outputname+" -copyInput="+dataset+"_"+str(ijob)
print command
os.system(command)
ijob = ijob+1