/
SubmitGENSamples.py
113 lines (98 loc) · 3.62 KB
/
SubmitGENSamples.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
#!/usr/bin/env python
import os, time, socket, sys
OutputLocation = "/cms/scratch/brochero/LepJetsAnalyzer/TopResults/"
InputLocation = "/xrootd/store/user/brochero/"
RunFileName = "SubmitCondorGEN"
InputDB = str(sys.argv[1])
CondorArg = "'$(filehead)$(filesample) $(outputref)'"
# Systematic Variations
SysThe = {"ScaleRnF Up","ScaleRnF Down","ScaleRuF Nom","ScaleRuF Up","ScaleRdF Up","ScaleRdF Down"}
SysDedicated = {"UEUp","UEDown","ISRUp","ISRDown","FSRUp","FSRDown"}
RunThe = False
RunDedicated = False
if(len(sys.argv)>2):
insys = sys.argv[2]
if (insys == "scale"):
RunThe = True
print "Scale Variations variations will be processed....."
RunFileName += "Scale"
elif (insys == "dedicated"):
RunDedicated = True
RunFileName += "Dedicated"
else:
sys.exit(0)
print "Reading database for Lepton+Jets in " + InputDB
fr = open(InputDB,'r')
CatVersion = ""
FileHeader = ""
OutNameRef = ""
SamNam = []
NLines = 0
for line in fr:
if line and "#" not in line:
if line.split():
for word in line.split():
if NLines is 0:
CatVersion = word
elif NLines is 1:
FileHeader = word
elif NLines is 2:
OutNameRef = word
else:
sample = word
fullpath = InputLocation + CatVersion + "/" + FileHeader + "_" + sample
if os.path.isfile(fullpath + ".root"):
print "Sample to be processed: " + str(fullpath)
SamNam.append(sample)
else:
print "File " + str(fullpath) + " not found!"
NLines += 1
fr.close()
if len(SamNam) is not 0:
LogCondorDir = OutputLocation + "CondorLog_" + OutNameRef
if (os.path.isdir(LogCondorDir)):
print "Directory already created."
else:
print "Creating " + LogCondorDir + " directory and changing rights"
os.system("mkdir " + LogCondorDir)
os.chmod(LogCondorDir,0777)
fout = open(RunFileName, "w")
print>>fout, "filehead =" + FileHeader + "_"
print>>fout, "outputref=" + OutNameRef
print>>fout, "filesample="
print>>fout, "sysvar=Central"
print>>fout, "################################"
print>>fout, """executable = CondorGENJob.sh
universe = vanilla
initial_dir= """ + LogCondorDir
print>>fout, """
getenv = True
should_transfer_files = YES
when_to_transfer_output = ON_EXIT
log = job_$(outputref)_$(filesample)_$(sysvar).log
output = job_$(outputref)_$(filesample)_$(sysvar).info
error = job_$(outputref)_$(filesample)_$(sysvar).err
requirements = OpSysMajorVer == 6
"""
if(RunThe):
for isam in SamNam:
for ithe in SysThe:
scale = " -s " + ithe
print>>fout, "filesample=" + isam
print>>fout, """arguments = " '$(filehead)$(filesample)' '$(outputref)""" + scale + """ '" """
print>>fout, "queue 1"
elif(RunDedicated):
for isam in SamNam:
for ided in SysDedicated:
print>>fout, "filesample=" + isam + "_SYS_"+ ided
print>>fout, """arguments = " '$(filehead)$(filesample)' '$(outputref) '" """
print>>fout, "queue 1"
else:
for isam in SamNam:
print>>fout, "filesample=" + isam
print>>fout, """
arguments = "'$(filehead)$(filesample)' '$(outputref)' "
queue 1
"""
fout = None
os.system("condor_submit " + RunFileName)