| The Gaudi Framework v32r1 (f65d50dc)

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 ) : Algorithm( name, pSvcLocator ) {
8 m_frequency.verifier().setBounds( 0, 1000 );
9 }
10
11 StatusCode EventCounter::initialize() {
12 info() << name() << ":EventCounter::initialize - Frequency: " << m_frequency << endmsg;
13 return StatusCode::SUCCESS;
14 }
15
16 StatusCode EventCounter::execute() {
17 m_total++;
18 int freq = m_frequency;
19 if ( freq > 0 ) {
20 ++m_skip;
21 if ( m_skip >= freq ) {
22 info() << name() << ":EventCounter::execute - seen events: " << m_total << endmsg;
23 m_skip = 0;
24 }
25 }
26 return StatusCode::SUCCESS;
27 }
28
29 StatusCode EventCounter::finalize() {
30 info() << name() << ":EventCounter::finalize - total events: " << m_total << endmsg;
31 return StatusCode::SUCCESS;
32 }
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
MsgStream.h
EventCounter::initialize
StatusCode initialize() override
Definition: EventCounter.cpp:11
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
EventCounter::m_total
int m_total
The total events seen.
Definition: EventCounter.h:40
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
EventCounter::EventCounter
EventCounter(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: EventCounter.cpp:7
EventCounter::m_skip
int m_skip
The number of events skipped since the last time the count was reported.
Definition: EventCounter.h:35
std::string
STL class.
EventCounter::finalize
StatusCode finalize() override
Definition: EventCounter.cpp:29
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Algorithm
Alias for backward compatibility.
Definition: Algorithm.h:56
EventCounter.h
EventCounter::m_frequency
Gaudi::CheckedProperty< int > m_frequency
The frequency with which the number of events should be reported.
Definition: EventCounter.h:29
EventCounter::execute
StatusCode execute() override
Definition: EventCounter.cpp:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645