1 |
lantonel |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
import os
|
3 |
|
|
import sys
|
4 |
|
|
import datetime
|
5 |
|
|
from optparse import OptionParser
|
6 |
|
|
|
7 |
lantonel |
1.2 |
from OSUT3Analysis.Configuration.configurationOptions import *
|
8 |
|
|
|
9 |
lantonel |
1.1 |
|
10 |
|
|
def split_composite_datasets(datasets):
|
11 |
|
|
for dataset in datasets:
|
12 |
|
|
if dataset in composite_dataset_definitions:
|
13 |
|
|
for component_dataset in composite_dataset_definitions[dataset]:
|
14 |
|
|
datasets.insert(datasets.index(dataset),component_dataset)
|
15 |
|
|
datasets.remove(dataset)
|
16 |
|
|
return datasets
|
17 |
|
|
|
18 |
|
|
def get_composite_datasets(datasets):
|
19 |
|
|
composite_datasets = []
|
20 |
|
|
for dataset in datasets:
|
21 |
|
|
if dataset in composite_dataset_definitions:
|
22 |
|
|
composite_datasets.append(dataset)
|
23 |
|
|
return composite_datasets
|
24 |
|
|
|
25 |
|
|
def set_condor_submit_dir(options):
|
26 |
|
|
if options.condorDir:
|
27 |
|
|
condor_dir = "condor/%s" % options.condorDir
|
28 |
|
|
else:
|
29 |
|
|
now = datetime.datetime.now()
|
30 |
|
|
date_hash = now.strftime("%Y_%m_%d_%H:%M:%S")
|
31 |
|
|
condor_dir = "condor/condor_%s" % date_hash
|
32 |
lantonel |
1.3 |
#print "Condor submit directory set to ",condor_dir
|
33 |
lantonel |
1.1 |
return condor_dir
|
34 |
|
|
|
35 |
|
|
def set_condor_output_dir(options):
|
36 |
|
|
if options.condorDir:
|
37 |
|
|
condor_dir = "condor/%s" % options.condorDir
|
38 |
|
|
else: #get most recent condor submission directory
|
39 |
|
|
dir_list = []
|
40 |
|
|
for directory in os.listdir("./condor/"):
|
41 |
|
|
if directory.find("condor_") is not -1:
|
42 |
|
|
dir_list.append(directory)
|
43 |
|
|
if len(dir_list) is 0:
|
44 |
|
|
sys.exit("Cannot find last condor working directory")
|
45 |
|
|
dir_list.sort(reverse=True)
|
46 |
|
|
condor_dir = "condor/%s" % dir_list[0]
|
47 |
lantonel |
1.3 |
#print "Condor output directory set to ",condor_dir
|
48 |
lantonel |
1.1 |
return condor_dir
|
49 |
|
|
|
50 |
|
|
def set_commandline_arguments(parser):
|
51 |
|
|
parser.add_option("-l", "--localConfig", dest="localConfig",
|
52 |
|
|
help="local configuration file")
|
53 |
|
|
|
54 |
|
|
parser.add_option("-c", "--condorDir", dest="condorDir",
|
55 |
|
|
help="condor output directory")
|
56 |
lantonel |
1.4 |
parser.add_option("-n", "--normalize", action="store_true", dest="normalizeToData", default=False,
|
57 |
lantonel |
1.3 |
help="normalize total background MC yield to the data")
|
58 |
lantonel |
1.4 |
parser.add_option("-u", "--unit-area", action="store_true", dest="normalizeToUnitArea", default=False,
|
59 |
|
|
help="normalize all samples to unit area (useful to compare shapes)")
|
60 |
lantonel |
1.1 |
|
61 |
|
|
return parser
|
62 |
|
|
|
63 |
|
|
def get_short_name(dataset):
|
64 |
|
|
for key in dataset_names:
|
65 |
|
|
if dataset_names[key] == dataset:
|
66 |
|
|
return key;
|
67 |
|
|
return "Unknown"
|