5 |
|
from samplesclass import sample |
6 |
|
import getpass |
7 |
|
|
8 |
– |
|
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 |
+ |
parser.add_option("-S","--samples",dest="samples",default="", |
16 |
+ |
help="samples you want to run on") |
17 |
+ |
|
18 |
|
|
19 |
|
(opts, args) = parser.parse_args(sys.argv) |
20 |
|
if opts.tag == "": |
21 |
|
print "Please provide tag to run the analysis with, example '-T 8TeV' uses config8TeV and pathConfig8TeV to run the analysis." |
22 |
|
sys.exit(123) |
23 |
+ |
|
24 |
+ |
if opts.task == "": |
25 |
+ |
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" |
26 |
+ |
sys.exit(123) |
27 |
+ |
|
28 |
+ |
#create the list with the samples to run over |
29 |
+ |
samplesList=opts.samples.split(",") |
30 |
+ |
|
31 |
|
en = opts.tag |
32 |
|
configs = ['config%s'%(en),'pathConfig%s'%(en)] |
33 |
+ |
|
34 |
|
print configs |
35 |
|
config = BetterConfigParser() |
36 |
|
config.read(configs) |
43 |
|
shutil.copyfile('/scratch/%s/%s'%(getpass.getuser(),os.path.basename(btagLibrary)),btagLibrary) |
44 |
|
os.chdir(submitDir) |
45 |
|
logPath = config.get("Directories","logpath") |
46 |
< |
repDict = {'en':en,'logpath':logPath,'job':''} |
46 |
> |
#check if the logPath exist. If not exit |
47 |
> |
if( not os.path.isdir(logPath) ): |
48 |
> |
print 'ERROR: ' + logPath + ': dir not found.' |
49 |
> |
print 'ERROR: Create it before submitting ' |
50 |
> |
print 'Exit' |
51 |
> |
sys.exit(-1) |
52 |
> |
|
53 |
> |
repDict = {'en':en,'logpath':logPath,'job':'','task':opts.task,'queue': 'all.q'} |
54 |
|
def submit(job,repDict): |
55 |
|
repDict['job'] = job |
56 |
< |
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 |
56 |
> |
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 |
57 |
|
print command |
58 |
|
subprocess.call([command], shell=True) |
59 |
|
|
60 |
< |
path = config.get("Directories","samplepath") |
61 |
< |
infofile = open(path+'/env/samples.info','r') |
62 |
< |
info = pickle.load(infofile) |
63 |
< |
infofile.close() |
60 |
> |
if opts.task == 'dc': |
61 |
> |
DC_vars = config.items('Limit') |
62 |
> |
if opts.task == 'plot': |
63 |
> |
Plot_vars= (config.get('Plot_general','List')).split(',') |
64 |
> |
|
65 |
> |
if not opts.task == 'prep': |
66 |
> |
path = config.get("Directories","samplepath") |
67 |
> |
infofile = open(path+'/env/samples.info','r') |
68 |
> |
info = pickle.load(infofile) |
69 |
> |
infofile.close() |
70 |
> |
|
71 |
> |
|
72 |
> |
if opts.task == 'plot': |
73 |
> |
repDict['queue'] = 'short.q' |
74 |
> |
for item in Plot_vars: |
75 |
> |
submit(item,repDict) |
76 |
> |
|
77 |
> |
elif opts.task == 'dc': |
78 |
> |
repDict['queue'] = 'short.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) |
84 |
> |
|
85 |
> |
elif opts.task == 'prep': |
86 |
> |
submit('prepare',repDict) |
87 |
|
|
88 |
< |
for job in info: |
89 |
< |
submit(job.name,repDict) |
88 |
> |
elif opts.task == 'eval' or opts.task == 'sys': |
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 |
> |
|