forked from cms-l1-dpg/Legacy-L1Ntuples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmitTask.py
executable file
·188 lines (155 loc) · 4.16 KB
/
submitTask.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env python
#!/afs/cern.ch/cms/sw/slc4_ia32_gcc345/external/python/2.4.2-cms6/bin/python
# script to create & submit CRAB jobs for l1 prompt analysis
import sys
import os
import getopt
import re
import shutil
from subprocess import *
# constants
express = "/ExpressPhysics/Commissioning10-Express-v9/FEVT"
minbias = "/MinimumBias/Commissioning10-PromptReco-v9/RECO"
minbiasraw = "/MinimumBias/Commissioning10-v4/RAW"
zerobias = "/ZeroBias/Commissioning10-PromptReco-v9/RECO"
zerobiasraw = "/ZeroBias/Commissioning10-v4/RAW"
testenables = "/TestEnables/Commissioning10-v4/RAW"
hltmon = "/OfflineMonitor/Commissioning10-Express-v9/FEVTHLTALL"
goodcoll = "/MinimumBias/Commissioning10-GOODCOLL-v9/RAW-RECO"
goodvertex = "/ZeroBias/Commissioning10-GOODVERTEX-v9/RAW-RECO"
jobpath=os.environ['CAF_TRIGGER']+"/l1analysis/cmssw/"+os.environ['L1CMSSW']+"/src/UserCode/L1TriggerDPG/test/"
#
def usage():
print "Usage : submit.py [ -e | -n ] [ synchronisation ] <run>"
print
# arguments : file location and local dir for results
try:
opts, args = getopt.getopt(sys.argv[1:], "hen")
except getopt.GetoptError:
usage()
sys.exit(2)
doNtuple=False
doEmulator=False
for opt, arg in opts:
if opt=='-h':
usage()
exit.sys()
if opt=='-n':
doNtuple=True
if opt=='-e':
doEmulator=True
print args
dataset = " "
if (args[0]=="synchronisation"):
dataset="MinBias"
run = args[1]
if (len(run)==6):
run="000"+run
# run
# make directory for results if it doesn't already exist
# and add
wwwdir = os.environ['CAF_TRIGGER']+"/l1analysis/www/"+str(run)
if not os.path.exists(wwwdir):
os.mkdir(wwwdir)
shutil.copy(os.environ['CAF_TRIGGER']+"/l1analysis/www/subdir_htaccess.tmp", wwwdir+"/.htaccess")
# dataset
# set use_parent=1 for RECO datasets
datasetpath = minbias
useparent = 0
if (dataset=="MinBias"):
datasetpath=minbias
useparent=1
elif (dataset=="ZeroBias"):
datasetpath=zerobias
useparent=1
elif (dataset=="MinBiasRaw"):
datasetpath=minbiasraw
elif (dataset=="ZeroBiasRaw"):
datasetpath=zerobiasraw
elif (dataset=="TestEnables"):
datasetpath=testenables
elif (dataset=="HLTMon"):
datasetpath=hltmon
elif (dataset=="ExpressPhysics"):
datasetpath=express
elif (dataset=="GOODCOLL"):
datasetpath=goodcoll
elif (dataset=="GoodVertex"):
datasetpath=goodvertex
else :
print "Dataset name is not correct !"
sys.exit(1)
# set job dependent variables
job =""
label = ""
outfile = ""
# check if the dataset is RAW
p = re.compile('.+Raw')
raw = p.match(datasetpath)
if (doEmulator):
# emulator jobs will work on RECO (2 file solution) or RAW
job="l1EmulatorJob.py"
label=dataset+"_Emulator_"+str(run)
outfile="L1EmulHistos.root"
elif (doNtuple):
# ntuple job needs to be adjusted if run on RAW
label=dataset+"_Ntuple_"+str(run)
outfile = "L1Tree.root"
if raw:
job="l1NtupleFromRaw.py"
else:
job="l1NtupleFromReco.py"
else:
print "Please specify a type of job to run!"
sys.exit(1)
# CRAB file
crabfile="crab-"+dataset+"-"+run+".cfg"
# create job file
print "Making CRAB job for "+dataset+", run "+run+", using "+datasetpath
crab_returndata="""
[USER]
return_data = 1
copy_data = 0
ui_working_dir = """+label+"""
"""
crab_copydata="""
[USER]
return_data = 0
copy_data = 1
storage_element = T1_CH_CERN_Buffer
user_remote_dir = L1PromptAnalysis_"""+label+"""
ui_working_dir = """+label+"""
"""
crab_output=""
if (doEmulator):
crab_output=crab_returndata
else:
crab_output=crab_copydata
crab1="""
[CRAB]
jobtype = cmssw
scheduler = caf
[CMSSW]
dbs_url=http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet
datasetpath="""+datasetpath+"""
runselection="""+run+"""
pset="""+jobpath+job+"""
total_number_of_events=-1
events_per_job=100000
#number_of_jobs=-1
output_file = """+outfile+"""
use_parent="""+str(useparent)+"""
check_user_remote_dir=0
"""
crab2="""
[GRID]
rb = CERN
proxy_server = myproxy.cern.ch
"""
f = open(crabfile, 'w')
f.write(crab1)
f.write(crab_output)
f.write(crab2)
print "crab -create -submit -cfg "+crabfile
submit = Popen("crab -create -submit -cfg "+crabfile, shell=True)
#submit.wait()