| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- File List
- File Members

# Prescaler.cpp

Go to the documentation of this file.

    00001 #include "GaudiAlg/Prescaler.h"
    00002
    00003 #include "GaudiKernel/MsgStream.h"
    00004 #include "GaudiKernel/AlgFactory.h"
    00005
    00006 Prescaler::Prescaler(const std::string& name, ISvcLocator* pSvcLocator) :
    00007   GaudiAlgorithm(name, pSvcLocator) ,
    00008   m_pass( 0 ),
    00009   m_seen( 0 )
    00010 {
    00011   declareProperty( "PercentPass", m_percentPass=100.0 );
    00012   m_percentPass.verifier().setBounds( 0.0, 100.0 );
    00013 }
    00014
    00015 Prescaler::~Prescaler( )
    00016 {
    00017 }
    00018
    00019 StatusCode
    00020 Prescaler::initialize()
    00021 {
    00022   const StatusCode sc = GaudiAlgorithm::initialize();
    00023   if ( !sc) return sc;
    00024
    00025   info() << name( ) << ":Prescaler::Initialize - pass: " << m_percentPass << endreq;
    00026
    00027  return sc;
    00028 }
    00029
    00030 StatusCode
    00031 Prescaler::execute()
    00032 {
    00033   ++m_seen;
    00034   float fraction = (float(100.0) * (float)(m_pass+1)) / (float)m_seen;
    00035   if ( fraction > m_percentPass ) {
    00036     setFilterPassed( false );
    00037     info() << name() << ":Prescaler::execute - filter failed" << endreq;
    00038   } else {
    00039     info() << name() << ":Prescaler::execute - filter passed" << endreq;
    00040     ++m_pass;
    00041   }
    00042   return StatusCode::SUCCESS;
    00043 }
    00044
    00045 StatusCode
    00046 Prescaler::finalize()
    00047 {
    00048   info() << name( ) << ":Prescaler::finalize - total events: "
    00049          << m_seen << ", passed events: " << m_pass << endreq;
    00050   return GaudiAlgorithm::finalize();
    00051 }