The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 }
Prescaler::m_pass
int m_pass
Number of events passed.
Definition: Prescaler.h:41
std::string
STL class.
GaudiAlgorithm::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiAlgorithm.cpp:65
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:528
Gaudi::details::LegacyAlgorithmAdapter::setFilterPassed
void setFilterPassed(bool state) const
Set the filter passed flag to the specified state.
Definition: LegacyAlgorithm.cpp:30
Prescaler::finalize
StatusCode finalize() override
Definition: Prescaler.cpp:41
ISvcLocator
Definition: ISvcLocator.h:46
Prescaler::m_seen
int m_seen
Number of events seen.
Definition: Prescaler.h:46
Prescaler.h
Prescaler::initialize
StatusCode initialize() override
Definition: Prescaler.cpp:19
TimingHistograms.name
name
Definition: TimingHistograms.py:25
StatusCode
Definition: StatusCode.h:65
GaudiAlgorithm
Definition: GaudiAlgorithm.h:104
Prescaler::m_percentPass
Gaudi::CheckedProperty< double > m_percentPass
Percentage of events that should be passed.
Definition: Prescaler.h:35
GaudiAlgorithm::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiAlgorithm.cpp:52
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
Prescaler::execute
StatusCode execute() override
standard execution method
Definition: Prescaler.cpp:28
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std
STL namespace.
MsgStream.h
Prescaler::Prescaler
Prescaler(std::string name, ISvcLocator *pSvcLocator)
Constructor(s)
Definition: Prescaler.cpp:15