The Gaudi Framework  v29r0 (ff2e7097)
Prescaler.cpp
Go to the documentation of this file.
1 #include "GaudiAlg/Prescaler.h"
2 
4 
5 Prescaler::Prescaler( std::string name, ISvcLocator* pSvcLocator ) : GaudiAlgorithm( std::move( name ), pSvcLocator )
6 {
7  m_percentPass.verifier().setBounds( 0.0, 100.0 );
8 }
9 
11 {
13  if ( !sc ) return sc;
14 
15  info() << name() << ":Prescaler::Initialize - pass: " << m_percentPass << endmsg;
16 
17  return sc;
18 }
19 
21 {
22  ++m_seen;
23  float fraction = ( float( 100.0 ) * (float)( m_pass + 1 ) ) / (float)m_seen;
24  if ( fraction > m_percentPass ) {
25  setFilterPassed( false );
26  info() << name() << ":Prescaler::execute - filter failed" << endmsg;
27  } else {
28  info() << name() << ":Prescaler::execute - filter passed" << endmsg;
29  ++m_pass;
30  }
31  return StatusCode::SUCCESS;
32 }
33 
35 {
36  info() << name() << ":Prescaler::finalize - total events: " << m_seen << ", passed events: " << m_pass << endmsg;
37  return GaudiAlgorithm::finalize();
38 }
StatusCode initialize() override
Definition: Prescaler.cpp:10
StatusCode execute() override
Definition: Prescaler.cpp:20
int m_seen
Number of events seen.
Definition: Prescaler.h:42
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
void setFilterPassed(bool state) const override
Set the filter passed flag to the specified state.
Definition: Algorithm.cpp:768
Prescaler(std::string name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: Prescaler.cpp:5
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode initialize() override
standard initialization method
STL namespace.
int m_pass
Number of events passed.
Definition: Prescaler.h:37
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
StatusCode finalize() override
standard finalization method
The useful base class for data processing algorithms.
StatusCode finalize() override
Definition: Prescaler.cpp:34
Gaudi::CheckedProperty< double > m_percentPass
Percentage of events that should be passed.
Definition: Prescaler.h:31
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209