1 |
|
#!/usr/bin/env python |
2 |
|
import os |
3 |
+ |
import re |
4 |
|
import sys |
5 |
+ |
import math |
6 |
|
import datetime |
7 |
|
from optparse import OptionParser |
8 |
< |
from OSUT3Analysis.Configuration.configurationOptions import * |
8 |
> |
#from OSUT3Analysis.Configuration.configurationOptions import * |
9 |
|
|
10 |
< |
|
9 |
< |
def split_composite_datasets(datasets): |
10 |
> |
def split_composite_datasets(datasets, composite_dataset_definitions): |
11 |
|
for dataset in datasets: |
12 |
|
if dataset in composite_dataset_definitions: |
13 |
|
for component_dataset in composite_dataset_definitions[dataset]: |
15 |
|
datasets.remove(dataset) |
16 |
|
return datasets |
17 |
|
|
18 |
< |
def get_composite_datasets(datasets): |
18 |
> |
def get_composite_datasets(datasets, composite_dataset_definitions): |
19 |
|
composite_datasets = [] |
20 |
|
for dataset in datasets: |
21 |
|
if dataset in composite_dataset_definitions: |
57 |
|
help="specify an output file name for the histogram file, default is 'stacked_histograms.root'") |
58 |
|
parser.add_option("-t", "--no-weights", action="store_true", dest="noWeights", default=False, |
59 |
|
help="do not apply cross section weights") |
60 |
+ |
parser.add_option("-q", "--quickMerge", action="store_true", dest="quickMerge", default=False, |
61 |
+ |
help="do merge without making cutflow or plots") |
62 |
|
|
63 |
|
|
64 |
|
#### Histogram Formatting Options |
73 |
|
help="draw (data-MC)/MC plots below all 1D histograms") |
74 |
|
parser.add_option("-d", "--diff", action="store_true", dest="makeDiffPlots", default=False, |
75 |
|
help="draw data-MC plots below all 1D histograms") |
76 |
< |
parser.add_option("-b", "--rebin", dest="rebinFactor", |
76 |
> |
parser.add_option("-b", "--rebin", dest="rebinFactor", |
77 |
|
help="Rebin all the histograms which will have at least 10 bins after rebinning") |
78 |
|
parser.add_option("--2D", action="store_true", dest="draw2DPlots", default=False, |
79 |
|
help="draw stacked 2D histograms") |
80 |
+ |
parser.add_option("-y", "--yields", action="store_true", dest="printYields", default=False, |
81 |
+ |
help="Include the yield of each source in the legend") |
82 |
+ |
parser.add_option("-p", "--pdfs", action="store_true", dest="savePDFs", default=False, |
83 |
+ |
help="Save pdfs files for all plots made") |
84 |
|
|
85 |
|
|
86 |
|
return parser |
87 |
|
|
88 |
< |
def get_short_name(dataset): |
88 |
> |
def get_short_name(dataset, dataset_names): |
89 |
|
for key in dataset_names: |
90 |
|
if dataset_names[key] == dataset: |
91 |
< |
return key; |
91 |
> |
return key |
92 |
|
return "Unknown" |
93 |
+ |
|
94 |
+ |
def stop_ctau (dataset): |
95 |
+ |
if not re.match (r"stop[^_]*to[^_]*_[^_]*mm.*", dataset): |
96 |
+ |
return 0.0 |
97 |
+ |
return float (re.sub (r"stop[^_]*to[^_]*_([^_]*)mm.*", r"\1", dataset)) |
98 |
+ |
|
99 |
+ |
def source_stop_ctau (ctau): |
100 |
+ |
return int (math.pow (10.0, math.ceil (math.log10 (ctau)))) |
101 |
+ |
|
102 |
+ |
def add_stops (options, masses, ctaus, bottomBranchingRatios = []): |
103 |
+ |
if not bottomBranchingRatios: |
104 |
+ |
bottomBranchingRatios.append (50.0) |
105 |
+ |
for mass in masses: |
106 |
+ |
for ctau in ctaus: |
107 |
+ |
for bottomBranchingRatio in bottomBranchingRatios: |
108 |
+ |
datasetName = 'stop' + str (mass) + "_" + str (ctau) + "mm_br" + str (int (bottomBranchingRatio)) |
109 |
+ |
bottomDatasetName = 'stop' + str (mass) + "toBl_" + str (ctau) + "mm" |
110 |
+ |
sourceBottomDatasetName = 'stop' + str (mass) + "toBl_" + str (source_stop_ctau (ctau)) + "mm" |
111 |
+ |
topDatasetName = 'stop' + str (mass) + "toTnu_" + str (ctau) + "mm" |
112 |
+ |
sourceTopDatasetName = 'stop' + str (mass) + "toTnu_" + str (source_stop_ctau (ctau)) + "mm" |
113 |
+ |
mixedDatasetName = 'stop' + str (mass) + "toBT_" + str (ctau) + "mm" |
114 |
+ |
sourceMixedDatasetName = 'stop' + str (mass) + "toBT_" + str (source_stop_ctau (ctau)) + "mm" |
115 |
+ |
|
116 |
+ |
options['datasets'].append (datasetName) |
117 |
+ |
bottomBranchingRatio /= 100.0 |
118 |
+ |
options['composite_dataset_definitions'][datasetName] = { |
119 |
+ |
bottomDatasetName : bottomBranchingRatio * bottomBranchingRatio, |
120 |
+ |
topDatasetName : (1 - bottomBranchingRatio) * (1 - bottomBranchingRatio), |
121 |
+ |
mixedDatasetName : (1 - bottomBranchingRatio * bottomBranchingRatio - (1 - bottomBranchingRatio) * (1 - bottomBranchingRatio)) |
122 |
+ |
} |
123 |
+ |
options['dataset_names'][bottomDatasetName] = options['dataset_names'][sourceBottomDatasetName] |
124 |
+ |
options['dataset_names'][topDatasetName] = options['dataset_names'][sourceTopDatasetName] |
125 |
+ |
options['dataset_names'][mixedDatasetName] = options['dataset_names'][sourceMixedDatasetName] |
126 |
+ |
options['nJobs'][bottomDatasetName] = 1 |
127 |
+ |
options['nJobs'][topDatasetName] = 1 |
128 |
+ |
options['nJobs'][mixedDatasetName] = 1 |
129 |
+ |
options['maxEvents'][bottomDatasetName] = -1 |
130 |
+ |
options['maxEvents'][topDatasetName] = -1 |
131 |
+ |
options['maxEvents'][mixedDatasetName] = -1 |
132 |
+ |
options['types'][datasetName] = "signalMC" |
133 |
+ |
options['types'][bottomDatasetName] = "signalMC" |
134 |
+ |
options['types'][topDatasetName] = "signalMC" |
135 |
+ |
options['types'][mixedDatasetName] = "signalMC" |
136 |
+ |
options['labels'][datasetName] = str (mass) + " GeV stop (#LTc#tau#GT = " + str (ctau) + " mm)" |
137 |
+ |
options['labels'][bottomDatasetName] = "#tilde{t}#tilde{t}#rightarrowbbll (#LTc#tau#GT = " + str (ctau) + " mm)" |
138 |
+ |
options['labels'][topDatasetName] = "#tilde{t}#tilde{t}#rightarrowtt#nu#nu (#LTc#tau#GT = " + str (ctau) + " mm)" |
139 |
+ |
options['labels'][mixedDatasetName] = "#tilde{t}#tilde{t}#rightarrowbtl#nu (#LTc#tau#GT = " + str (ctau) + " mm)" |