ATLAS Offline Software
Loading...
Searching...
No Matches
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
 FilterReporter (const FilterReporterParams &val_params, bool val_passedDefault, const EventContext &val_eventContext)
 standard re-entrant constructor
 ~FilterReporter () noexcept
 standard destructor
void setPassed (bool val_passed=true) noexcept
 report the filter decision

Private Attributes

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

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:

StatusCode Foo::execute()
{
...
static constexpr bool DEFAULT_DECISION = false;
FilterReporter filter (m_filterParams, DEFAULT_DECISION);
...
filter.setPassed ();
return StatusCode::SUCCESS;
}
FilterReporter(FilterReporterParams &val_params, bool val_passedDefault)
standard constructor

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{
32 if (!m_params.m_isInitialized)
33 {
34 throw std::logic_error ("using uninitialized FilterReporterParams");
35 }
36}
const FilterReporterParams & m_params
the FilterReporterParams object
const EventContext * m_eventContext
current EventContext reference
bool m_passed
the value of passed we will set

◆ 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{
48 if (!m_params.m_isInitialized)
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{
59 m_params.m_setFilterPassed (m_passed, m_eventContext);
60
61 if (m_passed)
62 m_params.m_passed += 1;
63 m_params.m_total += 1;
64
65#ifndef XAOD_STANDALONE
66 try {
67 if (m_passed && m_params.m_cutID != 0)
68 {
69 SG::ReadHandle<xAOD::EventInfo> evtInfo (m_params.m_eventInfoKey, *m_eventContext);
70 // Only try to access the mcEventWeight if we are running on Monte Carlo
71 if (evtInfo.isValid() && evtInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) {
72 m_params.m_cutFlowSvc->addEvent (m_params.m_cutID, evtInfo->mcEventWeights());
73 } else {
74 m_params.m_cutFlowSvc->addEvent (m_params.m_cutID, 1.0);
75 }
76 }
77 }
78 catch (const SG::ExcBadVarName& e) {
79 std::cerr << e.what() << "\n";
80 std::abort();
81 }
82 catch (const SG::ExcBadAuxVar& e) {
83 std::cerr << e.what() << "\n";
84 std::abort();
85 }
86 catch (const GaudiException& e) {
87 std::cerr << e.what() << "\n";
88 std::abort();
89 }
90#endif
91}
@ IS_SIMULATION
true: simulation, false: data

Member Function Documentation

◆ setPassed()

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

report the filter decision

Guarantee
no-fail

Definition at line 95 of file FilterReporter.cxx.

97{
98 m_passed = val_passed;
99}

Member Data Documentation

◆ m_eventContext

const EventContext* FilterReporter::m_eventContext {}
private

current EventContext reference

Definition at line 89 of file FilterReporter.h.

89{};

◆ 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.

85{false};

The documentation for this class was generated from the following files: