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.4 by nmohr, Mon Sep 17 19:20:19 2012 UTC vs.
Revision 1.27 by nmohr, Fri Feb 1 10:47:38 2013 UTC

# Line 1 | Line 1
1   #! /usr/bin/env python
2 < import os,time,subprocess
3 < energy='8TeV'
4 < #energy='7TeV'
2 > from optparse import OptionParser
3 > import sys
4  
5 < def submit(job,en):
6 <        command = 'qsub -cwd -q all.q -N %s_%s -o /shome/nmohr/VHbbAnalysis/LOG/%s.out -e /shome/nmohr/VHbbAnalysis/LOG/%s.err runAll.sh %s %s' %(job,en,job,job,job,en)
5 > parser = OptionParser()
6 > parser.add_option("-T", "--tag", dest="tag", default="",
7 >                      help="Tag to run the analysis with, example '8TeV' uses config8TeV and pathConfig8TeV to run the analysis")
8 > parser.add_option("-J", "--task", dest="task", default="",
9 >                      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). ")
10 > parser.add_option("-M", "--mass", dest="mass", default="125",
11 >                      help="Mass for DC or Plots, 110...135")
12 > parser.add_option("-S","--samples",dest="samples",default="",
13 >                      help="samples you want to run on")
14 >
15 > (opts, args) = parser.parse_args(sys.argv)
16 >
17 > import os,shutil,pickle,subprocess,ROOT
18 > ROOT.gROOT.SetBatch(True)
19 > from myutils import BetterConfigParser, Sample, ParseInfo
20 > import getpass
21 >
22 > if opts.tag == "":
23 >        print "Please provide tag to run the analysis with, example '-T 8TeV' uses config8TeV and pathConfig8TeV to run the analysis."
24 >        sys.exit(123)
25 >
26 > if opts.task == "":
27 >    print "Please provide a task.\n-J prep:\tpreparation of Trees\n-J sys:\t\twrite regression and systematics\n-J eval:\tcreate MVA output\n-J plot:\tproduce Plots\n-J dc:\t\twrite workspaces and datacards"
28 >    sys.exit(123)
29 >
30 > #create the list with the samples to run over
31 > samplesList=opts.samples.split(",")
32 >
33 > en = opts.tag
34 > configs = ['%sconfig/general'%(en),'%sconfig/paths'%(en),'%sconfig/plots'%(en),'%sconfig/training'%(en),'%sconfig/datacards'%(en),'%sconfig/cuts'%(en)]
35 >        
36 > print configs
37 > config = BetterConfigParser()
38 > config.read(configs)
39 > btagLibrary = config.get('BTagReshaping','library')
40 > submitDir = os.getcwd()
41 > os.chdir(os.path.dirname(btagLibrary))
42 > if not os.path.exists(btagLibrary):
43 >    ROOT.gROOT.LoadMacro('%s+'%btagLibrary.replace('_h.so','.h'))
44 > shutil.copyfile(os.path.basename(btagLibrary),'/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)))
45 > shutil.copyfile('/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)),btagLibrary)
46 > os.chdir(submitDir)
47 > logPath = config.get("Directories","logpath")
48 > #check if the logPath exist. If not exit
49 > if( not os.path.isdir(logPath) ):
50 >        print 'ERROR: ' + logPath + ': dir not found.'
51 >        print 'ERROR: Create it before submitting '
52 >        print 'Exit'
53 >        sys.exit(-1)
54 >
55 > repDict = {'en':en,'logpath':logPath,'job':'','task':opts.task,'queue': 'all.q'}
56 > def submit(job,repDict):
57 >        repDict['job'] = job
58 >        command = 'qsub -V -cwd -q %(queue)s -l h_vmem=6G -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
59          print command
60          subprocess.call([command], shell=True)
61  
62 < theJobs = ['ZH110','ZH125','ZH120','DY','ZH115','ZH130','ZH135','ZZ','DY120','Zmm','ST_s','TT','Zee','STbar_s','STbar_t','WZ','WW','STbar_tW','ST_tW']
63 < if energy=='8TeV':
64 <        theJobs = ['ZH110','ZH125','ZH120','DY','DY5070','DY70100','DY100','ZH115','ZH130','ZH135','ZZ','DY120','Zmm','ST_s','TT','Zee','STbar_s','STbar_t','WZ','WW','STbar_tW','ST_tW']
62 > if opts.task == 'dc':
63 >    #DC_vars = config.items('Limit')
64 >    DC_vars= (config.get('LimitGeneral','List')).split(',')
65 >    print DC_vars
66 >
67 > if opts.task == 'plot':
68 >    Plot_vars= (config.get('Plot_general','List')).split(',')
69 >
70 > if not opts.task == 'prep':
71 >    path = config.get("Directories","samplepath")
72 >    samplesinfo = config.get("Directories","samplesinfo")
73 >    info = ParseInfo(samplesinfo,path)
74 >
75 > if opts.task == 'plot':
76 >    repDict['queue'] = 'all.q'
77 >    for item in Plot_vars:
78 >        submit(item,repDict)
79 >
80 > elif opts.task == 'dc':
81 >    repDict['queue'] = 'all.q'
82 >    for item in DC_vars:
83 >        if 'ZH%s'%opts.mass in item:
84 >            submit(item,repDict)
85 >        elif 'ZH' in item and opts.mass == 'all':
86 >            submit(item,repDict)
87 >            
88 > elif opts.task == 'prep':
89 >    submit('prepare',repDict)
90  
91 + elif opts.task == 'eval' or opts.task == 'sys' or opts.task == 'syseval':
92 +    if ( opts.samples == ""):
93 +        for job in info:
94 +            submit(job.name,repDict)
95 +    else:
96 +        for sample in samplesList:
97 +            submit(sample,repDict)
98  
99 < for job in theJobs:
17 <        submit(job,energy)
18 <        #time.sleep(10)
99 > os.system('qstat')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines