ATLAS Offline Software
JetMonitoringConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 # #######################################
4 
30 
31 from AthenaCommon import SystemOfUnits
32 
33 class ConfigDict(dict):
34  """A python dictionary extended so that each entry in the dict can also be accessed as
35  member attribute.
36  Ex:
37  d = ConfigDict(aKey = 4)
38  d.aKey # --> == 4 is the same as d["aKey"]
39  d.bKey = 12 # now d["bKey"] is existing and set to 12
40 
41  all other usual methods of dictionary are working as expected.
42  """
43  def __init__(self, **kwargs):
44  dict.__init__(self, **kwargs)
45  for k,v in kwargs.items():
46  dict.__setattr__(self, k, v)
47  def __getattr__(self, attr):
48  try:
49  return self[attr]
50  except KeyError:
51  dict.__getattribute__(self,attr)
52  #raise AttributeError(attr)
53 
54  def __setattr__(self, attr, value):
55  if attr in ['keys', 'clear', 'update', 'pop', 'iteritems', 'values','setdefault','get','has_key','copy']:
56  print('ConfigDict ERROR can not assign attribute ', attr)
57  return
58  dict.__setitem__(self, attr, value)
59  dict.__setattr__(self, attr, value)
60  def __setitem__(self, attr, value):
61  if attr in ['keys', 'clear', 'update', 'pop', 'iteritems', 'values','setdefault','get','has_key','copy']:
62  print('ConfigDict ERROR can not assign attribute ', attr)
63  return
64  dict.__setitem__(self, attr, value)
65  dict.__setattr__(self, attr, value)
66 
67 
68  def clone(self, **kwargs):
69  from copy import deepcopy
70  c = deepcopy(self)
71  for k,v in kwargs.items():
72  setattr(c,k,v)
73  return c
74 
75 
76  def dump(self, out=None):
77  """ prints the content of this dict on stdout (default) or in the file 'out' """
78  if out is None :
79  from sys import stdout
80  out = stdout
81  _write = out.write
82  def write(s, e='\n'): _write(s+e)
83  self._dump(write)
84 
85  def _dump(self, writeFunc):
86  def write(s, e='\n'): writeFunc(' '+s,e)
87  writeFunc(self.__class__.__name__+'(')
88  for k,v in sorted(self.items()):
89  if isinstance(v, ConfigDict):
90  write(k+' = ','')
91  v._dump(write)
92  else:
93  write(k+' = '+str(v))
94  writeFunc(')')
95 
96 
97 
98 
99 # **********************************************************
100 # **********************************************************
101 # Helper functions
102 # **********************************************************
103 
104 
106  selL = selStr.split('&')
107  interpL = [interpretSelStr( s ) for s in selL]
108  # interpL is in the form [ (min1,v1,max1), (min2,v2,max2),..]
109  # unpack it into 3 lists :
110  minL, varL, maxL = zip(*interpL)
111  return minL, varL, maxL
112 
113 def interpretSelStr(selStr):
114  """Interpret a selection string in the form '12.3<var<42.0'
115  and returns a tuple.
116  '12.3<var<42.0' -> returns (12.3, 'var', 42.)
117  'var<42.0' -> returns (None, 'var', 42.)
118  '12.3<var' -> returns (12.3, 'var', None)
119  """
120 
121  if '>' in selStr:
122  print("JetMonitoring ERROR interpreting selection string ", selStr)
123  print("JetMonitoring ERROR can not interpret '>', please use only '<' ")
124 
125  parts = selStr.split('<')
126  cmin, cmax = -3.4e38, 3.4e38 #we declare std::vector<float> for both on the c++ side, but will not necessarily pass actual values for them, so we use min/max float values in python as default (hardcoded numbers, because not easily accessible)
127  var = selStr
128  if len(parts)==2:
129  ismin = False
130  try :
131  var, cut = parts[0] , float(parts[1])
132  except ValueError:
133  cut, var = float(parts[0]) ,parts[1]
134  ismin=True
135  if ismin : cmin = cut
136  else: cmax = cut
137  elif len(parts)==3:
138  cmin, var, cmax = parts
139  cmin = float(cmin)
140  cmax = float(cmax)
141 
142  return cmin, var, cmax
143 
144 def findSelectIndex( name):
145  """ interprets 'varName[X]' into ('varName',x) """
146  try:
147  name, index = name.split('[')
148  except ValueError:
149  name, index = name, ''
150  if not index.endswith(']'):
151  return name, -1
152  index = int(index[:-1])
153  return name, index
154 
155 # **********************************************************
156 
157 
159  """A dictionary specialized for containing the specification of a Athena tool.
160  """
161  def __init__(self, klass, name, **args):
162  self.name = name
163  self.klass = klass
164  ConfigDict.__init__(self, **args)
165 
166 
167  def toTool(self):
168  from AthenaConfiguration.ComponentFactory import CompFactory
169  conf = self.clone(self.name)
170  klass = getattr(CompFactory,conf.pop('klass')) # remove 'klass'
171  conf.pop('name')
172  conf.pop('topLevelDir',None)
173  conf.pop('bottomLevelDir',None)
174  conf.pop('defineHistoFunc',None) # not used here.
175  for k, v in conf.items():
176  if isinstance(v,ToolSpec):
177  v.topLevelDir = self.topLevelDir
178  v.bottomLevelDir = self.bottomLevelDir
179  conf[k] = v.toTool()
180  if isinstance(v,list):
181  if v == []: continue
182  if isinstance(v[0],ToolSpec):
183  # assume we have k is a ToolHandleArray
184  toolInstances = []
185  for toolSpec in v:
186  toolSpec.topLevelDir=self.topLevelDir
187  toolSpec.bottomLevelDir=self.bottomLevelDir
188  toolInstances.append( toolSpec.toTool() )
189  conf[k] = toolInstances
190  return klass(**conf)
191 
192  def clone(self, newname,**args):
193  return ConfigDict.clone(self, name=newname, **args)
194 
195  def defineHisto(self, parentAlg, monhelper , path):
196  # Assume a helper function was given :
197  defineHistoFunc = self.defineHistoFunc
198  # call it :
199  defineHistoFunc(self, parentAlg, monhelper , path)
200 
201 
202 
204  """A dictionary specialized to contain a jet variable specification"""
205  def __init__(self, Name , Type='float', Index=-1, Scale=1):
206  # by default we allow only the properties of a JetHistoVarTool
207  if Name.endswith(':GeV'):
208  Scale=1./SystemOfUnits.GeV
209  Name = Name[:-4]
210 
211 
212  Name , Index = findSelectIndex(Name)
213  if Index != -1:
214  if Type[:3] != 'vec': Type='vec'+Type
215  self.Name = Name
216  self.Type = Type
217  self.Scale = Scale
218  self.Index = Index
219  ConfigDict.__init__(self)
220 
221 
222  def toTool(self):
223  from AthenaConfiguration.ComponentFactory import CompFactory
224  self.pop('topLevelDir', None)
225  self.pop('bottomLevelDir', None)
226  return CompFactory.JetHistoVarTool(self.Name, **self)
227 
228  def vname(self):
229  if self.Index ==-1: return self.Name
230  return self.Name+str(self.Index)
231 
232 
233  def __str__(self):
234  if self.Index==-1: return 'VarSpec("{n}",{t})'.format(n=self.Name, t=self.Type)
235  else: return 'VarSpec("{n}[{i}]",{t})'.format(n=self.Name, t=self.Type, i=self.Index)
236 
237  def _dump(self, writeFunc):
238  writeFunc( str(self))
239 
241  """A dictionary specialized to contain a JetHistoAttributeFiller specification
242  Invocation is like : spec = HistoSpec( name, bins, ...optional args... ) where
243  - name : a string, from which the name of the Histogram is build.
244  AND also the description of variables to be plotted IF none of xvar, yvar or zvar is in the optional args.
245  The final name of histos is given by name.replace(':GeV','').replace(';','_')
246  ex: 'eta' --> histo name : 'eta', variable to plot is 'eta'
247  'pt:GeV' --> histo name : 'pt', variable to plot is 'pt' at GeV scale
248  'pt:GeV;eta' --> histo name : 'pt_eta', 2 variables to plot 'pt' at GeV scale on x axis and 'eta' on y axis
249  - bins : the binning of the histogram in the form (nbin, min, max) or (nbinX, minX, maxX, nbinY, minY, maxY )
250  - optionnal args are :
251  + xvar, yvar, zvar : strings specifying variables
252  + profile : boolean, True if the histo is a TProfile (or TProfile2D)
253  + any other args (ex: title) will be forwarded to the mongroup.defineHistogram() function.
254  """
255  def __init__(self, name , bins, xvar=None, yvar=None, zvar=None, profile=False,**args):
256  self.is1D = ';' not in name
257 
258  self.nVar = name.count(';')+1
259  self.isProfile = profile
260  if self.nVar==1:
261  self.xvar = retrieveVarToolConf( xvar if xvar is not None else name)
262  self.yvar = None
263  self.zvar = None
264  elif self.nVar==2:
265  xv , yv = name.split(';')
266  self.xvar = retrieveVarToolConf( xvar if xvar is not None else xv)
267  self.yvar = yvar if yvar is not None else yv
268  self.zvar = None
269  else:
270  xv , yv, zv = name.split(';')
271  self.xvar = xvar if xvar is not None else xv
272  self.yvar = yvar if yvar is not None else yv
273  self.zvar = zvar if zvar is not None else zv
274  self.isProfile = True
275  self.name = name.replace(':GeV','')
276  self.bins = bins
277  self.hargs = ConfigDict( **args)
278  ConfigDict.__init__(self, **args)
279 
280  def groupName(self):
281  return self.name if self.nVar==1 else self.name.replace(';','_')
282 
283 
284  def clone(self, newname, bins=None, xvar=None, yvar=None, zvar=None, **hargs):
285  c = ConfigDict.clone(self)
286  if xvar : c.xvar = xvar
287  if yvar : c.yvar = yvar
288  if zvar : c.zvar = zvar
289  if bins: c.bins = bins
290  c.hargs.update(**hargs)
291  c.name = newname
292  return c
293 
294  def to2DSpec(self, yspec, profile=False, zspec=None):
295  """ Merge this histo spec and yspec into a new 2D histo spec"""
296  tx, ax, _ = self.title.split(';')
297  ty, ay, _ = yspec.title.split(';')
298  title = ty+' vs '+tx+';'+ax+';'+ay
299  name = self.name+';'+yspec.name
300  if zspec is not None:
301  tz, az, _ = zspec.title.split(';')
302  title = tz+' vs '+tx+' and '+ty+';'+ax+';'+ay
303 
304  name = name + ';'+zspec.name
305  s2d = HistoSpec( name, self.bins+yspec.bins,
306  xvar = self.xvar,
307  yvar = yspec.xvar, title=title, profile=profile
308  )
309  if zspec is not None:
310  s2d.zvar = zspec.xvar
311  return s2d
312 
313 
314 
315  def toTool(self):
316  from AthenaConfiguration.ComponentFactory import CompFactory
317  vx = retrieveVarToolConf( self.xvar)
318  tool = CompFactory.JetHistoAttributeFiller(self.groupName()+"hfiller",
319  VarX = vx.toTool(),
320  Group = self.groupName(),
321  )
322  if self.nVar>1:
323  tool.VarY = retrieveVarToolConf( self.yvar).toTool()
324  if self.nVar>2:
325  tool.VarZ = retrieveVarToolConf( self.zvar).toTool()
326  else: tool.VarZ = None
327  else : tool.VarY = None
328 
329  return tool
330 
331 
332  def defineHisto(self, parentAlg, monhelper , path):
333  """ This function performs the standard monitoring config calls for this JetHisto tool.
334  - group = monhelper.addGroup( ... )
335  - group.defineHistogram( ... )
336  """
337 
338  # build the arguments to be passed to defineHistogram
339  hargs = ConfigDict()
340  bins = self.bins
341  if self.nVar==1:
342  hargs.update(xbins = bins[0],xmin = bins[1], xmax=bins[2],
343  type='TH1F',
344  )
345  elif self.nVar>1:
346  hargs.update(xbins = bins[0],xmin = bins[1], xmax=bins[2],
347  ybins = bins[3],ymin = bins[4], ymax=bins[5],
348  type='TH2F' if not self.isProfile else 'TProfile',
349  )
350  if self.nVar==3:
351  hargs.type = 'TProfile2D'
352  hargs.update( **self.hargs) # overwrite by user-given args if any
353 
354  # we create one group for each histoFiller : self.groupName() are unique within a JetMonitoringAlg
355  bottomLevelDir = self.bottomLevelDir if self.bottomLevelDir != '' else parentAlg.JetContainerName.Path
356  group = monhelper.addGroup(parentAlg, self.groupName(), self.topLevelDir+bottomLevelDir)
357 
358  # define the variables used by this tool
359  # we encode as 'varx,vary;alias' as requested ny standard monitoring config, see
360  # https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/Control/AthenaMonitoring/python/GenericMonitoringTool.py
361  name = retrieveVarToolConf( self.xvar).vname()
362  if self.nVar>1:
363  name = name +"," + retrieveVarToolConf( self.yvar).vname()
364  if self.nVar>2:
365  name = name +"," + retrieveVarToolConf( self.zvar).vname()
366 
367  name = name+";"+self.groupName()
368 
369  #print(' uuuuuuuuuuu ', self.name , ' --> ', name, hargs)
370  # call the standard histo definition routine :
371  group.defineHistogram(name, path=path, **hargs)
372 
373 
374  def _dump(self, writeFunc):
375  def write(s): writeFunc(' '+s)
376  writeFunc('HistoSpec("'+self.name+'", '+str(self.bins) )
377  for k in [ 'xvar', 'yvar', 'zvar', 'isProfile' ]:
378  if self[k] is not None:
379  write(' '+k +' = '+str(self[k]))
380  write(')')
381 
382 
384  """A similar dictionary to HistoSpec above, but specialized to contain a
385  JetHistoEventLevelFiller specification.
386  Invocation is like : spec = EventHistoSpec( name, bins=(n,xlow,xhigh) )
387  """
388  def __init__(self, name, bins, **args):
389  ToolSpec.__init__(self, klass=None, name=name, **args) # we don't really need to pass a klass because we're specialized for JetHistoEventLevelFiller, see toTool()
390  self.bins = bins
391  self.hargs = ConfigDict( **args)
392 
393  def histName(self):
394  from JetMonitoring.JetStandardHistoSpecs import knownEventVar
395  histname = self.name
396  while knownEventVar.get(histname,None) is None: #try to remove suffixes in the form of "_SelectionName" when using with external SelectSpecs
397  if "_" in histname:
398  histnamesplit = histname.split("_")
399  histname = histname.replace("_"+histnamesplit[-1],"")
400  else:
401  raise JetMonSpecException(" Unknown EventHisto specification : '{}' ".format(histname))
402  return histname
403 
404  def toTool(self):
405  from AthenaConfiguration.ComponentFactory import CompFactory
406  from JetMonitoring.JetStandardHistoSpecs import knownEventVar
407  # force the property "VarName" to simply be the name of the variable specification:
408  v = knownEventVar[self.histName()]
409  v.VarName = v.name
410  tool = CompFactory.JetHistoEventLevelFiller( self.name+"hfiller",
411  Var = v.toTool(),
412  Group = self.name,
413  )
414  return tool
415 
416  def defineHisto(self, parentAlg, monhelper , path):
417  hargs = dict(xbins = self.bins[0],xmin = self.bins[1], xmax=self.bins[2],
418  type='TH1F', )
419  hargs.update( **self.hargs)
420  # we create one group for each histoFiller : self.name() are unique within a JetMonitoringAlg
421  bottomLevelDir = self.bottomLevelDir if self.bottomLevelDir != '' else parentAlg.JetContainerName.Path
422  group = monhelper.addGroup(parentAlg, self.name, self.topLevelDir+bottomLevelDir)
423  group.defineHistogram(self.histName()+";"+self.name, path=path, **hargs) #give a recognisable histogram name in case of SelectSpec usage
424 
425 
427  """A dictionary specialized to contain a JetHistoSelectSort specification
428  Invocation is like : spec = SelectSpec( name, , expr, path ) where
429  - name : a string naming the selection being applied
430  - expr : s string, defining a selection in the form '0.123<var<4.567' where var is an attribute/variable
431  - path : optional string, giving the sub-directory into which histos for this selection will be put. if not set, defaults to name.
432  """
433  def __init__(self, selname, selexpr, path=None, **args):
434  path = selname if path is None else path
435  if '<' in selexpr:
436  # interpret it as a list of min<v<max
437  cminList , varList , cmaxList = interpretManySelStr(selexpr)
438  specname = '_'.join(varList)
439  if args.setdefault('isEventVariable', False) :
440  VarList = [retrieveEventVarToolConf(v) for v in varList]
441  selProp = 'EventSelector'
442  selSpec = ToolSpec('JetEventSelector', specname+'_sel', Var = VarList, )
443  else:
444  VarList = [retrieveVarToolConf(v) for v in varList]
445  selProp = 'Selector'
446  selSpec = ToolSpec('JetSelectorAttribute', specname+'_sel', Var = VarList, )
447  selSpec['CutMin'] = cminList
448  selSpec['CutMax'] = cmaxList
449  args[selProp] = selSpec
450  elif selexpr != '':
451  from JetMonitoring.JetStandardHistoSpecs import knownSelector
452  # assume it's a known pre-defined jet selector
453  selSpec = knownSelector.get(selexpr, None)
454  if selSpec is None :
455  print("ERROR ", selexpr , " is an unknown JetSelector ")
456  # should raise an exception ??
457  return
458  args['Selector'] = selSpec
459 
460  self.name = selname
461  self.path = path
462  ConfigDict.__init__(self, **args)
463  tmpL = self.FillerTools
464  self.FillerTools = []
465  self.appendHistos(*tmpL)
466 
467  def appendHistos(self, *hfillers):
468  tmpL = [retrieveHistoToolConf(hspec) for hspec in hfillers]
469  self.FillerTools += tmpL
470 
471  def toTool(self):
472  from AthenaConfiguration.ComponentFactory import CompFactory
473  # conf = self.clone(self.name)
474  # name = conf.pop('name')
475  selTool = CompFactory.JetHistoSelectSort(self.name, SelectedIndex=self.get('SelectedIndex',-1), InverseJetSel=self.get('InverseJetSel',False))
476  if hasattr(self,'Selector'):
477  self.Selector.topLevelDir = self.topLevelDir
478  self.Selector.bottomLevelDir = self.bottomLevelDir
479  selTool.Selector = self.Selector.toTool()
480  if hasattr(self,'EventSelector'):
481  self.EventSelector.topLevelDir = self.topLevelDir
482  self.EventSelector.bottomLevelDir = self.bottomLevelDir
483  selTool.EventSelector = self.EventSelector.toTool()
484  if hasattr(self, 'SortVariable'):
485  selTool.SortVariable = retrieveVarToolConf(self.SortVariable)
486  suffix = '_'+self.name
487  for i,tconf in enumerate(self.FillerTools):
488  tconf.topLevelDir = self.topLevelDir
489  tconf.bottomLevelDir = self.bottomLevelDir
490  newname = tconf.name if suffix in tconf.name else tconf.name+suffix #prevent duplicating of Selection name when loading external SelectSpecs
491  tconf = tconf.clone(newname=newname)
492  self.FillerTools[i] = tconf # re-assign the modified conf so it's consistently re-used elsewhere
493  selTool.FillerTools += [ tconf.toTool() ] # assign a configured tool to the JetHistoSelectSort instance
494  return selTool
495 
496  def defineHisto(self, parentAlg, monhelper , path):
497  # redefine path for sub-histos if needed :
498  path = path if self.path is None else self.path
499  # define histos for each subtools
500  for tconf in self.FillerTools:
501  tconf.defineHisto(parentAlg, monhelper, path)
502 
503 
504  def _dump(self, writeFunc):
505  def write(s,e='\n'): writeFunc(' '+s,e)
506  def write2(s,e='\n'): writeFunc(' '+s,e)
507  writeFunc('SelectSpec("'+self.name+'", path='+self.path+',')
508  if hasattr(self, 'Selector' ):
509  write(' Selector=','')
510  self.Selector._dump( write2)
511  if hasattr(self, 'EventSelector' ):
512  write(' EventSelector=','')
513  self.EventSelector._dump( write2)
514  write('FillerTools= [')
515  for hspec in self.FillerTools:
516  hspec._dump(write2)
517  write(']')
518  writeFunc(')')
519 
521  """A dictionary specialized to contain a JetMonitoringAlg specification"""
522 
523  def __init__(self, name , defaultPath='standardHistos/', TriggerChain='' ,**args):
524 
525  self.name = name
526  args.setdefault('FillerTools',[])
527  args.setdefault('topLevelDir', 'Jets/')
528  args.setdefault('bottomLevelDir', '')
529  args.setdefault('failureOnMissingContainer', True)
530  args.setdefault('onlyPassingJets', True)
531  args.setdefault('eventFiresAnyJetChain',False)
532  args.setdefault('isExpressStreamJob', False)
533  ConfigDict.__init__(self, defaultPath=defaultPath, TriggerChain=TriggerChain, **args)
534  tmpL = self.FillerTools
535  self.FillerTools = []
536  self.appendHistos(*tmpL)
537 
538  def appendHistos(self, *hfillers):
539  tmpL = [retrieveHistoToolConf(hspec) for hspec in hfillers]
540  self.FillerTools += tmpL
541 
542  def toAlg(self, monhelper):
543  from AthenaConfiguration.ComponentFactory import CompFactory
544  alg = monhelper.addAlgorithm(CompFactory.JetMonitoringAlg, self.name)
545  alg.TriggerChain = self.TriggerChain
546  alg.JetContainerName = self.JetContainerName
547  alg.FailureOnMissingContainer = self.failureOnMissingContainer
548  alg.OnlyPassingJets = self.onlyPassingJets
549  alg.EventFiresAnyJetChain = self.eventFiresAnyJetChain
550  alg.EnforceExpressTriggers = self.isExpressStreamJob
551 
552  path = self.defaultPath
553  tools = []
554  for tconf in self.FillerTools:
555  tconf.topLevelDir = self.topLevelDir
556  tconf.bottomLevelDir = self.bottomLevelDir
557  tools.append( tconf.toTool( ))
558  tconf.defineHisto(alg, monhelper, path)
559  alg.FillerTools = tools
560  return alg
561 
562  def _dump(self, writeFunc):
563  def write(s,e='\n'): writeFunc(' '+s,e)
564  def write2(s,e='\n'): writeFunc(' '+s,e)
565  writeFunc(self.__class__.__name__+'(')
566  for k,v in sorted(self.items()):
567  if k == 'FillerTools':
568  write('FillerTools = [')
569  for hspec in v:
570  #print ' uuuu ', hspec
571  hspec._dump(write2)
572  write('')
573  write(']')
574  else:
575  write(k+' = '+str(v))
576  writeFunc(')')
577 
578 
579 # **************************************
580 
581 class JetMonSpecException(Exception):
582  pass
583 
585  """Return a VarSpec from alias :
586  * if alias is a string look up in JetStandardHistoSpecs.knownVar
587  --> if not found build a VarSpec, assuming alias is an attribute of type float.
588  * if alias is a VarSpec, returns it directly
589  """
590  from JetMonitoring.JetStandardHistoSpecs import knownVar
591  if isinstance(alias, str):
592  conf = knownVar.get(alias,None)
593  if conf is None:
594  conf=VarSpec( Name=alias, Type='float')
595  else: # assume it's a config dict
596  conf = alias
597  return conf
598 
599 
601  """Return a ToolSpec from alias : (now with EventInfo or JetContainer variables)
602  * if alias is a string build a ToolSpec, assuming alias is an attribute of type float.
603  * if alias is a ToolSpec, returns it directly
604  """
605  from JetMonitoring.JetStandardHistoSpecs import knownEventVar
606  if isinstance(alias, str): #check for existing event or jetcontainer specs
607  conf = knownEventVar.get(alias,None)
608  if conf is None: #assume it's an eventInfo variable
609  conf = ToolSpec('EventHistoVarTool', alias, Attribute=alias)
610  else: # assume it's a config dict
611  conf = alias
612  return conf
613 
614 
616  """Return a HistoSpec from alias :
617  * if alias is a string look up in JetStandardHistoSpecs.knownHistos
618  --> if found, return a full clone (so client can modify it safely)
619  --> if not found and contain a ';' build a HistoSpec for a 2D histograms
620  * if alias is a ToolSpec, returns it directly
621  """
622  if isinstance(alias, ToolSpec):
623  return alias
624  elif isinstance(alias,str):
625  from JetMonitoring.JetStandardHistoSpecs import knownHistos
626  # get it from knownHistos
627  c = knownHistos.get(alias,None)
628  if c :
629  # found a knownHistos.
630  # we return a *clone* so that it can be modified without changing the standard spec.
631  return c.clone(c.name)
632  if ';' not in alias:
633  raise JetMonSpecException(" Unknown Histo specification : '{}' ".format(alias))
634  # print 'ERROR unknown Histo Filler specification ', alias
635  # return None
636  # we have a ';' : try to generate a 2D histo
637  aliases = alias.split(';')
638  aliasX, aliasY = aliases[0], aliases[1]
639  cX = knownHistos.get(aliasX,None)
640  cY = knownHistos.get(aliasY,None)
641  if len(aliases) == 2:
642  if None in (cX,cY):
643  print("ERROR unknown Histo Filler specification ", cX if cX is None else cY)
644  return None
645  # merge the spec
646  return cX.to2DSpec(cY)
647  else: # must be 3
648  aliasZ = aliases[2]
649  cZ = knownHistos.get(aliasZ,None)
650  if cZ is None:
651  # then we can try to build a dummy HistoSpec from a variable
652  # this is ok, since we're building a TProfile2D and we don't need
653  # binning info on the xAxis
654  vZ = retrieveVarToolConf(aliasZ)
655  cZ = HistoSpec(vZ.Name, (10,0,1) , title=vZ.Name+';'+vZ.Name+';', xvar=vZ )
656  return cX.to2DSpec(cY, zspec=cZ)
657 
658  else:
659  # What is this :
660  print('ERROR can not instantiate a tool from ', alias)
661  return None
662 
663 
JetMonitoringConfig.SelectSpec.defineHisto
def defineHisto(self, parentAlg, monhelper, path)
Definition: JetMonitoringConfig.py:496
JetMonitoringConfig.JetMonAlgSpec
Definition: JetMonitoringConfig.py:520
JetMonitoringConfig.SelectSpec
Definition: JetMonitoringConfig.py:426
JetMonitoringConfig.ConfigDict.__getattr__
def __getattr__(self, attr)
Definition: JetMonitoringConfig.py:47
JetMonitoringConfig.HistoSpec.nVar
nVar
Definition: JetMonitoringConfig.py:258
JetMonitoringConfig.VarSpec.toTool
def toTool(self)
Definition: JetMonitoringConfig.py:222
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
JetMonitoringConfig.VarSpec.Name
Name
Definition: JetMonitoringConfig.py:215
JetMonitoringConfig.EventHistoSpec.toTool
def toTool(self)
Definition: JetMonitoringConfig.py:404
JetMonitoringConfig.HistoSpec.groupName
def groupName(self)
Definition: JetMonitoringConfig.py:280
JetMonitoringConfig.EventHistoSpec
Definition: JetMonitoringConfig.py:383
JetMonitoringConfig.JetMonAlgSpec._dump
def _dump(self, writeFunc)
Definition: JetMonitoringConfig.py:562
JetMonitoringConfig.retrieveEventVarToolConf
def retrieveEventVarToolConf(alias)
Definition: JetMonitoringConfig.py:600
JetMonitoringConfig.HistoSpec.hargs
hargs
Definition: JetMonitoringConfig.py:277
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
JetMonitoringConfig.HistoSpec.to2DSpec
def to2DSpec(self, yspec, profile=False, zspec=None)
Definition: JetMonitoringConfig.py:294
JetMonitoringConfig.interpretManySelStr
def interpretManySelStr(selStr)
Definition: JetMonitoringConfig.py:105
JetMonitoringConfig.HistoSpec.bins
bins
Definition: JetMonitoringConfig.py:276
JetMonitoringConfig.ConfigDict.clone
def clone(self, **kwargs)
Definition: JetMonitoringConfig.py:68
JetMonitoringConfig.VarSpec
Definition: JetMonitoringConfig.py:203
JetMonitoringConfig.ConfigDict.__setitem__
def __setitem__(self, attr, value)
Definition: JetMonitoringConfig.py:60
JetMonitoringConfig.HistoSpec.__init__
def __init__(self, name, bins, xvar=None, yvar=None, zvar=None, profile=False, **args)
Definition: JetMonitoringConfig.py:255
JetMonitoringConfig.HistoSpec.is1D
is1D
Definition: JetMonitoringConfig.py:256
JetMonitoringConfig.VarSpec.Index
Index
Definition: JetMonitoringConfig.py:218
JetMonitoringConfig.VarSpec.Type
Type
Definition: JetMonitoringConfig.py:216
JetMonitoringConfig.JetMonAlgSpec.__init__
def __init__(self, name, defaultPath='standardHistos/', TriggerChain='', **args)
Definition: JetMonitoringConfig.py:523
JetMonitoringConfig.interpretSelStr
def interpretSelStr(selStr)
Definition: JetMonitoringConfig.py:113
klass
This class describe the base functionalities of a HypoTool used by the ComboAlg.
JetMonitoringConfig.SelectSpec.__init__
def __init__(self, selname, selexpr, path=None, **args)
Definition: JetMonitoringConfig.py:433
JetMonitoringConfig.EventHistoSpec.bins
bins
Definition: JetMonitoringConfig.py:390
JetMonitoringConfig.EventHistoSpec.histName
def histName(self)
Definition: JetMonitoringConfig.py:393
JetMonitoringConfig.VarSpec.Scale
Scale
Definition: JetMonitoringConfig.py:217
JetMonitoringConfig.ToolSpec
Definition: JetMonitoringConfig.py:158
JetMonitoringConfig.ConfigDict.__setattr__
def __setattr__(self, attr, value)
Definition: JetMonitoringConfig.py:54
JetMonitoringConfig.HistoSpec.yvar
yvar
Definition: JetMonitoringConfig.py:262
JetMonitoringConfig.retrieveVarToolConf
def retrieveVarToolConf(alias)
Definition: JetMonitoringConfig.py:584
JetMonitoringConfig.HistoSpec.xvar
xvar
Definition: JetMonitoringConfig.py:261
JetMonitoringConfig.VarSpec.vname
def vname(self)
Definition: JetMonitoringConfig.py:228
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
JetMonitoringConfig.SelectSpec._dump
def _dump(self, writeFunc)
Definition: JetMonitoringConfig.py:504
JetMonitoringConfig.EventHistoSpec.__init__
def __init__(self, name, bins, **args)
Definition: JetMonitoringConfig.py:388
JetMonitoringConfig.ConfigDict.__init__
def __init__(self, **kwargs)
Definition: JetMonitoringConfig.py:43
JetMonitoringConfig.HistoSpec.clone
def clone(self, newname, bins=None, xvar=None, yvar=None, zvar=None, **hargs)
Definition: JetMonitoringConfig.py:284
JetMonitoringConfig.HistoSpec
Definition: JetMonitoringConfig.py:240
JetMonitoringConfig.ToolSpec.defineHisto
def defineHisto(self, parentAlg, monhelper, path)
Definition: JetMonitoringConfig.py:195
JetMonitoringConfig.JetMonAlgSpec.toAlg
def toAlg(self, monhelper)
Definition: JetMonitoringConfig.py:542
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
JetMonitoringConfig.VarSpec.__init__
def __init__(self, Name, Type='float', Index=-1, Scale=1)
Definition: JetMonitoringConfig.py:205
JetMonitoringConfig.JetMonAlgSpec.name
name
Definition: JetMonitoringConfig.py:525
JetMonitoringConfig.SelectSpec.appendHistos
def appendHistos(self, *hfillers)
Definition: JetMonitoringConfig.py:467
JetMonitoringConfig.JetMonAlgSpec.appendHistos
def appendHistos(self, *hfillers)
Definition: JetMonitoringConfig.py:538
JetMonitoringConfig.ConfigDict.dump
def dump(self, out=None)
Definition: JetMonitoringConfig.py:76
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
JetMonitoringConfig.HistoSpec.isProfile
isProfile
Definition: JetMonitoringConfig.py:259
JetMonitoringConfig.HistoSpec.zvar
zvar
Definition: JetMonitoringConfig.py:263
JetMonitoringConfig.SelectSpec.FillerTools
FillerTools
Definition: JetMonitoringConfig.py:464
JetMonitoringConfig.EventHistoSpec.defineHisto
def defineHisto(self, parentAlg, monhelper, path)
Definition: JetMonitoringConfig.py:416
JetMonitoringConfig.retrieveHistoToolConf
def retrieveHistoToolConf(alias)
Definition: JetMonitoringConfig.py:615
JetMonitoringConfig.HistoSpec._dump
def _dump(self, writeFunc)
Definition: JetMonitoringConfig.py:374
JetMonitoringConfig.ToolSpec.name
name
Definition: JetMonitoringConfig.py:162
JetMonitoringConfig.SelectSpec.toTool
def toTool(self)
Definition: JetMonitoringConfig.py:471
JetMonitoringConfig.JetMonAlgSpec.FillerTools
FillerTools
Definition: JetMonitoringConfig.py:535
JetMonitoringConfig.EventHistoSpec.hargs
hargs
Definition: JetMonitoringConfig.py:391
JetMonitoringConfig.ConfigDict._dump
def _dump(self, writeFunc)
Definition: JetMonitoringConfig.py:85
JetMonitoringConfig.HistoSpec.toTool
def toTool(self)
Definition: JetMonitoringConfig.py:315
str
Definition: BTagTrackIpAccessor.cxx:11
JetMonitoringConfig.JetMonSpecException
Definition: JetMonitoringConfig.py:581
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
JetMonitoringConfig.ToolSpec.toTool
def toTool(self)
Definition: JetMonitoringConfig.py:167
JetMonitoringConfig.SelectSpec.path
path
Definition: JetMonitoringConfig.py:461
JetMonitoringConfig.ToolSpec.clone
def clone(self, newname, **args)
Definition: JetMonitoringConfig.py:192
JetMonitoringConfig.VarSpec._dump
def _dump(self, writeFunc)
Definition: JetMonitoringConfig.py:237
JetMonitoringConfig.HistoSpec.defineHisto
def defineHisto(self, parentAlg, monhelper, path)
Definition: JetMonitoringConfig.py:332
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
JetMonitoringConfig.ToolSpec.klass
klass
Definition: JetMonitoringConfig.py:163
JetMonitoringConfig.ToolSpec.__init__
def __init__(self, klass, name, **args)
Definition: JetMonitoringConfig.py:161
JetMonitoringConfig.VarSpec.__str__
def __str__(self)
Definition: JetMonitoringConfig.py:233
JetMonitoringConfig.findSelectIndex
def findSelectIndex(name)
Definition: JetMonitoringConfig.py:144
JetMonitoringConfig.ConfigDict
Definition: JetMonitoringConfig.py:33