6 #include "boost/algorithm/string.hpp" 7 #include "cetlib/container_algorithms.h" 21 init(pathspecs, names);
24 EventSelector::EventSelector(
Strings const& pathspecs)
25 : results_from_current_process_(false), paths_(pathspecs)
31 auto paths = config.
get<
Strings>(
"SelectEvents", {});
32 init(paths, triggernames);
52 bool unrestricted_star =
false;
53 bool negated_star =
false;
54 bool exception_star =
false;
56 for (std::string
const& pathSpecifier : paths) {
58 string specifier{pathSpecifier};
60 boost::erase_all(specifier,
" \t");
62 unrestricted_star =
true;
63 if (specifier ==
"!*")
65 if (specifier ==
"exception@*")
66 exception_star =
true;
69 bool noex_demanded{
false};
70 std::string
const& noexLiteral{
"&noexception"};
71 auto const noexception_pos = specifier.find(noexLiteral);
72 if (noexception_pos != string::npos) {
73 if (noexception_pos + noexLiteral.length() < specifier.length()) {
75 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 76 "to request a trigger name that has extra characters after " 78 <<
"The improper trigger name is: " << pathSpecifier <<
"\n";
80 specifier.erase(noexception_pos);
85 bool negative_criterion{
false};
86 if (specifier[0] ==
'!') {
87 negative_criterion =
true;
88 specifier.erase(0, 1);
90 bool exception_spec{
false};
91 std::string
const& exLiteral{
"exception@"};
92 auto const pos = specifier.find(exLiteral);
94 exception_spec =
true;
95 specifier.erase(0, exLiteral.length());
96 }
else if (pos != std::string::npos) {
98 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 99 "to request a trigger name that has disallowed characters before " 101 <<
"The improper trigger name is: " << pathSpecifier <<
"\n";
104 if (negative_criterion && exception_spec)
106 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 107 "to request a trigger name starting with !exception@.\n" 108 "This is not supported.\n" 109 <<
"The improper trigger name is: " << pathSpecifier <<
"\n";
111 if (noex_demanded && exception_spec)
113 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 114 "to request a trigger name starting with exception@ " 115 "and also demanding no &exceptions.\n" 116 <<
"The improper trigger name is: " << pathSpecifier <<
"\n";
123 std::string
const& realname{specifier};
124 vector<Strings::const_iterator> matches =
127 if (matches.empty()) {
130 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 131 "to request a wildcarded trigger name that does not match any " 133 <<
"The wildcarded trigger name is: " << realname
134 <<
" (from trigger-path specification: " << pathSpecifier <<
") \n";
137 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 138 "to request a trigger name that does not exist\n" 139 <<
"The unknown trigger name is: " << realname
140 <<
" (from trigger-path specification: " << pathSpecifier <<
") \n";
144 auto makeBitInfoPass = [&triggernames](
auto m) {
145 return BitInfo(distance(triggernames.begin(), m),
true);
148 auto makeBitInfoFail = [&triggernames](
auto m) {
149 return BitInfo(distance(triggernames.begin(), m),
false);
152 if (!negative_criterion && !noex_demanded && !exception_spec) {
155 }
else if (!negative_criterion && noex_demanded) {
158 }
else if (exception_spec) {
161 }
else if (negative_criterion && !noex_demanded) {
162 if (matches.empty()) {
164 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 165 "to request all fails on a set of trigger names that do not " 167 <<
"The problematic name is: " << pathSpecifier <<
"\n";
169 }
else if (matches.size() == 1) {
170 BitInfo bi(distance(triggernames.begin(), matches[0]),
false);
176 matches, std::back_inserter(mustfail), makeBitInfoFail);
179 }
else if (negative_criterion && noex_demanded) {
180 if (matches.empty()) {
182 <<
"EventSelector::init, An OutputModule is using SelectEvents\n" 183 "to request all fails on a set of trigger names that do not " 185 <<
"The problematic name is: " << pathSpecifier <<
"\n";
186 }
else if (matches.size() == 1) {
187 BitInfo bi(distance(triggernames.begin(), matches[0]),
false);
192 matches, std::back_inserter(mustfail), makeBitInfoFail);
198 if (unrestricted_star && negated_star && exception_star)
233 <<
"EventSelector::acceptEvent cannot find the trigger names for\n" 234 "a process for which the configuration has requested that the\n" 235 "OutputModule use TriggerResults to select events from. This " 237 "be impossible, please send information to reproduce this " 239 "the art developers at artists@fnal.gov.\n";
257 bool exceptionPresent =
false;
258 bool exceptionsLookedFor =
false;
264 if (!exceptionPresent)
266 exceptionsLookedFor =
true;
278 if (!exceptionsLookedFor) {
281 return !exceptionPresent;
301 for (
auto const& b : bits) {
305 if (tr[b.pos_].
state() == bstate)
317 for (
auto const& b : bits) {
319 if (tr[b.pos_].
state() != bstate)
341 std::shared_ptr<TriggerResults>
346 if (N != inputResults.
size()) {
348 <<
"EventSelector::maskTriggerResults, the TriggerResults\n" 349 <<
"size (" << inputResults.
size()
350 <<
") does not match the number of paths in the\n" 351 <<
"full trigger list (" << N <<
").\n";
360 bool all_fail =
true;
361 for (
unsigned int ipath = 0; ipath < N; ++ipath) {
362 if ((f[ipath]) && (inputResults[ipath].state() !=
hlt::Fail)) {
368 for (
unsigned int ipath = 0; ipath < N; ++ipath) {
377 bool all_fail =
true;
378 for (
unsigned int ipath = 0; ipath < N; ++ipath) {
379 if ((f[ipath]) && (inputResults[ipath].state() !=
hlt::Fail)) {
385 for (
unsigned int ipath = 0; ipath < N; ++ipath) {
397 vector<bool> aFailCon =
401 for (
unsigned int ipath = 0; ipath < N; ++ipath) {
403 if (((aPassAbs[ipath]) && (s ==
hlt::Pass)) ||
404 ((aPassCon[ipath]) && (s ==
hlt::Pass)) ||
405 ((aFailAbs[ipath]) && (s ==
hlt::Fail)) ||
406 ((aFailCon[ipath]) && (s ==
hlt::Fail)) ||
414 return std::make_shared<TriggerResults>(mask,
421 unsigned int e = tr.
size();
422 for (
unsigned int i = 0; i <
e; ++i) {
434 unsigned int n = a.size();
437 for (
unsigned int i = 0; i !=
n; ++i) {
468 vector<vector<bool>> aMustFail;
472 vector<vector<bool>> aMustFailNoex;
474 aMustFailNoex.push_back(
477 vector<vector<bool>> bMustFail;
481 vector<vector<bool>> bMustFailNoex;
483 bMustFailNoex.push_back(
487 for (
unsigned int m = 0; m != aMustFail.size(); ++m) {
489 for (
unsigned int k = 0; k != bMustFail.size(); ++k) {
490 if (
identical(aMustFail[m], bMustFail[k])) {
498 for (
unsigned int m = 0; m != aMustFailNoex.size(); ++m) {
500 for (
unsigned int k = 0; k != bMustFailNoex.size(); ++k) {
501 if (
identical(aMustFailNoex[m], bMustFailNoex[k])) {
519 vector<bool>
x(n,
false);
520 for (
unsigned int i = 0; i != b.size(); ++i) {
521 if (b[i].accept_state_ == PassOrFail)
531 if (a.size() != b.size())
533 for (
unsigned int i = 0; i != a.size(); ++i) {
545 if (a.size() != b.size())
548 bool aPresent =
false;
550 for (
unsigned int i = 0; i != a.size(); ++i) {
565 bool bPresent =
false;
567 for (
unsigned int i = 0; i != b.size(); ++i) {
588 assert(a.size() == b.size());
589 vector<bool>
x(a.size());
590 for (
unsigned int i = 0; i != a.size(); ++i) {
EventSelector(Strings const &pathspecs, Strings const &names)
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const ®exp)
bool results_from_current_process_
Bits conditional_acceptors_
std::vector< BitInfo > Bits
HLTState
status of a trigger path
hlt::HLTState state(std::size_t const i) const
bool acceptOneBit(Bits const &b, HLTGlobalStatus const &tr, hlt::HLTState const &s=hlt::Ready) const
Bits exception_acceptors_
std::vector< std::string > Strings
bool containsExceptions(HLTGlobalStatus const &tr) const
T get(std::string const &key) const
void init(Strings const &paths, Strings const &triggernames)
static bool overlapping(std::vector< bool > const &a, std::vector< bool > const &b)
fhicl::ParameterSetID const & parameterSetID() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
static bool identical(std::vector< bool > const &a, std::vector< bool > const &b)
static std::vector< bool > expandDecisionList(Bits const &b, bool PassOrFail, unsigned int n)
std::vector< Bits > all_must_fail_noex_
bool selectionDecision(HLTGlobalStatus const &tr) const
static std::vector< bool > combine(std::vector< bool > const &a, std::vector< bool > const &b)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::shared_ptr< TriggerResults > maskTriggerResults(TriggerResults const &inputResults)
std::vector< Bits > all_must_fail_
bool acceptAllBits(Bits const &b, HLTGlobalStatus const &tr) const
static bool subset(std::vector< bool > const &a, std::vector< bool > const &b)
bool is_glob(std::string const &pattern)
fhicl::ParameterSetID psetID_
bool acceptEvent(TriggerResults const &)