ATLAS Offline Software
Loading...
Searching...
No Matches
AthPrescaler.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// AthPrescaler.cxx
8// Implementation file for class AthPrescaler
9// Author: S.Binet<binet@cern.ch>
11
12#include "AthPrescaler.h"
13
14AthPrescaler::AthPrescaler(const std::string& name, ISvcLocator* pSvcLocator) :
15 AthAlgorithm( name, pSvcLocator ),
16 m_pass( 0 ),
17 m_seen( 0 )
18{
19 declareProperty( "PercentPass", m_percentPass=100.0,
20 "Percentage of events that should be passed" );
21 m_percentPass.verifier().setBounds( 0.0, 100.0 );
22}
23
26
27StatusCode
29{
30 ATH_MSG_INFO ("Initializing " << name() << "..."
31 << endmsg
32 << "initialize ==> pass: " << m_percentPass);
33 return StatusCode::SUCCESS;
34}
35
36StatusCode
38{
39 ++m_seen;
40 float fraction = (float(100.0) * (float)(m_pass+1)) / (float)m_seen;
41 if ( fraction > m_percentPass ) {
42 setFilterPassed( false );
43 ATH_MSG_INFO ("execute ==> filter failed");
44 } else {
45 ATH_MSG_INFO ("execute ==> filter passed");
46 ++m_pass;
47 }
48 return StatusCode::SUCCESS;
49}
50
51StatusCode
53{
54 ATH_MSG_INFO ("finalize : " << endmsg
55 << " - total events: " << m_seen << endmsg
56 << " - passed events: " << m_pass);
57
58 return StatusCode::SUCCESS;
59}
#define endmsg
#define ATH_MSG_INFO(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StatusCode initialize()
StatusCode execute()
StatusCode finalize()
AthPrescaler(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
~AthPrescaler()
Destructor.
int m_seen
Number of events seen.
int m_pass
Number of events passed.
Gaudi::CheckedProperty< double > m_percentPass
Percentage of events that should be passed.