All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EventCounter.cpp
Go to the documentation of this file.
3 
7 EventCounter::EventCounter(const std::string& name, ISvcLocator* pSvcLocator) :
8  Algorithm(name, pSvcLocator),
9  m_skip ( 0 ),
10  m_total( 0 )
11 {
12  declareProperty( "Frequency", m_frequency=1 );
13  m_frequency.verifier().setBounds( 0, 1000 );
14 }
15 
20 {
21 }
22 
25 {
26  MsgStream log(msgSvc(), name());
27  log << MSG::INFO << name( ) << ":EventCounter::initialize - Frequency: " << m_frequency << endmsg;
28  return StatusCode::SUCCESS;
29 }
30 
33 {
34  MsgStream log(msgSvc(), name());
35  m_total++;
36  int freq = m_frequency;
37  if ( freq > 0 ) {
38  m_skip++;
39  if ( m_skip >= freq ) {
40  log << MSG::INFO << name( ) << ":EventCounter::execute - seen events: " << m_total << endmsg;
41  m_skip = 0;
42  }
43  }
44  return StatusCode::SUCCESS;
45 }
46 
49 {
50  MsgStream log(msgSvc(), name());
51  log << MSG::INFO << name( ) << ":EventCounter::finalize - total events: " << m_total << endmsg;
52  return StatusCode::SUCCESS;
53 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
IntegerProperty m_frequency
The frequency with which the number of events should be reported.
Definition: EventCounter.h:36
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Algorithm.h:397
int m_total
The total events seen.
Definition: EventCounter.h:47
EventCounter(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: EventCounter.cpp:7
StatusCode finalize()
the default (empty) implementation of IStateful::finalize() method
int m_skip
The number of events skipped since the last time the count was reported.
Definition: EventCounter.h:42
StatusCode execute()
The action to be performed by the algorithm on an event.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
VERIFIER & verifier()
Definition: Property.h:415
StatusCode initialize()
the default (empty) implementation of IStateful::initialize() method
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
virtual ~EventCounter()
Destructor.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244