LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::EventSelector Class Reference

#include "EventSelector.h"

Classes

struct  BitInfo
 
struct  ScheduleData
 

Public Member Functions

 EventSelector (std::vector< std::string > const &pathspecs)
 
 EventSelector (EventSelector const &)
 
 EventSelector (EventSelector &&)
 
 ~EventSelector ()
 
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.

References accept_all_, acceptors_, path_specs_, and ~EventSelector().

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:29
PerScheduleContainer< ScheduleData > acceptors_
Definition: EventSelector.h:39
bool const accept_all_
Definition: EventSelector.h:30
art::EventSelector::EventSelector ( EventSelector const &  )
default
art::EventSelector::EventSelector ( EventSelector &&  )
default
art::EventSelector::~EventSelector ( )
default

Referenced by EventSelector().

Member Function Documentation

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

Definition at line 315 of file EventSelector.cc.

References accept_all_, acceptors_, data_for(), art::TriggerResults::parameterSetID(), and selectionDecision().

Referenced by art::detail::ProcessAndEventSelector::match().

317  {
318  if (accept_all_) {
319  return true;
320  }
321 
322  auto& data = acceptors_.at(id);
323  if (data.psetID != tr.parameterSetID()) {
324  data = data_for(tr);
325  }
326  return selectionDecision(data, tr);
327  }
PerScheduleContainer< ScheduleData > acceptors_
Definition: EventSelector.h:39
bool const accept_all_
Definition: EventSelector.h:30
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 160 of file EventSelector.cc.

References art::errors::Configuration, fhicl::ParameterSetRegistry::get(), fhicl::ParameterSet::get(), art::is_glob(), art::TriggerResults::parameterSetID(), path_specs_, art::regexMatch(), art::HLTGlobalStatus::size(), and art::errors::Unknown.

Referenced by acceptEvent().

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

References art::EventSelector::ScheduleData::absolute_acceptors, accept_all_, art::EventSelector::ScheduleData::all_must_fail, art::EventSelector::ScheduleData::all_must_fail_noex, art::EventSelector::ScheduleData::conditional_acceptors, art::HLTGlobalStatus::error(), art::hlt::Exception, art::EventSelector::ScheduleData::exception_acceptors, and f.

Referenced by acceptEvent().

332  {
333  if (accept_all_) {
334  return true;
335  }
336 
337  if (any_bit(data.absolute_acceptors, tr)) {
338  return true;
339  }
340 
341  bool exceptionPresent = false;
342  bool exceptionsLookedFor = false;
343  if (any_bit(data.conditional_acceptors, tr)) {
344  exceptionPresent = tr.error();
345  if (!exceptionPresent) {
346  return true;
347  }
348  exceptionsLookedFor = true;
349  }
350 
351  if (any_bit(data.exception_acceptors, tr, hlt::Exception)) {
352  return true;
353  }
354 
355  for (auto const& f : data.all_must_fail) {
356  if (all_bits(f, tr)) {
357  return true;
358  }
359  }
360 
361  for (auto const& fn : data.all_must_fail_noex) {
362  if (all_bits(fn, tr)) {
363  if (!exceptionsLookedFor) {
364  exceptionPresent = tr.error();
365  }
366  return !exceptionPresent;
367  }
368  }
369  return false;
370  }
TFile f
Definition: plotHisto.C:6
bool const accept_all_
Definition: EventSelector.h:30

Member Data Documentation

bool const art::EventSelector::accept_all_
private

Definition at line 30 of file EventSelector.h.

Referenced by acceptEvent(), EventSelector(), and selectionDecision().

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

Definition at line 39 of file EventSelector.h.

Referenced by acceptEvent(), and EventSelector().

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

Definition at line 29 of file EventSelector.h.

Referenced by data_for(), and EventSelector().


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