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.5 by bortigno, Thu Sep 20 12:52:44 2012 UTC vs.
Revision 1.9 by peller, Fri Sep 28 14:15:01 2012 UTC

# Line 1 | Line 1
1   #! /usr/bin/env python
2 < import os,time,subprocess
3 < #energy='8TeV'
4 < energy='7TeV'
2 > import os,shutil,sys,pickle,subprocess,ROOT
3 > from optparse import OptionParser
4 > from BetterConfigParser import BetterConfigParser
5 > from samplesclass import sample
6 > import getpass
7  
8 < def submit(job,en):
9 <        command = 'qsub -V -cwd -q all.q -N %s_%s -o /shome/bortigno/VHbbAnalysis/VHbbTest/LOG/%s.out -e /shome/bortigno/VHbbAnalysis/VHbbTest/LOG/%s.err runAll.sh %s %s' %(job,en,job,job,job,en)
8 > parser = OptionParser()
9 > parser.add_option("-T", "--tag", dest="tag", default="",
10 >                      help="Tag to run the analysis with, example '8TeV' uses config8TeV and pathConfig8TeV to run the analysis")
11 > parser.add_option("-J", "--task", dest="task", default="",
12 >                      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. ")
13 > parser.add_option("-M", "--mass", dest="mass", default="125",
14 >                      help="Mass for DC or Plots, 110...135")
15 >
16 > (opts, args) = parser.parse_args(sys.argv)
17 > if opts.tag == "":
18 >        print "Please provide tag to run the analysis with, example '-T 8TeV' uses config8TeV and pathConfig8TeV to run the analysis."
19 >        sys.exit(123)
20 >
21 > if opts.task == "":
22 >    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"
23 >    sys.exit(123)
24 >
25 > en = opts.tag
26 > configs = ['config%s'%(en),'pathConfig%s'%(en)]
27 > print configs
28 > config = BetterConfigParser()
29 > config.read(configs)
30 > btagLibrary = config.get('BTagReshaping','library')
31 > submitDir = os.getcwd()
32 > os.chdir(os.path.dirname(btagLibrary))
33 > if not os.path.exists(btagLibrary):
34 >    ROOT.gROOT.LoadMacro('%s+'%btagLibrary.replace('_h.so','.h'))
35 > shutil.copyfile(os.path.basename(btagLibrary),'/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)))
36 > shutil.copyfile('/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)),btagLibrary)
37 > os.chdir(submitDir)
38 > logPath = config.get("Directories","logpath")
39 > repDict = {'en':en,'logpath':logPath,'job':''}
40 > def submit(job,repDict):
41 >        repDict['job'] = job
42 >        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
43          print command
44          subprocess.call([command], shell=True)
45  
46 < #theJobs = ['ZH110','ZH125','ZH120','DY','ZH115','ZH130','ZH135','ZZ','DY120','Zmm','ST_s','ST_t','TT','Zee','STbar_s','STbar_t','WZ','WW','STbar_tW','ST_tW']
47 < #if energy=='8TeV':
48 < #       theJobs = ['ZH110','ZH125','ZH120','DY','DY5070','DY70100','DY100','ZH115','ZH130','ZH135','ZZ','DY120','Zmm','ST_s','ST_t','TT','Zee','STbar_s','STbar_t','WZ','WW','STbar_tW','ST_tW']
49 < theJobs = ["ZH120"]
50 <
51 < for job in theJobs:
52 <        submit(job,energy)
53 <        #time.sleep(10)
46 > if opts.task == 'dc':
47 >    DC_vars = config.items('Limit')
48 > if opts.task == 'plot':
49 >    Plot_vars= config.items('Plot')
50 >
51 > path = config.get("Directories","samplepath")
52 > infofile = open(path+'/env/samples.info','r')
53 > info = pickle.load(infofile)
54 > infofile.close()
55 >
56 >
57 > if opts.task == 'plot':
58 >    for item in Plot_vars:
59 >        if 'ZH%s'%opts.mass in item[0]:
60 >            submit(item[0],repDict)
61 >        elif opts.mass == '' and 'ZH' in item[0]:
62 >            submit(item[0],repDict)
63 >
64 > elif opts.task == 'dc':
65 >    for item in DC_vars:
66 >        if 'ZH%s'%opts.mass in item[0] and opts.tag in item[0]:
67 >            submit(item[0],repDict)
68 >        elif 'ZH' in item[0] and opts.tag in item[0] and opts.mass == '*':
69 >            submit(item[0],repDict)
70 > elif opts.task == 'prep':
71 >    submit('prepare',repDict)
72 >
73 > elif opts.task == 'eval' or opts.task == 'sys':
74 >    for job in info:
75 >        submit(job.name,repDict)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines