ATLAS Offline Software
Public Member Functions | Protected Attributes | List of all members
Monitored::Group Class Reference

Group of local monitoring quantities and retain correlation when filling histograms More...

#include <MonitoredGroup.h>

Collaboration diagram for Monitored::Group:

Public Member Functions

template<typename... T>
 Group (const ToolHandle< GenericMonitoringTool > &tool, T &&... monitoredGroup)
 Group of monitored variables. More...
 
 Group (const ToolHandle< GenericMonitoringTool > &tool, const std::vector< std::reference_wrapper< IMonitoredVariable >> &monitoredGroup)
 
 Group (const ToolHandle< GenericMonitoringTool > &tool, std::vector< std::reference_wrapper< IMonitoredVariable >> &&monitoredGroup)
 
 ~Group ()
 
void fill ()
 Explicitly fill the monitoring histograms and disable autoFill. More...
 
void setAutoFill (bool isEnabled)
 enables/disables filling when Monitored::Group leaves the scope More...
 

Protected Attributes

ToolHandle< GenericMonitoringToolm_tool
 
bool m_autoFill
 
const std::vector< std::reference_wrapper< IMonitoredVariable > > m_monitoredGroup
 

Detailed Description

Group of local monitoring quantities and retain correlation when filling histograms

In order to maintain correlations when filling histograms (e.g. eta and phi of a track) the monitored quantities need to be grouped within a Monitored::Group. The filling of the histogram occurs when the Monitored::Group object goes out of scope or when fill() is called explicitly.

The actual histogram definitions, i.e. which variable gets filled into which histogram, is configured entirely in Python. See GenericMonitoringTool.defineHistogram for the available options.

Examples

Monitored quantities can be used to fill 2D histograms. No code change is needed for it however the monitored variables need to be grouped correctly

// For 2D histogram to be filled the two histogrammed variables need to be grouped.
// This code will cause the 2D histogram fill
auto phi = Monitored::Scalar( "Phi", -99.0 );
auto eta = Monitored::Scalar( "Eta", -99.0 );
auto group = Monitored::Group( monTool, eta, phi );
eta = 0.2;
phi = -0.1;

The same variables can be re-used to perform multiple fill operations:

// The variable are declared in an outer scope
auto phi = Monitored::Scalar( "Phi", -99.0 );
auto eta = Monitored::Scalar<double>( "Eta", -99 );
for ( size_t i =0; i < 3; ++i ) {
// Inside another scope the Group is instantiated and destroyed resulting in multiple histogram fills.
auto group = Monitored::Group( monTool, phi );
phi = 0.1;
eta = -0.2;
}

The automatic filling at the end of the scope can be disabled:

auto phi = Monitored::Scalar( "Phi", -99.0 );
auto eta = Monitored::Scalar( "Eta", -99.0 );
{
auto group = Monitored::Group( monTool, eta, phi );
group.setAutoFill( false ); // results in no histogram fills
eta = 0.2;
phi = -0.1;
}

Instead explicit filling can be used:

auto group = Monitored::Group( monTool, eta, phi );
for ( size_t i = 0; i < 3; ++i ) {
group.fill(); // this will fill and disable AutoFill
}

Histograms can be filled conditionally with one variable serving as a (boolean) cut mask:

for (int ctr = 0; ctr < 10; ++ctr) {
auto eta = Monitored::Scalar<double>( "Eta", -99 );
auto cutMask = Monitored::Scalar<bool>( "CutMask", (ctr % 2) == 0); // filter every second entry
auto group = Monitored::Group( monTool, eta, cutMask );
eta = -0.2;

The same can be done with a Monitored::Collection:

std::vector<float> etaVec{-0.2, 0.2, -0.4, 0.4, -0.6};
std::vector<char> cutMaskVec{0, 1, 1, 1, 0};
auto eta = Monitored::Collection( "Eta", etaVec );
auto cutMask = Monitored::Collection( "CutMask", cutMaskVec );
auto group = Monitored::Group( monTool, eta, cutMask );

A weight variable can be used for scalars:

auto pt = Monitored::Scalar<double>( "pt", 3.0 );
auto weight = Monitored::Scalar<float>( "Weight", 0.5 );
auto group = Monitored::Group( monTool, pt, weight );

and collections:

std::vector<double> ptvec{1.0, 2.0, 3.0 ,4.0, 5.0};
std::vector<float> wvec{0.0, 0.5, 0.5, 1.0, 2.0};
auto pt = Monitored::Collection( "pt", ptvec );
auto weight = Monitored::Collection( "Weight", wvec );
auto group = Monitored::Group( monTool, pt, weight );
See also
GenericMonitoringTool.defineHistogram

Definition at line 54 of file MonitoredGroup.h.

Constructor & Destructor Documentation

◆ Group() [1/3]

template<typename... T>
Monitored::Group::Group ( const ToolHandle< GenericMonitoringTool > &  tool,
T &&...  monitoredGroup 
)
inline

Group of monitored variables.

The filling of the associated histograms occurs when the object goes out of scope or when fill() is called explicitly.

Parameters
toola handle to a monitoring tool, if invalid nothing is done
monitoredGrouplist of variables to be monitored

Definition at line 66 of file MonitoredGroup.h.

67  : m_tool(tool),
68  m_autoFill(true),
69  m_monitoredGroup{monitoredGroup...}
70  { }

◆ Group() [2/3]

Monitored::Group::Group ( const ToolHandle< GenericMonitoringTool > &  tool,
const std::vector< std::reference_wrapper< IMonitoredVariable >> &  monitoredGroup 
)
inline

Definition at line 72 of file MonitoredGroup.h.

73  : m_tool(tool),
74  m_autoFill(true),
75  m_monitoredGroup(monitoredGroup)
76  { }

◆ Group() [3/3]

Monitored::Group::Group ( const ToolHandle< GenericMonitoringTool > &  tool,
std::vector< std::reference_wrapper< IMonitoredVariable >> &&  monitoredGroup 
)
inline

Definition at line 78 of file MonitoredGroup.h.

79  : m_tool(tool),
80  m_autoFill(true),
81  m_monitoredGroup(std::move(monitoredGroup))
82  { }

◆ ~Group()

Monitored::Group::~Group ( )
inline

Definition at line 84 of file MonitoredGroup.h.

84  {
85  if (m_autoFill) {
86  fill();
87  }
88  }

Member Function Documentation

◆ fill()

void Monitored::Group::fill ( )
inline

Explicitly fill the monitoring histograms and disable autoFill.

This will fill the monitoring histograms and also call setAutoFill(false) in order to disable the automatic filling when the Monitored::Group goes out of scope. A typical use-pattern is in tight loops in order not to re-create the Monitored::Group object many times:

auto group = Monitored::Group( monTool, eta, phi );
for ( size_t i = 0; i < 3; ++i ) {
group.fill(); // this will fill and disable AutoFill
}

Definition at line 100 of file MonitoredGroup.h.

100  {
101  if ( m_tool.empty() ) return;
102  setAutoFill(false);
103  m_tool->invokeFillers(m_monitoredGroup);
104  }

◆ setAutoFill()

void Monitored::Group::setAutoFill ( bool  isEnabled)
inline

enables/disables filling when Monitored::Group leaves the scope

By default Monitored::Group will perform a one time fill each time it goes out of scope. This feature can be disabled by calling setAutoFill(false). The same is achieved by calling fill() manually.

Definition at line 113 of file MonitoredGroup.h.

113 { m_autoFill = isEnabled; }

Member Data Documentation

◆ m_autoFill

bool Monitored::Group::m_autoFill
protected

Definition at line 117 of file MonitoredGroup.h.

◆ m_monitoredGroup

const std::vector<std::reference_wrapper<IMonitoredVariable> > Monitored::Group::m_monitoredGroup
protected

Definition at line 118 of file MonitoredGroup.h.

◆ m_tool

ToolHandle<GenericMonitoringTool> Monitored::Group::m_tool
protected

Definition at line 116 of file MonitoredGroup.h.


The documentation for this class was generated from the following file:
Monitored::Group::m_autoFill
bool m_autoFill
Definition: MonitoredGroup.h:117
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
Monitored::Group::m_monitoredGroup
const std::vector< std::reference_wrapper< IMonitoredVariable > > m_monitoredGroup
Definition: MonitoredGroup.h:118
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
test_pyathena.pt
pt
Definition: test_pyathena.py:11
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
lumiFormat.i
int i
Definition: lumiFormat.py:92
Monitored::Group::m_tool
ToolHandle< GenericMonitoringTool > m_tool
Definition: MonitoredGroup.h:116
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
Monitored::Group::fill
void fill()
Explicitly fill the monitoring histograms and disable autoFill.
Definition: MonitoredGroup.h:100
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
Monitored::Group::setAutoFill
void setAutoFill(bool isEnabled)
enables/disables filling when Monitored::Group leaves the scope
Definition: MonitoredGroup.h:113
dqt_zlumi_alleff_HIST.ctr
ctr
Definition: dqt_zlumi_alleff_HIST.py:193