ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RootMacros/overlayHists.py
(Generate patch)

Comparing UserCode/RootMacros/overlayHists.py (file contents):
Revision 1.3 by klukas, Thu Nov 19 19:32:52 2009 UTC vs.
Revision 1.5 by klukas, Thu Nov 19 21:06:14 2009 UTC

# Line 20 | Line 20 | naming: histograms whose names contain c
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
# Line 39 | Line 39 | if '-h' not in sys.argv:
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
# Line 60 | Line 58 | plot_dir = "%s/%s" % (os.path.abspath('.
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")]
# Line 73 | Line 72 | class RootFile:
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)
# Line 114 | Line 112 | def process_directory(path, files):
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):
# Line 130 | Line 128 | def process_directory(path, 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")
# Line 146 | Line 144 | def process_directory(path, files):
144              
145  
146  
149
147   def counter_generator():
148      k = 0
149      while True:
# Line 156 | Line 153 | next_counter = counter_generator().next
153  
154  
155  
159
156   if __name__ == "__main__":
157      sys.exit(main())
158  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines