20 |
|
'Logy': y-axis will be on log scale""" |
21 |
|
|
22 |
|
## Define colors |
23 |
< |
rgbcolors = [[82, 124, 219], |
24 |
< |
[145, 83, 207], |
25 |
< |
[231, 139, 77], |
26 |
< |
[114, 173, 117], |
27 |
< |
[67, 77, 83]] |
23 |
> |
rgbvals = [[82, 124, 219], |
24 |
> |
[145, 83, 207], |
25 |
> |
[231, 139, 77], |
26 |
> |
[114, 173, 117], |
27 |
> |
[67, 77, 83]] |
28 |
|
|
29 |
|
## Import python libraries |
30 |
|
import sys |
39 |
|
if os.path.exists('rootlogon.C'): ROOT.gROOT.Macro('rootlogon.C') |
40 |
|
sys.argv.remove('-b') |
41 |
|
ROOT.gErrorIgnoreLevel = ROOT.kWarning |
42 |
< |
colors = [] |
43 |
< |
for rgb in rgbcolors: |
44 |
< |
colors.append(ROOT.TColor.GetColor(rgb[0], rgb[1], rgb[2])) |
42 |
> |
colors = [ROOT.TColor.GetColor(rgb[0], rgb[1], rgb[2]) for rgb in rgbvals] |
43 |
|
c1 = ROOT.TCanvas() |
44 |
|
|
45 |
|
## Parse options |
58 |
|
regex = re.compile(options.match) |
59 |
|
|
60 |
|
|
61 |
+ |
|
62 |
|
class RootFile: |
63 |
|
def __init__(self, file_name): |
64 |
|
self.name = file_name[0:file_name.find(".root")] |
72 |
|
|
73 |
|
|
74 |
|
def main(): |
75 |
< |
files = [] |
77 |
< |
for filename in arguments: files.append(RootFile(filename)) |
75 |
> |
files = [RootFile(filename) for filename in arguments] |
76 |
|
if len(files) == 0: |
77 |
|
parser.print_help() |
78 |
|
sys.exit(0) |
112 |
|
if "Norm" in name or options.normalize: |
113 |
|
y_title = "Fraction of Events in Bin" |
114 |
|
hist.Draw() |
117 |
– |
hists = [] |
115 |
|
stack = ROOT.THStack("st%.3i" % int(counter), title) |
116 |
< |
legend = ROOT.TLegend(0.65, 0.77, 0.87, 0.89) |
116 |
> |
legend_height = 0.04 * len(files) + 0.02 |
117 |
> |
legend = ROOT.TLegend(0.65, 0.89 - legend_height, 0.87, 0.89) |
118 |
|
c1.SetLogx("Logx" in name) |
119 |
|
c1.SetLogy("Logy" in name) |
120 |
|
for i, file in enumerate(files): |
128 |
|
hist.SetMarkerStyle(i + 1) |
129 |
|
if "Norm" in name or options.normalize: |
130 |
|
integral = hist.Integral() |
131 |
< |
hist.Scale(1 / integral) |
131 |
> |
hist.Scale(1. / integral) |
132 |
|
stack.Add(hist) |
133 |
|
legend.AddEntry(hist) |
134 |
|
stack.Draw("nostack p H") |
144 |
|
|
145 |
|
|
146 |
|
|
149 |
– |
|
147 |
|
def counter_generator(): |
148 |
|
k = 0 |
149 |
|
while True: |
153 |
|
|
154 |
|
|
155 |
|
|
159 |
– |
|
156 |
|
if __name__ == "__main__": |
157 |
|
sys.exit(main()) |
158 |
|
|