| The Gaudi Framework v32r1 (f65d50dc)

Prescaler.cpp
Go to the documentation of this file.
1 #include "GaudiAlg/Prescaler.h"
2
3 #include "GaudiKernel/MsgStream.h"
4
5 Prescaler::Prescaler( std::string name, ISvcLocator* pSvcLocator ) : GaudiAlgorithm( std::move( name ), pSvcLocator ) {
6 m_percentPass.verifier().setBounds( 0.0, 100.0 );
7 }
8
9 StatusCode Prescaler::initialize() {
10 const StatusCode sc = GaudiAlgorithm::initialize();
11 if ( !sc ) return sc;
12
13 info() << name() << ":Prescaler::Initialize - pass: " << m_percentPass << endmsg;
14
15 return sc;
16 }
17
18 StatusCode Prescaler::execute() {
19 ++m_seen;
20 float fraction = ( float( 100.0 ) * (float)( m_pass + 1 ) ) / (float)m_seen;
21 if ( fraction > m_percentPass ) {
22 setFilterPassed( false );
23 info() << name() << ":Prescaler::execute - filter failed" << endmsg;
24 } else {
25 info() << name() << ":Prescaler::execute - filter passed" << endmsg;
26 ++m_pass;
27 }
28 return StatusCode::SUCCESS;
29 }
30
31 StatusCode Prescaler::finalize() {
32 info() << name() << ":Prescaler::finalize - total events: " << m_seen << ", passed events: " << m_pass << endmsg;
33 return GaudiAlgorithm::finalize();
34 }
Prescaler::initialize
StatusCode initialize() override
Definition: Prescaler.cpp:9
Prescaler::execute
StatusCode execute() override
Definition: Prescaler.cpp:18
Prescaler::m_seen
int m_seen
Number of events seen.
Definition: Prescaler.h:36
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
Prescaler::Prescaler
Prescaler(std::string name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: Prescaler.cpp:5
MsgStream.h
GaudiAlgorithm::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiAlgorithm.cpp:42
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std
STL namespace.
Prescaler::m_pass
int m_pass
Number of events passed.
Definition: Prescaler.h:31
std::string
STL class.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
GaudiAlgorithm::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiAlgorithm.cpp:55
GaudiAlgorithm
The useful base class for data processing algorithms.
Definition: GaudiAlgorithm.h:94
Prescaler.h
Prescaler::finalize
StatusCode finalize() override
Definition: Prescaler.cpp:31
Prescaler::m_percentPass
Gaudi::CheckedProperty< double > m_percentPass
Percentage of events that should be passed.
Definition: Prescaler.h:25
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192