5#ifndef AthenaMonitoringKernel_MonitoredGroup_h
6#define AthenaMonitoringKernel_MonitoredGroup_h
13#include "GaudiKernel/ToolHandle.h"
64 template <
typename... T>
65 Group(
const ToolHandle<GenericMonitoringTool>& tool, T&&... monitoredGroup)
71 Group(
const ToolHandle<GenericMonitoringTool>& tool,
const std::vector<std::reference_wrapper<IMonitoredVariable>>& monitoredGroup)
77 Group(
const ToolHandle<GenericMonitoringTool>& tool, std::vector<std::reference_wrapper<IMonitoredVariable>>&& monitoredGroup)
88 catch (std::exception &) {
107 if (
m_tool.empty() )
return;
122 ToolHandle<GenericMonitoringTool>
m_tool;
127 template <
typename... T>
128 void fill(
const ToolHandle<GenericMonitoringTool>& tool, T&&... variables) {
130 tool->invokeFillers({std::forward<T>(variables)...});
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.");
147 template<
typename V,
typename std::enable_if_t<std::is_
integral_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);
158 template<
typename V,
typename std::enable_if_t<!std::is_
integral_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);
169 template<
typename V,
typename std::enable_if_t<std::is_
integral_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;
180 template<
typename V,
typename std::enable_if_t<!std::is_
integral_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;
Group(const ToolHandle< GenericMonitoringTool > &tool, T &&... monitoredGroup)
Group of monitored variables.
ToolHandle< GenericMonitoringTool > m_tool
void setAutoFill(bool isEnabled)
enables/disables filling when Monitored::Group leaves the scope
Group(const ToolHandle< GenericMonitoringTool > &tool, std::vector< std::reference_wrapper< IMonitoredVariable > > &&monitoredGroup)
Group(const ToolHandle< GenericMonitoringTool > &tool, const std::vector< std::reference_wrapper< IMonitoredVariable > > &monitoredGroup)
const std::vector< std::reference_wrapper< IMonitoredVariable > > m_monitoredGroup
void fill()
Explicitly fill the monitoring histograms and disable autoFill.
std::string label(const std::string &format, int i)
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.
Generic monitoring tool for athena components.
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case)
void fill(const ToolHandle< GenericMonitoringTool > &tool, T &&... variables)