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:
104 return
105 if isinstance(pattern[0], (str, int)):
106
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
115
116
117 aliasBaseFormatted = aliasBase.format(*accessors)
118 if aliasBaseFormatted==aliasBase:
119
120 aliased = unAliased+';'+aliasBase+postfix
121 else:
122
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