3 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory
import CompFactory
5 from AthenaMonitoringKernel.GenericMonitoringTool
import GenericMonitoringTool
8 monsvc = CompFactory.SchedulerMonSvc(name)
12 def getFlag(flagName, defaultValue):
13 if flags.hasCategory(
'SchedulerMonSvc')
and flags.SchedulerMonSvc.hasFlag(flagName):
14 return eval(
'flags.SchedulerMonSvc.'+flagName)
18 def defineHist1D(varName, varLabel, labels=None, **kwargs):
19 monsvc.MonTool.defineHistogram(varName, path=
'EXPERT', type=
'TH1D',
20 title=varLabel+
';'+varLabel+
';Snapshots',
21 xlabels=labels, opt=
'kCanRebin', **kwargs)
23 def defineHistVsWallTime(varName, varLabel, _type, labels=None, **kwargs):
24 monsvc.MonTool.defineHistogram(
25 'WallTimeSeconds,'+varName, path=
'EXPERT', type=_type,
26 title=varLabel+
' vs time;Time [s];'+varLabel,
27 xbins=600, xmin=0, xmax=60, ylabels=labels, opt=
'kCanRebin', **kwargs)
29 def defineHistVsSnapNumber(varName, varLabel, _type, labels=None, **kwargs):
30 monsvc.MonTool.defineHistogram(
31 'SnapNumber,'+varName, path=
'EXPERT', type=_type,
32 title=varLabel+
' vs time (snap number);Snap number;'+varLabel,
33 xbins=1000, xmin=0, xmax=1000, ylabels=labels, opt=
'kCanRebin', **kwargs)
35 def defineStandardHistogramSet(varName, varLabel, nbins, min, max, labels=None, type2D='TProfile', **kwargs):
36 defineHist1D(varName, varLabel, labels, xbins=nbins, xmin=min, xmax=max, **kwargs)
37 defineHistVsWallTime(varName, varLabel, type2D, labels, ybins=nbins, ymin=min, ymax=max, **kwargs)
38 if enablePlotsVsSnapNumber:
39 defineHistVsSnapNumber(varName, varLabel, type2D, labels, ybins=nbins, ymin=min, ymax=max, **kwargs)
42 monsvc.SchedulerName =
getFlag(
'SchedulerName',
'AvalancheSchedulerSvc')
43 monsvc.MonIntervalMillisec =
getFlag(
'MonIntervalMillisec', 100)
46 enablePlotsVsSnapNumber =
getFlag(
'enablePlotsVsSnapNumber',
False)
47 enablePlotsOverThreads =
getFlag(
'enablePlotsOverThreads',
True)
48 enablePlotsOverSlots =
getFlag(
'enablePlotsOverSlots',
True)
49 enablePlotsOverActive =
getFlag(
'enablePlotsOverActive',
True)
52 stateNames = [
'INITIAL',
'CONTROLREADY',
'DATAREADY',
'RESOURCELESS',
53 'SCHEDULED',
'EVTACCEPTED',
'EVTREJECTED',
'ERROR']
54 activeStates = [
'CONTROLREADY',
'DATAREADY',
'RESOURCELESS',
'SCHEDULED']
57 defineStandardHistogramSet(
'AlgStates',
'Algorithm state', 8, -0.5, 7.5, labels=stateNames, type2D=
'TH2D', weight=
'StateTotalCounts')
58 defineStandardHistogramSet(
'FreeSlots',
'Number of free slots', 10, 0, 10)
59 defineStandardHistogramSet(
'FreeSlotsFraction',
'Fraction of free slots', 100, 0, 1)
60 for state
in stateNames:
61 defineStandardHistogramSet(state,
'N algs in '+state+
' state', 100, 0, 100)
62 for state
in activeStates:
63 if enablePlotsOverThreads:
64 defineStandardHistogramSet(state+
'_Over_Threads',
'N '+state+
' / N threads', 100, 0, 10)
65 if enablePlotsOverSlots:
66 defineStandardHistogramSet(state+
'_Over_Slots',
'N '+state+
' / N slots', 100, 0, 10)
67 if enablePlotsOverActive:
68 defineStandardHistogramSet(state+
'_Over_Active',
'N '+state+
' / N active states', 100, 0, 1)
70 monsvc.MonTool.defineHistogram(
'TIME_monCallback', path=
'EXPERT', type=
'TH1D',
71 title=
'Time of callback calls;Time [us];Calls',
72 xbins=500, xmin=0, xmax=5000)
75 acc.addService(monsvc)
79 errorMonTool = CompFactory.TrigErrorMonTool(name)
82 errorMonTool.MonTool.defineHistogram(
83 'ErrorAlgName,ErrorCode', path=
'EXPERT', type=
'TH2I',
84 title=
'Error StatusCodes per algorithm;Algorithm name;StatusCode',
85 xbins=1, xmin=0, xmax=1, ybins=1, ymin=0, ymax=1)