diff --git a/Trigger/TrigMonitoring/TrigMonitorBase/python/TrigGenericMonitoringToolConfig.py b/Trigger/TrigMonitoring/TrigMonitorBase/python/TrigGenericMonitoringToolConfig.py index 14e678dbbe1a9fa721e2a182cb6c3a0e1434d3dc..81bd3d0fabf77a6a75c90c31303ff6fffdb30942 100755 --- a/Trigger/TrigMonitoring/TrigMonitorBase/python/TrigGenericMonitoringToolConfig.py +++ b/Trigger/TrigMonitoring/TrigMonitorBase/python/TrigGenericMonitoringToolConfig.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration from AthenaCommon.Logging import logging log = logging.getLogger('TrigGenericMonitoringToolConfig.py') @@ -19,8 +19,42 @@ else: as TrigGenericMonitoringTool log.info("Using thread-safe TrigGenericMonitoringTool") -from AthenaMonitoring.GenericMonitoringTool import defineHistogram as __defineHistogram -defineHistogram = __defineHistogram + +## Generate histogram definition string for the `TrigGenericMonitoringTool.Histograms` property +# +# For full details see the TrigGenericMonitoringTool documentation. +# @param varname one (1D) or two (2D) variable names separated by comma +# @param type histogram type +# @param path top-level histrogram directory +# @param title Histogram title and optional axis title (same syntax as in TH constructor) +# @param opt Histrogram options (see TrigGenericMonitoringTool) +# @param labels List of bin labels (for a 2D histogram, sequential list of x- and y-axis labels) +def defineHistogram(varname, type='TH1F', path='EXPERT', + title=None, + xbins=100, xmin=0, xmax=1, + ybins=None, ymin=None, ymax=None, zmin=None, zmax=None, opt='', labels=None): + + if title is None: title=varname + coded = "%s, %s, %s, %s, %d, %f, %f" % (path, type, varname, title, xbins, xmin, xmax) + if ybins is not None: + coded += ",%d, %f, %f" % (ybins, ymin, ymax) + if zmin is not None: + coded += ", %f, %f" % (zmin, zmax) + if ybins is None and ymin is not None: + coded += ", %f, %f" % (ymin, ymax) + + if isinstance(labels, list) and len(labels)>0: + coded += ',' + ':'.join(labels) + ':' + + # For backwards compatibility + elif labels is not None: + labels = labels.strip() # remove spurious white-spaces + if len(labels)>0: + if labels[-1]!=':': labels += ':' # C++ parser expects at least one ":" + coded += ",%s " % labels + coded += ", %s" % opt + + return coded class TrigGenericMonitoringToolConfig(TrigGenericMonitoringTool):