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