ATLAS Offline Software
Public Member Functions | Public Attributes | Private Member Functions | List of all members
JetMonitoringConfig.HistoSpec Class Reference
Inheritance diagram for JetMonitoringConfig.HistoSpec:
Collaboration diagram for JetMonitoringConfig.HistoSpec:

Public Member Functions

def __init__ (self, name, bins, xvar=None, yvar=None, zvar=None, profile=False, **args)
 
def groupName (self)
 
def clone (self, newname, bins=None, xvar=None, yvar=None, zvar=None, **hargs)
 
def to2DSpec (self, yspec, profile=False, zspec=None)
 
def toTool (self)
 
def defineHisto (self, parentAlg, monhelper, path)
 
def clone (self, newname, **args)
 
def clone (self, **kwargs)
 
def __getattr__ (self, attr)
 
def __setattr__ (self, attr, value)
 
def __setitem__ (self, attr, value)
 
def dump (self, out=None)
 

Public Attributes

 is1D
 
 nVar
 
 isProfile
 
 xvar
 
 yvar
 
 zvar
 
 name
 
 bins
 
 hargs
 
 klass
 

Private Member Functions

def _dump (self, writeFunc)
 

Detailed Description

A dictionary specialized to contain a JetHistoAttributeFiller specification
Invocation is like : spec = HistoSpec( name, bins, ...optional args... ) where 
  - name : a string, from which the name of the Histogram is build.
           AND also the description of variables to be plotted IF none of xvar, yvar or zvar is in the optional args.
           The final name of histos is given by name.replace(':GeV','').replace(';','_')
       ex: 'eta'        --> histo name : 'eta', variable to plot is 'eta'
           'pt:GeV'     --> histo name : 'pt', variable to plot is 'pt' at GeV scale 
           'pt:GeV;eta' --> histo name : 'pt_eta', 2 variables to plot  'pt' at GeV scale on x axis and 'eta' on y axis
  - bins : the binning of the histogram in the form (nbin, min, max) or (nbinX, minX, maxX, nbinY, minY, maxY )
  - optionnal args are : 
     + xvar, yvar, zvar : strings specifying variables
     + profile : boolean, True if the histo is a TProfile (or TProfile2D)     
     + any other args (ex: title) will be forwarded to the mongroup.defineHistogram() function.

Definition at line 240 of file JetMonitoringConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def JetMonitoringConfig.HistoSpec.__init__ (   self,
  name,
  bins,
  xvar = None,
  yvar = None,
  zvar = None,
  profile = False,
**  args 
)

Definition at line 255 of file JetMonitoringConfig.py.

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 

Member Function Documentation

◆ __getattr__()

def JetMonitoringConfig.ConfigDict.__getattr__ (   self,
  attr 
)
inherited

Definition at line 47 of file JetMonitoringConfig.py.

47  def __getattr__(self, attr):
48  try:
49  return self[attr]
50  except KeyError:
51  dict.__getattribute__(self,attr)
52  #raise AttributeError(attr)
53 

◆ __setattr__()

def JetMonitoringConfig.ConfigDict.__setattr__ (   self,
  attr,
  value 
)
inherited

Definition at line 54 of file JetMonitoringConfig.py.

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)

◆ __setitem__()

def JetMonitoringConfig.ConfigDict.__setitem__ (   self,
  attr,
  value 
)
inherited

Definition at line 60 of file JetMonitoringConfig.py.

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 

◆ _dump()

def JetMonitoringConfig.HistoSpec._dump (   self,
  writeFunc 
)
private

Reimplemented from JetMonitoringConfig.ConfigDict.

Definition at line 374 of file JetMonitoringConfig.py.

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 

◆ clone() [1/3]

def JetMonitoringConfig.ConfigDict.clone (   self,
**  kwargs 
)
inherited

Definition at line 68 of file JetMonitoringConfig.py.

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 

◆ clone() [2/3]

def JetMonitoringConfig.ToolSpec.clone (   self,
  newname,
**  args 
)
inherited

Definition at line 192 of file JetMonitoringConfig.py.

192  def clone(self, newname,**args):
193  return ConfigDict.clone(self, name=newname, **args)
194 

◆ clone() [3/3]

def JetMonitoringConfig.HistoSpec.clone (   self,
  newname,
  bins = None,
  xvar = None,
  yvar = None,
  zvar = None,
**  hargs 
)

Definition at line 284 of file JetMonitoringConfig.py.

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 

◆ defineHisto()

def JetMonitoringConfig.HistoSpec.defineHisto (   self,
  parentAlg,
  monhelper,
  path 
)
This function performs the standard monitoring config calls for this JetHisto tool.
      - group = monhelper.addGroup( ... )
      - group.defineHistogram( ... )

Reimplemented from JetMonitoringConfig.ToolSpec.

Definition at line 332 of file JetMonitoringConfig.py.

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 

◆ dump()

def JetMonitoringConfig.ConfigDict.dump (   self,
  out = None 
)
inherited
prints the content of this dict on stdout (default) or in the file 'out' 

Definition at line 76 of file JetMonitoringConfig.py.

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 

◆ groupName()

def JetMonitoringConfig.HistoSpec.groupName (   self)

Definition at line 280 of file JetMonitoringConfig.py.

280  def groupName(self):
281  return self.name if self.nVar==1 else self.name.replace(';','_')
282 
283 

◆ to2DSpec()

def JetMonitoringConfig.HistoSpec.to2DSpec (   self,
  yspec,
  profile = False,
  zspec = None 
)
Merge this histo spec and yspec into a new 2D histo spec

Definition at line 294 of file JetMonitoringConfig.py.

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 

◆ toTool()

def JetMonitoringConfig.HistoSpec.toTool (   self)

Reimplemented from JetMonitoringConfig.ToolSpec.

Definition at line 315 of file JetMonitoringConfig.py.

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 

Member Data Documentation

◆ bins

JetMonitoringConfig.HistoSpec.bins

Definition at line 276 of file JetMonitoringConfig.py.

◆ hargs

JetMonitoringConfig.HistoSpec.hargs

Definition at line 277 of file JetMonitoringConfig.py.

◆ is1D

JetMonitoringConfig.HistoSpec.is1D

Definition at line 256 of file JetMonitoringConfig.py.

◆ isProfile

JetMonitoringConfig.HistoSpec.isProfile

Definition at line 259 of file JetMonitoringConfig.py.

◆ klass

JetMonitoringConfig.ToolSpec.klass
inherited

Definition at line 163 of file JetMonitoringConfig.py.

◆ name

JetMonitoringConfig.HistoSpec.name

Definition at line 275 of file JetMonitoringConfig.py.

◆ nVar

JetMonitoringConfig.HistoSpec.nVar

Definition at line 258 of file JetMonitoringConfig.py.

◆ xvar

JetMonitoringConfig.HistoSpec.xvar

Definition at line 261 of file JetMonitoringConfig.py.

◆ yvar

JetMonitoringConfig.HistoSpec.yvar

Definition at line 262 of file JetMonitoringConfig.py.

◆ zvar

JetMonitoringConfig.HistoSpec.zvar

Definition at line 263 of file JetMonitoringConfig.py.


The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
RunTileMonitoring.groupName
groupName
Definition: RunTileMonitoring.py:158
python.TIDAMonTool.defineHisto
def defineHisto(montool, name, **args)
Definition: TIDAMonTool.py:332
python.Utilities.clone
clone
Definition: Utilities.py:134
JetMonitoringConfig.retrieveVarToolConf
def retrieveVarToolConf(alias)
Definition: JetMonitoringConfig.py:584
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
python.ChapPy.dump
def dump(buf, stdout=sys.stdout)
Definition: ChapPy.py:25
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.Bindings.__setitem__
__setitem__
Definition: Control/AthenaPython/python/Bindings.py:763
str
Definition: BTagTrackIpAccessor.cxx:11
python.PyAthenaComps.__setattr__
__setattr__
Definition: PyAthenaComps.py:41
Trk::split
@ split
Definition: LayerMaterialProperties.h:38