Exemplo n.º 1
0
 def __iter__(self):
     """Start iteration over samples.
 Returns Variable, TH1D, list (of TH1D), list (of TH1D)"""
     vars = self.vars
     data = self.data
     exp = self.exp
     sig = self.signal
     if islist(vars):
         nvars = len(vars)
         if (exp and len(exp) != nvars) or (sig and len(sig) != nvars):
             LOG.warning(
                 "HistSet.__init__: Number of histograms (data=%d,exp=%d,sig=%s) does not match number of variables (%s)"
                 % (len(data), len(exp), len(sig), nvars))
         if not isinstance(data, dict) and not isinstance(
                 exp, dict) and (not sig or isinstance(sig, dict)):
             LOG.warning(
                 "HistSet.__init__: Types do not match: data=%s, exp=%s, sig=%s"
                 % (type(data), type(exp), type(sig)))
         if self.signal:
             for var in self.vars:
                 yield var, data[var], exp[var], sig[var]
         else:
             for var in self.vars:
                 yield var, data[var], exp[var]
     else:
         if self.signal:
             for val in [vars, data, exp, sig]:
                 yield val
         else:
             for val in [vars, data, exp]:
                 yield val
Exemplo n.º 2
0
def gettitle(sample,default=None,**kwargs):
  """Get title for some sample name."""
  if sample in sample_titles:
    LOG.verb("SampleStyle.gettitle: Found title %s for %r!"%(sample_titles[sample],sample),kwargs,level=3)
    sample = sample_titles[sample]
  elif default:
    sample = default
  else:
    LOG.warning("SampleStyle.gettitle: Could not find title for %r! Returning %r..."%(sample,sample))
  if kwargs.get('latex',False):
    sample = makelatex(sample)
  return sample
Exemplo n.º 3
0
def getcolor(sample,color=kWhite,**kwargs):
  """Get color for some sample name."""
  if hasattr(sample,'name'):
    sample = sample.name
  for key in sample_colors: #sorted(sample_colors,key=lambda x: len(x),reverse=True)
    if re.findall(key.replace('*',".*"),sample): # glob -> regex wildcard
      LOG.verb("SampleStyle.getcolor: Found color %s for %r from search term %r!"%(sample_colors[key],sample,key),kwargs,level=3)
      color = sample_colors[key]
      break
  else:
    LOG.warning("SampleStyle.getcolor: Could not find color for %r! Returning %s..."%(sample,color))
  return color