CMS 3D CMS Logo

utilities.py
Go to the documentation of this file.
1 """
2 Utilities for rootplot including histogram classes.
3 """
4 from __future__ import print_function
5 
6 __license__ = '''\
7 Copyright (c) 2009-2010 Jeff Klukas <klukas@wisc.edu>
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 '''
27 
28 ################ Import python libraries
29 
30 import math
31 import ROOT
32 import re
33 import copy
34 import array
35 import os.path
36 import sys
37 import fnmatch
38 from random import gauss
39 
40 ################ Define classes
41 
42 class Hist2D(object):
43  """A container to hold the parameters from a 2D ROOT histogram."""
44  def __init__(self, hist, label="__nolabel__", title=None,
45  xlabel=None, ylabel=None):
46  try:
47  if not hist.InheritsFrom("TH2"):
48  raise TypeError("%s does not inherit from TH2" % hist)
49  except:
50  raise TypeError("%s is not a ROOT object" % hist)
51  self.rootclass = hist.ClassName()
52  self.name = hist.GetName()
53  self.nbinsx = nx = hist.GetNbinsX()
54  self.nbinsy = ny = hist.GetNbinsY()
55  self.binlabelsx = process_bin_labels([hist.GetXaxis().GetBinLabel(i)
56  for i in range(1, nx + 1)])
57  if self.binlabelsx:
58  self.nbinsx = nx = self.binlabelsx.index('')
59  self.binlabelsx = self.binlabelsx[:ny]
60  self.binlabelsy = process_bin_labels([hist.GetYaxis().GetBinLabel(i)
61  for i in range(1, ny + 1)])
62  if self.binlabelsy:
63  self.nbinsy = ny = self.binlabelsy.index('')
64  self.binlabelsy = self.binlabelsy[:ny]
65  self.entries = hist.GetEntries()
66  self.content = [[hist.GetBinContent(i, j) for i in range(1, nx + 1)]
67  for j in range(1, ny + 1)]
68  self.xedges = [hist.GetXaxis().GetBinLowEdge(i)
69  for i in range(1, nx + 2)]
70  self.yedges = [hist.GetYaxis().GetBinLowEdge(i)
71  for i in range(1, ny + 2)]
72  self.x = [(self.xedges[i+1] + self.xedges[i])/2
73  for i in range(nx)]
74  self.y = [(self.yedges[i+1] + self.yedges[i])/2
75  for i in range(ny)]
76  self.title = title or hist.GetTitle()
77  self.xlabel = xlabel or hist.GetXaxis().GetTitle()
78  self.ylabel = ylabel or hist.GetYaxis().GetTitle()
79  self.label = label
80  def _flat_content(self):
81  flatcontent = []
82  for row in self.content:
83  flatcontent += row
84  return flatcontent
85  def __getitem__(self, index):
86  """Return contents of indexth bin: x.__getitem__(y) <==> x[y]"""
87  return self._flat_content()[index]
88  def __len__(self):
89  """Return the number of bins: x.__len__() <==> len(x)"""
90  return len(self._flat_content())
91  def __iter__(self):
92  """Iterate through bins: x.__iter__() <==> iter(x)"""
93  return iter(self._flat_content())
94  def TH2F(self, name=""):
95  """Return a ROOT.TH2F object with contents of this Hist2D."""
96  th2f = ROOT.TH2F(name, "",
97  self.nbinsx, array.array('f', self.xedges),
98  self.nbinsy, array.array('f', self.yedges))
99  th2f.SetTitle("%s;%s;%s" % (self.title, self.xlabel, self.ylabel))
100  for ix in range(self.nbinsx):
101  for iy in range(self.nbinsy):
102  th2f.SetBinContent(ix + 1, iy + 1, self.content[iy][ix])
103  return th2f
104 
105 class Hist(object):
106  """A container to hold the parameters from a ROOT histogram."""
107  def __init__(self, hist, label="__nolabel__",
108  name=None, title=None, xlabel=None, ylabel=None):
109  try:
110  hist.GetNbinsX()
111  self.__init_TH1(hist)
112  except AttributeError:
113  try:
114  hist.GetN()
115  self.__init_TGraph(hist)
116  except AttributeError:
117  raise TypeError("%s is not a 1D histogram or TGraph" % hist)
118  self.rootclass = hist.ClassName()
119  self.name = name or hist.GetName()
120  self.title = title or hist.GetTitle().split(';')[0]
121  self.xlabel = xlabel or hist.GetXaxis().GetTitle()
122  self.ylabel = ylabel or hist.GetYaxis().GetTitle()
123  self.label = label
124  def __init_TH1(self, hist):
125  self.nbins = n = hist.GetNbinsX()
126  self.binlabels = process_bin_labels([hist.GetXaxis().GetBinLabel(i)
127  for i in range(1, n + 1)])
128  if self.binlabels and '' in self.binlabels:
129  # Get rid of extra non-labeled bins
130  self.nbins = n = self.binlabels.index('')
131  self.binlabels = self.binlabels[:n]
132  self.entries = hist.GetEntries()
133  self.xedges = [hist.GetBinLowEdge(i) for i in range(1, n + 2)]
134  self.x = [(self.xedges[i+1] + self.xedges[i])/2 for i in range(n)]
135  self.xerr = [(self.xedges[i+1] - self.xedges[i])/2 for i in range(n)]
136  self.xerr = [self.xerr[:], self.xerr[:]]
137  self.width = [(self.xedges[i+1] - self.xedges[i]) for i in range(n)]
138  self.y = [hist.GetBinContent(i) for i in range(1, n + 1)]
139  self.yerr = [hist.GetBinError( i) for i in range(1, n + 1)]
140  self.yerr = [self.yerr[:], self.yerr[:]]
141  self.underflow = hist.GetBinContent(0)
142  self.overflow = hist.GetBinContent(self.nbins + 1)
143  def __init_TGraph(self, hist):
144  self.nbins = n = hist.GetN()
145  self.x, self.y = [], []
146  x, y = ROOT.Double(0), ROOT.Double(0)
147  for i in range(n):
148  hist.GetPoint(i, x, y)
149  self.x.append(copy.copy(x))
150  self.y.append(copy.copy(y))
151  lower = [max(0, hist.GetErrorXlow(i)) for i in xrange(n)]
152  upper = [max(0, hist.GetErrorXhigh(i)) for i in xrange(n)]
153  self.xerr = [lower[:], upper[:]]
154  lower = [max(0, hist.GetErrorYlow(i)) for i in xrange(n)]
155  upper = [max(0, hist.GetErrorYhigh(i)) for i in xrange(n)]
156  self.yerr = [lower[:], upper[:]]
157  self.xedges = [self.x[i] - self.xerr[0][i] for i in xrange(n)]
158  self.xedges.append(self.x[n - 1] + self.xerr[1][n - 1])
159  self.width = [self.xedges[i + 1] - self.xedges[i] for i in range(n)]
160  self.underflow, self.overflow = 0, 0
161  self.binlabels = None
162  self.entries = n
163  def __add__(self, b):
164  """Return the sum of self and b: x.__add__(y) <==> x + y"""
165  c = copy.copy(self)
166  for i in range(len(self)):
167  c.y[i] += b.y[i]
168  c.yerr[0][i] += b.yerr[0][i]
169  c.yerr[1][i] += b.yerr[1][i]
170  c.overflow += b.overflow
171  c.underflow += b.underflow
172  return c
173  def __sub__(self, b):
174  """Return the difference of self and b: x.__sub__(y) <==> x - y"""
175  c = copy.copy(self)
176  for i in range(len(self)):
177  c.y[i] -= b.y[i]
178  c.yerr[0][i] -= b.yerr[0][i]
179  c.yerr[1][i] -= b.yerr[1][i]
180  c.overflow -= b.overflow
181  c.underflow -= b.underflow
182  return c
183  def __div__(self, denominator):
184  return self.divide(denominator)
185  def __getitem__(self, index):
186  """Return contents of indexth bin: x.__getitem__(y) <==> x[y]"""
187  return self.y[index]
188  def __setitem__(self, index, value):
189  """Set contents of indexth bin: x.__setitem__(i, y) <==> x[i]=y"""
190  self.y[index] = value
191  def __len__(self):
192  """Return the number of bins: x.__len__() <==> len(x)"""
193  return self.nbins
194  def __iter__(self):
195  """Iterate through bins: x.__iter__() <==> iter(x)"""
196  return iter(self.y)
197  def min(self, threshold=None):
198  """Return the y-value of the bottom tip of the lowest errorbar."""
199  vals = [(yval - yerr) for yval, yerr in zip(self.y, self.yerr[0])
200  if (yval - yerr) > threshold]
201  if vals:
202  return min(vals)
203  else:
204  return threshold
205  def av_xerr(self):
206  """Return average between the upper and lower xerr."""
207  return [(self.xerr[0][i] + self.xerr[1][i]) / 2
208  for i in range(self.nbins)]
209  def av_yerr(self):
210  """Return average between the upper and lower yerr."""
211  return [(self.yerr[0][i] + self.yerr[1][i]) / 2
212  for i in range(self.nbins)]
213  def scale(self, factor):
214  """
215  Scale contents, errors, and over/underflow by the given scale factor.
216  """
217  self.y = [x * factor for x in self.y]
218  self.yerr[0] = [x * factor for x in self.yerr[0]]
219  self.yerr[1] = [x * factor for x in self.yerr[1]]
220  self.overflow *= factor
221  self.underflow *= factor
222  def delete_bin(self, index):
223  """
224  Delete a the contents of a bin, sliding all the other data one bin to
225  the left. This can be useful for histograms with labeled bins.
226  """
227  self.nbins -= 1
228  self.xedges.pop()
229  self.x.pop()
230  self.width.pop()
231  self.y.pop(index)
232  self.xerr[0].pop(index)
233  self.xerr[1].pop(index)
234  self.yerr[0].pop(index)
235  self.yerr[1].pop(index)
236  if self.binlabels:
237  self.binlabels.pop(index)
238  def TH1F(self, name=None):
239  """Return a ROOT.TH1F object with contents of this Hist"""
240  th1f = ROOT.TH1F(name or self.name, "", self.nbins,
241  array.array('f', self.xedges))
242  th1f.Sumw2()
243  th1f.SetTitle("%s;%s;%s" % (self.title, self.xlabel, self.ylabel))
244  for i in range(self.nbins):
245  th1f.SetBinContent(i + 1, self.y[i])
246  try:
247  th1f.SetBinError(i + 1, (self.yerr[0][i] + self.yerr[1][i]) / 2)
248  except TypeError:
249  th1f.SetBinError(i + 1, self.yerr[i])
250  if self.binlabels:
251  th1f.GetXaxis().SetBinLabel(i + 1, self.binlabels[i])
252  th1f.SetBinContent(0, self.underflow)
253  th1f.SetBinContent(self.nbins + 2, self.overflow)
254  th1f.SetEntries(self.entries)
255  return th1f
256  def TGraph(self, name=None):
257  """Return a ROOT.TGraphAsymmErrors object with contents of this Hist"""
258  x = array.array('f', self.x)
259  y = array.array('f', self.y)
260  xl = array.array('f', self.xerr[0])
261  xh = array.array('f', self.xerr[1])
262  yl = array.array('f', self.yerr[0])
263  yh = array.array('f', self.yerr[1])
264  tgraph = ROOT.TGraphAsymmErrors(self.nbins, x, y, xl, xh, yl, yh)
265  tgraph.SetName(name or self.name)
266  tgraph.SetTitle('%s;%s;%s' % (self.title, self.xlabel, self.ylabel))
267  return tgraph
268  def divide(self, denominator):
269  """
270  Return the simple quotient with errors added in quadrature.
271 
272  This function is called by the division operator:
273  hist3 = hist1.divide_wilson(hist2) <--> hist3 = hist1 / hist2
274  """
275  if len(self) != len(denominator):
276  raise TypeError("Cannot divide %s with %i bins by "
277  "%s with %i bins." %
278  (denominator.name, len(denominator),
279  self.name, len(self)))
280  quotient = copy.deepcopy(self)
281  num_yerr = self.av_yerr()
282  den_yerr = denominator.av_yerr()
283  quotient.yerr = [0. for i in range(self.nbins)]
284  for i in range(self.nbins):
285  if denominator[i] == 0 or self[i] == 0:
286  quotient.y[i] = 0.
287  else:
288  quotient.y[i] = self[i] / denominator[i]
289  quotient.yerr[i] = quotient[i]
290  quotient.yerr[i] *= math.sqrt((num_yerr[i] / self[i]) ** 2 +
291  (den_yerr[i] / denominator[i]) ** 2)
292  if quotient.yerr[i] > quotient[i]:
293  quotient.yerr[i] = quotient[i]
294  quotient.yerr = [quotient.yerr, quotient.yerr]
295  return quotient
296  def divide_wilson(self, denominator):
297  """Return an efficiency plot with Wilson score interval errors."""
298  if len(self) != len(denominator):
299  raise TypeError("Cannot divide %s with %i bins by "
300  "%s with %i bins." %
301  (denominator.name, len(denominator),
302  self.name, len(self)))
303  eff, upper_err, lower_err = wilson_interval(self.y, denominator.y)
304  quotient = copy.deepcopy(self)
305  quotient.y = eff
306  quotient.yerr = [lower_err, upper_err]
307  return quotient
308 
310  """
311  A container to hold Hist objects for plotting together.
312 
313  When plotting, the title and the x and y labels of the last Hist added
314  will be used unless specified otherwise in the constructor.
315  """
316  def __init__(self, hists=None, title=None, xlabel=None, ylabel=None):
317  self.hists = []
318  self.kwargs = []
319  self.title = title
320  self.xlabel = xlabel
321  self.ylabel = ylabel
322  if hists:
323  for hist in hists:
324  self.add(hist)
325  def __getitem__(self, index):
326  """Return indexth hist: x.__getitem__(y) <==> x[y]"""
327  return self.hists[index]
328  def __setitem__(self, index, value):
329  """Replace indexth hist with value: x.__setitem__(i, y) <==> x[i]=y"""
330  self.hists[index] = value
331  def __len__(self):
332  """Return the number of hists in the stack: x.__len__() <==> len(x)"""
333  return len(self.hists)
334  def __iter__(self):
335  """Iterate through hists in the stack: x.__iter__() <==> iter(x)"""
336  return iter(self.hists)
337  def max(self):
338  """Return the value of the highest bin of all hists in the stack."""
339  maxes = [max(x) for x in self.hists]
340  try:
341  return max(maxes)
342  except ValueError:
343  return 0
344  def stackmax(self):
345  """Return the value of the highest bin in the addition of all hists."""
346  try:
347  return max([sum([h[i] for h in self.hists])
348  for i in range(self.hists[0].nbins)])
349  except:
350  print([h.nbins for h in self.hists])
351  def scale(self, factor):
352  """Scale all Hists by factor."""
353  for hist in self.hists:
354  hist.scale(factor)
355  def min(self, threshold=None):
356  """
357  Return the value of the lowest bin of all hists in the stack.
358 
359  If threshold is specified, only values above the threshold will be
360  considered.
361  """
362  mins = [x.min(threshold) for x in self.hists]
363  return min(mins)
364  def add(self, hist, **kwargs):
365  """
366  Add a Hist object to this stack.
367 
368  Any additional keyword arguments will be added to just this Hist
369  when the stack is plotted.
370  """
371  if "label" in kwargs:
372  hist.label = kwargs['label']
373  del kwargs['label']
374  if len(self) > 0:
375  if hist.xedges != self.hists[0].xedges:
376  raise ValueError("Cannot add %s to stack; all Hists must "
377  "have the same binning." % hist.name)
378  self.hists.append(hist)
379  self.kwargs.append(kwargs)
380 
381 
382 ################ Define functions and classes for navigating within ROOT
383 
385  """A wrapper for TFiles, allowing easier access to methods."""
386  def __init__(self, filename, name=None):
387  self.filename = filename
388  self.name = name or filename[:-5]
389  self.file = ROOT.TFile(filename, 'read')
390  if self.file.IsZombie():
391  raise ValueError("Error opening %s" % filename)
392  def cd(self, directory=''):
393  """Make directory the current directory."""
394  self.file.cd(directory)
395  def get(self, object_name, path=None, type1D=Hist, type2D=Hist2D):
396  """Return a Hist object from the given path within this file."""
397  if not path:
398  path = os.path.dirname(object_name)
399  object_name = os.path.basename(object_name)
400  try:
401  roothist = self.file.GetDirectory(path).Get(object_name)
402  except ReferenceError as e:
403  raise ReferenceError(e)
404  try:
405  return type2D(roothist)
406  except TypeError:
407  return type1D(roothist)
408 
409 def ls(directory=None):
410  """Return a python list of ROOT object names from the given directory."""
411  if directory == None:
412  keys = ROOT.gDirectory.GetListOfKeys()
413  else:
414  keys = ROOT.gDirectory.GetDirectory(directory).GetListOfKeys()
415  key = keys[0]
416  names = []
417  while key:
418  obj = key.ReadObj()
419  key = keys.After(key)
420  names.append(obj.GetName())
421  return names
422 
423 def pwd():
424  """Return ROOT's present working directory."""
425  return ROOT.gDirectory.GetPath()
426 
427 def get(object_name):
428  """Return a Hist object with the given name."""
429  return Hist(ROOT.gDirectory.Get(object_name))
430 
431 
432 ################ Define additional helping functions
433 
434 def loadROOT(batch=True):
435  ## We need to temporarily change sys.argv so that ROOT doesn't intercept
436  ## options from the command-line
437  saved_argv = sys.argv[:]
438  argstring = ' '.join(sys.argv)
439  sys.argv = [sys.argv[0]]
440  try:
441  import ROOT
442  except ImportError:
443  print("""\
444 The program was unable to access PyROOT. Usually, this just requires switching
445 to the same major version of python that used when compiling ROOT. To
446 determine which version that is, try the following command:
447  root -config 2>&1 | tr ' ' '\\n' | egrep 'python|PYTHON'
448 If this is different from the python version you are currently using, try
449 changing your PATH to point to the new one.""")
450  sys.exit(1)
451  ## Enter batch mode, unless outputting to C macros
452  ## There is a bug in pyROOT that fails to export colors in batch mode
453  if batch:
454  ROOT.gROOT.SetBatch()
455  ROOT.gErrorIgnoreLevel = ROOT.kWarning
456  ## PyROOT picks up ~/.rootlogon if it exists, but not ./rootlogon.C
457  if os.path.exists('rootlogon.C'):
458  ROOT.gROOT.Macro('rootlogon.C')
459  sys.argv = saved_argv[:]
460  return ROOT
461 
462 def replace(string, replacements):
463  """
464  Modify a string based on a list of patterns and substitutions.
465 
466  replacements should be a list of two-entry tuples, the first entry giving
467  a string to search for and the second entry giving the string with which
468  to replace it. If replacements includes a pattern entry containing
469  'use_regexp', then all patterns will be treated as regular expressions
470  using re.sub.
471  """
472  if not replacements:
473  return string
474  if 'use_regexp' in [x for x,y in replacements]:
475  for pattern, repl in [x for x in replacements
476  if x[0] != 'use_regexp']:
477  string = re.sub(pattern, repl, string)
478  else:
479  for pattern, repl in replacements:
480  string = string.replace(pattern, repl)
481  if re.match(_all_whitespace_string, string):
482  return ""
483  return string
484 
485 def process_bin_labels(binlabels):
486  has_labels = False
487  for binlabel in binlabels:
488  if binlabel:
489  has_labels = True
490  if has_labels:
491  return binlabels
492  else:
493  return None
494 
495 def wilson_interval(numerator_array, denominator_array):
496  eff, upper_err, lower_err = [], [], []
497  for n, d in zip(numerator_array, denominator_array):
498  try:
499  p = float(n) / d
500  s = math.sqrt(p * (1 - p) / d + 1 / (4 * d * d))
501  t = p + 1 / (2 * d)
502  eff.append(p)
503  upper_err.append(-p + 1/(1 + 1/d) * (t + s))
504  lower_err.append(+p - 1/(1 + 1/d) * (t - s))
505  except ZeroDivisionError:
506  eff.append(0)
507  upper_err.append(0)
508  lower_err.append(0)
509  return eff, upper_err, lower_err
510 
512  import os
513  try:
514  num_processors = os.sysconf('SC_NPROCESSORS_ONLN')
515  except:
516  try:
517  num_processors = os.environ['NUMBER_OF_PROCESSORS']
518  except:
519  num_processors = 1
520  return num_processors
521 
522 def testfile():
523  outfile = ROOT.TFile("test.root", "recreate")
524  for i in range(4):
525  d = outfile.mkdir("dir%i" % (i + 1))
526  d.cd()
527  for j in range(4):
528  hist = ROOT.TH1F("hist%i" % (j + 1), "A Histogram", 10, 0, 10)
529  hist.Fill(j)
530  hist.Write()
531  outfile.Write()
532  return outfile
533 
534 #### Functions for globbing within root files
535 
536 glob_magic_check = re.compile('[*?[]')
537 
539  return glob_magic_check.search(s) is not None
540 
541 # These 2 helper functions non-recursively glob inside a literal directory.
542 # They return a list of basenames. `_rootglob1` accepts a pattern while
543 # `_rootglob0` takes a literal basename (so it only has to check for its
544 # existence).
545 
546 def _rootglob1(tdirectory, dirname, pattern):
547  if not tdirectory.GetDirectory(dirname):
548  return []
549  names = [key.GetName() for key in
550  tdirectory.GetDirectory(dirname).GetListOfKeys()]
551  return fnmatch.filter(names, pattern)
552 
553 def _rootglob0(tdirectory, dirname, basename):
554  if tdirectory.Get(os.path.join(dirname, basename)):
555  return [basename]
556  return []
557 
558 def rootglob(tdirectory, pathname):
559  """Return a list of paths matching a pathname pattern.
560 
561  The pattern may contain simple shell-style wildcards a la fnmatch.
562 
563  >>> import rootplot.utilities
564  >>> f = rootplot.utilities.testfile()
565  >>> rootglob(f, '*')
566  ['dir1', 'dir2', 'dir3', 'dir4']
567  >>> rootglob(f, 'dir1/*')
568  ['dir1/hist1', 'dir1/hist2', 'dir1/hist3', 'dir1/hist4']
569  >>> rootglob(f, '*/hist1')
570  ['dir1/hist1', 'dir2/hist1', 'dir3/hist1', 'dir4/hist1']
571  >>> rootglob(f, 'dir1/hist[1-2]')
572  ['dir1/hist1', 'dir1/hist2']
573  """
574  return list(irootglob(tdirectory, pathname))
575 
576 def irootglob(tdirectory, pathname):
577  """Return an iterator which yields the paths matching a pathname pattern.
578 
579  The pattern may contain simple shell-style wildcards a la fnmatch.
580 
581  """
582  if not has_glob_magic(pathname):
583  if tdirectory.Get(pathname):
584  yield pathname
585  return
586  dirname, basename = os.path.split(pathname)
587  if has_glob_magic(dirname):
588  dirs = irootglob(tdirectory, dirname)
589  else:
590  dirs = [dirname]
591  if has_glob_magic(basename):
592  glob_in_dir = _rootglob1
593  else:
594  glob_in_dir = _rootglob0
595  for dirname in dirs:
596  for name in glob_in_dir(tdirectory, dirname, basename):
597  yield os.path.join(dirname, name)
598 
599 if __name__ == '__main__':
600  import doctest
601  doctest.testmod()
def __init__(self, hists=None, title=None, xlabel=None, ylabel=None)
Definition: utilities.py:316
def TH1F(self, name=None)
Definition: utilities.py:238
def loadROOT(batch=True)
Define additional helping functions.
Definition: utilities.py:434
def __init_TH1(self, hist)
Definition: utilities.py:124
def process_bin_labels(binlabels)
Definition: utilities.py:485
def ls(directory=None)
Definition: utilities.py:409
def _rootglob0(tdirectory, dirname, basename)
Definition: utilities.py:553
def min(self, threshold=None)
Definition: utilities.py:355
def divide(self, denominator)
Definition: utilities.py:268
def delete_bin(self, index)
Definition: utilities.py:222
def __init__(self, hist, label="__nolabel__", name=None, title=None, xlabel=None, ylabel=None)
Definition: utilities.py:108
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def replace(string, replacements)
Definition: utilities.py:462
def __init__(self, filename, name=None)
Definition: utilities.py:386
def __getitem__(self, index)
Definition: utilities.py:185
def irootglob(tdirectory, pathname)
Definition: utilities.py:576
def scale(self, factor)
Definition: utilities.py:213
def __getitem__(self, index)
Definition: utilities.py:85
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def min(self, threshold=None)
Definition: utilities.py:197
def __setitem__(self, index, value)
Definition: utilities.py:188
def _rootglob1(tdirectory, dirname, pattern)
Definition: utilities.py:546
def wilson_interval(numerator_array, denominator_array)
Definition: utilities.py:495
def get(object_name)
Definition: utilities.py:427
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def __div__(self, denominator)
Definition: utilities.py:183
def add(self, hist, kwargs)
Definition: utilities.py:364
def __setitem__(self, index, value)
Definition: utilities.py:328
def TGraph(self, name=None)
Definition: utilities.py:256
def rootglob(tdirectory, pathname)
Definition: utilities.py:558
def __init__(self, hist, label="__nolabel__", title=None, xlabel=None, ylabel=None)
Definition: utilities.py:45
def TH2F(self, name="")
Definition: utilities.py:94
def __init_TGraph(self, hist)
Definition: utilities.py:143
def cd(self, directory='')
Definition: utilities.py:392
double split
Definition: MVATrainer.cc:139
def get(self, object_name, path=None, type1D=Hist, type2D=Hist2D)
Definition: utilities.py:395
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def divide_wilson(self, denominator)
Definition: utilities.py:296