CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Friends

edm::service::ELstatistics Class Reference

#include <ELstatistics.h>

Inheritance diagram for edm::service::ELstatistics:
edm::service::ELdestination

List of all members.

Public Member Functions

virtual ELstatisticsclone () const
 ELstatistics (std::ostream &osp)
 ELstatistics (int spaceLimit)
 ELstatistics (int spaceLimit, std::ostream &osp)
 ELstatistics (const ELstatistics &orig)
 ELstatistics ()
virtual bool log (const edm::ErrorObj &msg)
virtual ~ELstatistics ()

Static Public Member Functions

static void noteGroupedCategory (std::string const &cat)

Protected Member Functions

virtual void clearSummary ()
void noTerminationSummary ()
virtual std::map< ELextendedID,
StatsCount
statisticsMap () const
virtual void summary (ELdestControl &dest, const ELstring &title="")
virtual void summary ()
virtual void summary (std::ostream &os, const ELstring &title="")
virtual void summary (ELstring &s, const ELstring &title="")
virtual void summaryForJobReport (std::map< std::string, double > &sm)
virtual void wipe ()
virtual void zero ()

Static Protected Member Functions

static ELstring formSummary (ELmap_stats &stats)

Protected Attributes

bool printAtTermination
ELmap_stats stats
int tableLimit
std::ostream & termStream
bool updatedStats

Static Protected Attributes

static std::set< std::string > groupedCategories

Private Member Functions

std::string dualLogName (std::string const &s)
ELstatisticsoperator= (const ELstatistics &orig)

Friends

class ELadministrator
class ELdestControl

Detailed Description

Definition at line 54 of file ELstatistics.h.


Constructor & Destructor Documentation

edm::service::ELstatistics::ELstatistics ( )

Definition at line 55 of file ELstatistics.cc.

References dtNoiseDBValidation_cfg::cerr.

Referenced by clone().

: ELdestination     (           )
, tableLimit        ( -1        )
, stats             (           )
, updatedStats      ( false     )
, termStream        ( std::cerr )
, printAtTermination( true      )
{

  #ifdef ELstatisticsCONSTRUCTOR_TRACE
    std::cerr << "Constructor for ELstatistics()\n";
  #endif

}  // ELstatistics()
edm::service::ELstatistics::ELstatistics ( std::ostream &  osp)

Definition at line 71 of file ELstatistics.cc.

References dtNoiseDBValidation_cfg::cerr.

: ELdestination     (       )
, tableLimit        ( -1    )
, stats             (       )
, updatedStats      ( false )
, termStream        ( osp   )
, printAtTermination( true  )
{

  #ifdef ELstatisticsCONSTRUCTOR_TRACE
    std::cerr << "Constructor for ELstatistics(osp)\n";
  #endif

}  // ELstatistics()
edm::service::ELstatistics::ELstatistics ( int  spaceLimit)

Definition at line 87 of file ELstatistics.cc.

References dtNoiseDBValidation_cfg::cerr.

: ELdestination     (            )
, tableLimit        ( spaceLimit )
, stats             (            )
, updatedStats      ( false      )
, termStream        ( std::cerr  )
, printAtTermination( true       )
{

  #ifdef ELstatisticsCONSTRUCTOR_TRACE
    std::cerr << "Constructor for ELstatistics(spaceLimit)\n";
  #endif

}  // ELstatistics()
edm::service::ELstatistics::ELstatistics ( int  spaceLimit,
std::ostream &  osp 
)

Definition at line 103 of file ELstatistics.cc.

References dtNoiseDBValidation_cfg::cerr.

: ELdestination     (            )
, tableLimit        ( spaceLimit )
, stats             (            )
, updatedStats      ( false      )
, termStream        ( osp        )
, printAtTermination( true       )
{

  #ifdef ELstatisticsCONSTRUCTOR_TRACE
    std::cerr << "Constructor for ELstatistics(spaceLimit,osp)\n";
  #endif

}  // ELstatistics()
edm::service::ELstatistics::ELstatistics ( const ELstatistics orig)

Definition at line 119 of file ELstatistics.cc.

References dtNoiseDBValidation_cfg::cerr, edm::service::ELdestination::ignoreMostModules, edm::service::ELdestination::ignoreThese, edm::service::ELdestination::respondToMostModules, and edm::service::ELdestination::respondToThese.

: ELdestination     (                         )
, tableLimit        ( orig.tableLimit         )
, stats             ( orig.stats              )
, updatedStats      ( orig.updatedStats       )
, termStream        ( orig.termStream         )
, printAtTermination( orig.printAtTermination )
{

  #ifdef ELstatisticsCONSTRUCTOR_TRACE
    std::cerr << "Copy constructor for ELstatistics()\n";
  #endif

  ignoreMostModules    = orig.ignoreMostModules;
  respondToThese       = orig.respondToThese;
  respondToMostModules = orig.respondToMostModules;
  ignoreThese          = orig.ignoreThese;

}  // ELstatistics()
edm::service::ELstatistics::~ELstatistics ( ) [virtual]

Definition at line 140 of file ELstatistics.cc.

References dtNoiseDBValidation_cfg::cerr, printAtTermination, summary(), termStream, and updatedStats.

                             {

  #ifdef ELstatisticsCONSTRUCTOR_TRACE
    std::cerr << "Destructor for ELstatistics\n";
  #endif

  if ( updatedStats && printAtTermination )
    summary( termStream, "Termination Summary" );

}  // ~ELstatistics()

Member Function Documentation

void edm::service::ELstatistics::clearSummary ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 230 of file ELstatistics.cc.

References edm::service::ELdestination::limits, alignCSCRings::s, stats, and edm::service::ELlimitsTable::zero().

                                  {

  limits.zero();
  ELmap_stats::iterator s;
  for ( s = stats.begin();  s != stats.end();  ++s )  {
    (*s).second.n = 0;
    (*s).second.context1 = (*s).second.context2 = (*s).second.contextLast = "";
  }

}  // clearSummary()
ELstatistics * edm::service::ELstatistics::clone ( void  ) const [virtual]

Implements edm::service::ELdestination.

Definition at line 157 of file ELstatistics.cc.

References ELstatistics().

                           {

  return  new ELstatistics( *this );

}  // clone()
std::string edm::service::ELstatistics::dualLogName ( std::string const &  s) [private]

Definition at line 550 of file ELstatistics.cc.

Referenced by summaryForJobReport().

{
  if (s=="LogDebug")   return  "LogDebug_LogTrace";
  if (s=="LogInfo")    return  "LogInfo_LogVerbatim";
  if (s=="LogWarning") return  "LogWarnng_LogPrint";
  if (s=="LogError")   return  "LogError_LogProblem";
  if (s=="LogSystem")  return  "LogSystem_LogAbsolute";
  return "UnusedSeverity";
}
ELstring edm::service::ELstatistics::formSummary ( ELmap_stats stats) [static, protected]

Definition at line 257 of file ELstatistics.cc.

References edm::eq(), g, edm::ELseverityLevel::getLevel(), edm::ELseverityLevel::getName(), edm::ELseverityLevel::getSymbol(), groupedCategories, i, gen::k, dttmaxenums::L, n, edm::ELseverityLevel::nLevels, p3, alignCSCRings::s, edm::ELextendedID::severity, and lumiQTWidget::t.

Referenced by summary().

                                                          {
                        // Major changes 8/16/07 mf, including making this
                        // a static member function instead of a free function
                        
  using std::ios;       /* _base ? */
  using std::setw;
  using std::right;
  using std::left;

  std::ostringstream          s;
  int                         n = 0;

  // -----  Summary part I:
  //
  ELstring  lastProcess( "" );
  bool      ftnote( false );

  struct part3  {
    long n, t;
    part3() : n(0L), t(0L)  { ; }
  }  p3[ELseverityLevel::nLevels];

  std::set<std::string>::iterator gcEnd = groupedCategories.end(); 
  std::set<std::string> gCats = groupedCategories;  // TEMP FOR DEBUGGING SANITY
  for ( ELmap_stats::const_iterator i = stats.begin();  i != stats.end();  ++i )  {

     // If this is a grouped category, wait till later to output its stats
    std::string cat = (*i).first.id; 
    if ( groupedCategories.find(cat) != gcEnd )
    {                                                           // 8/16/07 mf
       continue; // We will process these categories later
    }
                                                        
    // -----  Emit new process and part I header, if needed:
    //
    if ( n == 0  || ! eq(lastProcess, (*i).first.process) ) {
      s << "\n";
      lastProcess = (*i).first.process;
      if ( lastProcess.size() > 0) {
        s << "Process " << (*i).first.process << '\n';
      }
      s << " type     category        sev    module        "
             "subroutine        count    total\n"
        << " ---- -------------------- -- ---------------- "
             "----------------  -----    -----\n"
        ;
    }
    // -----  Emit detailed message information:
    //
    s << right << std::setw( 5) << ++n                                     << ' '
      << left  << std::setw(20) << (*i).first.id.substr(0,20)              << ' '
      << left  << std::setw( 2) << (*i).first.severity.getSymbol()         << ' '
      << left  << std::setw(16) << (*i).first.module.substr(0,16)          << ' '
      << left  << std::setw(16) << (*i).first.subroutine.substr(0,16)
      << right << std::setw( 7) << (*i).second.n
      << left  << std::setw( 1) << ( (*i).second.ignoredFlag ? '*' : ' ' )
      << right << std::setw( 8) << (*i).second.aggregateN                  << '\n'
      ;
    ftnote = ftnote || (*i).second.ignoredFlag;

    // -----  Obtain information for Part III, below:
    //
    ELextendedID xid = (*i).first;
    p3[xid.severity.getLevel()].n += (*i).second.n;
    p3[xid.severity.getLevel()].t += (*i).second.aggregateN;
  }  // for i

  // ----- Part Ia:  The grouped categories
  for ( std::set<std::string>::iterator g = groupedCategories.begin(); g != gcEnd; ++g ) {
    int groupTotal = 0;
    int groupAggregateN = 0;
    ELseverityLevel severityLevel;
    bool groupIgnored = true;
    for ( ELmap_stats::const_iterator i = stats.begin();  i != stats.end();  ++i )  {
      if ( (*i).first.id == *g ) {
        if (groupTotal==0) severityLevel = (*i).first.severity;
        groupIgnored &= (*i).second.ignoredFlag;
        groupAggregateN += (*i).second.aggregateN;
        ++groupTotal;
      } 
    } // for i
    if (groupTotal > 0) {
      // -----  Emit detailed message information:
      //
      s << right << std::setw( 5) << ++n                                     << ' '
        << left  << std::setw(20) << (*g).substr(0,20)                       << ' '
        << left  << std::setw( 2) << severityLevel.getSymbol()               << ' '
        << left  << std::setw(16) << "  <Any Module>  "                      << ' '
        << left  << std::setw(16) << "<Any Function>"
        << right << std::setw( 7) << groupTotal
        << left  << std::setw( 1) << ( groupIgnored ? '*' : ' ' )
        << right << std::setw( 8) << groupAggregateN                  << '\n'
        ;
      ftnote = ftnote || groupIgnored;

      // -----  Obtain information for Part III, below:
      //
      int lev = severityLevel.getLevel();
      p3[lev].n += groupTotal;
      p3[lev].t += groupAggregateN;
    } // end if groupTotal>0
  }  // for g

  // -----  Provide footnote to part I, if needed:
  //
  if ( ftnote )
    s << "\n* Some occurrences of this message"
         " were suppressed in all logs, due to limits.\n"
      ;

  // -----  Summary part II:
  //
  n = 0;
  for ( ELmap_stats::const_iterator i = stats.begin();  i != stats.end();  ++i )  {
    std::string cat = (*i).first.id; 
    if ( groupedCategories.find(cat) != gcEnd )
    {                                                           // 8/16/07 mf
       continue; // We will process these categories later
    }
    if ( n ==  0 ) {
      s << '\n'
        << " type    category    Examples: "
           "run/evt        run/evt          run/evt\n"
        << " ---- -------------------- ----"
           "------------ ---------------- ----------------\n"
        ;
    }
    s << right << std::setw( 5) << ++n                             << ' '
      << left  << std::setw(20) << (*i).first.id.c_str()           << ' '
      << left  << std::setw(16) << (*i).second.context1.c_str()    << ' '
      << left  << std::setw(16) << (*i).second.context2.c_str()    << ' '
                           << (*i).second.contextLast.c_str() << '\n'
      ;
  }  // for

  // -----  Summary part III:
  //
  s << "\nSeverity    # Occurrences   Total Occurrences\n"
    <<   "--------    -------------   -----------------\n";
  for ( int k = 0;  k < ELseverityLevel::nLevels;  ++k )  {
    if ( p3[k].n != 0  ||  p3[k].t != 0 )  {
      s << left  << std::setw( 8) << ELseverityLevel( ELseverityLevel::ELsev_(k) ).getName().c_str()
        << right << std::setw(17) << p3[k].n
        << right << std::setw(20) << p3[k].t
                             << '\n'
        ;
    }
  }  // for

  return s.str();

}  // formSummary()
bool edm::service::ELstatistics::log ( const edm::ErrorObj msg) [virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 164 of file ELstatistics.cc.

References dtNoiseDBValidation_cfg::cerr, instance, edm::service::ELadministrator::instance(), edm::ELextendedID::module, edm::ErrorObj::reactedTo(), alignCSCRings::s, edm::ELextendedID::severity, stats, edm::service::ELcontextSupplier::summaryContext(), tableLimit, edm::service::ELdestination::thisShouldBeIgnored(), edm::service::ELdestination::threshold, updatedStats, and edm::ErrorObj::xid().

                                                  {

  #ifdef ELstatsLOG_TRACE
    std::cerr << "  =:=:=: Log to an ELstatistics\n";
  #endif

  // See if this message is to be counted.

  if ( msg.xid().severity < threshold )        return false;
  if ( thisShouldBeIgnored(msg.xid().module) ) return false;

  // Account for this message, making a new table entry if needed:
  //
  ELmap_stats::iterator s = stats.find( msg.xid() );
  if ( s == stats.end() )  {
    if ( tableLimit < 0  ||  static_cast<int>(stats.size()) < tableLimit )  {
      stats[msg.xid()] = StatsCount();
      s = stats.find( msg.xid() );
    }
  }
  #ifdef ELstatsLOG_TRACE
    std::cerr << "    =:=:=: Message accounted for in stats \n";
  #endif
  if ( s != stats.end() )  {
    #ifdef ELstatsLOG_TRACE
        std::cerr << "    =:=:=: Message not last stats \n";
        std::cerr << "    =:=:=: getContextSupplier \n";
        const ELcontextSupplier & csup
          = ELadministrator::instance()->getContextSupplier();
        std::cerr << "    =:=:=: getContextSupplier \n";
        ELstring sumcon;
        std::cerr << "    =:=:=: summaryContext \n";
        sumcon = csup.summaryContext();
        std::cerr << "    =:=:=: summaryContext is: " << sumcon << "\n";
        (*s).second.add( sumcon, msg.reactedTo() );
        std::cerr << "    =:=:=: add worked. \n";
    #else
        (*s).second.add( ELadministrator::instance()->
                    getContextSupplier().summaryContext(), msg.reactedTo() );
    #endif

    updatedStats = true;
    #ifdef ELstatsLOG_TRACE
      std::cerr << "    =:=:=: Updated stats \n";
    #endif
  }


  // For the purposes of telling whether any log destination has reacted
  // to the message, the statistics destination does not count:
  //

  #ifdef ELstatsLOG_TRACE
    std::cerr << "  =:=:=: log(msg) done (stats) \n";
  #endif

  return false;


}  // log()
void edm::service::ELstatistics::noteGroupedCategory ( std::string const &  cat) [static]

Definition at line 562 of file ELstatistics.cc.

References groupedCategories.

Referenced by edm::service::MessageLoggerScribe::runCommand().

                                                            {
  groupedCategories.insert(cat);
}
void edm::service::ELstatistics::noTerminationSummary ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 444 of file ELstatistics.cc.

References printAtTermination.

{ printAtTermination = false; }
ELstatistics& edm::service::ELstatistics::operator= ( const ELstatistics orig) [private]
std::map< ELextendedID, StatsCount > edm::service::ELstatistics::statisticsMap ( ) const [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 446 of file ELstatistics.cc.

References stats.

                                                                    {
  return std::map<ELextendedID , StatsCount> ( stats );
}
void edm::service::ELstatistics::summary ( std::ostream &  os,
const ELstring title = "" 
) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 419 of file ELstatistics.cc.

References edm::service::ELdestination::flush(), formSummary(), stats, and updatedStats.

                                                                      {

  os << title << std::endl << formSummary(stats) << std::flush;
  updatedStats = false;

}  // summary()
void edm::service::ELstatistics::summary ( ELstring s,
const ELstring title = "" 
) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 436 of file ELstatistics.cc.

References formSummary(), stats, and updatedStats.

                                                                   {

  s = title + '\n' + formSummary(stats);
  updatedStats = false;

}  // summary()
void edm::service::ELstatistics::summary ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 426 of file ELstatistics.cc.

References edm::service::ELdestination::flush(), formSummary(), stats, termStream, and updatedStats.

Referenced by ~ELstatistics().

                              {

  termStream << "\n=============================================\n\n"
             << "MessageLogger Summary" << std::endl << formSummary(stats) 
             << std::flush;
  updatedStats = false;

}  // summary()
void edm::service::ELstatistics::summary ( ELdestControl dest,
const ELstring title = "" 
) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 411 of file ELstatistics.cc.

References formSummary(), stats, edm::service::ELdestControl::summarization(), and updatedStats.

                                                                           {

  dest.summarization( title, formSummary(stats) );
  updatedStats = false;

}  // summary()
void edm::service::ELstatistics::summaryForJobReport ( std::map< std::string, double > &  sm) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 452 of file ELstatistics.cc.

References dualLogName(), g, edm::ELseverityLevel::getLevel(), edm::ELseverityLevel::getName(), edm::ELseverityLevel::getSymbol(), groupedCategories, i, gen::k, dttmaxenums::L, n, edm::ELseverityLevel::nLevels, p3, alignCSCRings::s, edm::ELextendedID::severity, stats, and lumiQTWidget::t.

                                                                       {

  struct part3  {
    long n, t;
    part3() : n(0L), t(0L)  { ; }
  }  p3[ELseverityLevel::nLevels];

  std::set<std::string>::iterator gcEnd = groupedCategories.end(); 
  std::set<std::string> gCats = groupedCategories;  // TEMP FOR DEBUGGING SANITY

  // ----- Part I:  The ungrouped categories
  for ( ELmap_stats::const_iterator i = stats.begin();  i != stats.end();  ++i )  {

     // If this is a grouped category, wait till later to output its stats
    std::string cat = (*i).first.id; 
    if ( groupedCategories.find(cat) != gcEnd )
    {                                                           
       continue; // We will process these categories later
    }
                                                        
    // -----  Emit detailed message information:
    //
    std::ostringstream s;
    s << "Category_";
    std::string sevSymbol = (*i).first.severity.getSymbol();
    if ( sevSymbol[0] == '-' ) sevSymbol = sevSymbol.substr(1);
    s << sevSymbol << "_" << (*i).first.id;
    int n = (*i).second.aggregateN;    
    std::string catstr = s.str();
    if (sm.find(catstr) != sm.end()) {
      sm[catstr] += n; 
    } else {
       sm[catstr] = n;
    } 
    // -----  Obtain information for Part III, below:
    //
    ELextendedID xid = (*i).first;
    p3[xid.severity.getLevel()].n += (*i).second.n;
    p3[xid.severity.getLevel()].t += (*i).second.aggregateN;
  }  // for i

  // ----- Part Ia:  The grouped categories
  for ( std::set<std::string>::iterator g = groupedCategories.begin(); g != gcEnd; ++g ) {
    int groupTotal = 0;
    int groupAggregateN = 0;
    ELseverityLevel severityLevel;
    for ( ELmap_stats::const_iterator i = stats.begin();  i != stats.end();  ++i )  {
      if ( (*i).first.id == *g ) {
        if (groupTotal==0) severityLevel = (*i).first.severity;
        groupAggregateN += (*i).second.aggregateN;
        ++groupTotal;
      } 
    } // for i
    if (groupTotal > 0) {
      // -----  Emit detailed message information:
      //
      std::ostringstream s;
      s << "Category_";
      std::string sevSymbol = severityLevel.getSymbol();
      if ( sevSymbol[0] == '-' ) sevSymbol = sevSymbol.substr(1);
      s << sevSymbol << "_" << *g;
      int n = groupAggregateN;    
      std::string catstr = s.str();
      if (sm.find(catstr) != sm.end()) {
        sm[catstr] += n; 
      } else {
         sm[catstr] = n;
      } 

      // -----  Obtain information for Part III, below:
      //
      int lev = severityLevel.getLevel();
      p3[lev].n += groupTotal;
      p3[lev].t += groupAggregateN;
    } // end if groupTotal>0
  }  // for g

  // part II (sample event numbers) does not exist for the job report.

  // -----  Summary part III:
  //
  for ( int k = 0;  k < ELseverityLevel::nLevels;  ++k )  {
    //if ( p3[k].t != 0 )  {
    if (true) {
      std::string sevName;
      sevName = ELseverityLevel( ELseverityLevel::ELsev_(k) ).getName();
      if (sevName == "Severe")  sevName = "System";
      if (sevName == "Success") sevName = "Debug";
      sevName = std::string("Log")+sevName;
      sevName = dualLogName(sevName);
      if (sevName != "UnusedSeverity") {
        sm[sevName] = p3[k].t;
      }
    }
  }  // for k

} // summaryForJobReport()
void edm::service::ELstatistics::wipe ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 242 of file ELstatistics.cc.

References edm::service::ELdestination::limits, stats, and edm::service::ELlimitsTable::wipe().

                          {

  limits.wipe();
  stats.erase( stats.begin(), stats.end() );  //stats.clear();

}  // wipe()
void edm::service::ELstatistics::zero ( ) [protected, virtual]

Reimplemented from edm::service::ELdestination.

Definition at line 250 of file ELstatistics.cc.

References edm::service::ELdestination::limits, and edm::service::ELlimitsTable::zero().

                          {

  limits.zero();

}  // zero()

Friends And Related Function Documentation

friend class ELadministrator [friend]

Reimplemented from edm::service::ELdestination.

Definition at line 56 of file ELstatistics.h.

friend class ELdestControl [friend]

Reimplemented from edm::service::ELdestination.

Definition at line 57 of file ELstatistics.h.


Member Data Documentation

std::set< std::string > edm::service::ELstatistics::groupedCategories [static, protected]

Definition at line 121 of file ELstatistics.h.

Referenced by formSummary(), noteGroupedCategory(), and summaryForJobReport().

Definition at line 119 of file ELstatistics.h.

Referenced by noTerminationSummary(), and ~ELstatistics().

Definition at line 115 of file ELstatistics.h.

Referenced by clearSummary(), log(), statisticsMap(), summary(), summaryForJobReport(), and wipe().

Definition at line 114 of file ELstatistics.h.

Referenced by log().

std::ostream& edm::service::ELstatistics::termStream [protected]

Definition at line 117 of file ELstatistics.h.

Referenced by summary(), and ~ELstatistics().

Definition at line 116 of file ELstatistics.h.

Referenced by log(), summary(), and ~ELstatistics().