ATLAS Offline Software
Loading...
Searching...
No Matches
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
10CounterAlgorithm::CounterAlgorithm(const std::string& name, const MonitorBase* parent, const bool skipHistograms)
11 : CounterBase(name, parent)
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
30StatusCode CounterAlgorithm::newEvent(const CostData& data, size_t index, const float weight) {
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
@ kPerCall
Variable should fill underlying histogram on each fill.
@ kLog
Logarithmic x-binning.
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
virtual StatusCode newEvent(const CostData &data, size_t index, const float weight=1.) override
Concrete implimentation.
CounterAlgorithm()=delete
Forbid default constructor.
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...
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
CounterBase()=delete
Forbid default constructor.
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.
Variable & getVariable(const std::string &name)
Returns a mutable reference to a named Variable.
StatusCode setDenominator(const std::string &name, float value)
Optional for per-Event Variables.
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
static const std::string hash2string(HLTHash, const std::string &category="TE")
hash function translating identifiers into names (via internal dictionary)
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
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
size_t getCalls() const
Getter for how many times fill() has already been called on this Variable in this event.
Definition Variable.cxx:29
bool getDetail(const std::string &name, TYPE &value) const
Get an TYPE detail from the object.
Definition index.py:1
TrigComposite_v1 TrigComposite
Declare the latest version of the class.