ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaMonitoring
src
AthenaMon.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// ********************************************************************
6
//
7
// NAME: AthenaMon.cxx
8
//
9
// AUTHOR: Rob McPherson & Manuel Diaz
10
// Manuel Diaz 01.04.2004 Changed interface access from
11
// IAlgTool to IMonitorToolBase
12
//
13
// ********************************************************************
14
15
#include "GaudiKernel/MsgStream.h"
16
#include "GaudiKernel/IToolSvc.h"
17
#include "GaudiKernel/StatusCode.h"
18
#include "GaudiKernel/TypeNameString.h"
19
20
#include "
AthenaMon.h
"
21
22
class
ISvcLocator;
23
// class AlgFactory;
24
25
/*---------------------------------------------------------------*/
26
AthenaMon::AthenaMon
(
const
std::string& name, ISvcLocator* pSvcLocator) :
27
AthAlgorithm
(name, pSvcLocator)
28
{
29
MsgStream log(msgSvc(),
"AthenaMon"
);
30
31
declareProperty
(
"AthenaMonTools"
,
m_monToolNames
);
32
declareProperty
(
"CheckEveryNoEvents"
,
m_everyNevents
=-1);
33
declareProperty
(
"BookHistsinInitialize"
,
m_bookHistsinInitialize
=
true
);
34
m_THistSvc_streamnameMapping
.clear();
35
declareProperty
(
"THistSvc_OutPutStreamMapping"
,
m_THistSvc_streamnameMapping
);
36
}
37
38
/*---------------------------------------------------------------*/
39
AthenaMon::~AthenaMon
()
40
{
41
}
42
43
/*---------------------------------------------------------------*/
44
StatusCode
AthenaMon::initialize
()
45
/*---------------------------------------------------------------*/
46
{
47
MsgStream log(msgSvc(), name());
48
log << MSG::INFO <<
"initialize AthenaMon algorithm"
<<
endmsg
;
49
50
std::vector<std::string>::iterator it =
m_monToolNames
.begin();
51
SmartIF<IToolSvc> p_toolSvc{service(
"ToolSvc"
)};
52
ATH_CHECK
( p_toolSvc.isValid() );
53
54
for
(; it <
m_monToolNames
.end(); ++it) {
55
56
std::string toolname(*it);
57
IMonitorToolBase
* p_tool;
58
59
Gaudi::Utils::TypeNameString mytool(toolname);
60
61
StatusCode
sc
= p_toolSvc->retrieveTool(mytool.type(), mytool.name(), p_tool);
62
if
(
sc
.isFailure()) {
63
log << MSG::FATAL <<
"Unable to create "
<< toolname
64
<<
" AlgTool"
<<
endmsg
;
65
return
StatusCode::FAILURE;
66
}
else
{
67
68
log << MSG::INFO
69
<<
"Tool Name = "
<< toolname
70
<<
endmsg
;
71
72
sc
= p_tool->
setupOutputStreams
(
m_THistSvc_streamnameMapping
);
73
if
(
sc
.isFailure()) {
74
log << MSG::WARNING <<
"Unable to setup the OutPutStreams in "
75
<< toolname <<
endmsg
;
76
}
77
78
// shall I book histograms now ?
79
if
(
m_bookHistsinInitialize
)
80
{
81
// Try to book the histograms now. If the tool uses
82
// dynamic booking, it should define bookHists as empty.
83
sc
= p_tool->
bookHists
();
84
if
(
sc
.isFailure()) {
85
log << MSG::WARNING <<
"Unable to book in "
<< toolname <<
endmsg
;
86
}
87
}
88
m_monTools
.push_back(p_tool);
89
}
90
}
91
m_eventCounter
=
m_everyNevents
;
92
return
StatusCode::SUCCESS;
93
}
94
95
/*---------------------------------------------------------------*/
96
StatusCode
AthenaMon::execute
(
const
EventContext& ctx)
97
{
98
99
MsgStream log(msgSvc(), name());
100
101
log << MSG::DEBUG <<
"executing AthenaMon algorithm"
<<
endmsg
;
102
103
//Invoke all declared alg monitoring tools to fill their histograms
104
std::vector<IMonitorToolBase*>::iterator it =
m_monTools
.begin();
105
106
for
(; it <
m_monTools
.end(); ++it) {
107
if
((*it)->preSelector())
108
if
((*it)->fillHists(ctx).isFailure()) {
109
log << MSG::WARNING <<
"Error Filling Histograms"
<<
endmsg
;
110
// return StatusCode::FAILURE;
111
}
112
}
113
if
(
m_eventCounter
==0) {
114
//Invoke periodically all declared alg monitoring tools to check their histograms
115
it =
m_monTools
.begin();
116
117
for
(; it <
m_monTools
.end(); ++it) {
118
log << MSG::INFO <<
"calling checkHists of tool "
<<
endmsg
;
119
StatusCode
sc
= (*it)->checkHists(
false
);
120
if
(
sc
.isFailure()) {
121
log << MSG::WARNING <<
"Can\'t call checkHists of tool."
<<
endmsg
;
122
// return StatusCode::FAILURE;
123
}
124
}
125
m_eventCounter
=
m_everyNevents
;
126
}
127
if
(
m_eventCounter
>0)
m_eventCounter
--;
128
return
StatusCode::SUCCESS;
129
}
130
131
/*---------------------------------------------------------------*/
132
StatusCode
AthenaMon::finalize
()
133
{
134
MsgStream log(msgSvc(), name());
135
136
log << MSG::INFO <<
"finalizing AthenaMon algorithm"
<<
endmsg
;
137
138
//Invoke all declared alg monitoring tools to finalize their histograms
139
std::vector<IMonitorToolBase*>::iterator it =
m_monTools
.begin();
140
141
for
(; it <
m_monTools
.end(); ++it) {
142
log << MSG::INFO <<
"finalizing tool "
<<
endmsg
;
143
StatusCode
sc
= (*it)->finalHists();
144
if
(
sc
.isFailure()) {
145
log << MSG::WARNING <<
"Can\'t finalize a tool."
<<
endmsg
;
146
// return StatusCode::FAILURE;
147
}
148
}
149
//Invoke all declared alg monitoring tools to check their histograms
150
it =
m_monTools
.begin();
151
152
for
(; it <
m_monTools
.end(); ++it) {
153
log << MSG::INFO <<
"calling checkHists of tool "
<<
endmsg
;
154
StatusCode
sc
= (*it)->checkHists(
true
);
155
if
(
sc
.isFailure()) {
156
log << MSG::WARNING <<
"Can\'t call checkHists of tool."
<<
endmsg
;
157
// return StatusCode::FAILURE;
158
}
159
}
160
161
return
StatusCode::SUCCESS;
162
}
163
164
/*---------------------------------------------------------------*/
165
StatusCode
AthenaMon::start
()
166
{
167
MsgStream log(msgSvc(), name());
168
log << MSG::INFO <<
"start()"
<<
endmsg
;
169
170
// histograms already booked
171
if
(
m_bookHistsinInitialize
)
172
return
StatusCode::SUCCESS;
173
174
std::vector<IMonitorToolBase*>::iterator it =
m_monTools
.begin();
175
for
(; it <
m_monTools
.end(); ++it)
176
if
((*it)->bookHists().isFailure())
177
log << MSG::WARNING <<
"Error Filling Histograms"
<<
endmsg
;
178
179
return
StatusCode::SUCCESS;
180
}
181
182
/*---------------------------------------------------------------*/
183
StatusCode
AthenaMon::stop
()
184
{
185
MsgStream log(msgSvc(), name());
186
log << MSG::INFO <<
"stop()"
<<
endmsg
;
187
188
std::vector<IMonitorToolBase*>::iterator it =
m_monTools
.begin();
189
for
(; it <
m_monTools
.end(); ++it)
190
if
((*it)->runStat().isFailure())
191
log << MSG::WARNING <<
"Error calling runStat"
<<
endmsg
;
192
193
return
StatusCode::SUCCESS;
194
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
AthenaMon.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthenaMon::m_eventCounter
long m_eventCounter
Definition
AthenaMon.h:37
AthenaMon::m_everyNevents
long m_everyNevents
Definition
AthenaMon.h:36
AthenaMon::finalize
virtual StatusCode finalize()
Definition
AthenaMon.cxx:132
AthenaMon::AthenaMon
AthenaMon(const std::string &name, ISvcLocator *pSvcLocator)
Definition
AthenaMon.cxx:26
AthenaMon::m_monTools
std::vector< IMonitorToolBase * > m_monTools
Definition
AthenaMon.h:28
AthenaMon::initialize
virtual StatusCode initialize()
Definition
AthenaMon.cxx:44
AthenaMon::m_THistSvc_streamnameMapping
std::vector< std::string > m_THistSvc_streamnameMapping
Definition
AthenaMon.h:34
AthenaMon::stop
virtual StatusCode stop()
Definition
AthenaMon.cxx:183
AthenaMon::~AthenaMon
virtual ~AthenaMon()
Definition
AthenaMon.cxx:39
AthenaMon::m_monToolNames
std::vector< std::string > m_monToolNames
Definition
AthenaMon.h:32
AthenaMon::m_bookHistsinInitialize
bool m_bookHistsinInitialize
Definition
AthenaMon.h:39
AthenaMon::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
AthenaMon.cxx:96
AthenaMon::start
virtual StatusCode start()
Definition
AthenaMon.cxx:165
IMonitorToolBase
Definition
IMonitorToolBase.h:26
IMonitorToolBase::setupOutputStreams
virtual StatusCode setupOutputStreams(std::vector< std::string > Mapping=std::vector< std::string >())=0
IMonitorToolBase::bookHists
virtual StatusCode bookHists()=0
Generated on
for ATLAS Offline Software by
1.17.0