17 |
|
parser = OptionParser() |
18 |
|
parser = set_commandline_arguments(parser) |
19 |
|
|
20 |
+ |
parser.remove_option("-c") |
21 |
+ |
parser.remove_option("-n") |
22 |
+ |
parser.remove_option("-e") |
23 |
+ |
parser.remove_option("-r") |
24 |
+ |
parser.remove_option("-d") |
25 |
+ |
parser.remove_option("--2D") |
26 |
+ |
|
27 |
|
|
28 |
|
parser.add_option("--hist", action="store_true", dest="plot_hist", default=False, |
29 |
|
help="plot as hollow histograms instead of error bar crosses") |
38 |
|
if arguments.localConfig: |
39 |
|
sys.path.insert(0,os.getcwd()) |
40 |
|
exec("from " + arguments.localConfig.rstrip('.py') + " import *") |
41 |
< |
print arguments.localConfig.rstrip('.py') |
41 |
> |
|
42 |
|
|
43 |
|
outputFileName = "simple_plot.root" |
44 |
|
if arguments.outputFileName: |
45 |
|
outputFileName = arguments.outputFileName |
46 |
|
|
47 |
|
|
41 |
– |
condor_dir = set_condor_output_dir(arguments) |
42 |
– |
|
43 |
– |
|
44 |
– |
if arguments.normalizeToData and arguments.normalizeToUnitArea: |
45 |
– |
print "Conflicting normalizations requsted, will normalize to unit area" |
46 |
– |
arguments.normalizeToData = False |
47 |
– |
if arguments.normalizeToData and arguments.noStack: |
48 |
– |
print "You have asked to scale non-stacked backgrounds to data. This is a very strange request. Will normalize to unit area instead" |
49 |
– |
arguments.normalizeToData = False |
50 |
– |
arguments.normalizeToUnitArea = True |
51 |
– |
|
48 |
|
if arguments.plot_hist: |
49 |
|
plotting_options = plotting_options + "HIST" |
50 |
|
|
51 |
|
|
56 |
– |
|
52 |
|
from ROOT import TFile, gROOT, gStyle, gDirectory, TStyle, THStack, TH1F, TCanvas, TString, TLegend, TArrow, THStack, TIter, TKey, TPaveLabel |
53 |
|
sys.argv = [] |
54 |
|
gROOT.SetBatch() |
68 |
|
if histogram['dataset'] not in datasets_needed: |
69 |
|
datasets_needed.append(histogram['dataset']) |
70 |
|
|
76 |
– |
weight = intLumi / 10000.0 |
77 |
– |
for dataset in datasets_needed: |
78 |
– |
|
79 |
– |
dataset_file = "%s/%s.root" % (condor_dir,dataset) |
80 |
– |
if types[dataset] != "data": |
81 |
– |
os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", weight)) |
82 |
– |
else: |
83 |
– |
os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", 1.0)) |
84 |
– |
|
71 |
|
|
72 |
|
Legend = TLegend(0.70,0.65,0.9,0.9) |
73 |
|
Legend.SetBorderSize(0) |
81 |
|
Histograms = [] |
82 |
|
for histogram in input_histograms: |
83 |
|
|
84 |
< |
fileName = condor_dir + "/" + histogram['dataset'] + ".root" |
84 |
> |
fileName = "condor/" + histogram['condor_dir'] + "/" + histogram['dataset'] + ".root" |
85 |
|
if not os.path.exists(fileName): |
86 |
|
continue |
87 |
|
inputFile = TFile(fileName) |
93 |
|
inputFile.Close() |
94 |
|
|
95 |
|
|
96 |
< |
Histogram.SetTitle("") |
96 |
> |
fullTitle = Histogram.GetTitle() |
97 |
> |
splitTitle = fullTitle.split(":") |
98 |
> |
# print splitTitle |
99 |
> |
Histogram.SetTitle(splitTitle[1].lstrip(" ")) |
100 |
> |
|
101 |
|
Histogram.SetMarkerColor(histogram['color']) |
102 |
|
Histogram.SetLineColor(histogram['color']) |
103 |
|
Histogram.SetLineWidth(line_width) |
104 |
|
Histogram.SetFillStyle(0) |
105 |
|
if(arguments.normalizeToUnitArea and Histogram.Integral() > 0): |
106 |
|
Histogram.Scale(1./Histogram.Integral()) |
107 |
+ |
if arguments.rebinFactor: |
108 |
+ |
RebinFactor = int(arguments.rebinFactor) |
109 |
+ |
if Histogram.GetNbinsX() >= RebinFactor*10: |
110 |
+ |
Histogram.Rebin(RebinFactor) |
111 |
+ |
|
112 |
|
|
113 |
|
currentMax = Histogram.GetMaximum() |
114 |
|
if currentMax > finalMax: |
118 |
|
Histograms.append(Histogram) |
119 |
|
|
120 |
|
|
121 |
< |
Canvas = TCanvas("plot") |
121 |
> |
Canvas = TCanvas(outputFileName.rstrip('.root')) |
122 |
|
|
123 |
|
counter = 0 |
124 |
|
for Histogram in Histograms: |
149 |
|
print "Saved file: " + pdfFileName |
150 |
|
|
151 |
|
|
157 |
– |
for dataset in datasets_needed: |
158 |
– |
dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) |
159 |
– |
os.remove(dataset_file) |
160 |
– |
|
152 |
|
outputFile.Close() |
153 |
|
print "Saved plot in file: " + outputFileName |