| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Private Attributes | List of all members
AlgErrorAuditor Class Reference

Monitors the cpu time usage of each algorithm. More...

`#include <src/AlgErrorAuditor.h>`

Inheritance diagram for AlgErrorAuditor:
[legend]
Collaboration diagram for AlgErrorAuditor:
[legend]

## Public Member Functions
| AlgErrorAuditor (const std::string &name, ISvcLocator *pSvcLocator)
virtual | ~AlgErrorAuditor ()=default
virtual StatusCode | initialize ()
virtual StatusCode | finalize ()
virtual void | beforeExecute (INamedInterface *alg)
virtual void | afterExecute (INamedInterface *alg, const StatusCode &)
Public Member Functions inherited from Auditor
| Auditor (const std::string &name, ISvcLocator *svcloc)
| Constructor. More...
| ~Auditor () override=default
| Destructor. More...
StatusCode | sysInitialize () override
| Initialization method invoked by the framework. More...
StatusCode | sysFinalize () override
| Finalization method invoked by the framework. More...
void | before (StandardEventType, INamedInterface *) override
| The following methods are meant to be implemented by the child class... More...
void | before (StandardEventType, const std::string &) override
void | before (CustomEventTypeRef, INamedInterface *) override
void | before (CustomEventTypeRef, const std::string &) override
void | after (StandardEventType, INamedInterface *, const StatusCode &) override
void | after (StandardEventType, const std::string &, const StatusCode &) override
void | after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
void | after (CustomEventTypeRef, const std::string &, const StatusCode &) override
void | beforeInitialize (INamedInterface *) override
void | afterInitialize (INamedInterface *) override
void | beforeReinitialize (INamedInterface *) override
void | afterReinitialize (INamedInterface *) override
void | beforeExecute (INamedInterface *) override
void | afterExecute (INamedInterface *, const StatusCode &) override
void | beforeFinalize (INamedInterface *) override
void | afterFinalize (INamedInterface *) override
void | beforeBeginRun (INamedInterface *) override
void | afterBeginRun (INamedInterface *) override
void | beforeEndRun (INamedInterface *) override
void | afterEndRun (INamedInterface *) override
const std::string & | name () const override
bool | isEnabled () const override
SmartIF< ISvcLocator > & | serviceLocator () const
| The standard service locator. More...
template<class T >
StatusCode | service (const std::string &name, T *&svc, bool createIf=false) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T = IService>
SmartIF< T > | service (const std::string &name, bool createIf=false) const
StatusCode | setProperty (const Property &p) override
| Set a value of a property of an auditor. More...
StatusCode | setProperty (const std::string &s) override
| Implementation of IProperty::setProperty. More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| Implementation of IProperty::setProperty. More...
StatusCode | getProperty (Property *p) const override
| Get the value of a property. More...
const Property & | getProperty (const std::string &name) const override
| Get the property by name. More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| Implementation of IProperty::getProperty. More...
const std::vector< Property * > & | getProperties () const override
| Get all properties. More...
bool | hasProperty (const std::string &name) const override
| Implementation of IProperty::hasProperty. More...
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | setProperties ()
| Set the auditor's properties. More...
template<class T >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...

## Private Member Functions
void | incrMap (const std::string &algName, int level)

## Private Attributes
BooleanProperty | m_abort
BooleanProperty | m_throw
int | m_error
int | m_fatal
std::map< std::string, int > | m_algMap [2]

## Additional Inherited Members
Public Types inherited from Auditor
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using | base_class = CommonMessaging
Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## Detailed Description

Monitors the cpu time usage of each algorithm.

Author
  David Quarrie

Definition at line 15 of file AlgErrorAuditor.h.

## Constructor & Destructor Documentation

AlgErrorAuditor::AlgErrorAuditor | ( | const std::string & | name,
|  | ISvcLocator * | pSvcLocator
| ) |  |

Definition at line 8 of file AlgErrorAuditor.cpp.

9 : Auditor(name, pSvcLocator), m_error(0), m_fatal(0) {
10
11 declareProperty( "Abort", m_abort = false,
12 "Abort job upon illegal Algorithm return code");
13 declareProperty( "Throw", m_throw = false,
14 "Throw GaudiException upon illegal Algorithm return code");
15 }
AlgErrorAuditor::m_error
int m_error
Definition: AlgErrorAuditor.h:31
AlgErrorAuditor::m_abort
BooleanProperty m_abort
Definition: AlgErrorAuditor.h:27
Auditor::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Auditor.h:232
Auditor::Auditor
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:12
AlgErrorAuditor::m_fatal
int m_fatal
Definition: AlgErrorAuditor.h:32
AlgErrorAuditor::m_throw
BooleanProperty m_throw
Definition: AlgErrorAuditor.h:27

virtual AlgErrorAuditor::~AlgErrorAuditor | ( |  | ) |
| virtual default

## Member Function Documentation

void AlgErrorAuditor::afterExecute | ( | INamedInterface * | alg,
|  | const StatusCode & | sc
| ) |  |
| virtual

Definition at line 36 of file AlgErrorAuditor.cpp.

36 {
37
38 bool fail(false);
39 if (msgSvc()->messageCount(MSG::ERROR) != m_error && ! sc.isRecoverable() ) {
40 std::ostringstream os;
41 os << "Illegal Return Code: Algorithm " << alg->name()
42 << " reported an ERROR, but returned a StatusCode \"" << sc << "\"";
43 os << std::endl << "Error policy described in "
44 << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
45
46 error() << os.str() << endmsg;
47 incrMap(alg->name(), 0);
48 fail = true;
49
50 if (m_throw && ! m_abort) {
51 throw GaudiException(os.str(),"AlgErrorAuditor",0);
52 }
53 }
54
55 if (msgSvc()->messageCount(MSG::FATAL) != m_fatal &&
56 sc != StatusCode::FAILURE ) {
57 std::ostringstream os;
58 os << "Illegal Return Code: Algorithm " << alg->name()
59 << " reported a FATAL, but returned a StatusCode \"" << sc << "\"";
60 os << std::endl << "Error policy described in "
61 << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
62
63 error() << os.str() << endmsg;
64 incrMap(alg->name(), 1);
65 fail = true;
66
67 if (m_throw && ! m_abort) {
68 throw GaudiException(os.str(),"AlgErrorAuditor",0);
69 }
70
71 }
72
73 if (fail && m_abort) {
74 abort();
75 }
76
77 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
std::endl
T endl(T...args)
AlgErrorAuditor::m_error
int m_error
Definition: AlgErrorAuditor.h:31
AlgErrorAuditor::m_abort
BooleanProperty m_abort
Definition: AlgErrorAuditor.h:27
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
MSG::FATAL
Definition: IMessageSvc.h:22
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
AlgErrorAuditor::incrMap
void incrMap(const std::string &algName, int level)
Definition: AlgErrorAuditor.cpp:110
StatusCode::FAILURE
Definition: StatusCode.h:29
IMessageSvc::messageCount
virtual int messageCount(MSG::Level level) const =0
Get the number of messages issued at a particular level.
std::ostringstream
STL class.
std::ostringstream::str
T str(T...args)
AlgErrorAuditor::m_fatal
int m_fatal
Definition: AlgErrorAuditor.h:32
StatusCode::isRecoverable
bool isRecoverable() const
Definition: StatusCode.h:87
AlgErrorAuditor::m_throw
BooleanProperty m_throw
Definition: AlgErrorAuditor.h:27
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
MSG::ERROR
Definition: IMessageSvc.h:21
std::abort
T abort(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

void AlgErrorAuditor::beforeExecute | ( | INamedInterface * | alg | ) |
| virtual

Definition at line 18 of file AlgErrorAuditor.cpp.

18 {
19 m_error = msgSvc()->messageCount(MSG::ERROR);
20 m_fatal = msgSvc()->messageCount(MSG::FATAL);
21 }
AlgErrorAuditor::m_error
int m_error
Definition: AlgErrorAuditor.h:31
MSG::FATAL
Definition: IMessageSvc.h:22
IMessageSvc::messageCount
virtual int messageCount(MSG::Level level) const =0
Get the number of messages issued at a particular level.
AlgErrorAuditor::m_fatal
int m_fatal
Definition: AlgErrorAuditor.h:32
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
MSG::ERROR
Definition: IMessageSvc.h:21

StatusCode AlgErrorAuditor::finalize | ( |  | ) |
| virtual

Reimplemented from Auditor.

Definition at line 80 of file AlgErrorAuditor.cpp.

80 {
81
82
83 if (m_algMap[0].size() != 0) {
84 info() << "Found " << m_algMap[0].size()
85 << " instances where an Algorithm::execute() produced an ERROR "
86 << "but returned a SUCCESS:" << std::endl;
87
88 for (const auto& i : m_algMap[0] ) {
89 msgStream() << i.first << ": " << i.second << std::endl;
90 }
91
92 msgStream() << endmsg;
93 }
94
95 if (m_algMap[1].size() != 0) {
96 info() << "Found " << m_algMap[1].size()
97 << " instances where an Algorithm::execute() produced a FATAL "
98 << "but returned a SUCCESS:" << std::endl;
99
100 for (const auto& i : m_algMap[1]) {
101 msgStream() << i.first << ": " << i.second << std::endl;
102 }
103
104 msgStream() << endmsg;
105 }
106 return StatusCode::SUCCESS;
107 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
AlgErrorAuditor::m_algMap
std::map< std::string, int > m_algMap[2]
Definition: AlgErrorAuditor.h:34
std::endl
T endl(T...args)
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::map::size
T size(T...args)
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:89
ana.i
list i
Definition: ana.py:128
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

void AlgErrorAuditor::incrMap | ( | const std::string & | algName,
|  | int | level
| ) |  |
| private

Definition at line 110 of file AlgErrorAuditor.cpp.

110 {
111 auto i=m_algMap[level].find(alg);
112 if ( i != m_algMap[level].end()) {
113 i->second++;
114 } else {
115 m_algMap[level].emplace( alg,1 );
116 }
117 }
AlgErrorAuditor::m_algMap
std::map< std::string, int > m_algMap[2]
Definition: AlgErrorAuditor.h:34
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
std::map::find
T find(T...args)
std::map::emplace
T emplace(T...args)
gaudirun.level
level
Definition: gaudirun.py:261
ana.i
list i
Definition: ana.py:128

StatusCode AlgErrorAuditor::initialize | ( |  | ) |
| virtual

Reimplemented from Auditor.

Definition at line 24 of file AlgErrorAuditor.cpp.

24 {
25
26 if (m_abort && m_throw) {
27 info() << "Both \"Throw\" and \"Abort\" options have been set."
28 << " Abort takes precedence." << endmsg;
29 }
30
31 return StatusCode::SUCCESS;
32 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
AlgErrorAuditor::m_abort
BooleanProperty m_abort
Definition: AlgErrorAuditor.h:27
StatusCode::SUCCESS
Definition: StatusCode.h:30
AlgErrorAuditor::m_throw
BooleanProperty m_throw
Definition: AlgErrorAuditor.h:27
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

## Member Data Documentation

BooleanProperty AlgErrorAuditor::m_abort
| private

Definition at line 27 of file AlgErrorAuditor.h.

std::map<std::string, int> AlgErrorAuditor::m_algMap[2]
| private

Definition at line 34 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_error
| private

Definition at line 31 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_fatal
| private

Definition at line 32 of file AlgErrorAuditor.h.

BooleanProperty AlgErrorAuditor::m_throw
| private

Definition at line 27 of file AlgErrorAuditor.h.

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

- GaudiAud/src/AlgErrorAuditor.h
- GaudiAud/src/AlgErrorAuditor.cpp