ATLAS Offline Software
CounterAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "CounterAlgorithm.h"
9 
10 CounterAlgorithm::CounterAlgorithm(const std::string& name, const MonitorBase* parent, const bool skipHistograms)
12 {
13  if (!skipHistograms){
14  regHistogram("Time_perCall", "CPU Time/Call;Time [ms];Calls", VariableType::kPerCall, kLog, 0.01, 100000);
15  regHistogram("FirstTime_perEvent", "First Call CPU Time;Time [ms];Events", VariableType::kPerCall, kLog, 0.01, 100000);
16  regHistogram("Time_perEvent", "CPU Time/Event;Time [ms];Events", VariableType::kPerEvent);
17  regHistogram("Time_perEventFractional", "CPU Time/Event CPU Time;Fractional Time;Events", VariableType::kPerEvent, kLinear, 0., 1.);
18  regHistogram("AlgCalls_perEvent", "Calls/Event;Calls;Events", VariableType::kPerEvent, kLinear, -0.5, 499.5, 500);
19  regHistogram("InEventView_perCall", "In Event View;Yes or No;Calls", VariableType::kPerCall, kLinear, -0.5, 1.5, 2);
20  regHistogram("RoIID_perCall", "RoI ID;RoI ID;Calls", VariableType::kPerCall, kLinear, -1.5, 20.5, 22);
21  regHistogram("Request_perEvent", "Number of requests/Event;Number of requests;Events", VariableType::kPerEvent, LogType::kLinear, -0.5, 299.5, 300);
22  regHistogram("NetworkRequest_perEvent", "Number of network requests/Event;Number of requests;Events", VariableType::kPerEvent, LogType::kLinear, -0.5, 299.5, 300);
23  regHistogram("CachedROBSize_perEvent", "Total ROB Size/Event;ROB size;Events", VariableType::kPerEvent, LogType::kLinear, 0, 1024, 50);
24  regHistogram("NetworkROBSize_perEvent", "Total ROB Size/Event;ROB size;Events", VariableType::kPerEvent, LogType::kLinear, 0, 1024, 50);
25  regHistogram("RequestTime_perEvent", "ROB Elapsed Time/Event;Elapsed Time [ms];Events", VariableType::kPerEvent);
26  }
27 }
28 
29 
31  const xAOD::TrigComposite* alg = data.costCollection().at(index);
32 
33  const uint64_t start = alg->getDetail<uint64_t>("start"); // in mus
34  const uint64_t stop = alg->getDetail<uint64_t>("stop"); // in mus
35  const float cpuTime = timeToMilliSec(start, stop);
36 
37  ATH_CHECK( fill("Time_perCall", cpuTime, weight) );
38 
39  ATH_CHECK( fill("Time_perEvent", cpuTime, weight) );
40 
41  Variable& firstTime_perEvent = getVariable("FirstTime_perEvent");
42  if (firstTime_perEvent.getCalls() == 0) {
43  ATH_CHECK( firstTime_perEvent.fill(cpuTime, weight) );
44  }
45 
46  ATH_CHECK( setDenominator("Time_perEventFractional", data.algTotalTimeMilliSec()) );
47  ATH_CHECK( fill("Time_perEventFractional", cpuTime, weight) );
48 
49  ATH_CHECK( increment("AlgCalls_perEvent", weight) );
50 
51  const bool globalScope = (TrigConf::HLTUtils::hash2string( alg->getDetail<TrigConf::HLTHash>("store"), "STORE").find("StoreGateSvc") != std::string::npos);
52  ATH_CHECK( fill("InEventView_perCall", (globalScope ? 0.0 : 1.0), weight) );
53 
54  ATH_CHECK( fill("RoIID_perCall", alg->getDetail<int32_t>("roi"), weight) );
55 
56  // Monitor data requests per algorithm
57  if (data.algToRequestMap().count(index)) {
58  for (size_t requestIdx : data.algToRequestMap().at(index)) {
59  const xAOD::TrigComposite* request = data.rosCollection().at(requestIdx);
60  const std::vector<unsigned> robs_history = request->getDetail<std::vector<unsigned>>("robs_history");
61  const std::vector<uint32_t> robs_size = request->getDetail<std::vector<uint32_t>>("robs_size");
62 
63  bool networkRequestIncremented = false;
64  for (size_t i = 0; i < robs_size.size(); ++i) {
65  // ROB request was fetched over the network
66  if (robs_history[i] == robmonitor::RETRIEVED) {
67  // size is stored in words, should be in kilobytes
68  ATH_CHECK( fill("NetworkROBSize_perEvent", robs_size[i] / 500., weight) );
69  networkRequestIncremented = true;
70  }
71  // ROB request was cached
72  else if (robs_history[i] == robmonitor::HLT_CACHED || robs_history[i] == robmonitor::DCM_CACHED) {
73  ATH_CHECK( fill("CachedROBSize_perEvent", robs_size[i] / 500., weight) );
74  }
75  }
76 
77  ATH_CHECK( increment("Request_perEvent", weight) );
78 
79  if (networkRequestIncremented) {
80  ATH_CHECK( increment("NetworkRequest_perEvent", weight) );
81  }
82 
83  const float rosTime = timeToMilliSec(request->getDetail<uint64_t>("start"), request->getDetail<uint64_t>("stop"));
84  ATH_CHECK( fill("RequestTime_perEvent", rosTime, weight) );
85  }
86  }
87 
88  return StatusCode::SUCCESS;
89 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CounterBase::setDenominator
StatusCode setDenominator(const std::string &name, float value)
Optional for per-Event Variables.
Definition: CounterBase.cxx:210
CounterBase
Forward declare.
Definition: CounterBase.h:25
CounterBase::regHistogram
void regHistogram(const std::string &name, const std::string &title, const VariableType type=VariableType::kPerCall, const LogType xaxis=kLog, const float min=0.1, const float max=1000000., const size_t bins=70)
Book a histogram for this Counter, to be filled in per-event monitoring.
Definition: CounterBase.cxx:27
SGout2dot.alg
alg
Definition: SGout2dot.py:243
index
Definition: index.py:1
CounterBase::fill
StatusCode fill(const std::string &name, float value, float weight=1.0)
Fill (for per-Call) or accumulate in a buffer (for per-Event) a quantity histogrammed by a named Vari...
Definition: CounterBase.cxx:191
TrigConf::HLTHash
uint32_t HLTHash
Definition: TrigConfHLTUtils/TrigConfHLTUtils/HLTUtils.h:19
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
robmonitor::DCM_CACHED
@ DCM_CACHED
Definition: ROBDataMonitor.h:30
kPerEvent
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:19
CounterAlgorithm.h
ROBDataMonitor.h
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
Variable::getCalls
size_t getCalls() const
Getter for how many times fill() has already been called on this Variable in this event.
Definition: Variable.cxx:29
CounterAlgorithm::CounterAlgorithm
CounterAlgorithm()=delete
Forbid default constructor.
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
kLog
@ kLog
Logarithmic x-binning.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:28
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
TrigCompositeContainer.h
kPerCall
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:18
CounterBase::getVariable
Variable & getVariable(const std::string &name)
Returns a mutable reference to a named Variable.
Definition: CounterBase.cxx:182
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigConf::HLTUtils::hash2string
static const std::string hash2string(HLTHash, const std::string &category="TE")
hash function translating identifiers into names (via internal dictionary)
Variable
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:39
kLinear
@ kLinear
Linear x-binning.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:27
MonitorBase
Forward declare.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:33
robmonitor::RETRIEVED
@ RETRIEVED
Definition: ROBDataMonitor.h:28
robmonitor::HLT_CACHED
@ HLT_CACHED
Definition: ROBDataMonitor.h:29
CounterBase::increment
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
Definition: CounterBase.cxx:220
xAOD::TrigComposite_v1::getDetail
bool getDetail(const std::string &name, TYPE &value) const
Get an TYPE detail from the object.
CounterAlgorithm::newEvent
virtual StatusCode newEvent(const CostData &data, size_t index, const float weight=1.) override
Concrete implimentation.
Definition: CounterAlgorithm.cxx:30
CounterBase::timeToMilliSec
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
Definition: CounterBase.cxx:243
Variable::fill
StatusCode fill(float value, float weight=1.0)
Fill histogram (per-Call Variable), or add value to internal accumulator (per-Event Variable) to be f...
Definition: Variable.cxx:49
CostData
Caches and propagates event data to be used by monitoring algorithms.
Definition: CostData.h:26