ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
FilterReporter Class Referencefinal

a guard class for use with ref FilterReporterParams More...

#include <FilterReporter.h>

Collaboration diagram for FilterReporter:

Public Member Functions

 FilterReporter (FilterReporterParams &val_params, bool val_passedDefault)
 standard constructor More...
 
 FilterReporter (const FilterReporterParams &val_params, bool val_passedDefault, const EventContext &val_eventContext)
 standard re-entrant constructor More...
 
 ~FilterReporter () noexcept
 standard destructor More...
 
void setPassed (bool val_passed=true) noexcept
 report the filter decision More...
 

Private Attributes

const FilterReporterParamsm_params
 the FilterReporterParams object More...
 
bool m_passed {false}
 the value of passed we will set More...
 
const EventContext * m_eventContext {}
 current EventContext reference More...
 

Detailed Description

a guard class for use with ref FilterReporterParams

In order to ensure that the filter decision will always be set as part of execute(), this guard class should be used like this:

{
...
static constexpr bool DEFAULT_DECISION = false;
FilterReporter filter (m_filterParams, DEFAULT_DECISION);
...
filter.setPassed ();
return StatusCode::SUCCESS;
}

Definition at line 34 of file FilterReporter.h.

Constructor & Destructor Documentation

◆ FilterReporter() [1/2]

FilterReporter::FilterReporter ( FilterReporterParams val_params,
bool  val_passedDefault 
)

standard constructor

Guarantee
strong
Failures
out of memory I
Author
Nils Krumnack
Tadej Novak

Definition at line 25 of file FilterReporter.cxx.

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 }

◆ FilterReporter() [2/2]

FilterReporter::FilterReporter ( const FilterReporterParams val_params,
bool  val_passedDefault,
const EventContext &  val_eventContext 
)

standard re-entrant constructor

Guarantee
strong
Failures
out of memory I

Definition at line 40 of file FilterReporter.cxx.

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 }

◆ ~FilterReporter()

FilterReporter::~FilterReporter ( )
noexcept

standard destructor

Guarantee
no-fail

Definition at line 56 of file FilterReporter.cxx.

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 }

Member Function Documentation

◆ setPassed()

void FilterReporter::setPassed ( bool  val_passed = true)
noexcept

report the filter decision

Guarantee
no-fail

Definition at line 81 of file FilterReporter.cxx.

83 {
84  m_passed = val_passed;
85 }

Member Data Documentation

◆ m_eventContext

const EventContext* FilterReporter::m_eventContext {}
private

current EventContext reference

Definition at line 89 of file FilterReporter.h.

◆ m_params

const FilterReporterParams& FilterReporter::m_params
private

the FilterReporterParams object

Definition at line 81 of file FilterReporter.h.

◆ m_passed

bool FilterReporter::m_passed {false}
private

the value of passed we will set

Definition at line 85 of file FilterReporter.h.


The documentation for this class was generated from the following files:
FilterReporterParams::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
event info read handle key
Definition: FilterReporterParams.h:149
FilterReporter
a guard class for use with ref FilterReporterParams
Definition: FilterReporter.h:35
FilterReporterParams::m_cutID
CutIdentifier m_cutID
the CutIdentifier for this filter algorithm
Definition: FilterReporterParams.h:155
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
FilterReporterParams::m_isInitialized
bool m_isInitialized
whether the handle was initialized
Definition: FilterReporterParams.h:126
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
covarianceTool.filter
filter
Definition: covarianceTool.py:514
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
FilterReporterParams::m_setFilterPassed
std::function< void(bool, const EventContext *ctx)> m_setFilterPassed
the function to call setFilterPassed() on the algorithm
Definition: FilterReporterParams.h:122
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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::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::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