ATLAS Offline Software
Public Member Functions | Public Attributes | Static Private Member Functions | List of all members
GenericMonitoringTool.GenericMonitoringArray Class Reference
Collaboration diagram for GenericMonitoringTool.GenericMonitoringArray:

Public Member Functions

def __init__ (self, flags, name, dimensions, **kwargs)
 
def __getitem__ (self, index)
 
def toolList (self)
 
def broadcast (self, member, value)
 
def defineHistogram (self, varname, title=None, path=None, pattern=None, **kwargs)
 

Public Attributes

 Tools
 
 Accessors
 

Static Private Member Functions

def _postfixes (dimensions, previous='')
 

Detailed Description

Array of configurables of GenericMonitoringTool objects

Definition at line 61 of file GenericMonitoringTool.py.

Constructor & Destructor Documentation

◆ __init__()

def GenericMonitoringTool.GenericMonitoringArray.__init__ (   self,
  flags,
  name,
  dimensions,
**  kwargs 
)

Definition at line 63 of file GenericMonitoringTool.py.

63  def __init__(self, flags, name, dimensions, **kwargs):
64  self.Tools = {}
65  self.Postfixes, self.Accessors = GenericMonitoringArray._postfixes(dimensions)
66  for postfix in self.Postfixes:
67  self.Tools[postfix] = GenericMonitoringTool(flags, name+postfix,**kwargs)
68 

Member Function Documentation

◆ __getitem__()

def GenericMonitoringTool.GenericMonitoringArray.__getitem__ (   self,
  index 
)
Forward operator[] on class to the list of tools

Definition at line 69 of file GenericMonitoringTool.py.

69  def __getitem__(self,index):
70  '''Forward operator[] on class to the list of tools'''
71  return self.toolList()[index]
72 

◆ _postfixes()

def GenericMonitoringTool.GenericMonitoringArray._postfixes (   dimensions,
  previous = '' 
)
staticprivate
Generates a list of subscripts to add to the name of each tool

Arguments:
dimensions -- List containing the lengths of each side of the array off tools
previous -- Strings appended from the other dimensions of the array

Definition at line 138 of file GenericMonitoringTool.py.

138  def _postfixes(dimensions, previous=''):
139  '''Generates a list of subscripts to add to the name of each tool
140 
141  Arguments:
142  dimensions -- List containing the lengths of each side of the array off tools
143  previous -- Strings appended from the other dimensions of the array
144  '''
145  import collections
146  assert isinstance(dimensions,list) and len(dimensions)>0, \
147  'GenericMonitoringArray must have list of dimensions.'
148  try:
149  if dimensions==[1]:
150  return [''], {'': ['']}
151  except AttributeError:
152  #Evidently not [1]
153  pass
154  postList = []
155  accessorDict = collections.OrderedDict()
156  first = dimensions[0]
157  if isinstance(first,list):
158  iterable = first
159  elif isinstance(first,int):
160  iterable = range(first)
161  else:
162  #Assume GaudiConfig2.semantics._ListHelper
163  iterable = list(first)
164  for i in iterable:
165  if len(dimensions)==1:
166  postList.append(previous+'_'+str(i))
167  accessorDict[previous+'_'+str(i)]=[str(i)]
168  else:
169  postfixes, accessors = GenericMonitoringArray._postfixes(dimensions[1:],previous+'_'+str(i))
170  postList.extend(postfixes)
171  for acckey, accval in accessors.items():
172  accessorDict[acckey] = [str(i)] + accval
173  return postList, accessorDict
174 
175 

◆ broadcast()

def GenericMonitoringTool.GenericMonitoringArray.broadcast (   self,
  member,
  value 
)
Allows one to set attributes of every tool simultaneously

Arguments:
member -- string which contains the name of the attribute to be set
value -- value of the attribute to be set

Definition at line 76 of file GenericMonitoringTool.py.

76  def broadcast(self, member, value):
77  '''Allows one to set attributes of every tool simultaneously
78 
79  Arguments:
80  member -- string which contains the name of the attribute to be set
81  value -- value of the attribute to be set
82  '''
83  for tool in self.toolList():
84  setattr(tool,member,value)
85 

◆ defineHistogram()

def GenericMonitoringTool.GenericMonitoringArray.defineHistogram (   self,
  varname,
  title = None,
  path = None,
  pattern = None,
**  kwargs 
)
Propogate defineHistogram to each tool, adding a unique tag.

Arguments:
pattern -- if specified, list of n-tuples of indices for plots to create

Definition at line 86 of file GenericMonitoringTool.py.

86  def defineHistogram(self, varname, title=None, path=None, pattern=None, **kwargs):
87  '''Propogate defineHistogram to each tool, adding a unique tag.
88 
89  Arguments:
90  pattern -- if specified, list of n-tuples of indices for plots to create
91  '''
92  unAliased = varname.split(';')[0]
93  _, aliasBase = _alias(varname)
94  if aliasBase is None or aliasBase.strip() == '':
95  raise ValueError(f'Unable to define histogram using definition "{varname}" since we cannot determine its name')
96  if pattern is not None:
97  try:
98  iter(pattern)
99  except TypeError:
100  raise ValueError('Argument to GenericMonitoringArray.defineHistogram must be iterable')
101  if not isinstance(pattern, list):
102  pattern = list(pattern)
103  if len(pattern) == 0: # nothing to do
104  return
105  if isinstance(pattern[0], (str, int)):
106  # assume we have list of strings or ints; convert to list of 1-element tuples
107  pattern = [(_2,) for _2 in pattern]
108  for postfix, tool in self.Tools.items():
109  try:
110  accessors = tuple(self.Accessors[postfix])
111  if pattern is not None:
112  if accessors not in pattern:
113  continue
114  # two options for alias formatting,
115  # a) default convention: (var_0, var_1, etc.)
116  # b) custom formatting: 'alias{0}custom'.format(*(0, 1))
117  aliasBaseFormatted = aliasBase.format(*accessors)
118  if aliasBaseFormatted==aliasBase:
119  # if format call did not do anything, use default
120  aliased = unAliased+';'+aliasBase+postfix
121  else:
122  # if format call changed the alias, use custom
123  aliased = unAliased+';'+aliasBaseFormatted
124  if title is not None:
125  kwargs['title'] = title.format(*accessors)
126  if path is not None:
127  kwargs['path'] = path.format(*accessors)
128  except IndexError as e:
129  log.error('In title or path template of histogram {0}, too many positional '\
130  'arguments were requested. Title and path templates were "{1}" and "{2}", '\
131  'while only {3} fillers were given: {4}.'.format(aliasBase, title,\
132  path, len(accessors), accessors))
133  raise e
134 
135  tool.defineHistogram(aliased, **kwargs)
136 

◆ toolList()

def GenericMonitoringTool.GenericMonitoringArray.toolList (   self)

Definition at line 73 of file GenericMonitoringTool.py.

73  def toolList(self):
74  return list(self.Tools.values())
75 

Member Data Documentation

◆ Accessors

GenericMonitoringTool.GenericMonitoringArray.Accessors

Definition at line 65 of file GenericMonitoringTool.py.

◆ Tools

GenericMonitoringTool.GenericMonitoringArray.Tools

Definition at line 64 of file GenericMonitoringTool.py.


The documentation for this class was generated from the following file:
vtune_athena.format
format
Definition: vtune_athena.py:14
GenericMonitoringTool
Definition: GenericMonitoringTool.h:53
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
GenericMonitoringTool._alias
def _alias(varname)
Generate an alias for a set of variables.
Definition: GenericMonitoringTool.py:199
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
GenericMonitoringTool.defineHistogram
def defineHistogram(flags, varname, type='TH1F', path=None, title=None, weight=None, xbins=100, xmin=0, xmax=1, xlabels=None, ybins=None, ymin=None, ymax=None, ylabels=None, zmin=None, zmax=None, zlabels=None, opt=None, convention=None, cutmask=None, treedef=None, merge=None)
Generate histogram definition string for the GenericMonitoringTool.Histograms property.
Definition: GenericMonitoringTool.py:306
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.__getitem__
__getitem__
Definition: Control/AthenaPython/python/Bindings.py:779