ATLAS Offline Software
FilterReporterParams.h
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 #ifndef EVENT_BOOKKEEPER_TOOLS__FILTER_REPORTER_PARAMS_H
10 #define EVENT_BOOKKEEPER_TOOLS__FILTER_REPORTER_PARAMS_H
11 
12 #include <atomic>
13 #include <functional>
14 
18 
19 #ifndef XAOD_STANDALONE
21 #include <GaudiKernel/ServiceHandle.h>
22 #endif
23 
24 class EventContext;
25 class StatusCode;
26 
56 
58 {
59  //
60  // public interface
61  //
62 
68 public:
69  template<typename T>
70  explicit FilterReporterParams (T *owner,
71  std::string val_filterKey,
72  std::string val_filterDescription);
73 
74 
80 public:
81  StatusCode initialize (bool enabled = true);
82 
83 
86 public:
87  std::string summary ();
88 
89 
91 public:
92  const std::string& key() const { return m_filterKey; }
93 
94 
96 public:
98 
99 
100 #ifndef XAOD_STANDALONE
101 
103 public:
105 
106 #endif
107 
108 
109  //
110  // private interface
111  //
112 
113  // this class does most of the actual work, and needs our
114  // internals for that.
115  friend class FilterReporter;
116 
121 private:
122  std::function<void(bool, const EventContext *ctx)> m_setFilterPassed;
123 
125 private:
126  bool m_isInitialized {false};
127 
129 private:
130  bool m_isEnabled {false};
131 
136 private:
137  mutable std::atomic<unsigned> m_passed {0}, m_total {0};
138 
140 private:
141  std::string m_filterKey;
142 
144 private:
145  std::string m_filterDescription;
146 
148 private:
150 
151 #ifndef XAOD_STANDALONE
152 
154 private:
156 
159 private:
161 
162 #endif
163 };
164 
165 
166 
167 //
168 // inline/template methods
169 //
170 
171 template<typename T> FilterReporterParams ::
172 FilterReporterParams (T *owner,
173  std::string val_filterKey,
174  std::string val_filterDescription)
175  : AsgMessagingForward (owner)
176  , m_setFilterPassed ([owner] (bool val_setFilterPassed, const EventContext *ctx)
177  {
178 #ifndef XAOD_STANDALONE
179  owner->execState (*ctx).setFilterPassed (val_setFilterPassed);
180 #else
181  (void)ctx;
182  owner->setFilterPassed (val_setFilterPassed);
183 #endif
184  })
185  , m_filterKey (std::move (val_filterKey))
186  , m_filterDescription (std::move (val_filterDescription))
187  , m_eventInfoKey (owner, "EventInfoKey", "EventInfo", "event info used for cutflow")
188 #ifndef XAOD_STANDALONE
189  , m_cutFlowSvc ("CutFlowSvc/CutFlowSvc", owner->name())
190 #endif
191 {
192  owner->declareProperty("FilterKey", m_filterKey,
193  "output filter key");
194  owner->declareProperty("FilterDescription", m_filterDescription,
195  "describe to the CutFlowSvc what this filter does");
196 
197 #ifndef XAOD_STANDALONE
198  owner->declareProperty("CutFlowSvc", m_cutFlowSvc,
199  "handle to the ICutFlowSvc instance this filtering algorithm"
200  " will use for building the flow of cuts.");
201 #endif
202 }
203 
204 
207 {
208  return m_eventInfoKey;
209 }
210 
211 
212 #ifndef XAOD_STANDALONE
215 {
216  return m_cutFlowSvc;
217 }
218 #endif
219 
220 #endif
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::FilterReporterParams
FilterReporterParams(T *owner, std::string val_filterKey, std::string val_filterDescription)
standard constructor
Definition: FilterReporterParams.h:172
asg::AsgMessagingForward
base class to forward messages to another class
Definition: AsgMessagingForward.h:29
FilterReporterParams::m_cutID
CutIdentifier m_cutID
the CutIdentifier for this filter algorithm
Definition: FilterReporterParams.h:155
FilterReporterParams::m_isInitialized
bool m_isInitialized
whether the handle was initialized
Definition: FilterReporterParams.h:126
FilterReporterParams::m_filterDescription
std::string m_filterDescription
description what this filter does
Definition: FilterReporterParams.h:145
AsgMessagingForward.h
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
SG::ReadHandleKey< xAOD::EventInfo >
FilterReporterParams::cutFlowSvc
ServiceHandle< ICutFlowSvc > & cutFlowSvc()
retrieve the CutFlowSvc handle reference
Definition: FilterReporterParams.h:214
FilterReporterParams::eventInfoKey
const SG::ReadHandleKey< xAOD::EventInfo > & eventInfoKey() const
retrieve the event info read handle key
Definition: FilterReporterParams.h:206
FilterReporterParams::m_isEnabled
bool m_isEnabled
whether the handle was initialized
Definition: FilterReporterParams.h:130
FilterReporterParams
a handle for applying algorithm filter decisions
Definition: FilterReporterParams.h:58
FilterReporterParams::key
const std::string & key() const
retrieve the key name
Definition: FilterReporterParams.h:92
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
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
FilterReporterParams::initialize
StatusCode initialize(bool enabled=true)
do anything we need to do in initialize
Definition: FilterReporterParams.cxx:24
CutIdentifier
uint32_t CutIdentifier
InstanceIdentifier is a unique identifer used for every AthFilterAlgorithm instance.
Definition: ICutFlowSvc.h:22
FilterReporterParams::m_filterKey
std::string m_filterKey
output key of the filter
Definition: FilterReporterParams.h:141
FilterReporterParams::m_cutFlowSvc
ServiceHandle< ICutFlowSvc > m_cutFlowSvc
the handle to the service holding tables of cut-flows for filtering algs.
Definition: FilterReporterParams.h:160
ICutFlowSvc.h
EventInfo.h
FilterReporterParams::m_total
std::atomic< unsigned > m_total
Definition: FilterReporterParams.h:137
FilterReporterParams::m_passed
std::atomic< unsigned > m_passed
the count of passed and total events
Definition: FilterReporterParams.h:137
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ServiceHandle< ICutFlowSvc >
FilterReporterParams::summary
std::string summary()
report the status of filtering
Definition: FilterReporterParams.cxx:60