| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

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

    00013   : Auditor(name, pSvcLocator), m_error(0), m_fatal(0) {
    00014
    00015   declareProperty( "Abort", m_abort = false,
    00016                    "Abort job upon illegal Algorithm return code");
    00017   declareProperty( "Throw", m_throw = false,
    00018                    "Throw GaudiException upon illegal Algorithm return code");
    00019 }

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

Definition at line 21 of file AlgErrorAuditor.cpp.

    00021                                  {
    00022 }

## Member Function Documentation

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

Reimplemented from Auditor.

Definition at line 32 of file AlgErrorAuditor.cpp.

    00032                              {
    00033
    00034   if (m_abort && m_throw) {
    00035     MsgStream log(msgSvc(), name());
    00036     log << MSG::INFO << "Both \"Throw\" and \"Abort\" options have been set."
    00037         << " Abort takes precedence." << endmsg;
    00038   }
    00039
    00040   return StatusCode::SUCCESS;
    00041 }

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

Reimplemented from Auditor.

Definition at line 91 of file AlgErrorAuditor.cpp.

    00091                           {
    00092
    00093
    00094   std::map<std::string,int>::const_iterator itr;
    00095   if (m_algMap[0].size() != 0) {
    00096     MsgStream log(msgSvc(), name());
    00097     log << MSG::INFO << "Found " << m_algMap[0].size()
    00098         << " instances where an Algorithm::execute() produced an ERROR "
    00099         << "but returned a SUCCESS:" << std::endl;
    00100
    00101     for (itr = m_algMap[0].begin(); itr != m_algMap[0].end(); ++itr) {
    00102       log << itr->first << ": " << itr->second << std::endl;
    00103     }
    00104
    00105     log << endmsg;
    00106   }
    00107
    00108   if (m_algMap[1].size() != 0) {
    00109     MsgStream log(msgSvc(), name());
    00110     log << MSG::INFO << "Found " << m_algMap[1].size()
    00111         << " instances where an Algorithm::execute() produced a FATAL "
    00112         << "but returned a SUCCESS:" << std::endl;
    00113
    00114     for (itr = m_algMap[1].begin(); itr != m_algMap[1].end(); ++itr) {
    00115       log << itr->first << ": " << itr->second << std::endl;
    00116     }
    00117
    00118     log << endmsg;
    00119   }
    00120
    00121
    00122   return StatusCode::SUCCESS;
    00123
    00124 }

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

Reimplemented from Auditor.

Definition at line 26 of file AlgErrorAuditor.cpp.

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

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

Reimplemented from Auditor.

Definition at line 45 of file AlgErrorAuditor.cpp.

    00045                                                                          {
    00046
    00047   bool fail(false);
    00048   if (msgSvc()->messageCount(MSG::ERROR) != m_error && ! sc.isRecoverable() ) {
    00049     std::ostringstream os;
    00050     os << "Illegal Return Code: Algorithm " << alg->name()
    00051        << " reported an ERROR, but returned a StatusCode \"" << sc << "\"";
    00052     os << std::endl << "Error policy described in "
    00053          << "https://twiki.cern.ch/twiki/bin/view/Atlas/ReportingErrors";
    00054
    00055     MsgStream log(msgSvc(), name());
    00056     log << MSG::ERROR << os.str() << endmsg;
    00057     incrMap(alg->name(), 0);
    00058     fail = true;
    00059
    00060     if (m_throw && ! m_abort) {
    00061       throw GaudiException(os.str(),"AlgErrorAuditor",0);
    00062     }
    00063   }
    00064
    00065   if (msgSvc()->messageCount(MSG::FATAL) != m_fatal &&
    00066       sc != StatusCode::FAILURE ) {
    00067     std::ostringstream os;
    00068     os << "Illegal Return Code: Algorithm " << alg->name()
    00069        << " reported a FATAL, but returned a StatusCode \"" << sc << "\"";
    00070     os << std::endl << "Error policy described in "
    00071          << "https://twiki.cern.ch/twiki/bin/view/Atlas/ReportingErrors";
    00072
    00073     MsgStream log(msgSvc(), name());
    00074     log << MSG::ERROR << os.str() << endmsg;
    00075     incrMap(alg->name(), 1);
    00076     fail = true;
    00077
    00078     if (m_throw && ! m_abort) {
    00079       throw GaudiException(os.str(),"AlgErrorAuditor",0);
    00080     }
    00081
    00082   }
    00083
    00084   if (fail && m_abort) {
    00085     abort();
    00086   }
    00087
    00088 }

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

Definition at line 127 of file AlgErrorAuditor.cpp.

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

## Member Data Documentation

BooleanProperty AlgErrorAuditor::m_abort`[private]`

Definition at line 27 of file AlgErrorAuditor.h.

BooleanProperty AlgErrorAuditor::m_throw`[private]`

Definition at line 27 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.

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

Definition at line 34 of file AlgErrorAuditor.h.

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

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