All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EventCounter.cpp
Go to the documentation of this file.
1 #include "GaudiAlg/EventCounter.h"
2 #include "GaudiKernel/MsgStream.h"
3 
7 EventCounter::EventCounter(const std::string& name, ISvcLocator* pSvcLocator) :
8  Algorithm( name, pSvcLocator)
9 {
10  declareProperty( "Frequency", m_frequency=1 );
11  m_frequency.verifier().setBounds( 0, 1000 );
12 }
13 
16 {
17  MsgStream log(msgSvc(), name());
18  log << MSG::INFO << name( ) << ":EventCounter::initialize - Frequency: " << m_frequency << endmsg;
19  return StatusCode::SUCCESS;
20 }
21 
24 {
25  MsgStream log(msgSvc(), name());
26  m_total++;
27  int freq = m_frequency;
28  if ( freq > 0 ) {
29  ++m_skip;
30  if ( m_skip >= freq ) {
31  log << MSG::INFO << name( ) << ":EventCounter::execute - seen events: " << m_total << endmsg;
32  m_skip = 0;
33  }
34  }
35  return StatusCode::SUCCESS;
36 }
37 
40 {
41  MsgStream log(msgSvc(), name());
42  log << MSG::INFO << name( ) << ":EventCounter::finalize - total events: " << m_total << endmsg;
43  return StatusCode::SUCCESS;
44 }
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:25
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode initialize() override
void setBounds(const T &lower, const T &upper)
Set both bounds (lower and upper) at the same time.
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:435
int m_total
The total events seen.
Definition: EventCounter.h:47
EventCounter(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: EventCounter.cpp:7
int m_skip
The number of events skipped since the last time the count was reported.
Definition: EventCounter.h:42
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:919
StatusCode finalize() override
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
VERIFIER & verifier()
Definition: Property.h:401
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:77
StatusCode execute() override
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:1001