16 |
|
help="samples you want to run on") |
17 |
|
parser.add_option("-F", "--folderTag", dest="ftag", default="", |
18 |
|
help="Creats a new folder structure for outputs or uses an existing one with the given name") |
19 |
+ |
parser.add_option("-N", "--number-of-events", dest="nevents_split", default=100000, |
20 |
+ |
help="Number of events per file when splitting.") |
21 |
+ |
parser.add_option("-P", "--philipp-love-progress-bars", dest="philipp_love_progress_bars", default=False, |
22 |
+ |
help="If you share the love of Philipp...") |
23 |
+ |
|
24 |
|
(opts, args) = parser.parse_args(sys.argv) |
25 |
|
|
26 |
< |
import os,shutil,pickle,subprocess,ROOT |
26 |
> |
import os,shutil,pickle,subprocess,ROOT,re |
27 |
|
ROOT.gROOT.SetBatch(True) |
28 |
|
from myutils import BetterConfigParser, Sample, ParseInfo |
29 |
|
import getpass |
99 |
|
print 'Exit' |
100 |
|
sys.exit(-1) |
101 |
|
|
102 |
< |
repDict = {'en':en,'logpath':logPath,'job':'','task':opts.task,'queue': 'all.q','timestamp':timestamp} |
102 |
> |
repDict = {'en':en,'logpath':logPath,'job':'','task':opts.task,'queue': 'all.q','timestamp':timestamp,'additional':'','job_id':''} |
103 |
|
def submit(job,repDict): |
104 |
|
repDict['job'] = job |
105 |
< |
command = 'qsub -V -cwd -q %(queue)s -l h_vmem=6G -N %(job)s_%(en)s%(task)s -o %(logpath)s/%(timestamp)s_%(job)s_%(en)s_%(task)s.out -e %(logpath)s/%(timestamp)s_%(job)s_%(en)s_%(task)s.err runAll.sh %(job)s %(en)s ' %(repDict) + opts.task |
105 |
> |
command = 'qsub -V -cwd -q %(queue)s -l h_vmem=6G -N %(job)s_%(en)s%(task)s -o %(logpath)s/%(timestamp)s_%(job)s_%(en)s_%(task)s.out -e %(logpath)s/%(timestamp)s_%(job)s_%(en)s_%(task)s.err runAll.sh %(job)s %(en)s ' %(repDict) + opts.task + ' ' + repDict['job_id'] + ' ' + repDict['additional'] |
106 |
|
print command |
107 |
|
subprocess.call([command], shell=True) |
108 |
|
|
131 |
|
for item in Plot_vars: |
132 |
|
submit(item,repDict) |
133 |
|
|
134 |
+ |
|
135 |
|
elif opts.task == 'dc': |
136 |
|
repDict['queue'] = 'all.q' |
137 |
|
for item in DC_vars: |
143 |
|
elif opts.task == 'prep': |
144 |
|
submit('prepare',repDict) |
145 |
|
|
146 |
< |
elif opts.task == 'eval' or opts.task == 'sys' or opts.task == 'syseval': |
146 |
> |
elif opts.task == 'sys' or opts.task == 'syseval': |
147 |
> |
path = config.get("Directories","SYSin") |
148 |
> |
samplesinfo = config.get("Directories","samplesinfo") |
149 |
> |
info = ParseInfo(samplesinfo,path) |
150 |
> |
if ( opts.samples == ""): |
151 |
> |
for job in info: |
152 |
> |
if (job.subsample): continue |
153 |
> |
submit(job.name,repDict) |
154 |
> |
else: |
155 |
> |
for sample in samplesList: |
156 |
> |
submit(sample,repDict) |
157 |
> |
|
158 |
> |
elif opts.task == 'eval': |
159 |
> |
path = config.get("Directories","MVAin") |
160 |
> |
samplesinfo = config.get("Directories","samplesinfo") |
161 |
> |
info = ParseInfo(samplesinfo,path) |
162 |
|
if ( opts.samples == ""): |
163 |
|
for job in info: |
164 |
+ |
if (job.subsample): continue |
165 |
|
submit(job.name,repDict) |
166 |
|
else: |
167 |
|
for sample in samplesList: |
168 |
|
submit(sample,repDict) |
169 |
|
|
170 |
< |
os.system('qstat') |
171 |
< |
os.system('./qstat.py') |
170 |
> |
|
171 |
> |
elif( opts.task == 'split' ): |
172 |
> |
path = config.get("Directories","SPLITin") |
173 |
> |
samplesinfo = config.get("Directories","samplesinfo") |
174 |
> |
repDict['additional']=opts.nevents_split |
175 |
> |
info = ParseInfo(samplesinfo,path) |
176 |
> |
if ( opts.samples == ""): |
177 |
> |
for job in info: |
178 |
> |
if (job.subsample): continue |
179 |
> |
submit(job.name,repDict) |
180 |
> |
else: |
181 |
> |
for sample in samplesList: |
182 |
> |
submit(sample,repDict) |
183 |
> |
|
184 |
> |
#BDT optimisation |
185 |
> |
elif opts.task == 'mva_opt': |
186 |
> |
total_number_of_steps=1 |
187 |
> |
setting = '' |
188 |
> |
for par in (config.get('Optimisation','parameters').split(',')): |
189 |
> |
scan_par=eval(config.get('Optimisation',par)) |
190 |
> |
setting+=par+'='+str(scan_par[0])+':' |
191 |
> |
if len(scan_par) > 1 and scan_par[2] != 0: |
192 |
> |
total_number_of_steps+=scan_par[2] |
193 |
> |
setting=setting[:-1] # eliminate last column at the end of the setting string |
194 |
> |
print setting |
195 |
> |
repDict['additional']=setting |
196 |
> |
repDict['job_id']=config.get('Optimisation','training') |
197 |
> |
submit('OPT_main_set',repDict) |
198 |
> |
main_setting=setting |
199 |
> |
|
200 |
> |
#Scanning all the parameters found in the training config in the Optimisation sector |
201 |
> |
for par in (config.get('Optimisation','parameters').split(',')): |
202 |
> |
scan_par=eval(config.get('Optimisation',par)) |
203 |
> |
print par |
204 |
> |
if len(scan_par) > 1 and scan_par[2] != 0: |
205 |
> |
for step in range(scan_par[2]): |
206 |
> |
value = (scan_par[0])+((1+step)*(scan_par[1]-scan_par[0])/scan_par[2]) |
207 |
> |
print value |
208 |
> |
setting=re.sub(par+'.*?:',par+'='+str(value)+':',main_setting) |
209 |
> |
repDict['additional']=setting |
210 |
> |
# repDict['job_id']=config.get('Optimisation','training') |
211 |
> |
submit('OPT_'+par+str(value),repDict) |
212 |
> |
# submit(config.get('Optimisation','training'),repDict) |
213 |
> |
print setting |
214 |
> |
|
215 |
> |
|
216 |
> |
os.system('qstat') |
217 |
> |
if (opts.philipp_love_progress_bars): |
218 |
> |
os.system('./qstat.py') |