ATLAS Offline Software
GenFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 GenFilter::GenFilter(const std::string& name, ISvcLocator* pSvcLocator)
9  : GenBase(name, pSvcLocator)
10 {
11  declareProperty("TotalPassed", m_nNeeded=-1);
12 #ifdef HEPMC3
13  declareProperty("KeepAllEvents", m_keepAll=false);
14 #endif
15  m_nPass = 0;
16  m_nFail = 0;
17 }
18 
19 
22  m_nPass = 0;
23  m_nFail = 0;
25  return StatusCode::SUCCESS;
26 }
27 
28 
30  if (events_const()->empty()) {
31  ATH_MSG_ERROR("No events found in McEventCollection");
32  return StatusCode::FAILURE;
33  } else if (events_const()->size() > 1) {
35  ATH_MSG_WARNING("More than one event in current McEventCollection -- which is valid?");
36  }
38 #ifdef HEPMC3
39  if (filterPassed() || m_keepAll ) {
40 #else
41  if (filterPassed() ) {
42 #endif
43  ATH_MSG_DEBUG("Event passed filter");
44  m_nPass += 1;
45  } else {
46  ATH_MSG_DEBUG("Event failed filter");
47  m_nFail += 1;
48  }
49  // Bail out once we have enough events
50  if (m_nPass >= m_nNeeded && m_nNeeded > 0)
51  sc = StatusCode::FAILURE;
52  return sc;
53 }
54 
55 
57  ATH_MSG_INFO("Events passed = " << m_nPass << " Events failed = " << m_nFail);
59  return StatusCode::SUCCESS;
60 }
GenFilter::m_nNeeded
int m_nNeeded
Definition: GenFilter.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GenFilter::initialize
StatusCode initialize()
Definition: GenFilter.cxx:20
GenBase::events_const
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition: GenBase.h:96
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
GenFilter.h
GenFilter::filterEvent
virtual StatusCode filterEvent()=0
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
GenFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: GenFilter.h:45
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
GenBase
Base class for common behaviour of MC truth algorithms.
Definition: GenBase.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
GenFilter::m_nPass
int m_nPass
Definition: GenFilter.h:65
GenFilter::filterFinalize
virtual StatusCode filterFinalize()
Definition: GenFilter.h:47
GenFilter::finalize
StatusCode finalize()
Definition: GenFilter.cxx:56
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
GenFilter::m_nFail
int m_nFail
Definition: GenFilter.h:66
test_pyathena.filterPassed
filterPassed
now, add a sequencer: it will only execute seqalg1 and 2 and never 3
Definition: test_pyathena.py:38
GenFilter::GenFilter
GenFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GenFilter.cxx:8
GenFilter::execute
StatusCode execute()
Definition: GenFilter.cxx:29
GenBase::initialize
virtual StatusCode initialize() override
Definition: GenBase.cxx:17