forked from CTPPS/pps-quick-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_multiple
executable file
·313 lines (233 loc) · 7.8 KB
/
run_multiple
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#!/bin/bash
function RunIfMatch()
{
if [ "$request" == "$era" ]
then
success="True"
cp "conditions.py" "$dir"
cat "templates/reco_cfg.py" | sed "\
s|\$year|$year|;\
s|\$input|$input|;\
s|\$rpId_45_F|$rpId_45_F|;\
s|\$rpId_45_N|$rpId_45_N|;\
s|\$rpId_56_N|$rpId_56_N|;\
s|\$rpId_56_F|$rpId_56_F|;\
s|\$output|reco_plots.root|;\
" > "$dir/cfg.py"
cd "$dir"
cmsRun "cfg.py" &> "log" &
cd - &> /dev/null
fi
}
#----------------------------------------------------------------------------------------------------
function ProcessOneReco()
{
request="$1"
success="False"
#--------------------
year="2016"
rpId_45_F="3"
rpId_45_N="2"
rpId_56_N="102"
rpId_56_F="103"
era="2016_preTS2"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/EAD70032-8836-E611-8C11-02163E014154.root"
RunIfMatch
era="2016_postTS2"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/3204EE5B-C298-E611-BC39-02163E01448F.root"
RunIfMatch
#--------------------
year="2017"
rpId_45_F="23"
rpId_45_N="3"
rpId_56_N="103"
rpId_56_F="123"
era="2017_preTS2"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/8ED63519-2282-E711-9073-02163E01A3C6.root"
RunIfMatch
era="2017_postTS2"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/001D08EE-C4B1-E711-B92D-02163E013864.root"
RunIfMatch
era="2017E_low_PU"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/FEC2DE9E-AFA0-E711-98B1-02163E0143E5.root"
RunIfMatch
era="2017H_W_mass"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/FE78107C-90D2-E711-84AB-02163E01A586.root"
RunIfMatch
#--------------------
year="2018"
rpId_45_F="23"
rpId_45_N="3"
rpId_56_N="103"
rpId_56_F="123"
era="2018"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/601A721D-AD95-E811-B21A-FA163E28A50A.root"
RunIfMatch
era="2018A"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/4E7ABE07-FE4C-E811-9395-FA163EC5FAA0.root"
RunIfMatch
era="2018B"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/4E7E26D5-A368-E811-B205-FA163E0D66CE.root"
RunIfMatch
era="2018C"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/FE1EE87D-FA83-E811-91D5-FA163E4DBEC7.root"
RunIfMatch
era="2018D"; input="root://eoscms.cern.ch//eos/cms/store/group/phys_pps/sw_test_input/D0D06D0E-9897-E811-99C9-FA163EBF0D83.root"
RunIfMatch
#--------------------
if [ "$success" == "True" ]
then
echo " - $request: executed"
else
echo " - $request: failed"
fi
}
#----------------------------------------------------------------------------------------------------
function ProcessOneDirsim()
{
local period="$1"
local year=""
local era=""
local config=""
if [ "$period" == "2016" ]; then year="2016"; era="Run2_2016"; periods="config.profile_2016_preTS2,config.profile_2016_postTS2"; fi
if [ "$period" == "2016_preTS2" ]; then year="2016"; era="Run2_2016"; periods="config.profile_2016_preTS2"; fi
if [ "$period" == "2016_postTS2" ]; then year="2016"; era="Run2_2016"; periods="config.profile_2016_postTS2"; fi
if [ "$period" == "2017" ]; then year="2017"; era="Run2_2017"; periods="config.profile_2017_preTS2,config.profile_2017_postTS2"; fi
if [ "$period" == "2017_preTS2" ]; then year="2017"; era="Run2_2017"; periods="config.profile_2017_preTS2"; fi
if [ "$period" == "2017_postTS2" ]; then year="2017"; era="Run2_2017"; periods="config.profile_2017_postTS2"; fi
if [ "$period" == "2018" ]; then year="2018"; era="Run2_2018"; periods="config.profile_2018_preTS1,config.profile_2018_TS1_TS2,config.profile_2018_postTS2"; fi
if [ "$period" == "2018_preTS1" ]; then year="2018"; era="Run2_2018"; periods="config.profile_2018_preTS1"; fi
if [ "$period" == "2018_TS1_TS2" ]; then year="2018"; era="Run2_2018"; periods="config.profile_2018_TS1_TS2"; fi
if [ "$period" == "2018_postTS2" ]; then year="2018"; era="Run2_2018"; periods="config.profile_2018_postTS2"; fi
if [ "$period" == "2021" ]; then year="2021"; era="Run3"; periods="config.profile_2021_default"; fi
if [ "$period" == "2022" ]; then year="2022"; era="Run3"; periods="config.profile_2022_default"; fi
if [ -n "$era" ]
then
cat "templates/dirsim_cfg.py" | sed "\
s|\$ERA|$era|;\
s|\$YEAR|$year|;\
s|\$PERIODS|$periods|;\
" > "$dir/cfg.py"
cd "$dir"
cmsRun "cfg.py" &> "log" &
cd - &> /dev/null
echo " - $period executed"
else
echo " - $period failed"
fi
}
#----------------------------------------------------------------------------------------------------
function ProcessOne()
{
local wf="$1"
local type="${wf%:*}"
local period="${wf#*:}"
echo " $type : $period"
dir="$output_dir/$wf"
mkdir -p "$dir"
case "$type" in
"reco")
ProcessOneReco "$period"
;;
"dirsim")
ProcessOneDirsim "$period"
;;
*)
echo " - unknown type $type"
esac
}
#----------------------------------------------------------------------------------------------------
# defaults
output_dir=""
force="False"
list="std"
declare -A lists
lists["reco_std"]="reco:2016_preTS2,reco:2016_postTS2,reco:2017_preTS2,reco:2017_postTS2,reco:2018"
lists["reco_full"]="reco:2016_preTS2,reco:2016_postTS2,reco:2017_preTS2,reco:2017_postTS2,reco:2017E_low_PU,reco:2017H_W_mass,reco:2018,reco:2018A,reco:2018B,reco:2018C,reco:2018D"
lists["dirsim_std"]="dirsim:2016,dirsim:2016_postTS2,dirsim:2017,dirsim:2017_postTS2,dirsim:2018,dirsim:2018_postTS2,dirsim:2021,dirsim:2022"
lists["dirsim_full"]="dirsim:2016,dirsim:2016_preTS2,dirsim:2016_postTS2,dirsim:2017,dirsim:2017_preTS2,dirsim:2017_postTS2,dirsim:2018,dirsim:2018_preTS1,dirsim:2018_TS1_TS2,dirsim:2018_postTS2,dirsim:2021"
lists["std"]="${lists[reco_std]},${lists[dirsim_std]}"
#----------------------------------------------------------------------------------------------------
function PrintUsage()
{
echo "USAGE: run_multiple <option> <option> ..."
echo "OPTIONS:"
echo " -o, --output <dir> set output directory"
echo " -l, --list <list> comma-separated list of tests, special groups:"
for ln in ${!lists[@]}
do
echo " $ln"
done
echo " -f force to overwrite the output directory"
}
#----------------------------------------------------------------------------------------------------
# parse command line
while [ -n "$1" ]
do
case "$1" in
"-o" | "--output")
shift
output_dir="$1"
;;
"-l" | "--list")
shift
list="$1"
;;
"-f")
force="True"
;;
"-h" | "--help")
PrintUsage
exit 0
;;
*)
echo "ERROR: argument '$1' not understood."
PrintUsage
exit 1
esac
shift
done
#----------------------------------------------------------------------------------------------------
# validate input
if [ -z "$output_dir" ]
then
echo "ERROR: output dir not set"
PrintUsage
exit 1
fi
if [ -d "$output_dir" -a "$force" != "True" ]
then
echo "ERROR: directory $output_dir already exists. Do the following to remove it:"
echo " rm -rf \"$output_dir\""
exit 2
fi
#----------------------------------------------------------------------------------------------------
# expand period-list groups
for ln in ${!lists[@]}
do
if [ "$list" == "$ln" ]
then
list="${lists[$ln]}"
break
fi
done
#----------------------------------------------------------------------------------------------------
# make output directory
echo "* $output_dir"
mkdir -p "$output_dir"
# make info file
(
cd ..
echo "DATE:"
date
echo ""
echo "AT:"
git log --oneline|head -n 1
echo ""
echo "STATUS:"
git st
cd - &> /dev/null
) > "$output_dir/info"
# go through list
while [ -n "$list" ]
do
wf=${list%%,*}
list_new=${list#*,}
if [ "$list_new" == "$list" ]
then
list=""
else
list="$list_new"
fi
ProcessOne "$wf"
done