forked from mhl0116/privateMC_gen
-
Notifications
You must be signed in to change notification settings - Fork 3
/
2016_missing_bkgs.chainpset.py
executable file
·493 lines (404 loc) · 18.2 KB
/
2016_missing_bkgs.chainpset.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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
import os
from metis.CMSSWTask import CMSSWTask
from metis.Sample import DirectorySample, DummySample
from metis.Path import Path
from metis.StatsParser import StatsParser
import time
import sys
sys.path.append("/home/users/fsetti/public_html/privateMC_gen")
from update_pset_NMSSM import edit_pset_NMSSM, edit_pset_gghh, edit_pset_gghh_WW
from allconfig import *
years = ['2016', '2016_APV', '2017', '2018' ]
condor_submit_params={
#"sites": "SDSC-PRP", # other_sites can be good_sites, your own list, etc.
"sites": "T2_US_UCSD,T2_US_CALTECH,T2_US_MIT,T2_US_WISCONSIN,T2_US_Vanderbilt,T2_US_Florida", # other_sites can be good_sites, your own list, etc.
"classads": [
["RequestK8SNamespace", "cms-ucsd-t2"],
["SingularityImage", "/cvmfs/singularity.opensciencegrid.org/cmssw/cms:rhel7"]
],
#"requirements_line": 'requirements = (HasSingularity==True)',
"requirements_line": 'requirements = (HAS_SINGULARITY=?=True) && (TARGET.K8SNamespace =!= "abc")',
#"use_xrootd":True
}
#condor_submit_params = {"sites" : "T2_US_UCSD,T2_US_CALTECH,T2_US_MIT,T2_US_WISCONSIN,T2_US_Nebraska,T2_US_Purdue,T2_US_Vanderbilt,T2_US_Florida",
couplings = [ 'cHHH0' , 'cHHH1' , 'cHHH2p45' , 'cHHH5' ]
decays = [ 'dileptonic' , 'semileptonic' ]
procs = [ "DiPhotonJetsBox_MGG_80toInf", "DiPhotonJetsBox1BJet_MGG_80toInf", "DiPhotonJetsBox_M40_80" ]
sus_procs = [ 'GJets_HT_600ToInf_TuneCP5_13TeV_madgraphMLM_pythia8' , 'GJets_HT_400To600_TuneCP5_13TeV_madgraphMLM_pythia8', "TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8", "TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8", "TTJets_TuneCP5_13TeV_amcatnloFXFX_pythia8" ]
def runall(special_dir, total_nevents, events_per_output):
for _ in range(2500):
proc_tag = "v1"
for proc in missing_UL_bkgs.keys():
for year in years:
#still to figure out how to start production from miniAOD
if proc in sus_procs:
continue
tag = str(proc) + "_" + year
total_nevents_tmp = total_nevents
steps = []
if '2016' in year:
total_nevents_tmp /= 2
try:
cmssw_v_gen = missing_UL_bkgs[proc][year]["cmssw_v_gen"]
pset_gen = missing_UL_bkgs[proc][year]["pset_gen"]
scram_arch_gen = missing_UL_bkgs[proc][year]["scram_arch_gen"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP1_%s"%(special_dir,tag,proc_tag))
step1 = CMSSWTask(
# Change dataset to something more meaningful (but keep STEP1, as we use this
# for string replacement later); keep N=1
sample = DummySample(N=1, dataset="/"+ tag+ "_STEP1"),
# A unique identifier
tag = proc_tag,
special_dir = special_dir,
# Probably want to beef up the below two numbers to control splitting,
# but note that step2 is the bottleneck, so don't put too many events
# in one output file here
events_per_output = events_per_output,
total_nevents = total_nevents_tmp,
# We have one input dummy file, so this must be True
split_within_files = True,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_gen,
cmssw_version = cmssw_v_gen,
scram_arch = scram_arch_gen,
condor_submit_params = condor_submit_params
)
steps += [ step1 ]
except:
print("Could not process STEP1 for: " + proc + " for " + year )
try:
cmssw_v_sim = missing_UL_bkgs[proc][year]["cmssw_v_sim"]
pset_sim = missing_UL_bkgs[proc][year]["pset_sim"]
scram_arch_sim = missing_UL_bkgs[proc][year]["scram_arch_sim"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP2_%s"%(special_dir,tag,proc_tag))
step2 = CMSSWTask(
sample = DirectorySample(
location = step1.get_outputdir(),
dataset = step1.get_sample().get_datasetname().replace("STEP1","STEP2"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
files_per_output = 1,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_sim,
cmssw_version = cmssw_v_sim,
scram_arch = scram_arch_sim,
condor_submit_params = condor_submit_params
)
steps += [ step2 ]
except:
print("Could not process STEP2 for: " + proc + " for " + year )
try:
cmssw_v_mix = missing_UL_bkgs[proc][year]["cmssw_v_mix"]
pset_mix = missing_UL_bkgs[proc][year]["pset_mix"]
scram_arch_mix = missing_UL_bkgs[proc][year]["scram_arch_mix"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP3_%s"%(special_dir,tag,proc_tag))
step3 = CMSSWTask(
sample = DirectorySample(
location = step2.get_outputdir(),
dataset = step2.get_sample().get_datasetname().replace("STEP2","STEP3"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
files_per_output = 1,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_mix,
cmssw_version = cmssw_v_mix,
scram_arch = scram_arch_mix,
condor_submit_params = condor_submit_params
)
steps += [ step3 ]
except:
print("Could not process STEP3 for: " + proc + " for " + year )
try:
cmssw_v_hlt = missing_UL_bkgs[proc][year]["cmssw_v_hlt"]
pset_hlt = missing_UL_bkgs[proc][year]["pset_hlt"]
scram_arch_hlt = missing_UL_bkgs[proc][year]["scram_arch_hlt"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP4_%s"%(special_dir,tag,proc_tag))
step4 = CMSSWTask(
sample = DirectorySample(
location = step3.get_outputdir(),
dataset = step3.get_sample().get_datasetname().replace("STEP3","STEP4"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
#output_name = "step4.root",
pset = "cmsDrivers/UL20/"+proc+"/" + pset_hlt,
cmssw_version = cmssw_v_hlt,
scram_arch = scram_arch_hlt,
condor_submit_params = condor_submit_params
)
steps += [ step4 ]
except:
print("Could not process STEP4 for: " + proc + " for " + year )
try:
cmssw_v_reco = missing_UL_bkgs[proc][year]["cmssw_v_reco"]
pset_reco = missing_UL_bkgs[proc][year]["pset_reco"]
scram_arch_reco = missing_UL_bkgs[proc][year]["scram_arch_reco"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP5_%s"%(special_dir,tag,proc_tag))
step5 = CMSSWTask(
sample = DirectorySample(
location = step4.get_outputdir(),
dataset = step4.get_sample().get_datasetname().replace("STEP4","STEP5"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_reco,
cmssw_version = cmssw_v_reco,
scram_arch = scram_arch_reco,
condor_submit_params = condor_submit_params
)
steps += [ step5 ]
except:
print("Could not process STEP5 for: " + proc + " for " + year )
try:
cmssw_v_miniaodsim = missing_UL_bkgs[proc][year]["cmssw_v_miniaodsim"]
pset_miniaodsim = missing_UL_bkgs[proc][year]["pset_miniaodsim"]
scram_arch_miniaodsim = missing_UL_bkgs[proc][year]["scram_arch_miniaodsim"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP6_%s"%(special_dir,tag,proc_tag))
step6 = CMSSWTask(
sample = DirectorySample(
location = step5.get_outputdir(),
dataset = step5.get_sample().get_datasetname().replace("STEP5","STEP6"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
#output_name = "step6.root",
pset = "cmsDrivers/UL20/"+proc+"/" + pset_miniaodsim,
cmssw_version = cmssw_v_miniaodsim,
scram_arch = scram_arch_miniaodsim,
condor_submit_params = condor_submit_params
)
steps += [ step6 ]
except:
print("Could not process STEP6 for: " + proc + " for " + year )
try:
cmssw_v_nanoaodsim = missing_UL_bkgs[proc][year]["cmssw_v_nanoaodsim"]
pset_nanoaodsim = missing_UL_bkgs[proc][year]["pset_nanoaodsim"]
scram_arch_nanoaodsim = missing_UL_bkgs[proc][year]["scram_arch_nanoaodsim"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP7_%s"%(special_dir,tag,proc_tag))
step7 = CMSSWTask(
sample = DirectorySample(
location = step6.get_outputdir(),
dataset = step6.get_sample().get_datasetname().replace("STEP6","STEP7"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
#output_name = "step7.root",
pset = "cmsDrivers/UL20/"+proc+"/" + pset_nanoaodsim,
cmssw_version = cmssw_v_nanoaodsim,
scram_arch = scram_arch_nanoaodsim,
condor_submit_params = condor_submit_params
)
steps += [ step7 ]
except:
print("Could not process STEP7 for: " + proc + " for " + year )
if len(steps) == 0:
continue
total_summary = {}
for task in steps:
task.process()
summary = task.get_task_summary()
total_summary[task.get_sample().get_datasetname()] = summary
StatsParser(data=total_summary, webdir="~/public_html/dump/metis/").do()
'''
#Produce resonant samples for IC people
for proc in resonant_signals.keys() :
for year in years:
#still to figure out how to start production from miniAOD
if proc in sus_procs:
continue
tag = str(proc) + "_" + year
total_nevents_tmp = total_nevents
steps = []
if '2016' in year:
total_nevents_tmp /= 2
try:
cmssw_v_gen = resonant_signals[proc][year]["cmssw_v_gen"]
pset_gen = resonant_signals[proc][year]["pset_gen"]
scram_arch_gen = resonant_signals[proc][year]["scram_arch_gen"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP1_%s"%(special_dir,tag,proc_tag))
step1 = CMSSWTask(
# Change dataset to something more meaningful (but keep STEP1, as we use this
# for string replacement later); keep N=1
sample = DummySample(N=1, dataset="/"+ tag+ "_STEP1"),
# A unique identifier
tag = proc_tag,
special_dir = special_dir,
# Probably want to beef up the below two numbers to control splitting,
# but note that step2 is the bottleneck, so don't put too many events
# in one output file here
events_per_output = events_per_output,
total_nevents = total_nevents_tmp,
# We have one input dummy file, so this must be True
split_within_files = True,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_gen,
cmssw_version = cmssw_v_gen,
scram_arch = scram_arch_gen,
condor_submit_params = condor_submit_params
)
steps += [ step1 ]
except:
print("Could not process STEP1 for: " + proc + " for " + year )
try:
cmssw_v_sim = resonant_signals[proc][year]["cmssw_v_sim"]
pset_sim = resonant_signals[proc][year]["pset_sim"]
scram_arch_sim = resonant_signals[proc][year]["scram_arch_sim"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP2_%s"%(special_dir,tag,proc_tag))
step2 = CMSSWTask(
sample = DirectorySample(
location = step1.get_outputdir(),
dataset = step1.get_sample().get_datasetname().replace("STEP1","STEP2"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
files_per_output = 1,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_sim,
cmssw_version = cmssw_v_sim,
scram_arch = scram_arch_sim,
condor_submit_params = condor_submit_params
)
steps += [ step2 ]
except:
print("Could not process STEP2 for: " + proc + " for " + year )
try:
cmssw_v_mix = resonant_signals[proc][year]["cmssw_v_mix"]
pset_mix = resonant_signals[proc][year]["pset_mix"]
scram_arch_mix = resonant_signals[proc][year]["scram_arch_mix"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP3_%s"%(special_dir,tag,proc_tag))
step3 = CMSSWTask(
sample = DirectorySample(
location = step2.get_outputdir(),
dataset = step2.get_sample().get_datasetname().replace("STEP2","STEP3"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
files_per_output = 1,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_mix,
cmssw_version = cmssw_v_mix,
scram_arch = scram_arch_mix,
condor_submit_params = condor_submit_params
)
steps += [ step3 ]
except:
print("Could not process STEP3 for: " + proc + " for " + year )
try:
cmssw_v_hlt = resonant_signals[proc][year]["cmssw_v_hlt"]
pset_hlt = resonant_signals[proc][year]["pset_hlt"]
scram_arch_hlt = resonant_signals[proc][year]["scram_arch_hlt"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP4_%s"%(special_dir,tag,proc_tag))
step4 = CMSSWTask(
sample = DirectorySample(
location = step3.get_outputdir(),
dataset = step3.get_sample().get_datasetname().replace("STEP3","STEP4"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
#output_name = "step4.root",
pset = "cmsDrivers/UL20/"+proc+"/" + pset_hlt,
cmssw_version = cmssw_v_hlt,
scram_arch = scram_arch_hlt,
condor_submit_params = condor_submit_params
)
steps += [ step4 ]
except:
print("Could not process STEP4 for: " + proc + " for " + year )
try:
cmssw_v_reco = resonant_signals[proc][year]["cmssw_v_reco"]
pset_reco = resonant_signals[proc][year]["pset_reco"]
scram_arch_reco = resonant_signals[proc][year]["scram_arch_reco"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP5_%s"%(special_dir,tag,proc_tag))
step5 = CMSSWTask(
sample = DirectorySample(
location = step4.get_outputdir(),
dataset = step4.get_sample().get_datasetname().replace("STEP4","STEP5"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
pset = "cmsDrivers/UL20/"+proc+"/" + pset_reco,
cmssw_version = cmssw_v_reco,
scram_arch = scram_arch_reco,
condor_submit_params = condor_submit_params
)
steps += [ step5 ]
except:
print("Could not process STEP5 for: " + proc + " for " + year )
try:
cmssw_v_miniaodsim = resonant_signals[proc][year]["cmssw_v_miniaodsim"]
pset_miniaodsim = resonant_signals[proc][year]["pset_miniaodsim"]
scram_arch_miniaodsim = resonant_signals[proc][year]["scram_arch_miniaodsim"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP6_%s"%(special_dir,tag,proc_tag))
step6 = CMSSWTask(
sample = DirectorySample(
location = step5.get_outputdir(),
dataset = step5.get_sample().get_datasetname().replace("STEP5","STEP6"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
#output_name = "step6.root",
pset = "cmsDrivers/UL20/"+proc+"/" + pset_miniaodsim,
cmssw_version = cmssw_v_miniaodsim,
scram_arch = scram_arch_miniaodsim,
condor_submit_params = condor_submit_params
)
steps += [ step6 ]
except:
print("Could not process STEP6 for: " + proc + " for " + year )
try:
cmssw_v_nanoaodsim = resonant_signals[proc][year]["cmssw_v_nanoaodsim"]
pset_nanoaodsim = resonant_signals[proc][year]["pset_nanoaodsim"]
scram_arch_nanoaodsim = resonant_signals[proc][year]["scram_arch_nanoaodsim"]
os.system("mkdir -p /hadoop/cms/store/user/fsetti/%s/%s_STEP7_%s"%(special_dir,tag,proc_tag))
step7 = CMSSWTask(
sample = DirectorySample(
location = step6.get_outputdir(),
dataset = step6.get_sample().get_datasetname().replace("STEP6","STEP7"),
),
tag = proc_tag,
special_dir = special_dir,
open_dataset = True,
#files_per_output = 1,
files_per_output = 2,
#output_name = "step7.root",
pset = "cmsDrivers/UL20/"+proc+"/" + pset_nanoaodsim,
cmssw_version = cmssw_v_nanoaodsim,
scram_arch = scram_arch_nanoaodsim,
condor_submit_params = condor_submit_params
)
steps += [ step7 ]
except:
print("Could not process STEP7 for: " + proc + " for " + year )
if len(steps) == 0:
continue
total_summary = {}
for task in steps:
task.process()
summary = task.get_task_summary()
total_summary[task.get_sample().get_datasetname()] = summary
StatsParser(data=total_summary, webdir="~/public_html/dump/metis/").do()
'''
time.sleep(60*60)
runall("nanoAOD_runII_20UL", 400000, 250)
#runall("nanoAOD_runII_20UL_test", 10000, 250)