ATLAS Offline Software
Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MonitoredRange.h"
6 #include "MonitorBase.h"
7 #include "CounterBase.h"
8 
10 
11 MonitorBase::MonitorBase(const std::string& name, const MonitoredRange* parent) :
12  m_msgStream(nullptr, name.c_str()),
13  m_name(name),
14  m_parent(parent) {
16 }
17 
18 
19 const std::string& MonitorBase::getName() const {
20  return m_name;
21 }
22 
23 
25  return m_parent;
26 }
27 
28 
30  for (auto& nameCounterPair : m_counters ) {
31  ATH_CHECK( nameCounterPair.second->endEvent(weight) );
32  }
33  return StatusCode::SUCCESS;
34 }
35 
36 
37 TH1* MonitorBase::bookGetPointer(TH1* hist, const std::string& tDir) const {
38  std::string dir = getName();
39  if (tDir != "") {
40  dir += "/";
41  dir += tDir;
42  }
43  return getParent()->bookGetPointer(hist, dir);
44 }
45 
46 
47 bool MonitorBase::counterExists(const std::string& name) const {
48  return (m_counters.count(name) == 1);
49 }
50 
51 
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 }
62 
63 
64 MsgStream& MonitorBase::msg() {
65  return m_msgStream;
66 }
67 
68 MsgStream& MonitorBase::msg(const MSG::Level lvl) {
69  return m_msgStream << lvl;
70 }
71 
73  return lvl >= m_msgStream.level();
74 }
MonitorBase::msgLvl
bool msgLvl(const MSG::Level lvl)
Returns if requested level is same or higher than logging level.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:72
MonitorBase.h
MonitorBase::m_counters
std::unordered_map< std::string, std::unique_ptr< CounterBase > > m_counters
Storage of Monitor's collection of Counters.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:138
CounterBase
Forward declare.
Definition: CounterBase.h:25
MonitorBase::counterExists
bool counterExists(const std::string &name) const
Check if a counter of a given name exists.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:47
get_generator_info.result
result
Definition: get_generator_info.py:21
MonitoredRange::bookGetPointer
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...
Definition: MonitoredRange.cxx:34
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MonitorBase::bookGetPointer
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Appends Monitor name (to histogram path) and forwards histogram book request to parent Range.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:37
MonitorBase::m_name
const std::string m_name
Monitor's name.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:144
MonitoredRange.h
plotmaker.hist
hist
Definition: plotmaker.py:148
MonitorBase::newCounter
virtual std::unique_ptr< CounterBase > newCounter(const std::string &name)=0
Pure virtual Counter instantiation specialisation.
MonitorBase::m_msgStream
MsgStream m_msgStream
Logging member.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:140
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
CounterBase.h
MonitorBase::endEvent
virtual StatusCode endEvent(float weight=1.)
Called by the framework.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:29
MonitorBase::getParent
const MonitoredRange * getParent() const
Return cached non-owning const ptr to this Monitor's parent Range.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:24
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
MonitorBase::m_parent
const MonitoredRange * m_parent
Monitor's parent Range.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:145
MonitorBase::getCounter
CounterBase * getCounter(const std::string &name)
Retrieve counter by name.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MonitorBase::getName
const std::string & getName() const
Getter for Monitor's name.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:19
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MonitorBase::MonitorBase
MonitorBase()=delete
Forbid default constructor.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
beamspotman.dir
string dir
Definition: beamspotman.py:623
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MonitoredRange
Container which represents a time range and holds a collection of Monitors which monitor this range.
Definition: MonitoredRange.h:29
MonitorBase::msg
MsgStream & msg()
Logging.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:64
TH1
Definition: rootspy.cxx:268