ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/submitThem.py
(Generate patch)

Comparing UserCode/VHbb/python/submitThem.py (file contents):
Revision 1.12 by peller, Mon Oct 1 09:16:34 2012 UTC vs.
Revision 1.25 by nmohr, Thu Jan 17 08:22:25 2013 UTC

# Line 1 | Line 1
1   #! /usr/bin/env python
2   import os,shutil,sys,pickle,subprocess,ROOT
3   from optparse import OptionParser
4 from BetterConfigParser import BetterConfigParser
5 from samplesclass import sample
4   import getpass
5 + from myutils import BetterConfigParser, sample, parse_info
6  
7   parser = OptionParser()
8   parser.add_option("-T", "--tag", dest="tag", default="",
9                        help="Tag to run the analysis with, example '8TeV' uses config8TeV and pathConfig8TeV to run the analysis")
10   parser.add_option("-J", "--task", dest="task", default="",
11 <                      help="Task to be done, i.e. 'dc' for Datacards, 'prep' for preparation of Trees, 'plot' to produce plots or 'eval' to write the MVA output or 'sys' to write regression and systematics. ")
11 >                      help="Task to be done, i.e. 'dc' for Datacards, 'prep' for preparation of Trees, 'plot' to produce plots or 'eval' to write the MVA output or 'sys' to write regression and systematics (or 'syseval' for both). ")
12   parser.add_option("-M", "--mass", dest="mass", default="125",
13                        help="Mass for DC or Plots, 110...135")
14   parser.add_option("-S","--samples",dest="samples",default="",
# Line 29 | Line 28 | if opts.task == "":
28   samplesList=opts.samples.split(",")
29  
30   en = opts.tag
31 < configs = ['config%s'%(en),'pathConfig%s'%(en)]
31 > configs = ['%sconfig/general'%(en),'%sconfig/paths'%(en),'%sconfig/plots'%(en),'%sconfig/training'%(en),'%sconfig/datacards'%(en),'%sconfig/cuts'%(en)]
32          
33   print configs
34   config = BetterConfigParser()
# Line 43 | Line 42 | shutil.copyfile(os.path.basename(btagLib
42   shutil.copyfile('/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)),btagLibrary)
43   os.chdir(submitDir)
44   logPath = config.get("Directories","logpath")
45 < repDict = {'en':en,'logpath':logPath,'job':''}
45 > #check if the logPath exist. If not exit
46 > if( not os.path.isdir(logPath) ):
47 >        print 'ERROR: ' + logPath + ': dir not found.'
48 >        print 'ERROR: Create it before submitting '
49 >        print 'Exit'
50 >        sys.exit(-1)
51 >
52 > repDict = {'en':en,'logpath':logPath,'job':'','task':opts.task,'queue': 'all.q'}
53   def submit(job,repDict):
54          repDict['job'] = job
55 <        command = 'qsub -V -cwd -q all.q -N %(job)s_%(en)s -o %(logpath)s/%(job)s_%(en)s.out -e %(logpath)s/%(job)s_%(en)s.err runAll.sh %(job)s %(en)s ' %(repDict) + opts.task
55 >        command = 'qsub -V -cwd -q %(queue)s -N %(job)s_%(en)s%(task)s -o %(logpath)s/%(job)s_%(en)s_%(task)s.out -e %(logpath)s/%(job)s_%(en)s_%(task)s.err runAll.sh %(job)s %(en)s ' %(repDict) + opts.task
56          print command
57          subprocess.call([command], shell=True)
58  
59   if opts.task == 'dc':
60 <    DC_vars = config.items('Limit')
60 >    #DC_vars = config.items('Limit')
61 >    DC_vars= (config.get('LimitGeneral','List')).split(',')
62 >    print DC_vars
63 >
64   if opts.task == 'plot':
65 <    Plot_vars= config.items('Plot')
65 >    Plot_vars= (config.get('Plot_general','List')).split(',')
66  
67   if not opts.task == 'prep':
68      path = config.get("Directories","samplepath")
69 <    infofile = open(path+'/env/samples.info','r')
70 <    info = pickle.load(infofile)
62 <    infofile.close()
63 <
69 >    samplesinfo = config.get("Directories","samplesinfo")
70 >    info = parse_info(samplesinfo,path)
71  
72   if opts.task == 'plot':
73 +    repDict['queue'] = 'all.q'
74      for item in Plot_vars:
75 <        if 'ZH%s'%opts.mass in item[0]:
68 <            submit(item[0],repDict)
69 <        elif opts.mass == '' and 'ZH' in item[0]:
70 <            submit(item[0],repDict)
75 >        submit(item,repDict)
76  
77   elif opts.task == 'dc':
78 +    repDict['queue'] = 'all.q'
79      for item in DC_vars:
80 <        if 'ZH%s'%opts.mass in item[0] and opts.tag in item[0]:
81 <            submit(item[0],repDict)
82 <        elif 'ZH' in item[0] and opts.tag in item[0] and opts.mass == '*':
83 <            submit(item[0],repDict)
80 >        if 'ZH%s'%opts.mass in item:
81 >            submit(item,repDict)
82 >        elif 'ZH' in item and opts.mass == 'all':
83 >            submit(item,repDict)
84 >            
85   elif opts.task == 'prep':
86      submit('prepare',repDict)
87  
88 < elif opts.task == 'eval' or opts.task == 'sys':
88 > elif opts.task == 'eval' or opts.task == 'sys' or opts.task == 'syseval':
89      if ( opts.samples == ""):
90          for job in info:
91              submit(job.name,repDict)
92      else:
93          for sample in samplesList:
94              submit(sample,repDict)
95 <            
95 >
96 > os.system('qstat')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines