ATLAS Offline Software
Loading...
Searching...
No Matches
CounterSequence.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include "CounterSequence.h"
9
10
11CounterSequence::CounterSequence(const std::string& name, const MonitorBase* parent)
12 : CounterBase(name, parent)
13{
14 regHistogram("Sequence_perEvent", "Sequnece calls/Event;Sequence call;Events", VariableType::kPerEvent, kLinear, -0.5, 49.5);
15 regHistogram("AlgCalls_perEvent", "Algorithm Calls/Event;Calls;Events", VariableType::kPerEvent, kLinear, -0.5, 499.5, 100);
16 regHistogram("Time_perCall", "CPU Time/Call;Time [ms];Calls", VariableType::kPerCall);
17 regHistogram("Time_perEvent", "CPU Time/Event;Time [ms];Events", VariableType::kPerEvent);
18 regHistogram("Request_perEvent", "Number of requests/Event;Number of requests;Events", VariableType::kPerEvent, LogType::kLinear, -0.5, 299.5, 300);
19 regHistogram("NetworkRequest_perEvent", "Number of network requests/Event;Number of requests;Events", VariableType::kPerEvent, LogType::kLinear, -0.5, 149.5, 150);
20 regHistogram("CachedROBSize_perEvent", "Cached ROB Size/Event;ROB size;Events", VariableType::kPerEvent, LogType::kLinear, 0, 1024, 50);
21 regHistogram("NetworkROBSize_perEvent", "Network ROB Size/Event;ROB size;Events", VariableType::kPerEvent, LogType::kLinear, 0, 1024, 50);
22 regHistogram("RequestTime_perEvent", "ROB Elapsed Time/Event;Elapsed Time [ms];Events", VariableType::kPerEvent);
23}
24
25
26StatusCode CounterSequence::newEvent(const CostData& data, size_t index, const float weight) {
27
28 ATH_CHECK( increment("Sequence_perEvent", weight) );
29 float viewTime = 0;
30 // Monitor algorithms associated with sequence name
31 for (const size_t algIndex : data.sequencersMap().at(getName()).at(index)){
32
33 const xAOD::TrigComposite* alg = data.costCollection().at(algIndex);
34 const uint32_t slot = alg->getDetail<uint32_t>("slot");
35 if (slot != data.onlineSlot()) {
36 continue; // When monitoring the master slot, this Monitor ignores algs running in different slots
37 }
38
39 ATH_CHECK( increment("AlgCalls_perEvent", weight) );
40
41 const uint64_t start = alg->getDetail<uint64_t>("start"); // in mus
42 const uint64_t stop = alg->getDetail<uint64_t>("stop"); // in mus
43 const float cpuTime = timeToMilliSec(start, stop);
44 ATH_CHECK( fill("Time_perEvent", cpuTime, weight) );
45 viewTime += cpuTime;
46
47 // Monitor data requests
48 if (!data.algToRequestMap().count(algIndex)) continue;
49
50 for (size_t requestIdx : data.algToRequestMap().at(algIndex)) {
51 const xAOD::TrigComposite* request = data.rosCollection().at(requestIdx);
52 const std::vector<unsigned> robs_history = request->getDetail<std::vector<unsigned>>("robs_history");
53 const std::vector<uint32_t> robs_size = request->getDetail<std::vector<uint32_t>>("robs_size");
54
55 bool networkRequestIncremented = false;
56 for (size_t i = 0; i < robs_size.size(); ++i) {
57 // ROB request was fetched over the network
58 if (robs_history[i] == robmonitor::RETRIEVED) {
59 // size is stored in words, should be in kilobytes
60 ATH_CHECK( fill("NetworkROBSize_perEvent", robs_size[i] / 500., weight) );
61 networkRequestIncremented = true;
62 }
63 // ROB request was cached
64 else if (robs_history[i] == robmonitor::HLT_CACHED || robs_history[i] == robmonitor::DCM_CACHED) {
65 ATH_CHECK( fill("CachedROBSize_perEvent", robs_size[i] / 500., weight) );
66 }
67 }
68
69 ATH_CHECK( increment("Request_perEvent", weight) );
70
71 if (networkRequestIncremented) {
72 ATH_CHECK( increment("NetworkRequest_perEvent", weight) );
73 }
74
75 const float rosTime = timeToMilliSec(request->getDetail<uint64_t>("start"), request->getDetail<uint64_t>("stop"));
76 ATH_CHECK( fill("RequestTime_perEvent", rosTime, weight) );
77 }
78 }
79
80 ATH_CHECK( fill("Time_perCall", viewTime, weight) );
81
82 return StatusCode::SUCCESS;
83}
#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.
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
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.
const std::string & getName() const
Getter for Counter's name.
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
virtual StatusCode newEvent(const CostData &data, size_t index, const float weight=1.) override
Concrete implimentation.
CounterSequence()=delete
Forbid default constructor.
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.