All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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) :
6  GaudiAlgorithm( std::move(name), pSvcLocator) ,
7  m_pass( 0 ),
8  m_seen( 0 )
9 {
10  declareProperty( "PercentPass", m_percentPass=100.0 );
11  m_percentPass.verifier().setBounds( 0.0, 100.0 );
12 }
13 
16 {
18  if ( !sc) return sc;
19 
20  info() << name( ) << ":Prescaler::Initialize - pass: " << m_percentPass << endmsg;
21 
22  return sc;
23 }
24 
27 {
28  ++m_seen;
29  float fraction = (float(100.0) * (float)(m_pass+1)) / (float)m_seen;
30  if ( fraction > m_percentPass ) {
31  setFilterPassed( false );
32  info() << name() << ":Prescaler::execute - filter failed" << endmsg;
33  } else {
34  info() << name() << ":Prescaler::execute - filter passed" << endmsg;
35  ++m_pass;
36  }
37  return StatusCode::SUCCESS;
38 }
39 
42 {
43  info() << name( ) << ":Prescaler::finalize - total events: "
44  << m_seen << ", passed events: " << m_pass << endmsg;
45  return GaudiAlgorithm::finalize();
46 }
StatusCode initialize() override
Definition: Prescaler.cpp:15
StatusCode execute() override
Definition: Prescaler.cpp:26
int m_seen
Number of events seen.
Definition: Prescaler.h:43
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
Prescaler(std::string name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: Prescaler.cpp:5
DoubleProperty m_percentPass
Percentage of events that should be passed.
Definition: Prescaler.h:33
StatusCode initialize() override
standard initialization method
void setBounds(const T &lower, const T &upper)
Set both bounds (lower and upper) at the same time.
STL namespace.
int m_pass
Number of events passed.
Definition: Prescaler.h:38
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode finalize() override
standard finalization method
The useful base class for data processing algorithms.
VERIFIER & verifier()
Definition: Property.h:401
StatusCode finalize() override
Definition: Prescaler.cpp:41
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)