ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/submitThem.py
Revision: 1.7
Committed: Fri Sep 21 14:50:48 2012 UTC (12 years, 7 months ago) by nmohr
Content type: text/x-python
Branch: MAIN
Changes since 1.6: +11 -1 lines
Log Message:
Add btag compilation, copy

File Contents

# Content
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
6 import getpass
7
8
9 parser = OptionParser()
10 parser.add_option("-T", "--tag", dest="tag", default="",
11 help="Tag to run the analysis with, example '8TeV' uses config8TeV and pathConfig8TeV to run the analysis")
12
13 (opts, args) = parser.parse_args(sys.argv)
14 if opts.tag == "":
15 print "Please provide tag to run the analysis with, example '-T 8TeV' uses config8TeV and pathConfig8TeV to run the analysis."
16 sys.exit(123)
17 en = opts.tag
18 configs = ['config%s'%(en),'pathConfig%s'%(en)]
19 print configs
20 config = BetterConfigParser()
21 config.read(configs)
22 btagLibrary = config.get('BTagReshaping','library')
23 submitDir = os.getcwd()
24 os.chdir(os.path.dirname(btagLibrary))
25 if not os.path.exists(btagLibrary):
26 ROOT.gROOT.LoadMacro('%s+'%btagLibrary.replace('_h.so','.h'))
27 shutil.copyfile(os.path.basename(btagLibrary),'/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)))
28 shutil.copyfile('/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)),btagLibrary)
29 os.chdir(submitDir)
30 logPath = config.get("Directories","logpath")
31 repDict = {'en':en,'logpath':logPath,'job':''}
32 def submit(job,repDict):
33 repDict['job'] = job
34 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
35 print command
36 subprocess.call([command], shell=True)
37
38 path = config.get("Directories","samplepath")
39 infofile = open(path+'/env/samples.info','r')
40 info = pickle.load(infofile)
41 infofile.close()
42
43 for job in info:
44 submit(job.name,repDict)