ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaMonitoringKernel
AthenaMonitoringKernel
MonitoredGroup.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef AthenaMonitoringKernel_MonitoredGroup_h
6
#define AthenaMonitoringKernel_MonitoredGroup_h
7
8
#include <functional>
9
#include <string>
10
#include <vector>
11
#include <stdexcept>
12
13
#include "GaudiKernel/ToolHandle.h"
14
15
#include "
AthenaMonitoringKernel/GenericMonitoringTool.h
"
16
#include "
AthenaMonitoringKernel/IMonitoredVariable.h
"
17
18
namespace
Monitored
{
53
class
Group
{
54
public
:
64
template
<
typename
... T>
65
Group
(
const
ToolHandle<GenericMonitoringTool>& tool, T&&... monitoredGroup)
66
:
m_tool
(tool),
67
m_autoFill
(true),
68
m_monitoredGroup
{monitoredGroup...}
69
{ }
70
71
Group
(
const
ToolHandle<GenericMonitoringTool>& tool,
const
std::vector<std::reference_wrapper<IMonitoredVariable>>& monitoredGroup)
72
:
m_tool
(tool),
73
m_autoFill
(true),
74
m_monitoredGroup
(monitoredGroup)
75
{ }
76
77
Group
(
const
ToolHandle<GenericMonitoringTool>& tool, std::vector<std::reference_wrapper<IMonitoredVariable>>&& monitoredGroup)
78
:
m_tool
(tool),
79
m_autoFill
(true),
80
m_monitoredGroup
(
std
::move(monitoredGroup))
81
{ }
82
83
~Group
() {
84
if
(
m_autoFill
) {
85
try
{
86
fill
();
87
}
88
catch
(std::exception &) {
89
// fill can throw due to dereferencing a Gaudi handle
90
//or boost container exception
91
std::abort();
92
}
93
}
94
}
95
106
void
fill
() {
107
if
(
m_tool
.empty() )
return
;
108
setAutoFill
(
false
);
109
m_tool
->invokeFillers(
m_monitoredGroup
);
110
}
111
119
void
setAutoFill
(
bool
isEnabled) {
m_autoFill
= isEnabled; }
120
121
protected
:
122
ToolHandle<GenericMonitoringTool>
m_tool
;
123
bool
m_autoFill
;
124
const
std::vector<std::reference_wrapper<IMonitoredVariable>>
m_monitoredGroup
;
125
};
126
127
template
<
typename
... T>
128
void
fill
(
const
ToolHandle<GenericMonitoringTool>& tool, T&&... variables) {
129
if
(!tool.empty()) {
130
tool->invokeFillers({std::forward<T>(variables)...});
131
}
132
}
133
134
// Sub-namespace for internal-use functions
135
namespace
detail
{
137
template
<
typename
T =
int
>
138
int
findToolIndex
(
const
ToolHandleArray<GenericMonitoringTool>& toolArray,
const
std::string& name ) {
139
auto
it = std::find_if(toolArray.begin(),toolArray.end(),[&](
const
auto
&
r
) {return r.name()==name;});
140
return
it!=toolArray.end()
141
? std::distance(toolArray.begin(),it)
142
:
throw
std::runtime_error(
"The tool "
+name+
" could not be found in the tool array."
);
143
}
144
}
145
147
template
<
typename
V,
typename
std::enable_if_t<std::is_
int
egral_v<V>>* =
nullptr
>
148
std::vector<V>
buildToolMap
(
const
ToolHandleArray<GenericMonitoringTool> &
tools
,
const
std::string& baseName,
int
nHist) {
149
std::vector<int> indexArray;
150
for
(
int
iHist=0; iHist<nHist; iHist++ ) {
151
std::string groupName = baseName +
"_"
+ std::to_string(iHist);
152
indexArray.push_back(
detail::findToolIndex
(
tools
,groupName));
153
}
154
return
indexArray;
155
}
156
158
template
<
typename
V,
typename
std::enable_if_t<!std::is_
int
egral_v<V>>* =
nullptr
,
typename
...T>
159
std::vector<V>
buildToolMap
(
const
ToolHandleArray<GenericMonitoringTool> &
tools
,
const
std::string& baseName,
int
nHist, T... dimensions) {
160
std::vector<V> indexArray;
161
for
(
int
iHist=0; iHist<nHist; iHist++ ) {
162
std::string groupName = baseName +
"_"
+ std::to_string(iHist);
163
indexArray.push_back(
buildToolMap<typename V::value_type>
(
tools
,groupName,dimensions...));
164
}
165
return
indexArray;
166
}
167
169
template
<
typename
V,
typename
std::enable_if_t<std::is_
int
egral_v<V>>* =
nullptr
>
170
std::map<std::string,int>
buildToolMap
(
const
ToolHandleArray<GenericMonitoringTool> &
tools
,
const
std::string& baseName,
const
std::vector<std::string>& labels) {
171
std::map<std::string,int> indexMap;
172
for
(
const
std::string&
label
: labels ) {
173
std::string groupName = baseName +
"_"
+
label
;
174
indexMap[
label
] =
detail::findToolIndex
(
tools
,groupName);
175
}
176
return
indexMap;
177
}
178
180
template
<
typename
V,
typename
std::enable_if_t<!std::is_
int
egral_v<V>>* =
nullptr
,
typename
...T>
181
std::map<std::string,V>
buildToolMap
(
const
ToolHandleArray<GenericMonitoringTool> &
tools
,
const
std::string& baseName,
const
std::vector<std::string>& labels, T... dimensions) {
182
std::map<std::string,V> indexMap;
183
for
(
const
std::string&
label
: labels ) {
184
std::string groupName = baseName +
"_"
+
label
;
185
indexMap[
label
] =
buildToolMap<typename V::mapped_type>
(
tools
,groupName,dimensions...);
186
}
187
return
indexMap;
188
}
189
190
}
// namespace Monitored
191
192
#endif
/* AthenaMonitoringKernel_MonitoredGroup_h */
GenericMonitoringTool.h
IMonitoredVariable.h
Monitored::Group::Group
Group(const ToolHandle< GenericMonitoringTool > &tool, T &&... monitoredGroup)
Group of monitored variables.
Definition
MonitoredGroup.h:65
Monitored::Group::m_tool
ToolHandle< GenericMonitoringTool > m_tool
Definition
MonitoredGroup.h:122
Monitored::Group::setAutoFill
void setAutoFill(bool isEnabled)
enables/disables filling when Monitored::Group leaves the scope
Definition
MonitoredGroup.h:119
Monitored::Group::Group
Group(const ToolHandle< GenericMonitoringTool > &tool, std::vector< std::reference_wrapper< IMonitoredVariable > > &&monitoredGroup)
Definition
MonitoredGroup.h:77
Monitored::Group::Group
Group(const ToolHandle< GenericMonitoringTool > &tool, const std::vector< std::reference_wrapper< IMonitoredVariable > > &monitoredGroup)
Definition
MonitoredGroup.h:71
Monitored::Group::m_monitoredGroup
const std::vector< std::reference_wrapper< IMonitoredVariable > > m_monitoredGroup
Definition
MonitoredGroup.h:124
Monitored::Group::~Group
~Group()
Definition
MonitoredGroup.h:83
Monitored::Group::fill
void fill()
Explicitly fill the monitoring histograms and disable autoFill.
Definition
MonitoredGroup.h:106
Monitored::Group::m_autoFill
bool m_autoFill
Definition
MonitoredGroup.h:123
r
int r
Definition
globals.cxx:22
label
std::string label(const std::string &format, int i)
Definition
label.h:19
Monitored::detail::findToolIndex
int findToolIndex(const ToolHandleArray< GenericMonitoringTool > &toolArray, const std::string &name)
Finds the index of an element in a tool handle array by its string name.
Definition
MonitoredGroup.h:138
Monitored
Generic monitoring tool for athena components.
Definition
GenericMonitoringTool.h:28
Monitored::buildToolMap
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case).
Definition
MonitoredGroup.h:148
Monitored::fill
void fill(const ToolHandle< GenericMonitoringTool > &tool, T &&... variables)
Definition
MonitoredGroup.h:128
detail
Definition
extract_histogram_tag.cxx:14
std
STL namespace.
tools
Definition
DataQuality/ZLumiScripts/python/tools/__init__.py:1
Generated on
for ATLAS Offline Software by
1.17.0