ATLAS Offline Software
Loading...
Searching...
No Matches
MonitorBase Class Referenceabstract

Forward declare. More...

#include <MonitorBase.h>

Inheritance diagram for MonitorBase:
Collaboration diagram for MonitorBase:

Public Member Functions

 MonitorBase ()=delete
 Forbid default constructor.
 MonitorBase (const std::string &name, const MonitoredRange *parent)
 Construct monitor.
virtual ~MonitorBase ()=default
 Default destructor.
MonitorBaseoperator= (const MonitorBase &)=delete
 Forbid assignment.
 MonitorBase (const MonitorBase &)=delete
 Forbid copy.
const std::string & getName () const
 Getter for Monitor's name.
const MonitoredRangegetParent () const
 Return cached non-owning const ptr to this Monitor's parent Range.
TH1 * bookGetPointer (TH1 *hist, const std::string &tDir="") const
 Appends Monitor name (to histogram path) and forwards histogram book request to parent Range.
bool counterExists (const std::string &name) const
 Check if a counter of a given name exists.
CounterBasegetCounter (const std::string &name)
 Retrieve counter by name.
virtual StatusCode newEvent (const CostData &data, float weight=1.)=0
 Pure virtual interface called by Range to instruct this Monitor to perform its analysis.
virtual StatusCode endEvent (float weight=1.)
 Called by the framework.
MsgStream & msg ()
 Logging.
MsgStream & msg (const MSG::Level lvl)
 Logging on a given level.
bool msgLvl (const MSG::Level lvl)
 Returns if requested level is same or higher than logging level.

Protected Member Functions

virtual std::unique_ptr< CounterBasenewCounter (const std::string &name)=0
 Pure virtual Counter instantiation specialisation.

Protected Attributes

std::unordered_map< std::string, std::unique_ptr< CounterBase > > m_counters
 Storage of Monitor's collection of Counters.
MsgStream m_msgStream
 Logging member.

Private Attributes

const std::string m_name
 Monitor's name.
const MonitoredRangem_parent
 Monitor's parent Range.

Detailed Description

Forward declare.

Base class for all "Monitor" objects, which maintain a collection of Counters of a given specialisation.

A Monitor is responsible for monitoring a specific feature of an event. It could be, monitoring all Chains, all ROS', all Algorithms, etc. It maintains an internal name-keyed map of Counters of a given specialisation and for a given event it loops over all instances of the feature it monitors and dispatches to the matching Counter objects.

Definition at line 33 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h.

Constructor & Destructor Documentation

◆ MonitorBase() [1/3]

MonitorBase::MonitorBase ( )
delete

Forbid default constructor.

◆ MonitorBase() [2/3]

MonitorBase::MonitorBase ( const std::string & name,
const MonitoredRange * parent )

Construct monitor.

Parameters
[in]nameMonitor's name
[in]parentMonitor's parent Range, cached non-owning pointer.

Definition at line 11 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

11 :
12 m_msgStream(nullptr, name.c_str()),
13 m_name(name),
14 m_parent(parent) {
16}
const MonitoredRange * m_parent
Monitor's parent Range.
const std::string m_name
Monitor's name.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ ~MonitorBase()

virtual MonitorBase::~MonitorBase ( )
virtualdefault

Default destructor.

◆ MonitorBase() [3/3]

MonitorBase::MonitorBase ( const MonitorBase & )
delete

Forbid copy.

Member Function Documentation

◆ bookGetPointer()

TH1 * MonitorBase::bookGetPointer ( TH1 * hist,
const std::string & tDir = "" ) const

Appends Monitor name (to histogram path) and forwards histogram book request to parent Range.

Parameters
[in]histBare pointer to histogram. Ownership transferred to THistSvc.
[in]tDirHistogram name & directory.
Returns
Cached pointer to histogram. Used to fill histogram without having to perform THishSvc lookup.

Definition at line 37 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

37 {
38 std::string dir = getName();
39 if (tDir != "") {
40 dir += "/";
41 dir += tDir;
42 }
43 return getParent()->bookGetPointer(hist, dir);
44}
const MonitoredRange * getParent() const
Return cached non-owning const ptr to this Monitor's parent Range.
const std::string & getName() const
Getter for Monitor's name.
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Appends Range's name (to histogram path) and forwards histogram book request to parent Athena algorit...

◆ counterExists()

bool MonitorBase::counterExists ( const std::string & name) const

Check if a counter of a given name exists.

Parameters
[in]nameName of Counter.
Returns
True if counter already exists.

Definition at line 47 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

47 {
48 return (m_counters.count(name) == 1);
49}
std::unordered_map< std::string, std::unique_ptr< CounterBase > > m_counters
Storage of Monitor's collection of Counters.

◆ endEvent()

StatusCode MonitorBase::endEvent ( float weight = 1.)
virtual

Called by the framework.

Causes per-Event Variables to fill their histograms with their accumulated data.

Definition at line 29 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

29 {
30 for (auto& nameCounterPair : m_counters ) {
31 ATH_CHECK( nameCounterPair.second->endEvent(weight) );
32 }
33 return StatusCode::SUCCESS;
34}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ getCounter()

CounterBase * MonitorBase::getCounter ( const std::string & name)

Retrieve counter by name.

If no such counter exists, a new one will be instanced and returned.

Parameters
[in]nameName of Counter.
Returns
Mutable base-class pointer to Counter.

Definition at line 52 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

52 {
53 auto it = m_counters.find(name);
54 if (it != m_counters.end()) {
55 return it->second.get();
56 }
57 // If no counter exists, then we make a new one on the fly & return it.
58 auto result = m_counters.insert( std::make_pair(name, newCounter(name)) ); // newCounter is specialised
59 it = result.first;
60 return it->second.get();
61}
virtual std::unique_ptr< CounterBase > newCounter(const std::string &name)=0
Pure virtual Counter instantiation specialisation.

◆ getName()

const std::string & MonitorBase::getName ( ) const

Getter for Monitor's name.

Returns
Counter's name const string reference.

Definition at line 19 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

19 {
20 return m_name;
21}

◆ getParent()

const MonitoredRange * MonitorBase::getParent ( ) const

Return cached non-owning const ptr to this Monitor's parent Range.

Returns
Cached pointer parent Range.

Definition at line 24 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

24 {
25 return m_parent;
26}

◆ msg() [1/2]

MsgStream & MonitorBase::msg ( )

Logging.

Returns
Message stream reference.

Definition at line 64 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

64 {
65 return m_msgStream;
66}

◆ msg() [2/2]

MsgStream & MonitorBase::msg ( const MSG::Level lvl)

Logging on a given level.

Parameters
[in]lvlVerbosity level
Returns
Message stream reference.

Definition at line 68 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

68 {
69 return m_msgStream << lvl;
70}

◆ msgLvl()

bool MonitorBase::msgLvl ( const MSG::Level lvl)

Returns if requested level is same or higher than logging level.

Parameters
[in]lvlVerbosity level
Returns
If requested level is same or higher than logging level

Definition at line 72 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx.

72 {
73 return lvl >= m_msgStream.level();
74}

◆ newCounter()

virtual std::unique_ptr< CounterBase > MonitorBase::newCounter ( const std::string & name)
protectedpure virtual

Pure virtual Counter instantiation specialisation.

Derived Monitor must instantiate a concrete Counter of the correct type for the Monitor and return it wrapped in an owning unique ptr.

Parameters
[in]nameName of Counter to mint.
Returns
Owning unique ptr object typed on the CounterBase base class which points to concrete Counter of specialised type.

Implemented in MonitorAlgorithm, MonitorAlgorithmClass, MonitorChain, MonitorChainAlgorithm, MonitorGlobal, MonitorROS, MonitorSequence, and MonitorThreadOccupancy.

◆ newEvent()

virtual StatusCode MonitorBase::newEvent ( const CostData & data,
float weight = 1. )
pure virtual

Pure virtual interface called by Range to instruct this Monitor to perform its analysis.

Parameters
[in]dataAccess to event data
[in]weightGlobal event weight

Implemented in MonitorAlgorithm, MonitorAlgorithmClass, MonitorChain, MonitorChainAlgorithm, MonitorGlobal, MonitorROS, MonitorSequence, and MonitorThreadOccupancy.

◆ operator=()

MonitorBase & MonitorBase::operator= ( const MonitorBase & )
delete

Forbid assignment.

Member Data Documentation

◆ m_counters

std::unordered_map< std::string, std::unique_ptr<CounterBase> > MonitorBase::m_counters
protected

Storage of Monitor's collection of Counters.

Keyed by name.

Definition at line 138 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h.

◆ m_msgStream

MsgStream MonitorBase::m_msgStream
protected

Logging member.

Definition at line 140 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h.

◆ m_name

const std::string MonitorBase::m_name
private

Monitor's name.

Definition at line 144 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h.

◆ m_parent

const MonitoredRange* MonitorBase::m_parent
private

Monitor's parent Range.

Cached non-owning const ptr.

Definition at line 145 of file Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h.


The documentation for this class was generated from the following files: