| The Gaudi Framework v30r0 (c919700c)

- 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 () override=default
StatusCode | initialize () override
StatusCode | finalize () override
void | beforeExecute (INamedInterface *alg) override
void | afterExecute (INamedInterface *alg, const StatusCode &) override
Public Member Functions inherited from Auditor
| Auditor (const std::string &name, ISvcLocator *svcloc)
| Constructor. More...
| Auditor (const Auditor &a)=delete
Auditor & | operator= (const Auditor &rhs)=delete
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 override
| 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 | setProperties ()
| Set the auditor's properties. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const 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 cached level (originally extracted 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
Gaudi::Property< bool > | m_abort {this, "Abort", false, "abort job upon illegal Algorithm return code"}
Gaudi::Property< bool > | m_throw {this, "Throw", false, "throw GaudiException upon illegal Algorithm return code"}
int | m_error = 0
int | m_fatal = 0
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 PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using | base_class = CommonMessaging
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
MSG::Level | setUpMessaging ()
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
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 | ( |  | ) |
| override default

## Member Function Documentation

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

Definition at line 25 of file AlgErrorAuditor.cpp.

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

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

Definition at line 8 of file AlgErrorAuditor.cpp.

9 {
10 m_error = msgSvc()->messageCount( MSG::ERROR );
11 m_fatal = msgSvc()->messageCount( MSG::FATAL );
12 }
IMessageSvc::messageCount
virtual int messageCount(MSG::Level level) const =0
Get the number of messages issued at a particular level.
AlgErrorAuditor::m_error
int m_error
Definition: AlgErrorAuditor.h:33
MSG::FATAL
Definition: IMessageSvc.h:16
AlgErrorAuditor::m_fatal
int m_fatal
Definition: AlgErrorAuditor.h:34
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:75
MSG::ERROR
Definition: IMessageSvc.h:16

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

Reimplemented from Auditor.

Definition at line 68 of file AlgErrorAuditor.cpp.

69 {
70
71 if ( m_algMap[0].size() != 0 ) {
72 info() << "Found " << m_algMap[0].size() << " instances where an Algorithm::execute() produced an ERROR "
73 << "but returned a SUCCESS:" << std::endl;
74
75 for ( const auto& i : m_algMap[0] ) {
76 msgStream() << i.first << ": " << i.second << std::endl;
77 }
78
79 msgStream() << endmsg;
80 }
81
82 if ( m_algMap[1].size() != 0 ) {
83 info() << "Found " << m_algMap[1].size() << " instances where an Algorithm::execute() produced a FATAL "
84 << "but returned a SUCCESS:" << std::endl;
85
86 for ( const auto& i : m_algMap[1] ) {
87 msgStream() << i.first << ": " << i.second << std::endl;
88 }
89
90 msgStream() << endmsg;
91 }
92 return StatusCode::SUCCESS;
93 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
AlgErrorAuditor::m_algMap
std::map< std::string, int > m_algMap[2]
Definition: AlgErrorAuditor.h:36
std::endl
T endl(T...args)
std::map::size
T size(T...args)
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:78
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

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

Definition at line 95 of file AlgErrorAuditor.cpp.

96 {
97 auto i = m_algMap[level].find( alg );
98 if ( i != m_algMap[level].end() ) {
99 i->second++;
100 } else {
101 m_algMap[level].emplace( alg, 1 );
102 }
103 }
AlgErrorAuditor::m_algMap
std::map< std::string, int > m_algMap[2]
Definition: AlgErrorAuditor.h:36
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
std::map::find
T find(T...args)
std::map::emplace
T emplace(T...args)
gaudirun.level
level
Definition: gaudirun.py:271

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

Reimplemented from Auditor.

Definition at line 14 of file AlgErrorAuditor.cpp.

15 {
16
17 if ( m_abort && m_throw ) {
18 info() << "Both \"Throw\" and \"Abort\" options have been set."
19 << " Abort takes precedence." << endmsg;
20 }
21
22 return StatusCode::SUCCESS;
23 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
AlgErrorAuditor::m_abort
Gaudi::Property< bool > m_abort
Definition: AlgErrorAuditor.h:28
AlgErrorAuditor::m_throw
Gaudi::Property< bool > m_throw
Definition: AlgErrorAuditor.h:29
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

## Member Data Documentation

Gaudi::Property<bool> AlgErrorAuditor::m_abort {this, "Abort", false, "abort job upon illegal Algorithm return code"}
| private

Definition at line 28 of file AlgErrorAuditor.h.

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

Definition at line 36 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_error = 0
| private

Definition at line 33 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_fatal = 0
| private

Definition at line 34 of file AlgErrorAuditor.h.

Gaudi::Property<bool> AlgErrorAuditor::m_throw {this, "Throw", false, "throw GaudiException upon illegal Algorithm return code"}
| private

Definition at line 29 of file AlgErrorAuditor.h.

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

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