ATLAS Offline Software
Loading...
Searching...
No Matches
CounterROS.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include "CounterROS.h"
9
10#include <algorithm>
11#include <string>
12#include <vector>
13
14CounterROS::CounterROS(const std::string& name, const MonitorBase* parent)
15 : CounterBase(name, parent) {
16
17 regHistogram("Request_perEvent", "Number of requests/Event;Number of requests;Events", VariableType::kPerEvent, LogType::kLinear, -0.5, 49.5, 50);
18 regHistogram("NetworkRequest_perEvent", "Number of network requests/Event;Number of requests;Events", VariableType::kPerEvent, LogType::kLinear, -0.5, 20.5, 21);
19 regHistogram("CachedROBSize_perEvent", "Total Cached ROB Size/Event;ROB size;Events", VariableType::kPerEvent, LogType::kLinear, 0, 1024, 50);
20 regHistogram("NetworkROBSize_perEvent", "Total Network ROB Size/Event;ROB size;Events", VariableType::kPerEvent, LogType::kLinear, 0, 1024, 50);
21 regHistogram("Time_perEvent", "ROB Elapsed Time/Event;Elapsed Time [ms];Events", VariableType::kPerEvent);
22 regHistogram("ROBStatus_perCall", "ROB status/Call;Status;Calls", VariableType::kPerCall, LogType::kLinear, 0, robmonitor::NUM_ROBHIST_CODES+1, robmonitor::NUM_ROBHIST_CODES+1);
23 regHistogram("NROBsPerRequest_perCall", "Number of requested ROBs;Number of requestes ROBs;Number of requests", VariableType::kPerCall, LogType::kLinear, 0.5, 30.5, 30);
24}
25
26CounterROS::CounterROS(const std::string& name, unsigned nRobs, const MonitorBase* parent)
27 : CounterROS(name, parent) {
28
29 regHistogram("ROBsPerRequest_perCall", "Number of ROB requests;ROBs names;Number of requests", VariableType::kPerCall, LogType::kLinear, 0, nRobs, nRobs);
30}
31
32StatusCode CounterROS::newEvent(const CostData& data, size_t index, const float weight) {
33
34 // Monitor only ROB data for corresponding ROS
35 const xAOD::TrigComposite* tc = data.rosCollection()[index];
36 const std::vector<uint32_t> robIdsPerRequest = tc->getDetail<std::vector<uint32_t>>("robs_id");
37 const std::vector<uint32_t> robs_size = tc->getDetail<std::vector<uint32_t>>("robs_size");
38 const std::vector<unsigned> robs_history = tc->getDetail<std::vector<unsigned>>("robs_history");
39 const std::vector<unsigned short> robs_status = tc->getDetail<std::vector<unsigned short>>("robs_status");
40
41
42 if (m_robIdToBin.empty()) {
43 // Set lables of status histogram
44 ATH_CHECK( getVariable("ROBStatus_perCall").setBinLabel(1, "Unclassified"));
45 ATH_CHECK( getVariable("ROBStatus_perCall").setBinLabel(2, "Retrieved"));
46 ATH_CHECK( getVariable("ROBStatus_perCall").setBinLabel(3, "HLT Cached"));
47 ATH_CHECK( getVariable("ROBStatus_perCall").setBinLabel(4, "DCM Cached"));
48 ATH_CHECK( getVariable("ROBStatus_perCall").setBinLabel(5, "Ignored"));
49 ATH_CHECK( getVariable("ROBStatus_perCall").setBinLabel(6, "Disabled"));
50 ATH_CHECK( getVariable("ROBStatus_perCall").setBinLabel(7, "IsNotOK"));
51
52 if (variableExists("ROBsPerRequest_perCall")) {
53 // This monitor has it's own binning for ROBs due to the fact that limited number of ROBs are associated with one ROS
54 unsigned robCounter = 0;
55 for (uint32_t robId : data.costROSData().getROBForROS(getName())) {
56 std::string robName = data.costROSData().getROBName(robId);
57 ATH_CHECK( getVariable("ROBsPerRequest_perCall").setBinLabel(robCounter+1, robName));
58
59 m_robIdToBin[robId] = robCounter;
60 ++robCounter;
61 }
62 }
63 }
64
65
66 // Find all ROB requests that are both in request and correspond to this ROS
67 bool networkRequestIncremented = false;
68 int nRequestedRobs = 0;
69 for (size_t i = 0; i < robIdsPerRequest.size(); ++i) {
70
71 // Check if the ROB was requested by ROS
72 if (data.costROSData().getROSForROB(robIdsPerRequest[i]) != getName() ) continue;
73
74 if (m_robIdToBin.find(robIdsPerRequest[i]) != m_robIdToBin.end()) {
75 ATH_CHECK( fill("ROBStatus_perCall", getROBHistoryBin(robs_history[i]), weight) );
76 // If status is okay robs_status[i] equals true
77 if (robs_status[i] == false ) {
78 // The last bin of ROBStatus_perCall histogram store isStatusNotOk bool value
79 ATH_CHECK( fill("ROBStatus_perCall", robmonitor::NUM_ROBHIST_CODES, weight) );
80 }
81
82 // ROB request was fetched over the network
83 if (robs_history[i] == robmonitor::RETRIEVED) {
84 // size is stored in words, should be in kilobytes
85 ATH_CHECK( fill("NetworkROBSize_perEvent", robs_size[i] / 500., weight) );
86 networkRequestIncremented = true;
87 }
88 else if (robs_history[i] == robmonitor::HLT_CACHED || robs_history[i] == robmonitor::DCM_CACHED) {
89 ATH_CHECK( fill("CachedROBSize_perEvent", robs_size[i] / 500., weight) );
90 }
91
92 if (variableExists("ROBsPerRequest_perCall")){
93 ATH_CHECK( fill("ROBsPerRequest_perCall", m_robIdToBin.at(robIdsPerRequest[i]), weight) );
94 }
95
96 ++nRequestedRobs;
97 }
98 }
99
100 ATH_CHECK( fill("NROBsPerRequest_perCall", nRequestedRobs, weight) );
101
102 ATH_CHECK( increment("Request_perEvent", weight) );
103
104 if (networkRequestIncremented) {
105 ATH_CHECK( increment("NetworkRequest_perEvent", weight) );
106 }
107
108 const float rosTime = timeToMilliSec(tc->getDetail<uint64_t>("start"), tc->getDetail<uint64_t>("stop"));
109 ATH_CHECK( fill("Time_perEvent", rosTime, weight) );
110
111 return StatusCode::SUCCESS;
112}
113
114int CounterROS::getROBHistoryBin(const unsigned history){
115 int history_bin;
116 switch (history) {
118 history_bin = 1;
119 break;
121 history_bin = 2;
122 break;
124 history_bin = 3;
125 break;
127 history_bin = 4;
128 break;
130 history_bin = 5;
131 break;
132 default: // UNCLASSIFIED
133 history_bin = 0;
134 break;
135 }
136
137 return history_bin;
138}
#define ATH_CHECK
Evaluate an expression and check for errors.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t tc
@ 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.
bool variableExists(const std::string &name) const
Check if a variable of a given name exists.
Variable & getVariable(const std::string &name)
Returns a mutable reference to a named Variable.
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
int getROBHistoryBin(const unsigned history)
Get histogram bin for ROBHistory enum values.
CounterROS()=delete
Forbid default constructor.
virtual StatusCode newEvent(const CostData &data, size_t index, const float weight=1.) override
Concrete implementation.
std::map< uint32_t, unsigned > m_robIdToBin
Cached mapping of rob id to bin in ROBsPerRequest_perEvent histogram.
Definition CounterROS.h:67
Definition index.py:1
TrigComposite_v1 TrigComposite
Declare the latest version of the class.