The Gaudi Framework  v33r0 (d5ea422b)
Prescaler.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include "GaudiAlg/Prescaler.h"
12 
13 #include "GaudiKernel/MsgStream.h"
14 
15 Prescaler::Prescaler( std::string name, ISvcLocator* pSvcLocator ) : GaudiAlgorithm( std::move( name ), pSvcLocator ) {
16  m_percentPass.verifier().setBounds( 0.0, 100.0 );
17 }
18 
21  if ( !sc ) return sc;
22 
23  info() << name() << ":Prescaler::Initialize - pass: " << m_percentPass << endmsg;
24 
25  return sc;
26 }
27 
29  ++m_seen;
30  float fraction = ( float( 100.0 ) * (float)( m_pass + 1 ) ) / (float)m_seen;
31  if ( fraction > m_percentPass ) {
32  setFilterPassed( false );
33  info() << name() << ":Prescaler::execute - filter failed" << endmsg;
34  } else {
35  info() << name() << ":Prescaler::execute - filter passed" << endmsg;
36  ++m_pass;
37  }
38  return StatusCode::SUCCESS;
39 }
40 
42  info() << name() << ":Prescaler::finalize - total events: " << m_seen << ", passed events: " << m_pass << endmsg;
43  return GaudiAlgorithm::finalize();
44 }
StatusCode initialize() override
Definition: Prescaler.cpp:19
StatusCode execute() override
Definition: Prescaler.cpp:28
int m_seen
Number of events seen.
Definition: Prescaler.h:46
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
Prescaler(std::string name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: Prescaler.cpp:15
StatusCode initialize() override
standard initialization method
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
STL namespace.
int m_pass
Number of events passed.
Definition: Prescaler.h:41
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode finalize() override
standard finalization method
The useful base class for data processing algorithms.
StatusCode finalize() override
Definition: Prescaler.cpp:41
Gaudi::CheckedProperty< double > m_percentPass
Percentage of events that should be passed.
Definition: Prescaler.h:35
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202