| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# EventCounter.cpp

Go to the documentation of this file.

    00001 //$Id: EventCounter.cpp,v 1.1 2004/07/12 13:39:20 mato Exp $
    00002 #include "GaudiAlg/EventCounter.h"
    00003 #include "GaudiKernel/MsgStream.h"
    00004 #include "GaudiKernel/AlgFactory.h"
    00005
    00009 EventCounter::EventCounter(const std::string& name, ISvcLocator* pSvcLocator) :
    00010   Algorithm(name, pSvcLocator),
    00011   m_skip ( 0 ),
    00012   m_total( 0 )
    00013 {
    00014     declareProperty( "Frequency", m_frequency=1 );
    00015     m_frequency.verifier().setBounds( 0, 1000 );
    00016 }
    00017
    00021 EventCounter::~EventCounter( )
    00022 {
    00023 }
    00024
    00025 StatusCode
    00026 EventCounter::initialize()
    00027 {
    00028     MsgStream log(msgSvc(), name());
    00029     log << MSG::INFO << name( ) << ":EventCounter::initialize - Frequency: " << m_frequency << endmsg;
    00030     return StatusCode::SUCCESS;
    00031 }
    00032
    00033 StatusCode
    00034 EventCounter::execute()
    00035 {
    00036      MsgStream log(msgSvc(), name());
    00037      m_total++;
    00038      int freq = m_frequency;
    00039      if ( freq > 0 ) {
    00040          m_skip++;
    00041          if ( m_skip >= freq ) {
    00042              log << MSG::INFO << name( ) << ":EventCounter::execute - seen events: " << m_total << endmsg;
    00043              m_skip = 0;
    00044          }
    00045      }
    00046     return StatusCode::SUCCESS;
    00047 }
    00048
    00049 StatusCode
    00050 EventCounter::finalize()
    00051 {
    00052     MsgStream log(msgSvc(), name());
    00053     log << MSG::INFO << name( ) << ":EventCounter::finalize - total events: " << m_total << endmsg;
    00054     return StatusCode::SUCCESS;
    00055 }