| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Member Functions | Private Member Functions | Private Attributes

# AlgErrorAuditor Class Reference

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

`#include <AlgErrorAuditor.h>`

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

List of all members.

## Public Member Functions
| AlgErrorAuditor (const std::string &name, ISvcLocator *pSvcLocator)
virtual | ~AlgErrorAuditor ()
virtual StatusCode | initialize ()
virtual StatusCode | finalize ()
virtual void | beforeExecute (INamedInterface *alg)
virtual void | afterExecute (INamedInterface *alg, const StatusCode &)
## 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]

## 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 9 of file AlgErrorAuditor.cpp.

      : Auditor(name, pSvcLocator), m_error(0), m_fatal(0) {

      declareProperty( "Abort", m_abort = false,
                       "Abort job upon illegal Algorithm return code");
      declareProperty( "Throw", m_throw = false,
                       "Throw GaudiException upon illegal Algorithm return code");
    }

AlgErrorAuditor::~AlgErrorAuditor | ( | ) | `[virtual]`

Definition at line 18 of file AlgErrorAuditor.cpp.

                                     {
    }

## Member Function Documentation

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

Reimplemented from Auditor.

Definition at line 42 of file AlgErrorAuditor.cpp.

                                                                             {

      bool fail(false);
      if (msgSvc()->messageCount(MSG::ERROR) != m_error && ! sc.isRecoverable() ) {
        std::ostringstream os;
        os << "Illegal Return Code: Algorithm " << alg->name()
           << " reported an ERROR, but returned a StatusCode \"" << sc << "\"";
        os << std::endl << "Error policy described in "
             << "https://twiki.cern.ch/twiki/bin/view/Atlas/ReportingErrors";

        MsgStream log(msgSvc(), name());
        log << MSG::ERROR << os.str() << endmsg;
        incrMap(alg->name(), 0);
        fail = true;

        if (m_throw && ! m_abort) {
          throw GaudiException(os.str(),"AlgErrorAuditor",0);
        }
      }

      if (msgSvc()->messageCount(MSG::FATAL) != m_fatal &&
          sc != StatusCode::FAILURE ) {
        std::ostringstream os;
        os << "Illegal Return Code: Algorithm " << alg->name()
           << " reported a FATAL, but returned a StatusCode \"" << sc << "\"";
        os << std::endl << "Error policy described in "
             << "https://twiki.cern.ch/twiki/bin/view/Atlas/ReportingErrors";

        MsgStream log(msgSvc(), name());
        log << MSG::ERROR << os.str() << endmsg;
        incrMap(alg->name(), 1);
        fail = true;

        if (m_throw && ! m_abort) {
          throw GaudiException(os.str(),"AlgErrorAuditor",0);
        }

      }

      if (fail && m_abort) {
        abort();
      }

    }

void AlgErrorAuditor::beforeExecute | ( | INamedInterface * | alg ) | `[virtual]`

Reimplemented from Auditor.

Definition at line 23 of file AlgErrorAuditor.cpp.

                                                    {
      m_error = msgSvc()->messageCount(MSG::ERROR);
      m_fatal = msgSvc()->messageCount(MSG::FATAL);
    }

StatusCode AlgErrorAuditor::finalize | ( | void | ) | `[virtual]`

Reimplemented from Auditor.

Definition at line 88 of file AlgErrorAuditor.cpp.

                              {

      std::map<std::string,int>::const_iterator itr;
      if (m_algMap[0].size() != 0) {
        MsgStream log(msgSvc(), name());
        log << MSG::INFO << "Found " << m_algMap[0].size()
            << " instances where an Algorithm::execute() produced an ERROR "
            << "but returned a SUCCESS:" << std::endl;

        for (itr = m_algMap[0].begin(); itr != m_algMap[0].end(); ++itr) {
          log << itr->first << ": " << itr->second << std::endl;
        }

        log << endmsg;
      }

      if (m_algMap[1].size() != 0) {
        MsgStream log(msgSvc(), name());
        log << MSG::INFO << "Found " << m_algMap[1].size()
            << " instances where an Algorithm::execute() produced a FATAL "
            << "but returned a SUCCESS:" << std::endl;

        for (itr = m_algMap[1].begin(); itr != m_algMap[1].end(); ++itr) {
          log << itr->first << ": " << itr->second << std::endl;
        }

        log << endmsg;
      }

      return StatusCode::SUCCESS;

    }

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

Definition at line 124 of file AlgErrorAuditor.cpp.

                                                            {
      std::map<std::string, int>::iterator itr;
      if ( (itr=m_algMap[level].find(alg)) != m_algMap[level].end()) {
        itr->second++;
      } else {
        m_algMap[level].insert( std::pair<std::string,int>(alg,1) );
      }
    }

StatusCode AlgErrorAuditor::initialize | ( | ) | `[virtual]`

Reimplemented from Auditor.

Definition at line 29 of file AlgErrorAuditor.cpp.

                                 {

      if (m_abort && m_throw) {
        MsgStream log(msgSvc(), name());
        log << MSG::INFO << "Both \"Throw\" and \"Abort\" options have been set."
            << " Abort takes precedence." << endmsg;
      }

      return StatusCode::SUCCESS;
    }

## 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:

- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiAud/src/AlgErrorAuditor.h
- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiAud/src/AlgErrorAuditor.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines