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)
 
 EventSelector (edm::ParameterSet const &pset, Strings const &pathNames)
 
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

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

Definition at line 74 of file EventSelector.h.

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

Definition at line 37 of file EventSelector.h.

Constructor & Destructor Documentation

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:80
void initPathNames(Strings const &pathNames)
bool const accept_all_
Definition: EventSelector.h:72
Strings initPathSpecs(Strings const &pathSpecs)
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:79
Strings const pathspecs_
Definition: EventSelector.h:70
ParameterSetID psetID_
Definition: EventSelector.h:82
bool const results_from_current_process_
Definition: EventSelector.h:71
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:80
bool const accept_all_
Definition: EventSelector.h:72
Strings initPathSpecs(Strings const &pathSpecs)
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:79
Strings const pathspecs_
Definition: EventSelector.h:70
ParameterSetID psetID_
Definition: EventSelector.h:82
bool const results_from_current_process_
Definition: EventSelector.h:71
EventSelector::EventSelector ( edm::ParameterSet const &  pset,
Strings const &  pathNames 
)

Definition at line 75 of file EventSelector.cc.

References initPathNames().

76  : pathspecs_(config.empty() ? Strings() : initPathSpecs(config.getParameter<Strings>("SelectEvents"))),
84  psetID_(),
85  nPathNames_(0) {
86  initPathNames(pathNames);
87  }
std::vector< Bits > all_must_fail_noex_
Definition: EventSelector.h:80
void initPathNames(Strings const &pathNames)
std::vector< std::string > Strings
Definition: EventSelector.h:37
bool const accept_all_
Definition: EventSelector.h:72
std::vector< std::string > Strings
Definition: MsgTools.h:18
Definition: config.py:1
Strings initPathSpecs(Strings const &pathSpecs)
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:79
Strings const pathspecs_
Definition: EventSelector.h:70
ParameterSetID psetID_
Definition: EventSelector.h:82
bool const results_from_current_process_
Definition: EventSelector.h:71

Member Function Documentation

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

Definition at line 379 of file EventSelector.cc.

References edm::hlt::Fail, edm::hlt::Pass, and edm::HLTGlobalStatus::state().

Referenced by selectionDecision().

379  {
380  for (auto const& bit : b) {
381  hlt::HLTState bstate = bit.accept_state_ ? hlt::Pass : hlt::Fail;
382  if (tr[bit.pos_].state() != bstate)
383  return false;
384  }
385  return true;
386  } // acceptAllBits
HLTState
status of a trigger path
Definition: HLTenums.h:18
reject
Definition: HLTenums.h:20
accept
Definition: HLTenums.h:19
double b
Definition: hdecay.h:120
bool EventSelector::acceptEvent ( TriggerResults const &  tr)

Definition at line 245 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 maskTriggerResults(), edm::detail::NamedEventSelector::match(), selectionIsValid(), and testSelectionOverlap().

245  {
246  if (accept_all_)
247  return true;
248 
250  // The path names for prior processes may be different in different runs.
251  // Check for this, and modify the selector accordingly if necessary.
252  if (!psetID_.isValid() || psetID_ != tr.parameterSetID()) {
253  Strings pathNames;
254  bool fromPSetRegistry = false;
256  if (tns->getTrigPaths(tr, pathNames, fromPSetRegistry)) {
257  initPathNames(pathNames);
258  if (fromPSetRegistry) {
259  psetID_ = tr.parameterSetID();
260  } else {
261  // This can only happen for very old data, when the path names were stored
262  // in TriggerResults itself, rather than in the parameter set registry.
263  psetID_.reset();
264  }
265  } else {
266  // This should never happen
268  << "EventSelector::acceptEvent cannot find the trigger names for\n"
269  "a process for which the configuration has requested that the\n"
270  "OutputModule use TriggerResults to select events from. This should\n"
271  "be impossible, please send information to reproduce this problem to\n"
272  "the edm developers.\n";
273  }
274  }
275  }
276 
277  // Now make the decision, based on the supplied TriggerResults tr,
278  // which of course can be treated as an HLTGlobalStatus by inheritance
279 
280  return selectionDecision(tr);
281 
282  } // acceptEvent(TriggerResults const& tr)
void initPathNames(Strings const &pathNames)
bool const accept_all_
Definition: EventSelector.h:72
std::vector< std::string > Strings
Definition: MsgTools.h:18
bool selectionDecision(HLTGlobalStatus const &tr) const
ParameterSetID psetID_
Definition: EventSelector.h:82
bool isValid() const
Definition: Hash.h:154
bool const results_from_current_process_
Definition: EventSelector.h:71
void reset()
Definition: Hash.h:147
bool EventSelector::acceptEvent ( unsigned char const *  array_of_trigger_results,
int  number_of_trigger_paths 
) const

Definition at line 284 of file EventSelector.cc.

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

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

Definition at line 367 of file EventSelector.cc.

References edm::hlt::Exception, edm::hlt::Fail, edm::hlt::Pass, and edm::HLTGlobalStatus::state().

Referenced by selectionDecision().

367  {
368  bool lookForException = (s == hlt::Exception);
369  for (auto const& bit : b) {
370  hlt::HLTState bstate = lookForException ? hlt::Exception : bit.accept_state_ ? hlt::Pass : hlt::Fail;
371  if (tr[bit.pos_].state() == bstate)
372  return true;
373  }
374  return false;
375  } // acceptOneBit
HLTState
status of a trigger path
Definition: HLTenums.h:18
reject
Definition: HLTenums.h:20
accept
Definition: HLTenums.h:19
double b
Definition: hdecay.h:120
bool EventSelector::acceptTriggerPath ( HLTPathStatus const &  pathStatus,
BitInfo const &  pathInfo 
) const
private

Definition at line 358 of file EventSelector.cc.

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

358  {
359  return (((pathStatus.state() == hlt::Pass) && (pathInfo.accept_state_)) ||
360  ((pathStatus.state() == hlt::Fail) && !(pathInfo.accept_state_)) ||
361  ((pathStatus.state() == hlt::Exception)));
362  }
reject
Definition: HLTenums.h:20
accept
Definition: HLTenums.h:19
std::vector< bool > EventSelector::combine ( std::vector< bool > const &  a,
std::vector< bool > const &  b 
)
staticprivate

Definition at line 982 of file EventSelector.cc.

References mps_fire::i.

Referenced by testSelectionOverlap().

982  {
983  assert(a.size() == b.size());
984  std::vector<bool> x(a.size());
985  for (unsigned int i = 0; i != a.size(); ++i) {
986  x[i] = a[i] || b[i];
987  } // a really sharp compiler will optimize the hell out of this,
988  // exploiting word-size OR operations.
989  return x;
990  } // combine
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
bool EventSelector::containsExceptions ( HLTGlobalStatus const &  tr) const
private

Definition at line 833 of file EventSelector.cc.

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

Referenced by selectionDecision().

833  {
834  unsigned int e = tr.size();
835  for (unsigned int i = 0; i < e; ++i) {
836  if (tr[i].state() == hlt::Exception)
837  return true;
838  }
839  return false;
840  }
std::vector< bool > EventSelector::expandDecisionList ( Bits const &  b,
bool  PassOrFail,
unsigned int  n 
)
staticprivate

Definition at line 919 of file EventSelector.cc.

References mps_fire::i.

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

919  {
920  std::vector<bool> x(n, false);
921  for (unsigned int i = 0; i != b.size(); ++i) {
922  if (b[i].accept_state_ == PassOrFail)
923  x[b[i].pos_] = true;
924  }
925  return x;
926  } // expandDecisionList
double b
Definition: hdecay.h:120
void EventSelector::fillDescription ( ParameterSetDescription desc)
static
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 812 of file EventSelector.cc.

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

Referenced by dqmservices::TriggerSelector::getEventSelectionVString(), and edm::StreamerOutputModuleCommon::StreamerOutputModuleCommon().

812  {
813  // default the selection to everything (wildcard)
815  selection.push_back("*");
816  selection.push_back("!*");
817  selection.push_back("exception@*");
818 
819  // the SelectEvents parameter is a ParameterSet within
820  // a ParameterSet, so we have to pull it out twice
821  ParameterSet selectEventsParamSet = pset.getUntrackedParameter("SelectEvents", ParameterSet());
822  if (!selectEventsParamSet.empty()) {
823  Strings path_specs = selectEventsParamSet.getParameter<Strings>("SelectEvents");
824  if (!path_specs.empty()) {
825  selection = path_specs;
826  }
827  }
828 
829  // return the result
830  return selection;
831  }
std::vector< std::string > Strings
Definition: MsgTools.h:18
selection
main part
Definition: corrVsCorr.py:100
static std::string edm::EventSelector::glob2reg ( std::string const &  s)
staticprivate
bool EventSelector::identical ( std::vector< bool > const &  a,
std::vector< bool > const &  b 
)
staticprivate

Definition at line 844 of file EventSelector.cc.

References mps_fire::i, and gen::n.

Referenced by identical(), and testSelectionOverlap().

844  {
845  unsigned int n = a.size();
846  if (n != b.size())
847  return false;
848  for (unsigned int i = 0; i != n; ++i) {
849  if (a[i] != b[i])
850  return false;
851  }
852  return true;
853  }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
bool EventSelector::identical ( EventSelector const &  a,
EventSelector const &  b,
unsigned int  N 
)
staticprivate

Definition at line 855 of file EventSelector.cc.

References absolute_acceptors_, all_must_fail_, all_must_fail_noex_, conditional_acceptors_, exception_acceptors_, expandDecisionList(), identical(), gen::k, funct::m, and edm::match().

855  {
856  // create the expanded masks for the various decision lists in a and b
857  if (!identical(expandDecisionList(a.absolute_acceptors_, true, N),
858  expandDecisionList(b.absolute_acceptors_, true, N)))
859  return false;
860  if (!identical(expandDecisionList(a.conditional_acceptors_, true, N),
861  expandDecisionList(b.conditional_acceptors_, true, N)))
862  return false;
863  if (!identical(expandDecisionList(a.absolute_acceptors_, false, N),
864  expandDecisionList(b.absolute_acceptors_, false, N)))
865  return false;
866  if (!identical(expandDecisionList(a.conditional_acceptors_, false, N),
867  expandDecisionList(b.conditional_acceptors_, false, N)))
868  return false;
869  if (!identical(expandDecisionList(a.exception_acceptors_, true, N),
870  expandDecisionList(b.exception_acceptors_, true, N)))
871  return false;
872  if (a.all_must_fail_.size() != b.all_must_fail_.size())
873  return false;
874 
875  std::vector<std::vector<bool> > aMustFail;
876  for (unsigned int m = 0; m != a.all_must_fail_.size(); ++m) {
877  aMustFail.push_back(expandDecisionList(a.all_must_fail_[m], false, N));
878  }
879  std::vector<std::vector<bool> > aMustFailNoex;
880  for (unsigned int m = 0; m != a.all_must_fail_noex_.size(); ++m) {
881  aMustFailNoex.push_back(expandDecisionList(a.all_must_fail_noex_[m], false, N));
882  }
883  std::vector<std::vector<bool> > bMustFail;
884  for (unsigned int m = 0; m != b.all_must_fail_.size(); ++m) {
885  bMustFail.push_back(expandDecisionList(b.all_must_fail_[m], false, N));
886  }
887  std::vector<std::vector<bool> > bMustFailNoex;
888  for (unsigned int m = 0; m != b.all_must_fail_noex_.size(); ++m) {
889  bMustFailNoex.push_back(expandDecisionList(b.all_must_fail_noex_[m], false, N));
890  }
891 
892  for (unsigned int m = 0; m != aMustFail.size(); ++m) {
893  bool match = false;
894  for (unsigned int k = 0; k != bMustFail.size(); ++k) {
895  if (identical(aMustFail[m], bMustFail[k])) {
896  match = true;
897  break;
898  }
899  }
900  if (!match)
901  return false;
902  }
903  for (unsigned int m = 0; m != aMustFailNoex.size(); ++m) {
904  bool match = false;
905  for (unsigned int k = 0; k != bMustFailNoex.size(); ++k) {
906  if (identical(aMustFailNoex[m], bMustFailNoex[k])) {
907  match = true;
908  break;
909  }
910  }
911  if (!match)
912  return false;
913  }
914 
915  return true;
916 
917  } // identical (EventSelector, EventSelector, N);
int k[5][pyjets_maxn]
#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)
bool EventSelector::initAcceptAll ( )
private

Definition at line 98 of file EventSelector.cc.

References pathspecs_.

98  {
99  if (pathspecs_.empty()) {
100  return true;
101  }
102  // The following are for the purpose of establishing accept_all_ by
103  // virtue of an inclusive set of paths:
104  bool unrestricted_star = false;
105  bool negated_star = false;
106  bool exception_star = false;
107 
108  for (auto const& pathspecifier : pathspecs_) {
109  if (pathspecifier == "*")
110  unrestricted_star = true;
111  if (pathspecifier == "!*")
112  negated_star = true;
113  if (pathspecifier == "exception@*")
114  exception_star = true;
115  }
116  return (unrestricted_star && negated_star && exception_star);
117  }
Strings const pathspecs_
Definition: EventSelector.h:70
void EventSelector::initPathNames ( Strings const &  pathNames)
private

Definition at line 119 of file EventSelector.cc.

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

Referenced by acceptEvent(), and EventSelector().

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

Definition at line 89 of file EventSelector.cc.

89  {
90  Strings trimmedPathSpecs(pathSpecs);
91  for (auto& pathspecifier : trimmedPathSpecs) {
92  boost::erase_all(pathspecifier, " \t"); // whitespace eliminated
93  }
94  // Return value optimization should avoid another copy;
95  return trimmedPathSpecs;
96  }
std::vector< std::string > Strings
Definition: MsgTools.h:18
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 676 of file EventSelector.cc.

References absolute_acceptors_, acceptEvent(), all_must_fail_, all_must_fail_noex_, conditional_acceptors_, edm::errors::EventCorruption, edm::hlt::Exception, Exception, exception_acceptors_, expandDecisionList(), f, edm::hlt::Fail, funct::m, RecoTauDiscriminantConfiguration::mask, N, nPathNames_, edm::TriggerResults::parameterSetID(), edm::hlt::Pass, edm::HLTGlobalStatus::reset(), alignCSCRings::s, edm::HLTGlobalStatus::size(), edm::HLTGlobalStatus::state(), and wantAll().

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

Definition at line 929 of file EventSelector.cc.

References mps_fire::i.

Referenced by testSelectionOverlap().

929  {
930  if (a.size() != b.size())
931  return false;
932  for (unsigned int i = 0; i != a.size(); ++i) {
933  if (a[i] && b[i])
934  return true;
935  }
936  return false;
937  } // overlapping
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
bool EventSelector::selectionDecision ( HLTGlobalStatus const &  tr) const
private

Definition at line 320 of file EventSelector.cc.

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

Referenced by acceptEvent().

320  {
321  if (accept_all_)
322  return true;
323 
324  bool exceptionPresent = false;
325  bool exceptionsLookedFor = false;
326 
328  return true;
330  exceptionPresent = containsExceptions(tr);
331  if (!exceptionPresent)
332  return true;
333  exceptionsLookedFor = true;
334  }
336  return true;
337 
338  for (auto const& bit : all_must_fail_) {
339  if (acceptAllBits(bit, tr))
340  return true;
341  }
342  for (auto const& bitn : all_must_fail_noex_) {
343  if (acceptAllBits(bitn, tr)) {
344  if (!exceptionsLookedFor)
345  exceptionPresent = containsExceptions(tr);
346  return (!exceptionPresent);
347  }
348  }
349 
350  // If we have not accepted based on any of the acceptors, nor on any one of
351  // the all_must_fail_ collections, then we reject this event.
352 
353  return false;
354 
355  } // selectionDecision()
std::vector< Bits > all_must_fail_noex_
Definition: EventSelector.h:80
bool const accept_all_
Definition: EventSelector.h:72
bool acceptAllBits(Bits const &b, HLTGlobalStatus const &tr) const
std::vector< Bits > all_must_fail_
Definition: EventSelector.h:79
bool acceptOneBit(Bits const &b, HLTGlobalStatus const &tr, hlt::HLTState const &s=hlt::Ready) const
bool containsExceptions(HLTGlobalStatus const &tr) const
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 403 of file EventSelector.cc.

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

Referenced by testSelectionOverlap().

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

Definition at line 941 of file EventSelector.cc.

References mps_fire::i.

Referenced by testSelectionOverlap().

941  {
942  if (a.size() != b.size())
943  return false;
944  // First test whether a is a non-empty subset of b
945  bool aPresent = false;
946  bool aSubset = true;
947  for (unsigned int i = 0; i != a.size(); ++i) {
948  if (a[i]) {
949  aPresent = true;
950  if (!b[i]) {
951  aSubset = false;
952  break;
953  }
954  }
955  }
956  if (!aPresent)
957  return false;
958  if (aSubset)
959  return true;
960 
961  // Now test whether b is a non-empty subset of a
962  bool bPresent = false;
963  bool bSubset = true;
964  for (unsigned int i = 0; i != b.size(); ++i) {
965  if (b[i]) {
966  bPresent = true;
967  if (!a[i]) {
968  bSubset = false;
969  break;
970  }
971  }
972  }
973  if (!bPresent)
974  return false;
975  if (bSubset)
976  return true;
977 
978  return false;
979  } // subset
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
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 485 of file EventSelector.cc.

References a, absolute_acceptors_, acceptEvent(), all_must_fail_, all_must_fail_noex_, b, combine(), conditional_acceptors_, edm::evtSel::ExactMatch, edm::hlt::Exception, exception_acceptors_, expandDecisionList(), f, g, identical(), edm::evtSel::InvalidSelection, funct::m, N, edm::evtSel::NoOverlap, muon::overlap(), overlapping(), edm::evtSel::PartialOverlap, edm::hlt::Pass, edm::HLTGlobalStatus::reset(), selectionIsValid(), subset(), and wantAll().

487  {
488  bool overlap = false;
489 
490  // first, test that the selection lists are valid
491  if (!selectionIsValid(pathspec1, fullPathList) || !selectionIsValid(pathspec2, fullPathList)) {
493  }
494 
495  // catch exceptions from the EventSelector constructor
496  // (and anywhere else) and mark those as failures
497  try {
498  // create an EventSelector instance for each selection list
499  EventSelector a(pathspec1, fullPathList);
500  EventSelector b(pathspec2, fullPathList);
501 
502  unsigned int N = fullPathList.size();
503 
504  // create the expanded masks for the various decision lists in a and b
505  std::vector<bool> aPassAbs = expandDecisionList(a.absolute_acceptors_, true, N);
506  std::vector<bool> aPassCon = expandDecisionList(a.conditional_acceptors_, true, N);
507  std::vector<bool> aFailAbs = expandDecisionList(a.absolute_acceptors_, false, N);
508  std::vector<bool> aFailCon = expandDecisionList(a.conditional_acceptors_, false, N);
509  std::vector<bool> aExc = expandDecisionList(a.exception_acceptors_, true, N);
510  std::vector<std::vector<bool> > aMustFail;
511  for (unsigned int m = 0; m != a.all_must_fail_.size(); ++m) {
512  aMustFail.push_back(expandDecisionList(a.all_must_fail_[m], false, N));
513  }
514  std::vector<std::vector<bool> > aMustFailNoex;
515  for (unsigned int m = 0; m != a.all_must_fail_noex_.size(); ++m) {
516  aMustFailNoex.push_back(expandDecisionList(a.all_must_fail_noex_[m], false, N));
517  }
518 
519  std::vector<bool> bPassAbs = expandDecisionList(b.absolute_acceptors_, true, N);
520  std::vector<bool> bPassCon = expandDecisionList(b.conditional_acceptors_, true, N);
521  std::vector<bool> bFailAbs = expandDecisionList(b.absolute_acceptors_, false, N);
522  std::vector<bool> bFailCon = expandDecisionList(b.conditional_acceptors_, false, N);
523  std::vector<bool> bExc = expandDecisionList(b.exception_acceptors_, true, N);
524  std::vector<std::vector<bool> > bMustFail;
525  for (unsigned int m = 0; m != b.all_must_fail_.size(); ++m) {
526  bMustFail.push_back(expandDecisionList(b.all_must_fail_[m], false, N));
527  }
528  std::vector<std::vector<bool> > bMustFailNoex;
529  for (unsigned int m = 0; m != b.all_must_fail_noex_.size(); ++m) {
530  bMustFailNoex.push_back(expandDecisionList(b.all_must_fail_noex_[m], false, N));
531  }
532 
533  std::vector<bool> aPass = combine(aPassAbs, aPassCon);
534  std::vector<bool> bPass = combine(bPassAbs, bPassCon);
535  std::vector<bool> aFail = combine(aFailAbs, aFailCon);
536  std::vector<bool> bFail = combine(bFailAbs, bFailCon);
537 
538  // Check for overlap in the primary masks
539  overlap = overlapping(aPass, bPass) || overlapping(aFail, bFail) || overlapping(aExc, bExc);
540  if (overlap)
542 
543  // Check for overlap of a primary fail mask with a must fail mask
544  for (unsigned int f = 0; f != aMustFail.size(); ++f) {
545  overlap = overlapping(aMustFail[f], bFail);
546  if (overlap)
547  return evtSel::PartialOverlap;
548  for (unsigned int g = 0; g != bMustFail.size(); ++g) {
549  overlap = subset(aMustFail[f], bMustFail[g]);
550  if (overlap)
551  return evtSel::PartialOverlap;
552  }
553  for (unsigned int g = 0; g != bMustFailNoex.size(); ++g) {
554  overlap = subset(aMustFail[f], bMustFailNoex[g]);
555  if (overlap)
556  return evtSel::PartialOverlap;
557  }
558  }
559  for (unsigned int f = 0; f != aMustFailNoex.size(); ++f) {
560  overlap = overlapping(aMustFailNoex[f], bFail);
561  if (overlap)
562  return evtSel::PartialOverlap;
563  for (unsigned int g = 0; g != bMustFail.size(); ++g) {
564  overlap = subset(aMustFailNoex[f], bMustFail[g]);
565  if (overlap)
566  return evtSel::PartialOverlap;
567  }
568  for (unsigned int g = 0; g != bMustFailNoex.size(); ++g) {
569  overlap = subset(aMustFailNoex[f], bMustFailNoex[g]);
570  if (overlap)
571  return evtSel::PartialOverlap;
572  }
573  }
574  for (unsigned int g = 0; g != bMustFail.size(); ++g) {
575  overlap = overlapping(bMustFail[g], aFail);
576  if (overlap)
577  return evtSel::PartialOverlap;
578  }
579  for (unsigned int g = 0; g != bMustFailNoex.size(); ++g) {
580  overlap = overlapping(bMustFail[g], aFail);
581  if (overlap)
582  return evtSel::PartialOverlap;
583  }
584 
585  } catch (edm::Exception const&) {
587  }
588 
589  // If we get to here without overlap becoming true, there is no overlap
590 
591  return evtSel::NoOverlap;
592 
593  } // 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
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
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)
bool edm::EventSelector::wantAll ( ) const
inline

Definition at line 45 of file EventSelector.h.

References muonDTDigis_cfi::pset.

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

45 { return accept_all_; }
bool const accept_all_
Definition: EventSelector.h:72

Member Data Documentation

Bits edm::EventSelector::absolute_acceptors_
private
bool const edm::EventSelector::accept_all_
private

Definition at line 72 of file EventSelector.h.

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

std::vector<Bits> edm::EventSelector::all_must_fail_
private
std::vector<Bits> edm::EventSelector::all_must_fail_noex_
private
Bits edm::EventSelector::conditional_acceptors_
private
Bits edm::EventSelector::exception_acceptors_
private
int edm::EventSelector::nPathNames_
private

Definition at line 84 of file EventSelector.h.

Referenced by initPathNames(), and maskTriggerResults().

Strings const edm::EventSelector::pathspecs_
private

Definition at line 70 of file EventSelector.h.

Referenced by initAcceptAll(), and initPathNames().

ParameterSetID edm::EventSelector::psetID_
private

Definition at line 82 of file EventSelector.h.

Referenced by acceptEvent().

bool const edm::EventSelector::results_from_current_process_
private

Definition at line 71 of file EventSelector.h.

Referenced by acceptEvent().