ATLAS Offline Software
Algorithm_HLT_TableConstructor.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4 #
5 
6 from TrigCostAnalysis.TableConstructorBase import TableConstructorBase, Column
7 from AthenaCommon.Logging import logging
8 log = logging.getLogger('Algorithm_HLT')
9 
10 '''
11 @file Algorithm_HLT_TableConstructor.py
12 @brief Contains TableConstructor classes per Algorithm_HLT table. Defines what
13  should be saved in table and fills them
14 '''
15 
16 
17 class Algorithm_HLT_TableConstructor(TableConstructorBase):
18  ''' @brief Class representing Algorithm_HLT table
19  '''
20  def __init__(self, tableObj, underflowThreshold, overflowThreshold):
21  super(). __init__(tableObj, underflowThreshold, overflowThreshold)
22  # Dump summary of mean time execution for all the algorithms to the log
23  self.dumpSummary = False
24  self.expectedHistograms = ["Time_perCall",
25  "FirstTime_perEvent",
26  "Time_perEvent",
27  "Time_perEventFractional",
28  "AlgCalls_perEvent",
29  "RoIID_perCall",
30  "InEventView_perCall",
31  "Request_perEvent",
32  "NetworkRequest_perEvent",
33  "CachedROBSize_perEvent",
34  "NetworkROBSize_perEvent",
35  "RequestTime_perEvent"]
36 
37 
38  def defineColumns(self):
39  self.columns["name"] = Column("Name", "Algorithms name")
40  self.columns["events"] = Column("Raw Active Events", "Raw underlying statistics on number of events processed with the alg active")
41  self.columns["eventsWeighted"] = Column("Active Events", "Total weighted number of events with the alg active")
42  self.columns["callsPerEvent"] = Column("Calls/Event", "Mean number of alg calls in events with one or more calls")
43  self.columns["callsSlow"] = Column("Calls > 1000 ms", "Weighted number of events in which this alg was exceptionally slow")
44  self.columns["eventRate"] = Column("Event Rate [Hz]", "Walltime normalised rate of events with one or more executions of the alg", True)
45  self.columns["callRate"] = Column("Call Rate [Hz]", "Walltime normalised rate of calls in events with one or more executions of the alg", True)
46  self.columns["totalTimeSec"] = Column("Alg Total Time [s]", "Total weighted integrated walltime of the alg")
47  self.columns["totalTimePerc"] = Column("Alg Total Time [%]", "Total weighted integrated walltime of the alg as a percentage of all algs")
48  self.columns["timePerCall"] = Column("Alg Total Time/Call [ms]", "Mean weighted alg time. Normalised to all alg calls")
49  self.columns["timePerEvent"] = Column("Alg Total Time/Event [ms]", "Mean weighted alg time. Normalised to all events with one or more alg calls")
50  self.columns["requestTimePerEvent"] = Column("ROS Data Request Time/Event [ms]", "Average time waiting for ROS data per event for events with at least one execution in this run range")
51  self.columns["dataRate"] = Column("Data Request Rate [Hz]", "Rate of data requests to ROSes from this algorithm in this run range", True)
52  self.columns["retrievedDataRate"] = Column("Retrieved Data request Rate [Hz]", "Rate of data request with at least one network ROS request from this algorithm in this run range", True)
53  self.columns["cachedDataSizeRate"] = Column("Cached ROB Rate [kB/s]", "Average size of cached ROB data fetches for this algorithm in this run range", True)
54  self.columns["retrievedDataSizeRate"] = Column("Retrieved ROB Rate [kB/s]", "Average size of retrieved ROB data fetches for this algorithm in this run range")
55 
56 
57  def fillColumns(self, itemName):
58  weightedEvents = self.getHistogram("AlgCalls_perEvent").Integral()
59  weightedCalls = self.getXWeightedIntegral("AlgCalls_perEvent", isLog=False)
60  slowCalls = self.getHistogram("Time_perCall").Integral(self.getHistogram("Time_perCall").FindBin(1000.), self.getHistogram("Time_perCall").GetNbinsX())
61 
62  self.columns["name"].addValue(itemName)
63  self.columns["events"].addValue(self.getHistogram("AlgCalls_perEvent").GetEntries())
64  self.columns["eventsWeighted"].addValue(weightedEvents)
65  self.columns["callsPerEvent"].addValue(self.getHistogram("AlgCalls_perEvent").GetMean())
66  self.columns["callsSlow"].addValue(slowCalls)
67  self.columns["eventRate"].addValue(weightedEvents)
68  self.columns["callRate"].addValue(weightedCalls)
69  self.columns["totalTimeSec"].addValue(self.getXWeightedIntegral("Time_perCall", isLog=True) * 1e-3)
70  #self.columns["totalTimePerc"] in post processing
71  self.columns["timePerCall"].addValue(self.getHistogram("Time_perCall").GetMean())
72  self.columns["timePerEvent"].addValue(self.getHistogram("Time_perEvent").GetMean())
73  self.columns["requestTimePerEvent"].addValue(self.getHistogram("RequestTime_perEvent").GetMean())
74  self.columns["dataRate"].addValue(self.getXWeightedIntegral("Request_perEvent", isLog=False))
75  self.columns["retrievedDataRate"].addValue(self.getXWeightedIntegral("NetworkRequest_perEvent", isLog=False))
76  self.columns["cachedDataSizeRate"].addValue(self.getXWeightedIntegral("CachedROBSize_perEvent", isLog=False))
77  self.columns["retrievedDataSizeRate"].addValue(self.getXWeightedIntegral("NetworkROBSize_perEvent", isLog=False))
78 
79  if self.dumpSummary:
80  log.info("Algorithm: {0:300} Mean Time per call [ms]: {1:10.4} Mean Time per event [ms]: {2:10.3}".format(itemName, self.getHistogram("Time_perCall").GetMean(), self.getHistogram("Time_perEvent").GetMean()))
81 
82 
83  def postProcessing(self):
84  totalTimeEntries = self.columns["totalTimeSec"].content
85  totalTime = sum(totalTimeEntries)
86  if (totalTime == 0):
87  log.error("No histograms for the Algorithm HLT summary were found")
88  raise ValueError
89 
90  for entry in totalTimeEntries:
91  self.columns["totalTimePerc"].addValue(100 * entry / totalTime)
vtune_athena.format
format
Definition: vtune_athena.py:14
Algorithm_HLT_TableConstructor.Algorithm_HLT_TableConstructor.__init__
def __init__(self, tableObj, underflowThreshold, overflowThreshold)
Definition: Algorithm_HLT_TableConstructor.py:20
RootHelpers::FindBin
Int_t FindBin(const TAxis *axis, const double x)
Definition: RootHelpers.cxx:14
GetMean
TGraphErrors * GetMean(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:3907
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
Algorithm_HLT_TableConstructor.Algorithm_HLT_TableConstructor
Definition: Algorithm_HLT_TableConstructor.py:17
Algorithm_HLT_TableConstructor.Algorithm_HLT_TableConstructor.postProcessing
def postProcessing(self)
Definition: Algorithm_HLT_TableConstructor.py:83
Algorithm_HLT_TableConstructor.Algorithm_HLT_TableConstructor.dumpSummary
dumpSummary
Definition: Algorithm_HLT_TableConstructor.py:23
Algorithm_HLT_TableConstructor.Algorithm_HLT_TableConstructor.expectedHistograms
expectedHistograms
Definition: Algorithm_HLT_TableConstructor.py:24
Algorithm_HLT_TableConstructor.Algorithm_HLT_TableConstructor.fillColumns
def fillColumns(self, itemName)
Definition: Algorithm_HLT_TableConstructor.py:57
Algorithm_HLT_TableConstructor.Algorithm_HLT_TableConstructor.defineColumns
def defineColumns(self)
Definition: Algorithm_HLT_TableConstructor.py:38