Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
art::EventSelector Class Reference

#include <EventSelector.h>

Classes

struct  BitInfo
 
struct  ScheduleData
 

Public Member Functions

 EventSelector (std::vector< std::string > const &pathspecs)
 
bool acceptEvent (ScheduleID id, TriggerResults const &tr) const
 

Private Member Functions

ScheduleData data_for (TriggerResults const &tr) const
 
bool selectionDecision (ScheduleData const &data, HLTGlobalStatus const &) const
 

Private Attributes

std::vector< std::string > const path_specs_
 
bool const accept_all_
 
PerScheduleContainer< ScheduleDataacceptors_
 

Detailed Description

Definition at line 14 of file EventSelector.h.

Constructor & Destructor Documentation

art::EventSelector::EventSelector ( std::vector< std::string > const &  pathspecs)
explicit

Definition at line 148 of file EventSelector.cc.

149  : path_specs_{pathspecs}, accept_all_{accept_all(path_specs_)}
150  {
151  acceptors_.expand_to_num_schedules();
152  }
std::vector< std::string > const path_specs_
Definition: EventSelector.h:26
PerScheduleContainer< ScheduleData > acceptors_
Definition: EventSelector.h:36
bool const accept_all_
Definition: EventSelector.h:27

Member Function Documentation

bool art::EventSelector::acceptEvent ( ScheduleID  id,
TriggerResults const &  tr 
) const

Definition at line 309 of file EventSelector.cc.

311  {
312  if (accept_all_) {
313  return true;
314  }
315 
316  auto& data = acceptors_.at(id);
317  if (data.psetID != tr.parameterSetID()) {
318  data = data_for(tr);
319  }
320  return selectionDecision(data, tr);
321  }
PerScheduleContainer< ScheduleData > acceptors_
Definition: EventSelector.h:36
bool const accept_all_
Definition: EventSelector.h:27
ScheduleData data_for(TriggerResults const &tr) const
bool selectionDecision(ScheduleData const &data, HLTGlobalStatus const &) const
EventSelector::ScheduleData art::EventSelector::data_for ( TriggerResults const &  tr) const
private

Definition at line 156 of file EventSelector.cc.

157  {
158  fhicl::ParameterSet pset;
159  if (!fhicl::ParameterSetRegistry::get(tr.parameterSetID(), pset)) {
160  // This should never happen
162  << "EventSelector::acceptEvent cannot find the trigger names for\n"
163  << "a process for which the configuration has requested that the\n"
164  << "OutputModule use TriggerResults to select events from. This "
165  "should\n"
166  << "be impossible, please send information to reproduce this problem "
167  "to\n"
168  << "the art developers at artists@fnal.gov.\n";
169  }
170  auto const trigger_path_specs =
171  pset.get<vector<string>>("trigger_paths", {});
172  if (trigger_path_specs.size() != tr.size()) {
174  << "EventSelector::acceptEvent: Trigger names vector and\n"
175  << "TriggerResults are different sizes. This should be impossible,\n"
176  << "please send information to reproduce this problem to\n"
177  << "the art developers.\n";
178  }
179 
180  std::vector<BitInfo> absolute_acceptors;
181  std::vector<BitInfo> conditional_acceptors;
182  std::vector<BitInfo> exception_acceptors;
183  std::vector<std::vector<BitInfo>> all_must_fail;
184  std::vector<std::vector<BitInfo>> all_must_fail_noex;
185 
186  for (string const& pathSpecifier : path_specs_) {
187  string specifier{pathSpecifier};
188 
189  bool const noex_demanded = remove_noexception(pathSpecifier, specifier);
190  bool const negative_criterion = remove_negation(specifier);
191  bool const exception_spec = remove_exception(pathSpecifier, specifier);
192 
193  if (negative_criterion && exception_spec) {
195  << "EventSelector::init, A module is using SelectEvents\n"
196  << "to request a trigger name starting with !exception@.\n"
197  << "This is not supported.\n"
198  << "The improper trigger name is: " << pathSpecifier << "\n";
199  }
200 
201  if (noex_demanded && exception_spec) {
203  << "EventSelector::init, A module is using SelectEvents\n"
204  << "to request a trigger name starting with exception@ "
205  << "and also demanding &noexception.\n"
206  << "The improper trigger name is: " << pathSpecifier << "\n";
207  }
208 
209  // instead of "see if the name can be found in the full list of
210  // paths" we want to find all paths that match this name.
211  //
212  // 'specifier' now corresponds to the real trigger-path name,
213  // free of any decorations.
214  string const& realname{specifier};
215  auto const matches = regexMatch(trigger_path_specs, realname);
216  if (matches.empty()) {
217  if (is_glob(realname)) {
218  mf::LogWarning("Configuration")
219  << "EventSelector::init, A module is using SelectEvents\n"
220  "to request a wildcarded trigger name that "
221  "does not match any trigger.\n"
222  "The wildcarded trigger name is: "
223  << realname
224  << " (from trigger-path specification: " << pathSpecifier << ") \n";
225  } else {
227  << "EventSelector::init, A module is using SelectEvents\n"
228  "to request a trigger name that does not exist.\n"
229  "The unknown trigger name is: "
230  << realname
231  << " (from trigger-path specification: " << pathSpecifier << ") \n";
232  }
233  }
234 
235  auto makeBitInfoPass = [&trigger_path_specs](auto m) {
236  return BitInfo{path_position(trigger_path_specs, m), true};
237  };
238  auto makeBitInfoFail = [&trigger_path_specs](auto m) {
239  return BitInfo{path_position(trigger_path_specs, m), false};
240  };
241 
242  if (!negative_criterion && !noex_demanded && !exception_spec) {
244  matches, back_inserter(absolute_acceptors), makeBitInfoPass);
245  continue;
246  }
247 
248  if (!negative_criterion && noex_demanded) {
250  matches, back_inserter(conditional_acceptors), makeBitInfoPass);
251  continue;
252  }
253 
254  if (exception_spec) {
256  matches, back_inserter(exception_acceptors), makeBitInfoPass);
257  continue;
258  }
259 
260  if (negative_criterion && !noex_demanded) {
261  if (matches.empty()) {
263  << "EventSelector::init, A module is using SelectEvents\n"
264  "to request all fails on a set of trigger names that do not "
265  "exist\n"
266  << "The problematic name is: " << pathSpecifier << "\n";
267  }
268 
269  if (matches.size() == 1) {
270  BitInfo bi{path_position(trigger_path_specs, matches[0]), false};
271  absolute_acceptors.push_back(bi);
272  } else {
273  // We set this to false because that will demand bits are Fail.
274  auto must_fail = matches | ranges::views::transform(makeBitInfoFail) |
275  ranges::to_vector;
276  all_must_fail.push_back(move(must_fail));
277  }
278  continue;
279  }
280 
281  if (negative_criterion && noex_demanded) {
282  if (matches.empty()) {
284  << "EventSelector::init, A module is using SelectEvents\n"
285  "to request all fails on a set of trigger names that do not "
286  "exist\n"
287  << "The problematic name is: " << pathSpecifier << "\n";
288  }
289 
290  if (matches.size() == 1) {
291  BitInfo bi{path_position(trigger_path_specs, matches[0]), false};
292  conditional_acceptors.push_back(bi);
293  } else {
294  auto must_fail = matches | ranges::views::transform(makeBitInfoFail) |
295  ranges::to_vector;
296  all_must_fail_noex.push_back(move(must_fail));
297  }
298  }
299  }
300  return ScheduleData{tr.parameterSetID(),
301  absolute_acceptors,
302  conditional_acceptors,
303  exception_acceptors,
304  all_must_fail,
305  all_must_fail_noex};
306  }
std::vector< std::string > const path_specs_
Definition: EventSelector.h:26
static collection_type const & get() noexcept
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::string const &pattern)
Definition: RegexMatch.cc:25
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:271
auto transform_all(Container &, OutputIt, UnaryOp)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:11
bool art::EventSelector::selectionDecision ( ScheduleData const &  data,
HLTGlobalStatus const &  tr 
) const
private

Definition at line 324 of file EventSelector.cc.

326  {
327  if (accept_all_) {
328  return true;
329  }
330 
331  if (any_bit(data.absolute_acceptors, tr)) {
332  return true;
333  }
334 
335  bool exceptionPresent = false;
336  bool exceptionsLookedFor = false;
337  if (any_bit(data.conditional_acceptors, tr)) {
338  exceptionPresent = tr.error();
339  if (!exceptionPresent) {
340  return true;
341  }
342  exceptionsLookedFor = true;
343  }
344 
345  if (any_bit(data.exception_acceptors, tr, hlt::Exception)) {
346  return true;
347  }
348 
349  for (auto const& f : data.all_must_fail) {
350  if (all_bits(f, tr)) {
351  return true;
352  }
353  }
354 
355  for (auto const& fn : data.all_must_fail_noex) {
356  if (all_bits(fn, tr)) {
357  if (!exceptionsLookedFor) {
358  exceptionPresent = tr.error();
359  }
360  return !exceptionPresent;
361  }
362  }
363  return false;
364  }
QAsciiDict< Entry > fn
bool const accept_all_
Definition: EventSelector.h:27

Member Data Documentation

bool const art::EventSelector::accept_all_
private

Definition at line 27 of file EventSelector.h.

PerScheduleContainer<ScheduleData> art::EventSelector::acceptors_
mutableprivate

Definition at line 36 of file EventSelector.h.

std::vector<std::string> const art::EventSelector::path_specs_
private

Definition at line 26 of file EventSelector.h.


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