All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Prescaler.cpp
Go to the documentation of this file.
1 #include "GaudiAlg/Prescaler.h"
2 
4 
5 Prescaler::Prescaler(const std::string& name, ISvcLocator* pSvcLocator) :
6  GaudiAlgorithm(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 
15 {
16 }
17 
20 {
22  if ( !sc) return sc;
23 
24  info() << name( ) << ":Prescaler::Initialize - pass: " << m_percentPass << endmsg;
25 
26  return sc;
27 }
28 
31 {
32  ++m_seen;
33  float fraction = (float(100.0) * (float)(m_pass+1)) / (float)m_seen;
34  if ( fraction > m_percentPass ) {
35  setFilterPassed( false );
36  info() << name() << ":Prescaler::execute - filter failed" << endmsg;
37  } else {
38  info() << name() << ":Prescaler::execute - filter passed" << endmsg;
39  ++m_pass;
40  }
41  return StatusCode::SUCCESS;
42 }
43 
46 {
47  info() << name( ) << ":Prescaler::finalize - total events: "
48  << m_seen << ", passed events: " << m_pass << endmsg;
49  return GaudiAlgorithm::finalize();
50 }
int m_seen
Number of events seen.
Definition: Prescaler.h:47
MsgStream & info() const
shortcut for the method msgStream ( MSG::INFO )
Definition: GaudiCommon.h:497
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
DoubleProperty m_percentPass
Percentage of events that should be passed.
Definition: Prescaler.h:37
virtual ~Prescaler()
Destructor.
Definition: Prescaler.cpp:14
virtual StatusCode initialize()
standard initialization method
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Algorithm.h:397
StatusCode finalize()
standard finalization method
Definition: Prescaler.cpp:45
StatusCode initialize()
standard initialization method
Definition: Prescaler.cpp:19
int m_pass
Number of events passed.
Definition: Prescaler.h:42
virtual StatusCode finalize()
standard finalization method
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual void setFilterPassed(bool state)
Set the filter passed flag to the specified state.
Definition: Algorithm.cpp:866
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
The useful base class for data processing algorithms.
VERIFIER & verifier()
Definition: Property.h:415
StatusCode execute()
standard execution method
Definition: Prescaler.cpp:30
Prescaler(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: Prescaler.cpp:5
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244