CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
edm::EventSelector Class Reference

#include <EventSelector.h>

Classes

struct  BitInfo
 

Public Types

typedef std::vector< std::string > Strings
 

Public Member Functions

bool acceptEvent (TriggerResults const &)
 
bool acceptEvent (unsigned char const *, int) const
 
 EventSelector (Strings const &pathspecs, Strings const &names)
 
 EventSelector (Strings const &pathspecs)
 
std::shared_ptr< TriggerResultsmaskTriggerResults (TriggerResults const &inputResults)
 
bool wantAll () const
 

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)
 
static std::vector< std::string > getEventSelectionVString (edm::ParameterSet const &pset)
 
static bool selectionIsValid (Strings const &pathspec, Strings const &fullPathList)
 
static evtSel::OverlapResult testSelectionOverlap (Strings const &pathspec1, Strings const &pathspec2, Strings const &fullPathList)
 

Private Types

typedef std::vector< BitInfoBits
 

Private Member Functions

bool acceptAllBits (Bits const &b, HLTGlobalStatus const &tr) const
 
bool acceptOneBit (Bits const &b, HLTGlobalStatus const &tr, hlt::HLTState const &s=hlt::Ready) const
 
bool acceptTriggerPath (HLTPathStatus const &, BitInfo const &) const
 
bool containsExceptions (HLTGlobalStatus const &tr) const
 
bool initAcceptAll ()
 
void initPathNames (Strings const &pathNames)
 
Strings initPathSpecs (Strings const &pathSpecs)
 
bool selectionDecision (HLTGlobalStatus const &tr) const
 

Static Private Member Functions

static std::vector< bool > combine (std::vector< bool > const &a, std::vector< bool > const &b)
 
static std::vector< bool > expandDecisionList (Bits const &b, bool PassOrFail, unsigned int n)
 
static std::string glob2reg (std::string const &s)
 
static bool identical (std::vector< bool > const &a, std::vector< bool > const &b)
 
static bool identical (EventSelector const &a, EventSelector const &b, unsigned int N)
 
static std::vector< Strings::const_iterator > matching_triggers (Strings const &trigs, std::string const &s)
 
static bool overlapping (std::vector< bool > const &a, std::vector< bool > const &b)
 
static bool subset (std::vector< bool > const &a, std::vector< bool > const &b)
 

Private Attributes

Bits absolute_acceptors_
 
bool const accept_all_
 
std::vector< Bitsall_must_fail_
 
std::vector< Bitsall_must_fail_noex_
 
Bits conditional_acceptors_
 
Bits exception_acceptors_
 
int nPathNames_
 
Strings const pathspecs_
 
ParameterSetID psetID_
 
bool const results_from_current_process_
 

Detailed Description

Definition at line 35 of file EventSelector.h.

Member Typedef Documentation

◆ Bits

typedef std::vector<BitInfo> edm::EventSelector::Bits
private

Definition at line 72 of file EventSelector.h.

◆ Strings

typedef std::vector<std::string> edm::EventSelector::Strings

Definition at line 37 of file EventSelector.h.

Constructor & Destructor Documentation

◆ EventSelector() [1/2]

EventSelector::EventSelector ( Strings const &  pathspecs,
Strings const &  names 
)

Definition at line 49 of file EventSelector.cc.

References initPathNames().

50  : pathspecs_(initPathSpecs(pathspecs)),
58  psetID_(),
59  nPathNames_(0) {
60  initPathNames(pathNames);
61  }
std::vector< Bits > all_must_fail_noex_
Definition: EventSelector.h:78
void initPathNames(Strings const &pathNames)
bool const accept_all_
Definition: EventSelector.h:70
Strings initPathSpecs(Strings const &pathSpecs)
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:77
Strings const pathspecs_
Definition: EventSelector.h:68
ParameterSetID psetID_
Definition: EventSelector.h:80
bool const results_from_current_process_
Definition: EventSelector.h:69

◆ EventSelector() [2/2]

EventSelector::EventSelector ( Strings const &  pathspecs)
explicit

Definition at line 63 of file EventSelector.cc.

64  : pathspecs_(initPathSpecs(pathspecs)),
72  psetID_(),
73  nPathNames_(0) {}
std::vector< Bits > all_must_fail_noex_
Definition: EventSelector.h:78
bool const accept_all_
Definition: EventSelector.h:70
Strings initPathSpecs(Strings const &pathSpecs)
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:77
Strings const pathspecs_
Definition: EventSelector.h:68
ParameterSetID psetID_
Definition: EventSelector.h:80
bool const results_from_current_process_
Definition: EventSelector.h:69

Member Function Documentation

◆ acceptAllBits()

bool EventSelector::acceptAllBits ( Bits const &  b,
HLTGlobalStatus const &  tr 
) const
private

Definition at line 368 of file EventSelector.cc.

References edm::HLTGlobalStatus::at(), b, triggerObjects_cff::bit, edm::hlt::Fail, edm::hlt::Pass, and edm::HLTPathStatus::state().

Referenced by selectionDecision().

368  {
369  for (auto const& bit : b) {
370  hlt::HLTState bstate = bit.accept_state_ ? hlt::Pass : hlt::Fail;
371  if (tr.at(bit.pos_).state() != bstate)
372  return false;
373  }
374  return true;
375  } // acceptAllBits
HLTState
status of a trigger path
Definition: HLTenums.h:16
reject
Definition: HLTenums.h:19
accept
Definition: HLTenums.h:18
double b
Definition: hdecay.h:120

◆ acceptEvent() [1/2]

bool EventSelector::acceptEvent ( TriggerResults const &  tr)

Definition at line 234 of file EventSelector.cc.

References accept_all_, Exception, initPathNames(), edm::Hash< I >::isValid(), edm::TriggerResults::parameterSetID(), psetID_, edm::Hash< I >::reset(), results_from_current_process_, selectionDecision(), and edm::errors::Unknown.

Referenced by edm::detail::NamedEventSelector::match(), and selectionIsValid().

234  {
235  if (accept_all_)
236  return true;
237 
239  // The path names for prior processes may be different in different runs.
240  // Check for this, and modify the selector accordingly if necessary.
241  if (!psetID_.isValid() || psetID_ != tr.parameterSetID()) {
242  Strings pathNames;
243  bool fromPSetRegistry = false;
245  if (tns->getTrigPaths(tr, pathNames, fromPSetRegistry)) {
246  initPathNames(pathNames);
247  if (fromPSetRegistry) {
248  psetID_ = tr.parameterSetID();
249  } else {
250  // This can only happen for very old data, when the path names were stored
251  // in TriggerResults itself, rather than in the parameter set registry.
252  psetID_.reset();
253  }
254  } else {
255  // This should never happen
257  << "EventSelector::acceptEvent cannot find the trigger names for\n"
258  "a process for which the configuration has requested that the\n"
259  "OutputModule use TriggerResults to select events from. This should\n"
260  "be impossible, please send information to reproduce this problem to\n"
261  "the edm developers.\n";
262  }
263  }
264  }
265 
266  // Now make the decision, based on the supplied TriggerResults tr,
267  // which of course can be treated as an HLTGlobalStatus by inheritance
268 
269  return selectionDecision(tr);
270 
271  } // acceptEvent(TriggerResults const& tr)
void initPathNames(Strings const &pathNames)
std::vector< std::string > Strings
Definition: EventSelector.h:37
bool const accept_all_
Definition: EventSelector.h:70
bool isValid() const
Definition: Hash.h:141
bool selectionDecision(HLTGlobalStatus const &tr) const
ParameterSetID psetID_
Definition: EventSelector.h:80
bool const results_from_current_process_
Definition: EventSelector.h:69
void reset()
Definition: Hash.h:136

◆ acceptEvent() [2/2]

bool EventSelector::acceptEvent ( unsigned char const *  array_of_trigger_results,
int  number_of_trigger_paths 
) const

Definition at line 273 of file EventSelector.cc.

References accept_all_, edm::errors::Configuration, Exception, results_from_current_process_, and selectionDecision().

273  {
274  // This should never occur unless someone uses this function in
275  // an incorrect way ...
277  throw edm::Exception(errors::Configuration) << "\nEventSelector.cc::acceptEvent, you are attempting to\n"
278  << "use a bit array for trigger results instead of the\n"
279  << "TriggerResults object for a previous process. This\n"
280  << "will not work and ought to be impossible\n";
281  }
282 
283  if (accept_all_)
284  return true;
285 
286  // Form HLTGlobalStatus object to represent the array_of_trigger_results
287  HLTGlobalStatus tr(number_of_trigger_paths);
288  int byteIndex = 0;
289  int subIndex = 0;
290  for (int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
291  int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
292  state &= 0x3;
293  HLTPathStatus pathStatus(static_cast<hlt::HLTState>(state));
294  tr[pathIndex] = pathStatus;
295  ++subIndex;
296  if (subIndex == 4) {
297  ++byteIndex;
298  subIndex = 0;
299  }
300  }
301 
302  // Now make the decision, based on the HLTGlobalStatus tr,
303  // which we have created from the supplied array of results
304 
305  return selectionDecision(tr);
306 
307  } // acceptEvent(array_of_trigger_results, number_of_trigger_paths)
bool const accept_all_
Definition: EventSelector.h:70
bool selectionDecision(HLTGlobalStatus const &tr) const
bool const results_from_current_process_
Definition: EventSelector.h:69

◆ acceptOneBit()

bool EventSelector::acceptOneBit ( Bits const &  b,
HLTGlobalStatus const &  tr,
hlt::HLTState const &  s = hlt::Ready 
) const
private

Definition at line 356 of file EventSelector.cc.

References edm::HLTGlobalStatus::at(), b, triggerObjects_cff::bit, edm::hlt::Exception, edm::hlt::Fail, edm::hlt::Pass, alignCSCRings::s, and edm::HLTPathStatus::state().

Referenced by selectionDecision().

356  {
357  bool lookForException = (s == hlt::Exception);
358  for (auto const& bit : b) {
359  hlt::HLTState bstate = lookForException ? hlt::Exception : bit.accept_state_ ? hlt::Pass : hlt::Fail;
360  if (tr.at(bit.pos_).state() == bstate)
361  return true;
362  }
363  return false;
364  } // acceptOneBit
HLTState
status of a trigger path
Definition: HLTenums.h:16
reject
Definition: HLTenums.h:19
accept
Definition: HLTenums.h:18
double b
Definition: hdecay.h:120

◆ acceptTriggerPath()

bool EventSelector::acceptTriggerPath ( HLTPathStatus const &  pathStatus,
BitInfo const &  pathInfo 
) const
private

Definition at line 347 of file EventSelector.cc.

References edm::EventSelector::BitInfo::accept_state_, edm::hlt::Exception, edm::hlt::Fail, edm::hlt::Pass, and edm::HLTPathStatus::state().

347  {
348  return (((pathStatus.state() == hlt::Pass) && (pathInfo.accept_state_)) ||
349  ((pathStatus.state() == hlt::Fail) && !(pathInfo.accept_state_)) ||
350  ((pathStatus.state() == hlt::Exception)));
351  }
reject
Definition: HLTenums.h:19
accept
Definition: HLTenums.h:18

◆ combine()

std::vector< bool > EventSelector::combine ( std::vector< bool > const &  a,
std::vector< bool > const &  b 
)
staticprivate

Definition at line 971 of file EventSelector.cc.

References a, cms::cuda::assert(), b, mps_fire::i, and x.

Referenced by testSelectionOverlap().

971  {
972  assert(a.size() == b.size());
973  std::vector<bool> x(a.size());
974  for (unsigned int i = 0; i != a.size(); ++i) {
975  x[i] = a[i] || b[i];
976  } // a really sharp compiler will optimize the hell out of this,
977  // exploiting word-size OR operations.
978  return x;
979  } // combine
assert(be >=bs)
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
float x

◆ containsExceptions()

bool EventSelector::containsExceptions ( HLTGlobalStatus const &  tr) const
private

Definition at line 822 of file EventSelector.cc.

References MillePedeFileConverter_cfg::e, edm::hlt::Exception, mps_fire::i, and edm::HLTGlobalStatus::size().

Referenced by selectionDecision().

822  {
823  unsigned int e = tr.size();
824  for (unsigned int i = 0; i < e; ++i) {
825  if (tr[i].state() == hlt::Exception)
826  return true;
827  }
828  return false;
829  }

◆ expandDecisionList()

std::vector< bool > EventSelector::expandDecisionList ( Bits const &  b,
bool  PassOrFail,
unsigned int  n 
)
staticprivate

Definition at line 908 of file EventSelector.cc.

References b, mps_fire::i, dqmiodumpmetadata::n, and x.

Referenced by identical(), maskTriggerResults(), and testSelectionOverlap().

908  {
909  std::vector<bool> x(n, false);
910  for (unsigned int i = 0; i != b.size(); ++i) {
911  if (b[i].accept_state_ == PassOrFail)
912  x[b[i].pos_] = true;
913  }
914  return x;
915  } // expandDecisionList
double b
Definition: hdecay.h:120
float x

◆ fillDescription()

void EventSelector::fillDescription ( ParameterSetDescription desc)
static

Definition at line 981 of file EventSelector.cc.

References submitPVResolutionJobs::desc, and collectionMerger::selector.

Referenced by edm::core::OutputModuleCore::fillDescription().

981  {
983  selector.addOptional<std::vector<std::string>>("SelectEvents");
984  desc.addUntracked<ParameterSetDescription>("SelectEvents", selector);
985  }

◆ getEventSelectionVString()

std::vector< std::string > EventSelector::getEventSelectionVString ( edm::ParameterSet const &  pset)
static

Returns the list of strings that correspond to the trigger selection request in the specified parameter set (the list of strings contained in the "SelectEvents" parameter).

Parameters
psetThe ParameterSet that contains the trigger selection.
Returns
the trigger selection list (vector of string).

Definition at line 801 of file EventSelector.cc.

References edm::ParameterSet::empty(), edm::ParameterSet::getParameter(), muonDTDigis_cfi::pset, and corrVsCorr::selection.

Referenced by edm::streamer::StreamerOutputMsgBuilders::parameters().

801  {
802  // default the selection to everything (wildcard)
804  selection.push_back("*");
805  selection.push_back("!*");
806  selection.push_back("exception@*");
807 
808  // the SelectEvents parameter is a ParameterSet within
809  // a ParameterSet, so we have to pull it out twice
810  ParameterSet selectEventsParamSet = pset.getUntrackedParameter("SelectEvents", ParameterSet());
811  if (!selectEventsParamSet.empty()) {
812  Strings path_specs = selectEventsParamSet.getParameter<Strings>("SelectEvents");
813  if (!path_specs.empty()) {
814  selection = path_specs;
815  }
816  }
817 
818  // return the result
819  return selection;
820  }
std::vector< std::string > Strings
Definition: EventSelector.h:37
selection
main part
Definition: corrVsCorr.py:100

◆ glob2reg()

static std::string edm::EventSelector::glob2reg ( std::string const &  s)
staticprivate

◆ identical() [1/2]

bool EventSelector::identical ( std::vector< bool > const &  a,
std::vector< bool > const &  b 
)
staticprivate

Definition at line 833 of file EventSelector.cc.

References a, b, mps_fire::i, and dqmiodumpmetadata::n.

Referenced by identical(), and testSelectionOverlap().

833  {
834  unsigned int n = a.size();
835  if (n != b.size())
836  return false;
837  for (unsigned int i = 0; i != n; ++i) {
838  if (a[i] != b[i])
839  return false;
840  }
841  return true;
842  }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ identical() [2/2]

bool EventSelector::identical ( EventSelector const &  a,
EventSelector const &  b,
unsigned int  N 
)
staticprivate

Definition at line 844 of file EventSelector.cc.

References a, b, expandDecisionList(), identical(), dqmdumpme::k, visualization-live-secondInstance_cfg::m, edm::match(), and N.

844  {
845  // create the expanded masks for the various decision lists in a and b
846  if (!identical(expandDecisionList(a.absolute_acceptors_, true, N),
847  expandDecisionList(b.absolute_acceptors_, true, N)))
848  return false;
849  if (!identical(expandDecisionList(a.conditional_acceptors_, true, N),
850  expandDecisionList(b.conditional_acceptors_, true, N)))
851  return false;
852  if (!identical(expandDecisionList(a.absolute_acceptors_, false, N),
853  expandDecisionList(b.absolute_acceptors_, false, N)))
854  return false;
855  if (!identical(expandDecisionList(a.conditional_acceptors_, false, N),
856  expandDecisionList(b.conditional_acceptors_, false, N)))
857  return false;
858  if (!identical(expandDecisionList(a.exception_acceptors_, true, N),
859  expandDecisionList(b.exception_acceptors_, true, N)))
860  return false;
861  if (a.all_must_fail_.size() != b.all_must_fail_.size())
862  return false;
863 
864  std::vector<std::vector<bool>> aMustFail;
865  for (unsigned int m = 0; m != a.all_must_fail_.size(); ++m) {
866  aMustFail.push_back(expandDecisionList(a.all_must_fail_[m], false, N));
867  }
868  std::vector<std::vector<bool>> aMustFailNoex;
869  for (unsigned int m = 0; m != a.all_must_fail_noex_.size(); ++m) {
870  aMustFailNoex.push_back(expandDecisionList(a.all_must_fail_noex_[m], false, N));
871  }
872  std::vector<std::vector<bool>> bMustFail;
873  for (unsigned int m = 0; m != b.all_must_fail_.size(); ++m) {
874  bMustFail.push_back(expandDecisionList(b.all_must_fail_[m], false, N));
875  }
876  std::vector<std::vector<bool>> bMustFailNoex;
877  for (unsigned int m = 0; m != b.all_must_fail_noex_.size(); ++m) {
878  bMustFailNoex.push_back(expandDecisionList(b.all_must_fail_noex_[m], false, N));
879  }
880 
881  for (unsigned int m = 0; m != aMustFail.size(); ++m) {
882  bool match = false;
883  for (unsigned int k = 0; k != bMustFail.size(); ++k) {
884  if (identical(aMustFail[m], bMustFail[k])) {
885  match = true;
886  break;
887  }
888  }
889  if (!match)
890  return false;
891  }
892  for (unsigned int m = 0; m != aMustFailNoex.size(); ++m) {
893  bool match = false;
894  for (unsigned int k = 0; k != bMustFailNoex.size(); ++k) {
895  if (identical(aMustFailNoex[m], bMustFailNoex[k])) {
896  match = true;
897  break;
898  }
899  }
900  if (!match)
901  return false;
902  }
903 
904  return true;
905 
906  } // identical (EventSelector, EventSelector, N);
#define N
Definition: blowfish.cc:9
double b
Definition: hdecay.h:120
static bool identical(std::vector< bool > const &a, std::vector< bool > const &b)
double a
Definition: hdecay.h:121
static std::vector< bool > expandDecisionList(Bits const &b, bool PassOrFail, unsigned int n)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)

◆ initAcceptAll()

bool EventSelector::initAcceptAll ( )
private

Definition at line 87 of file EventSelector.cc.

References pathspecs_.

87  {
88  if (pathspecs_.empty()) {
89  return true;
90  }
91  // The following are for the purpose of establishing accept_all_ by
92  // virtue of an inclusive set of paths:
93  bool unrestricted_star = false;
94  bool negated_star = false;
95  bool exception_star = false;
96 
97  for (auto const& pathspecifier : pathspecs_) {
98  if (pathspecifier == "*")
99  unrestricted_star = true;
100  if (pathspecifier == "!*")
101  negated_star = true;
102  if (pathspecifier == "exception@*")
103  exception_star = true;
104  }
105  return (unrestricted_star && negated_star && exception_star);
106  }
Strings const pathspecs_
Definition: EventSelector.h:68

◆ initPathNames()

void EventSelector::initPathNames ( Strings const &  pathNames)
private

Definition at line 108 of file EventSelector.cc.

References absolute_acceptors_, accept_all_, all_must_fail_, all_must_fail_noex_, conditional_acceptors_, edm::errors::Configuration, HLT_2024v14_cff::distance, Exception, exception_acceptors_, edm::is_glob(), oniaPATMuonsWithTrigger_cff::matches, nPathNames_, pathspecs_, edm::regexMatch(), AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

Referenced by acceptEvent(), and EventSelector().

108  {
109  if (accept_all_) {
110  return;
111  }
112  // std::cerr << "### init entered\n";
114  all_must_fail_noex_.clear();
115  nPathNames_ = pathNames.size();
116 
117  for (auto const& pathspecifier : pathspecs_) {
118  std::string basePathSpec(pathspecifier);
119  bool noex_demanded = false;
120  std::string::size_type and_noexception = pathspecifier.find("&noexception");
121  if (and_noexception != std::string::npos) {
122  basePathSpec = pathspecifier.substr(0, and_noexception);
123  noex_demanded = true;
124  }
125  std::string::size_type and_noex = pathspecifier.find("&noex");
126  if (and_noex != std::string::npos) {
127  basePathSpec = pathspecifier.substr(0, and_noexception);
128  noex_demanded = true;
129  }
130  and_noexception = basePathSpec.find("&noexception");
131  and_noex = basePathSpec.find("&noex");
132  if (and_noexception != std::string::npos || and_noex != std::string::npos)
133  throw edm::Exception(errors::Configuration) << "EventSelector::init, An OutputModule is using SelectEvents\n"
134  "to request a trigger name, but specifying &noexceptions twice\n"
135  << "The improper trigger name is: " << pathspecifier << "\n";
136 
137  std::string realname(basePathSpec);
138  bool negative_criterion = false;
139  if (basePathSpec[0] == '!') {
140  negative_criterion = true;
141  realname = basePathSpec.substr(1, std::string::npos);
142  }
143  bool exception_spec = false;
144  if (realname.find("exception@") == 0) {
145  exception_spec = true;
146  realname = realname.substr(10, std::string::npos);
147  // strip off 10 chars, which is length of "exception@"
148  }
149  if (negative_criterion && exception_spec)
150  throw edm::Exception(errors::Configuration) << "EventSelector::init, An OutputModule is using SelectEvents\n"
151  "to request a trigger name starting with !exception@.\n"
152  "This is not supported.\n"
153  << "The improper trigger name is: " << pathspecifier << "\n";
154  if (noex_demanded && exception_spec)
155  throw edm::Exception(errors::Configuration) << "EventSelector::init, An OutputModule is using SelectEvents\n"
156  "to request a trigger name starting with exception@ "
157  "and also demanding no &exceptions.\n"
158  << "The improper trigger name is: " << pathspecifier << "\n";
159 
160  // instead of "see if the name can be found in the full list of paths"
161  // we want to find all paths that match this name.
162  std::vector<Strings::const_iterator> matches = regexMatch(pathNames, realname);
163 
164  if (matches.empty() && !is_glob(realname)) {
165  throw edm::Exception(errors::Configuration) << "EventSelector::init, An OutputModule is using SelectEvents\n"
166  "to request a trigger name that does not exist\n"
167  << "The unknown trigger name is: " << realname << "\n";
168  }
169  if (matches.empty() && is_glob(realname)) {
170  LogWarning("Configuration") << "EventSelector::init, An OutputModule is using SelectEvents\n"
171  "to request a wildcarded trigger name that does not match any trigger \n"
172  << "The wildcarded trigger name is: " << realname << "\n";
173  }
174 
175  if (!negative_criterion && !noex_demanded && !exception_spec) {
176  for (unsigned int t = 0; t != matches.size(); ++t) {
177  BitInfo bi(distance(pathNames.begin(), matches[t]), true);
178  absolute_acceptors_.push_back(bi);
179  }
180  } else if (!negative_criterion && noex_demanded) {
181  for (unsigned int t = 0; t != matches.size(); ++t) {
182  BitInfo bi(distance(pathNames.begin(), matches[t]), true);
183  conditional_acceptors_.push_back(bi);
184  }
185  } else if (exception_spec) {
186  for (unsigned int t = 0; t != matches.size(); ++t) {
187  BitInfo bi(distance(pathNames.begin(), matches[t]), true);
188  exception_acceptors_.push_back(bi);
189  }
190  } else if (negative_criterion && !noex_demanded) {
191  if (matches.empty()) {
193  << "EventSelector::init, An OutputModule is using SelectEvents\n"
194  "to request all fails on a set of trigger names that do not exist\n"
195  << "The problematic name is: " << pathspecifier << "\n";
196 
197  } else if (matches.size() == 1) {
198  BitInfo bi(distance(pathNames.begin(), matches[0]), false);
199  absolute_acceptors_.push_back(bi);
200  } else {
201  Bits mustfail;
202  for (unsigned int t = 0; t != matches.size(); ++t) {
203  BitInfo bi(distance(pathNames.begin(), matches[t]), false);
204  // We set this to false because that will demand bits are Fail.
205  mustfail.push_back(bi);
206  }
207  all_must_fail_.push_back(mustfail);
208  }
209  } else if (negative_criterion && noex_demanded) {
210  if (matches.empty()) {
212  << "EventSelector::init, An OutputModule is using SelectEvents\n"
213  "to request all fails on a set of trigger names that do not exist\n"
214  << "The problematic name is: " << pathspecifier << "\n";
215 
216  } else if (matches.size() == 1) {
217  BitInfo bi(distance(pathNames.begin(), matches[0]), false);
218  conditional_acceptors_.push_back(bi);
219  } else {
220  Bits mustfail;
221  for (unsigned int t = 0; t != matches.size(); ++t) {
222  BitInfo bi(distance(pathNames.begin(), matches[t]), false);
223  mustfail.push_back(bi);
224  }
225  all_must_fail_noex_.push_back(mustfail);
226  }
227  }
228  } // end of the for loop on pathspecs
229 
230  // std::cerr << "### init exited\n";
231 
232  } // EventSelector::init
std::vector< Bits > all_must_fail_noex_
Definition: EventSelector.h:78
bool const accept_all_
Definition: EventSelector.h:70
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:17
std::vector< BitInfo > Bits
Definition: EventSelector.h:72
uint16_t size_type
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:77
Strings const pathspecs_
Definition: EventSelector.h:68
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const &regexp)
Definition: RegexMatch.cc:26
Log< level::Warning, false > LogWarning

◆ initPathSpecs()

Strings EventSelector::initPathSpecs ( Strings const &  pathSpecs)
private

Definition at line 75 of file EventSelector.cc.

References HltBtagPostValidation_cff::c.

75  {
76  Strings trimmedPathSpecs(pathSpecs);
77  for (auto& pathspecifier : trimmedPathSpecs) {
78  pathspecifier.erase(std::remove_if(pathspecifier.begin(),
79  pathspecifier.end(),
80  [](char c) { return std::isspace(static_cast<unsigned char>(c)); }),
81  pathspecifier.end()); // whitespace eliminated
82  }
83  // Return value optimization should avoid another copy;
84  return trimmedPathSpecs;
85  }
std::vector< std::string > Strings
Definition: EventSelector.h:37

◆ maskTriggerResults()

std::shared_ptr< TriggerResults > EventSelector::maskTriggerResults ( TriggerResults const &  inputResults)

Applies a trigger selection mask to a specified trigger result object. Within the trigger result object, each path status is left unchanged if it satisfies the trigger selection (path specs) or cleared if it does not satisfy the trigger selection. In this way, the resulting trigger result object contains only path status values that "pass" the selection criteria.

Parameters
inputResultsThe raw trigger results object that will be masked.
Returns
a copy of the input trigger results object with only the path status results that match the trigger selection.
Exceptions
edm::Exceptionif the number of paths in the TriggerResults object does not match the specified full trigger list, or if the trigger selection is invalid in the context of the full trigger list.

Definition at line 665 of file EventSelector.cc.

References absolute_acceptors_, all_must_fail_, all_must_fail_noex_, conditional_acceptors_, edm::errors::EventCorruption, edm::hlt::Exception, Exception, exception_acceptors_, expandDecisionList(), f, edm::hlt::Fail, visualization-live-secondInstance_cfg::m, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, N, nPathNames_, edm::TriggerResults::parameterSetID(), edm::hlt::Pass, alignCSCRings::s, edm::HLTGlobalStatus::size(), and edm::HLTGlobalStatus::state().

665  {
666  // fetch and validate the total number of paths
667  unsigned int fullPathCount = nPathNames_;
668  unsigned int N = fullPathCount;
669  if (fullPathCount != inputResults.size()) {
671  << "EventSelector::maskTriggerResults, the TriggerResults\n"
672  << "size (" << inputResults.size() << ") does not match the number of paths in the\n"
673  << "full trigger list (" << fullPathCount << ").\n";
674  }
675 
676  // create a suitable global status object to work with, all in Ready state
677  HLTGlobalStatus mask(fullPathCount);
678 
679  // Deal with must_fail acceptors that would cause selection
680  for (unsigned int m = 0; m < this->all_must_fail_.size(); ++m) {
681  std::vector<bool> f = expandDecisionList(this->all_must_fail_[m], false, N);
682  bool all_fail = true;
683  for (unsigned int ipath = 0; ipath < N; ++ipath) {
684  if ((f[ipath]) && (inputResults[ipath].state() != hlt::Fail)) {
685  all_fail = false;
686  break;
687  }
688  }
689  if (all_fail) {
690  for (unsigned int ipath = 0; ipath < N; ++ipath) {
691  if (f[ipath]) {
692  mask[ipath] = hlt::Fail;
693  }
694  }
695  }
696  }
697  for (unsigned int m = 0; m < this->all_must_fail_noex_.size(); ++m) {
698  std::vector<bool> f = expandDecisionList(this->all_must_fail_noex_[m], false, N);
699  bool all_fail = true;
700  for (unsigned int ipath = 0; ipath < N; ++ipath) {
701  if ((f[ipath]) && (inputResults[ipath].state() != hlt::Fail)) {
702  all_fail = false;
703  break;
704  }
705  }
706  if (all_fail) {
707  for (unsigned int ipath = 0; ipath < N; ++ipath) {
708  if (f[ipath]) {
709  mask[ipath] = hlt::Fail;
710  }
711  }
712  }
713  } // factoring opportunity - work done for fail_noex_ is same as for fail_
714 
715  // Deal with normal acceptors that would cause selection
716  std::vector<bool> aPassAbs = expandDecisionList(this->absolute_acceptors_, true, N);
717  std::vector<bool> aPassCon = expandDecisionList(this->conditional_acceptors_, true, N);
718  std::vector<bool> aFailAbs = expandDecisionList(this->absolute_acceptors_, false, N);
719  std::vector<bool> aFailCon = expandDecisionList(this->conditional_acceptors_, false, N);
720  std::vector<bool> aExc = expandDecisionList(this->exception_acceptors_, true, N);
721  for (unsigned int ipath = 0; ipath < N; ++ipath) {
722  hlt::HLTState s = inputResults[ipath].state();
723  if (((aPassAbs[ipath]) && (s == hlt::Pass)) || ((aPassCon[ipath]) && (s == hlt::Pass)) ||
724  ((aFailAbs[ipath]) && (s == hlt::Fail)) || ((aFailCon[ipath]) && (s == hlt::Fail)) ||
725  ((aExc[ipath]) && (s == hlt::Exception))) {
726  mask[ipath] = s;
727  }
728  }
729 
730  // Based on the global status for the mask, create and return a
731  // TriggerResults
732  auto maskedResults = std::make_shared<TriggerResults>(mask, inputResults.parameterSetID());
733  return maskedResults;
734  } // maskTriggerResults
std::vector< Bits > all_must_fail_noex_
Definition: EventSelector.h:78
HLTState
status of a trigger path
Definition: HLTenums.h:16
reject
Definition: HLTenums.h:19
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:77
accept
Definition: HLTenums.h:18
double f[11][100]
#define N
Definition: blowfish.cc:9
static std::vector< bool > expandDecisionList(Bits const &b, bool PassOrFail, unsigned int n)

◆ matching_triggers()

static std::vector<Strings::const_iterator> edm::EventSelector::matching_triggers ( Strings const &  trigs,
std::string const &  s 
)
staticprivate

◆ overlapping()

bool EventSelector::overlapping ( std::vector< bool > const &  a,
std::vector< bool > const &  b 
)
staticprivate

Definition at line 918 of file EventSelector.cc.

References a, b, and mps_fire::i.

Referenced by testSelectionOverlap().

918  {
919  if (a.size() != b.size())
920  return false;
921  for (unsigned int i = 0; i != a.size(); ++i) {
922  if (a[i] && b[i])
923  return true;
924  }
925  return false;
926  } // overlapping
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ selectionDecision()

bool EventSelector::selectionDecision ( HLTGlobalStatus const &  tr) const
private

Definition at line 309 of file EventSelector.cc.

References absolute_acceptors_, accept_all_, acceptAllBits(), acceptOneBit(), all_must_fail_, all_must_fail_noex_, triggerObjects_cff::bit, conditional_acceptors_, containsExceptions(), edm::hlt::Exception, and exception_acceptors_.

Referenced by acceptEvent().

309  {
310  if (accept_all_)
311  return true;
312 
313  bool exceptionPresent = false;
314  bool exceptionsLookedFor = false;
315 
317  return true;
319  exceptionPresent = containsExceptions(tr);
320  if (!exceptionPresent)
321  return true;
322  exceptionsLookedFor = true;
323  }
325  return true;
326 
327  for (auto const& bit : all_must_fail_) {
328  if (acceptAllBits(bit, tr))
329  return true;
330  }
331  for (auto const& bitn : all_must_fail_noex_) {
332  if (acceptAllBits(bitn, tr)) {
333  if (!exceptionsLookedFor)
334  exceptionPresent = containsExceptions(tr);
335  return (!exceptionPresent);
336  }
337  }
338 
339  // If we have not accepted based on any of the acceptors, nor on any one of
340  // the all_must_fail_ collections, then we reject this event.
341 
342  return false;
343 
344  } // selectionDecision()
std::vector< Bits > all_must_fail_noex_
Definition: EventSelector.h:78
bool acceptOneBit(Bits const &b, HLTGlobalStatus const &tr, hlt::HLTState const &s=hlt::Ready) const
bool const accept_all_
Definition: EventSelector.h:70
bool containsExceptions(HLTGlobalStatus const &tr) const
bool acceptAllBits(Bits const &b, HLTGlobalStatus const &tr) const
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:77

◆ selectionIsValid()

bool EventSelector::selectionIsValid ( Strings const &  pathspecs,
Strings const &  fullPathList 
)
static

Tests if the specified trigger selection list (pathspecs) is valid in the context of the specified full trigger list. Each element in the selection list is tested to see if it possible for some combination of trigger results to satisfy the selection. If all selection elements can be satisfied one way or another, then this method returns true. If one or more selection elements could never be satisfied given the input full trigger list, then this method returns false. At some level, this method tests whether the selection list is a "subset" of the full path list.

Parameters
pathspecsThe trigger selection list (vector of string).
fullPathListThe full list of path names (vector of string).
Returns
true if the selection list is valid, false otherwise.

Definition at line 392 of file EventSelector.cc.

References acceptEvent(), edm::hlt::Exception, edm::hlt::Fail, heavyIonCSV_trainingSettings::idx, edm::hlt::Pass, edm::HLTGlobalStatus::reset(), and wantAll().

Referenced by testSelectionOverlap().

392  {
393  // an empty selection list is not valid
394  // (we default an empty "SelectEvents" parameter to {"*","!*"} in
395  // the getEventSelectionVString method below to help avoid this)
396  if (pathspecs.empty()) {
397  return false;
398  }
399 
400  // loop over each element in the selection list
401  for (unsigned int idx = 0; idx < pathspecs.size(); idx++) {
402  Strings workingList;
403  workingList.push_back(pathspecs[idx]);
404 
405  // catch exceptions from the EventSelector constructor
406  // (and anywhere else) and mark those as failures.
407  // The EventSelector constructor seems to do the work of
408  // checking if the selection is outside the full trigger list.
409  try {
410  // create an EventSelector instance for this selection
411  EventSelector evtSelector(workingList, fullPathList);
412 
413  // create the TriggerResults instance that we'll use for testing
414  unsigned int fullPathCount = fullPathList.size();
415  HLTGlobalStatus hltGS(fullPathCount);
416  TriggerResults sampleResults(hltGS, fullPathList);
417 
418  // loop over each path
419  bool oneResultMatched = false;
420  for (unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
421  // loop over the possible values for the path status
422  for (int iState = static_cast<int>(hlt::Pass); iState <= static_cast<int>(hlt::Exception); iState++) {
423  sampleResults[iPath] = HLTPathStatus(static_cast<hlt::HLTState>(iState), 0);
424  if (evtSelector.wantAll() || evtSelector.acceptEvent(sampleResults)) {
425  oneResultMatched = true;
426  break;
427  }
428 
429  sampleResults.reset(iPath);
430  }
431 
432  if (oneResultMatched)
433  break;
434  }
435 
436  // Finally, check in case the selection element was a wildcarded
437  // negative such as "!*":
438 
439  if (!oneResultMatched) {
440  for (unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
441  sampleResults[iPath] = HLTPathStatus(hlt::Fail, 0);
442  }
443  if (evtSelector.acceptEvent(sampleResults)) {
444  oneResultMatched = true;
445  }
446  }
447 
448  // if none of the possible trigger results matched the
449  // selection element, then we declare the whole selection
450  // list invalid
451  if (!oneResultMatched) {
452  return false;
453  }
454  } catch (edm::Exception const&) {
455  return false;
456  }
457  }
458 
459  // if we made it to this point, then it must have been possible
460  // to satisfy every selection element one way or another
461  return true;
462  }
std::vector< std::string > Strings
Definition: EventSelector.h:37
reject
Definition: HLTenums.h:19
accept
Definition: HLTenums.h:18
A selector of events.
Definition: EventSelector.h:16

◆ subset()

bool EventSelector::subset ( std::vector< bool > const &  a,
std::vector< bool > const &  b 
)
staticprivate

Definition at line 930 of file EventSelector.cc.

References a, b, and mps_fire::i.

Referenced by testSelectionOverlap().

930  {
931  if (a.size() != b.size())
932  return false;
933  // First test whether a is a non-empty subset of b
934  bool aPresent = false;
935  bool aSubset = true;
936  for (unsigned int i = 0; i != a.size(); ++i) {
937  if (a[i]) {
938  aPresent = true;
939  if (!b[i]) {
940  aSubset = false;
941  break;
942  }
943  }
944  }
945  if (!aPresent)
946  return false;
947  if (aSubset)
948  return true;
949 
950  // Now test whether b is a non-empty subset of a
951  bool bPresent = false;
952  bool bSubset = true;
953  for (unsigned int i = 0; i != b.size(); ++i) {
954  if (b[i]) {
955  bPresent = true;
956  if (!a[i]) {
957  bSubset = false;
958  break;
959  }
960  }
961  }
962  if (!bPresent)
963  return false;
964  if (bSubset)
965  return true;
966 
967  return false;
968  } // subset
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ testSelectionOverlap()

evtSel::OverlapResult EventSelector::testSelectionOverlap ( Strings const &  pathspec1,
Strings const &  pathspec2,
Strings const &  fullPathList 
)
static

Tests if the specified trigger selection lists (path specs) overlap, where "overlap" means that a valid trigger result (given the full trigger list) could satisfy both selections.

Parameters
pathspec1The first trigger selection list (vector of string).
pathspec2The second trigger selection list (vector of string).
fullPathListThe full list of trigger names (vector of string).
Returns
OverlapResult which indicates the degree of overlap.

Definition at line 474 of file EventSelector.cc.

References a, b, combine(), edm::evtSel::ExactMatch, expandDecisionList(), f, g, identical(), edm::evtSel::InvalidSelection, visualization-live-secondInstance_cfg::m, N, edm::evtSel::NoOverlap, hltL1SingleMuFiltered5_cfi::overlap, overlapping(), edm::evtSel::PartialOverlap, selectionIsValid(), and subset().

476  {
477  bool overlap = false;
478 
479  // first, test that the selection lists are valid
480  if (!selectionIsValid(pathspec1, fullPathList) || !selectionIsValid(pathspec2, fullPathList)) {
482  }
483 
484  // catch exceptions from the EventSelector constructor
485  // (and anywhere else) and mark those as failures
486  try {
487  // create an EventSelector instance for each selection list
488  EventSelector a(pathspec1, fullPathList);
489  EventSelector b(pathspec2, fullPathList);
490 
491  unsigned int N = fullPathList.size();
492 
493  // create the expanded masks for the various decision lists in a and b
494  std::vector<bool> aPassAbs = expandDecisionList(a.absolute_acceptors_, true, N);
495  std::vector<bool> aPassCon = expandDecisionList(a.conditional_acceptors_, true, N);
496  std::vector<bool> aFailAbs = expandDecisionList(a.absolute_acceptors_, false, N);
497  std::vector<bool> aFailCon = expandDecisionList(a.conditional_acceptors_, false, N);
498  std::vector<bool> aExc = expandDecisionList(a.exception_acceptors_, true, N);
499  std::vector<std::vector<bool>> aMustFail;
500  for (unsigned int m = 0; m != a.all_must_fail_.size(); ++m) {
501  aMustFail.push_back(expandDecisionList(a.all_must_fail_[m], false, N));
502  }
503  std::vector<std::vector<bool>> aMustFailNoex;
504  for (unsigned int m = 0; m != a.all_must_fail_noex_.size(); ++m) {
505  aMustFailNoex.push_back(expandDecisionList(a.all_must_fail_noex_[m], false, N));
506  }
507 
508  std::vector<bool> bPassAbs = expandDecisionList(b.absolute_acceptors_, true, N);
509  std::vector<bool> bPassCon = expandDecisionList(b.conditional_acceptors_, true, N);
510  std::vector<bool> bFailAbs = expandDecisionList(b.absolute_acceptors_, false, N);
511  std::vector<bool> bFailCon = expandDecisionList(b.conditional_acceptors_, false, N);
512  std::vector<bool> bExc = expandDecisionList(b.exception_acceptors_, true, N);
513  std::vector<std::vector<bool>> bMustFail;
514  for (unsigned int m = 0; m != b.all_must_fail_.size(); ++m) {
515  bMustFail.push_back(expandDecisionList(b.all_must_fail_[m], false, N));
516  }
517  std::vector<std::vector<bool>> bMustFailNoex;
518  for (unsigned int m = 0; m != b.all_must_fail_noex_.size(); ++m) {
519  bMustFailNoex.push_back(expandDecisionList(b.all_must_fail_noex_[m], false, N));
520  }
521 
522  std::vector<bool> aPass = combine(aPassAbs, aPassCon);
523  std::vector<bool> bPass = combine(bPassAbs, bPassCon);
524  std::vector<bool> aFail = combine(aFailAbs, aFailCon);
525  std::vector<bool> bFail = combine(bFailAbs, bFailCon);
526 
527  // Check for overlap in the primary masks
528  overlap = overlapping(aPass, bPass) || overlapping(aFail, bFail) || overlapping(aExc, bExc);
529  if (overlap)
531 
532  // Check for overlap of a primary fail mask with a must fail mask
533  for (unsigned int f = 0; f != aMustFail.size(); ++f) {
534  overlap = overlapping(aMustFail[f], bFail);
535  if (overlap)
536  return evtSel::PartialOverlap;
537  for (unsigned int g = 0; g != bMustFail.size(); ++g) {
538  overlap = subset(aMustFail[f], bMustFail[g]);
539  if (overlap)
540  return evtSel::PartialOverlap;
541  }
542  for (unsigned int g = 0; g != bMustFailNoex.size(); ++g) {
543  overlap = subset(aMustFail[f], bMustFailNoex[g]);
544  if (overlap)
545  return evtSel::PartialOverlap;
546  }
547  }
548  for (unsigned int f = 0; f != aMustFailNoex.size(); ++f) {
549  overlap = overlapping(aMustFailNoex[f], bFail);
550  if (overlap)
551  return evtSel::PartialOverlap;
552  for (unsigned int g = 0; g != bMustFail.size(); ++g) {
553  overlap = subset(aMustFailNoex[f], bMustFail[g]);
554  if (overlap)
555  return evtSel::PartialOverlap;
556  }
557  for (unsigned int g = 0; g != bMustFailNoex.size(); ++g) {
558  overlap = subset(aMustFailNoex[f], bMustFailNoex[g]);
559  if (overlap)
560  return evtSel::PartialOverlap;
561  }
562  }
563  for (unsigned int g = 0; g != bMustFail.size(); ++g) {
564  overlap = overlapping(bMustFail[g], aFail);
565  if (overlap)
566  return evtSel::PartialOverlap;
567  }
568  for (unsigned int g = 0; g != bMustFailNoex.size(); ++g) {
569  overlap = overlapping(bMustFail[g], aFail);
570  if (overlap)
571  return evtSel::PartialOverlap;
572  }
573 
574  } catch (edm::Exception const&) {
576  }
577 
578  // If we get to here without overlap becoming true, there is no overlap
579 
580  return evtSel::NoOverlap;
581 
582  } // testSelectionOverlap
static bool selectionIsValid(Strings const &pathspec, Strings const &fullPathList)
static std::vector< bool > combine(std::vector< bool > const &a, std::vector< bool > const &b)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
double f[11][100]
static bool overlapping(std::vector< bool > const &a, std::vector< bool > const &b)
static bool subset(std::vector< bool > const &a, std::vector< bool > const &b)
#define N
Definition: blowfish.cc:9
double b
Definition: hdecay.h:120
A selector of events.
Definition: EventSelector.h:16
static bool identical(std::vector< bool > const &a, std::vector< bool > const &b)
double a
Definition: hdecay.h:121
static std::vector< bool > expandDecisionList(Bits const &b, bool PassOrFail, unsigned int n)

◆ wantAll()

bool edm::EventSelector::wantAll ( ) const
inline

Definition at line 43 of file EventSelector.h.

References accept_all_.

Referenced by selectionIsValid().

43 { return accept_all_; }
bool const accept_all_
Definition: EventSelector.h:70

Member Data Documentation

◆ absolute_acceptors_

Bits edm::EventSelector::absolute_acceptors_
private

Definition at line 74 of file EventSelector.h.

Referenced by initPathNames(), maskTriggerResults(), and selectionDecision().

◆ accept_all_

bool const edm::EventSelector::accept_all_
private

Definition at line 70 of file EventSelector.h.

Referenced by acceptEvent(), initPathNames(), selectionDecision(), and wantAll().

◆ all_must_fail_

std::vector<Bits> edm::EventSelector::all_must_fail_
private

Definition at line 77 of file EventSelector.h.

Referenced by initPathNames(), maskTriggerResults(), and selectionDecision().

◆ all_must_fail_noex_

std::vector<Bits> edm::EventSelector::all_must_fail_noex_
private

Definition at line 78 of file EventSelector.h.

Referenced by initPathNames(), maskTriggerResults(), and selectionDecision().

◆ conditional_acceptors_

Bits edm::EventSelector::conditional_acceptors_
private

Definition at line 75 of file EventSelector.h.

Referenced by initPathNames(), maskTriggerResults(), and selectionDecision().

◆ exception_acceptors_

Bits edm::EventSelector::exception_acceptors_
private

Definition at line 76 of file EventSelector.h.

Referenced by initPathNames(), maskTriggerResults(), and selectionDecision().

◆ nPathNames_

int edm::EventSelector::nPathNames_
private

Definition at line 82 of file EventSelector.h.

Referenced by initPathNames(), and maskTriggerResults().

◆ pathspecs_

Strings const edm::EventSelector::pathspecs_
private

Definition at line 68 of file EventSelector.h.

Referenced by initAcceptAll(), and initPathNames().

◆ psetID_

ParameterSetID edm::EventSelector::psetID_
private

Definition at line 80 of file EventSelector.h.

Referenced by acceptEvent().

◆ results_from_current_process_

bool const edm::EventSelector::results_from_current_process_
private

Definition at line 69 of file EventSelector.h.

Referenced by acceptEvent().