ATLAS Offline Software
FilterReporter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 
9 //
10 // includes
11 //
12 
16 #include <cassert>
17 
20 
21 //
22 // method implementations
23 //
24 
27  bool val_passedDefault)
28  : m_params (val_params)
29  , m_passed (val_passedDefault)
30  , m_eventContext (&Gaudi::Hive::currentContext())
31 {
33  {
34  throw std::logic_error ("using uninitialized FilterReporterParams");
35  }
36 }
37 
38 
39 
41 FilterReporter (const FilterReporterParams& val_params,
42  bool val_passedDefault,
43  const EventContext& val_eventContext)
44  : m_params (val_params)
45  , m_passed (val_passedDefault)
46  , m_eventContext (&val_eventContext)
47 {
49  {
50  throw std::logic_error ("using uninitialized FilterReporterParams");
51  }
52 }
53 
54 
55 
57 ~FilterReporter () noexcept
58 {
60 
61  if (m_passed)
62  m_params.m_passed += 1;
63  m_params.m_total += 1;
64 
65 #ifndef XAOD_STANDALONE
66  if (m_passed && m_params.m_cutID != 0)
67  {
69  // Only try to access the mcEventWeight if we are running on Monte Carlo
70  if (evtInfo.isValid() && evtInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) {
71  m_params.m_cutFlowSvc->addEvent (m_params.m_cutID, evtInfo->mcEventWeights());
72  } else {
73  m_params.m_cutFlowSvc->addEvent (m_params.m_cutID, 1.0);
74  }
75  }
76 #endif
77 }
78 
79 
80 
82 setPassed (bool val_passed) noexcept
83 {
84  m_passed = val_passed;
85 }
FilterReporter::setPassed
void setPassed(bool val_passed=true) noexcept
report the filter decision
Definition: FilterReporter.cxx:82
FilterReporterParams::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
event info read handle key
Definition: FilterReporterParams.h:149
FilterReporterParams::m_cutID
CutIdentifier m_cutID
the CutIdentifier for this filter algorithm
Definition: FilterReporterParams.h:155
xAOD::EventInfo_v1::mcEventWeights
const std::vector< float > & mcEventWeights() const
The weights of all the MC events used in the simulation.
CurrentContext.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
FilterReporterParams::m_isInitialized
bool m_isInitialized
whether the handle was initialized
Definition: FilterReporterParams.h:126
FilterReporter::FilterReporter
FilterReporter(FilterReporterParams &val_params, bool val_passedDefault)
standard constructor
Definition: FilterReporter.cxx:26
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
FilterReporterParams
a handle for applying algorithm filter decisions
Definition: FilterReporterParams.h:58
FilterReporterParams::m_setFilterPassed
std::function< void(bool, const EventContext *ctx)> m_setFilterPassed
the function to call setFilterPassed() on the algorithm
Definition: FilterReporterParams.h:122
MessageCheck.h
macros for messaging and checking status codes
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
FilterReporterParams::m_cutFlowSvc
ServiceHandle< ICutFlowSvc > m_cutFlowSvc
the handle to the service holding tables of cut-flows for filtering algs.
Definition: FilterReporterParams.h:160
FilterReporter.h
ReadHandle.h
Handle class for reading from StoreGate.
FilterReporter::m_params
const FilterReporterParams & m_params
the FilterReporterParams object
Definition: FilterReporter.h:81
FilterReporterParams::m_total
std::atomic< unsigned > m_total
Definition: FilterReporterParams.h:137
FilterReporter::m_eventContext
const EventContext * m_eventContext
current EventContext reference
Definition: FilterReporter.h:89
FilterReporter::~FilterReporter
~FilterReporter() noexcept
standard destructor
Definition: FilterReporter.cxx:57
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
FilterReporter::m_passed
bool m_passed
the value of passed we will set
Definition: FilterReporter.h:85
FilterReporterParams::m_passed
std::atomic< unsigned > m_passed
the count of passed and total events
Definition: FilterReporterParams.h:137
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
FilterReporterParams.h