ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/Configuration/python/processingUtilities.py
Revision: 1.8
Committed: Wed Mar 13 09:27:52 2013 UTC (12 years, 2 months ago) by lantonel
Content type: text/x-python
Branch: MAIN
Changes since 1.7: +8 -8 lines
Log Message:
switched back to optparse, since CMSSW_5_X_X has an older version of python

File Contents

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