ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigCost
TrigCostAnalysis
src
counters
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
5
#include "
xAODTrigger/TrigCompositeContainer.h
"
6
#include "
TrigDataAccessMonitoring/ROBDataMonitor.h
"
7
8
#include "
CounterROS.h
"
9
10
#include <algorithm>
11
#include <string>
12
#include <vector>
13
14
CounterROS::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
26
CounterROS::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
32
StatusCode
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
114
int
CounterROS::getROBHistoryBin
(
const
unsigned
history){
115
int
history_bin;
116
switch
(history) {
117
case
robmonitor::RETRIEVED
:
118
history_bin = 1;
119
break
;
120
case
robmonitor::HLT_CACHED
:
121
history_bin = 2;
122
break
;
123
case
robmonitor::DCM_CACHED
:
124
history_bin = 3;
125
break
;
126
case
robmonitor::IGNORED
:
127
history_bin = 4;
128
break
;
129
case
robmonitor::UNDEFINED
:
130
history_bin = 5;
131
break
;
132
default
:
// UNCLASSIFIED
133
history_bin = 0;
134
break
;
135
}
136
137
return
history_bin;
138
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
CounterROS.h
tc
static Double_t tc
Definition
LArPhysWaveHECTool.cxx:38
ROBDataMonitor.h
TrigCompositeContainer.h
kPerEvent
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
Definition
Variable.h:21
kPerCall
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition
Variable.h:20
kLinear
@ kLinear
Linear x-binning.
Definition
Variable.h:29
CostData
Caches and propagates event data to be used by monitoring algorithms.
Definition
CostData.h:26
CounterBase::timeToMilliSec
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
Definition
CounterBase.cxx:245
CounterBase::CounterBase
CounterBase()=delete
Forbid default constructor.
CounterBase::increment
StatusCode increment(std::string_view name, float weight=1.0)
Convenience function.
Definition
CounterBase.cxx:222
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:29
CounterBase::getName
const std::string & getName() const
Getter for Counter's name.
Definition
CounterBase.cxx:19
CounterBase::variableExists
bool variableExists(const std::string &name) const
Check if a variable of a given name exists.
Definition
CounterBase.cxx:180
CounterBase::getVariable
Variable & getVariable(std::string_view name)
Returns a mutable reference to a named Variable.
Definition
CounterBase.cxx:184
CounterBase::fill
StatusCode fill(std::string_view 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:193
CounterROS::getROBHistoryBin
int getROBHistoryBin(const unsigned history)
Get histogram bin for ROBHistory enum values.
Definition
CounterROS.cxx:114
CounterROS::CounterROS
CounterROS()=delete
Forbid default constructor.
CounterROS::newEvent
virtual StatusCode newEvent(const CostData &data, size_t index, const float weight=1.) override
Concrete implementation.
Definition
CounterROS.cxx:32
CounterROS::m_robIdToBin
std::map< uint32_t, unsigned > m_robIdToBin
Cached mapping of rob id to bin in ROBsPerRequest_perEvent histogram.
Definition
CounterROS.h:67
MonitorBase
Forward declare.
Definition
Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:33
index
Definition
index.py:1
robmonitor::RETRIEVED
@ RETRIEVED
Definition
ROBDataMonitor.h:26
robmonitor::DCM_CACHED
@ DCM_CACHED
Definition
ROBDataMonitor.h:28
robmonitor::UNDEFINED
@ UNDEFINED
Definition
ROBDataMonitor.h:30
robmonitor::HLT_CACHED
@ HLT_CACHED
Definition
ROBDataMonitor.h:27
robmonitor::NUM_ROBHIST_CODES
@ NUM_ROBHIST_CODES
Definition
ROBDataMonitor.h:31
robmonitor::IGNORED
@ IGNORED
Definition
ROBDataMonitor.h:29
xAOD::TrigComposite
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Definition
TrigComposite.h:16
Generated on
for ATLAS Offline Software by
1.17.0