-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprepare_NANOAOD_step.py
executable file
·43 lines (37 loc) · 1.76 KB
/
prepare_NANOAOD_step.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
#!/bin/env python
import os, stat
CMSSW_RELEASE='CMSSW_10_2_11/src'
NANOAOD_template_dir = 'NANOAOD/'
tag = 'prod-v0'
pwd = os.getcwd()
def copy_to_cmssw(f, replaceTemplateString = None, replacedataset = None, replaceTag = None):
f1 = f
if replaceTemplateString:
# replace file name
f1 = f.replace('template', replaceTemplateString)
sour = os.path.join(pwd, NANOAOD_template_dir, f)
dest = os.path.join(pwd, CMSSW_RELEASE, f1)
with open(sour, 'r') as in_f:
with open(dest, 'w+') as out_f:
for line in in_f:
if replaceTemplateString:
newline = line.replace('template', replaceTemplateString)
if replaceTag:
newline = newline.replace('TAG', replaceTag)
if replacedataset:
newline = newline.replace('DATASET', replacedataset)
out_f.write(newline)
return
def prepare_all_NANOAOD():
# loop over mass hypotheses and create the cmssw + crab config files:
with open('/nfs/scratch/fynu/asaggio/ZAPrivateProd_2018/ZAPrivateProduction/MINIAOD_published.txt', 'r') as f:
for line in f:
dataset = line.strip()
pd = dataset.split('/')[1]
#masspoint_list = pd.split('_')
#masspoint = masspoint_list[1]+'_'+masspoint_list[2]
copy_to_cmssw('crab_template_NANOAOD.py', replaceTemplateString = pd, replacedataset = dataset, replaceTag = tag)
#copy_to_cmssw('template_NANOAOD_cfg.py', replaceTemplateString = pd, replacedataset = dataset, replaceTag = tag)
copy_to_cmssw('template_NANOAOD_cfg.py', replaceTemplateString = pd, replacedataset = dataset, replaceTag = tag)
if __name__ == '__main__':
prepare_all_NANOAOD()