10 |
|
from OSUT3Analysis.Configuration.processingUtilities import * |
11 |
|
|
12 |
|
|
13 |
– |
|
14 |
– |
|
15 |
– |
|
16 |
– |
|
13 |
|
##set default plotting options |
14 |
|
line_width = 2 |
15 |
|
plotting_options = "" |
18 |
|
parser = set_commandline_arguments(parser) |
19 |
|
|
20 |
|
|
21 |
< |
parser.add_argument("--hist", action="store_true", dest="plot_hist", default=False, |
21 |
> |
parser.add_option("--hist", action="store_true", dest="plot_hist", default=False, |
22 |
|
help="plot as hollow histograms instead of error bar crosses") |
23 |
< |
parser.add_argument("--line-width", dest="line_width", |
23 |
> |
parser.add_option("--line-width", dest="line_width", |
24 |
|
help="set line width (default is 2)") |
25 |
+ |
parser.add_option("--pdf", action="store_true", dest="plot_savePdf", default=False, |
26 |
+ |
help="save plot as pdf in addition") |
27 |
|
|
28 |
|
|
29 |
|
(arguments, args) = parser.parse_args() |
30 |
|
|
31 |
|
if arguments.localConfig: |
32 |
< |
sys.path.append(os.getcwd()) |
32 |
> |
sys.path.insert(0,os.getcwd()) |
33 |
|
exec("from " + arguments.localConfig.rstrip('.py') + " import *") |
34 |
+ |
print arguments.localConfig.rstrip('.py') |
35 |
|
|
36 |
|
outputFileName = "simple_plot.root" |
37 |
|
if arguments.outputFileName: |
68 |
|
|
69 |
|
outputFile = TFile(outputFileName, "RECREATE") |
70 |
|
|
72 |
– |
|
71 |
|
datasets_needed = [] |
72 |
|
for histogram in input_histograms: |
73 |
|
if histogram['dataset'] not in datasets_needed: |
75 |
|
|
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)) |
102 |
|
if inputFile.IsZombie() or not inputFile.GetNkeys(): |
103 |
|
continue |
104 |
|
|
106 |
– |
print "OSUAnalysis/"+histogram['channel']+"/"+histogram['name'] |
105 |
|
Histogram = inputFile.Get("OSUAnalysis/"+histogram['channel']+"/"+histogram['name']).Clone() |
106 |
|
Histogram.SetDirectory(0) |
107 |
|
inputFile.Close() |
129 |
|
for Histogram in Histograms: |
130 |
|
if counter is 0: |
131 |
|
Histogram.SetMaximum(1.1*finalMax) |
132 |
+ |
Histogram.SetMinimum(0.0001) |
133 |
|
Histogram.Draw(plotting_options) |
134 |
|
|
135 |
|
else: |
147 |
|
|
148 |
|
outputFile.cd() |
149 |
|
Canvas.Write() |
150 |
< |
|
150 |
> |
|
151 |
> |
if arguments.plot_savePdf: |
152 |
> |
pdfFileName = outputFileName.replace(".root", ".pdf") |
153 |
> |
Canvas.SaveAs(pdfFileName) |
154 |
> |
print "Saved file: " + pdfFileName |
155 |
|
|
156 |
|
|
157 |
|
for dataset in datasets_needed: |
159 |
|
os.remove(dataset_file) |
160 |
|
|
161 |
|
outputFile.Close() |
162 |
+ |
print "Saved plot in file: " + outputFileName |