43 #include "boost/algorithm/string.hpp"
53 pathspecs_(initPathSpecs(pathspecs)),
54 results_from_current_process_(
true),
55 accept_all_(initAcceptAll()),
56 absolute_acceptors_(),
57 conditional_acceptors_(),
58 exception_acceptors_(),
60 all_must_fail_noex_(),
68 pathspecs_(initPathSpecs(pathspecs)),
69 results_from_current_process_(
false),
70 accept_all_(initAcceptAll()),
71 absolute_acceptors_(),
72 conditional_acceptors_(),
73 exception_acceptors_(),
75 all_must_fail_noex_(),
82 pathspecs_(config.
empty() ?
Strings() : initPathSpecs(config.getParameter<
Strings>(
"SelectEvents"))),
83 results_from_current_process_(
true),
84 accept_all_(initAcceptAll()),
85 absolute_acceptors_(),
86 conditional_acceptors_(),
87 exception_acceptors_(),
89 all_must_fail_noex_(),
98 Strings trimmedPathSpecs(pathSpecs);
99 for(
auto& pathspecifier : trimmedPathSpecs) {
100 boost::erase_all(pathspecifier,
" \t");
103 return trimmedPathSpecs;
113 bool unrestricted_star =
false;
114 bool negated_star =
false;
115 bool exception_star =
false;
118 if (pathspecifier ==
"*") unrestricted_star =
true;
119 if (pathspecifier ==
"!*") negated_star =
true;
120 if (pathspecifier ==
"exception@*") exception_star =
true;
122 return (unrestricted_star && negated_star && exception_star);
140 bool noex_demanded =
false;
142 and_noexception = pathspecifier.find(
"&noexception");
143 if (and_noexception != std::string::npos) {
144 basePathSpec = pathspecifier.substr(0,and_noexception);
145 noex_demanded =
true;
148 if (and_noex != std::string::npos) {
149 basePathSpec = pathspecifier.substr(0,and_noexception);
150 noex_demanded =
true;
152 and_noexception = basePathSpec.find(
"&noexception");
153 and_noex = basePathSpec.find(
"&noex");
154 if (and_noexception != std::string::npos ||
155 and_noex != std::string::npos)
157 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
158 "to request a trigger name, but specifying &noexceptions twice\n"
159 <<
"The improper trigger name is: " << pathspecifier <<
"\n";
162 bool negative_criterion =
false;
163 if (basePathSpec[0] ==
'!') {
164 negative_criterion =
true;
165 realname = basePathSpec.substr(1,std::string::npos);
167 bool exception_spec =
false;
168 if (realname.find(
"exception@") == 0) {
169 exception_spec =
true;
170 realname = realname.substr(10, std::string::npos);
173 if (negative_criterion && exception_spec)
175 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
176 "to request a trigger name starting with !exception@.\n"
177 "This is not supported.\n"
178 <<
"The improper trigger name is: " << pathspecifier <<
"\n";
179 if (noex_demanded && exception_spec)
181 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
182 "to request a trigger name starting with exception@ "
183 "and also demanding no &exceptions.\n"
184 <<
"The improper trigger name is: " << pathspecifier <<
"\n";
189 std::vector<Strings::const_iterator>
matches =
192 if (matches.empty() && !
is_glob(realname))
195 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
196 "to request a trigger name that does not exist\n"
197 <<
"The unknown trigger name is: " << realname <<
"\n";
199 if (matches.empty() &&
is_glob(realname))
202 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
203 "to request a wildcarded trigger name that does not match any trigger \n"
204 <<
"The wildcarded trigger name is: " << realname <<
"\n";
207 if (!negative_criterion && !noex_demanded && !exception_spec) {
208 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
212 }
else if (!negative_criterion && noex_demanded) {
213 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
217 }
else if (exception_spec) {
218 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
222 }
else if (negative_criterion && !noex_demanded) {
223 if (matches.empty()) {
225 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
226 "to request all fails on a set of trigger names that do not exist\n"
227 <<
"The problematic name is: " << pathspecifier <<
"\n";
229 }
else if (matches.size() == 1) {
234 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
237 mustfail.push_back(bi);
241 }
else if (negative_criterion && noex_demanded) {
242 if (matches.empty()) {
244 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
245 "to request all fails on a set of trigger names that do not exist\n"
246 <<
"The problematic name is: " << pathspecifier <<
"\n";
248 }
else if (matches.size() == 1) {
253 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
255 mustfail.push_back(bi);
274 bool fromPSetRegistry =
false;
276 if (tns->getTrigPaths(tr, pathNames, fromPSetRegistry)) {
278 if (fromPSetRegistry) {
288 <<
"EventSelector::acceptEvent cannot find the trigger names for\n"
289 "a process for which the configuration has requested that the\n"
290 "OutputModule use TriggerResults to select events from. This should\n"
291 "be impossible, please send information to reproduce this problem to\n"
292 "the edm developers.\n";
306 int number_of_trigger_paths)
const
313 <<
"\nEventSelector.cc::acceptEvent, you are attempting to\n"
314 <<
"use a bit array for trigger results instead of the\n"
315 <<
"TriggerResults object for a previous process. This\n"
316 <<
"will not work and ought to be impossible\n";
325 for (
int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex)
327 int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
330 tr[pathIndex] = pathStatus;
350 bool exceptionPresent =
false;
351 bool exceptionsLookedFor =
false;
356 if (!exceptionPresent)
return true;
357 exceptionsLookedFor =
true;
369 return (!exceptionPresent);
398 for(
auto const& bit : b) {
403 if (tr[bit.pos_].
state() == bstate)
return true;
414 for(
auto const& bit : b) {
416 if (tr[bit.pos_].
state() != bstate)
return false;
442 if (pathspecs.empty())
448 for (
unsigned int idx = 0;
idx < pathspecs.size();
idx++)
451 workingList.push_back(pathspecs[
idx]);
463 unsigned int fullPathCount = fullPathList.size();
468 bool oneResultMatched =
false;
469 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++)
472 for (
int iState = static_cast<int>(
hlt::Pass);
476 sampleResults[iPath] =
HLTPathStatus(static_cast<hlt::HLTState>(iState), 0);
479 oneResultMatched =
true;
483 sampleResults.
reset(iPath);
486 if (oneResultMatched)
break;
492 if (!oneResultMatched) {
493 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
497 oneResultMatched =
true;
504 if (!oneResultMatched)
553 unsigned int N = fullPathList.size();
566 std::vector< std::vector<bool> > aMustFail;
570 std::vector< std::vector<bool> > aMustFailNoex;
572 aMustFailNoex.push_back
586 std::vector< std::vector<bool> > bMustFail;
590 std::vector< std::vector<bool> > bMustFailNoex;
592 bMustFailNoex.push_back
596 std::vector<bool> aPass =
combine(aPassAbs, aPassCon);
597 std::vector<bool> bPass =
combine(bPassAbs, bPassCon);
598 std::vector<bool> aFail =
combine(aFailAbs, aFailCon);
599 std::vector<bool> bFail =
combine(bFailAbs, bFailCon);
609 for (
unsigned int f = 0;
f != aMustFail.size(); ++
f) {
612 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
613 overlap =
subset(aMustFail[f], bMustFail[
g]);
616 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
617 overlap =
subset(aMustFail[f], bMustFailNoex[
g]);
621 for (
unsigned int f = 0;
f != aMustFailNoex.size(); ++
f) {
624 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
625 overlap =
subset(aMustFailNoex[f], bMustFail[
g]);
628 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
629 overlap =
subset(aMustFailNoex[f], bMustFailNoex[
g]);
633 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
637 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
678 bool noOverlap =
true;
679 bool exactMatch =
true;
690 unsigned int fullPathCount = fullPathList.size();
691 HLTGlobalStatus hltGS(fullPathCount);
692 TriggerResults sampleResults(hltGS, fullPathList);
695 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++)
698 for (
int iState = static_cast<int>(
hlt::Pass);
702 sampleResults[iPath] =
703 HLTPathStatus(static_cast<hlt::HLTState>(iState), 0);
704 bool accept1 = selector1.wantAll() ||
705 selector1.acceptEvent(sampleResults);
706 bool accept2 = selector2.wantAll() ||
707 selector2.acceptEvent(sampleResults);
708 if (accept1 != accept2)
712 if (accept1 && accept2)
716 sampleResults.reset(iPath);
747 std::shared_ptr<TriggerResults>
752 unsigned int N = fullPathCount;
753 if (fullPathCount != inputResults.
size())
756 <<
"EventSelector::maskTriggerResults, the TriggerResults\n"
757 <<
"size (" << inputResults.
size()
758 <<
") does not match the number of paths in the\n"
759 <<
"full trigger list (" << fullPathCount <<
").\n";
769 bool all_fail =
true;
770 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
771 if ((f[ipath]) && (inputResults [ipath].state() !=
hlt::Fail)) {
777 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
787 bool all_fail =
true;
788 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
789 if ((f[ipath]) && (inputResults [ipath].state() !=
hlt::Fail)) {
795 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
814 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
816 if (((aPassAbs[ipath]) && (s ==
hlt::Pass))
832 auto maskedResults = std::make_shared<TriggerResults>(mask, inputResults.
parameterSetID());
833 return maskedResults;
859 std::shared_ptr<TriggerResults>
865 unsigned int fullPathCount = fullPathList.size();
866 if (fullPathCount != inputResults.
size())
869 <<
"EventSelector::maskTriggerResults, the TriggerResults\n"
870 <<
"size (" << inputResults.
size()
871 <<
") does not match the number of paths in the\n"
872 <<
"full trigger list (" << fullPathCount <<
").\n";
876 HLTGlobalStatus hltGS(fullPathCount);
877 auto maskedResults = std::make_shared<TriggerResults>(hltGS, inputResults.
parameterSetID());
878 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++)
880 (*maskedResults)[iPath] = inputResults[iPath];
887 HLTGlobalStatus hltGS2(fullPathCount);
888 TriggerResults sampleResults(hltGS2, fullPathList);
891 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++)
893 sampleResults[iPath] = (*maskedResults)[iPath];
894 if (!selector.wantAll() && !selector.acceptEvent(sampleResults))
896 maskedResults->reset(iPath);
898 sampleResults.reset(iPath);
900 return maskedResults;
912 std::vector<std::string>
917 selection.push_back(
"*");
918 selection.push_back(
"!*");
919 selection.push_back(
"exception@*");
925 if (!selectEventsParamSet.
empty()) {
928 if (!path_specs.empty()) {
929 selection = path_specs;
939 unsigned int e = tr.
size();
940 for (
unsigned int i = 0;
i <
e; ++
i) {
950 std::vector<bool>
const&
b) {
951 unsigned int n = a.size();
952 if (n != b.size())
return false;
953 for (
unsigned int i=0;
i!=
n; ++
i) {
954 if (a[
i] != b[
i])
return false;
982 std::vector< std::vector<bool> > aMustFail;
986 std::vector< std::vector<bool> > aMustFailNoex;
988 aMustFailNoex.push_back
991 std::vector< std::vector<bool> > bMustFail;
995 std::vector< std::vector<bool> > bMustFailNoex;
997 bMustFailNoex.push_back
1001 for (
unsigned int m = 0;
m != aMustFail.size(); ++
m) {
1003 for (
unsigned int k = 0;
k != bMustFail.size(); ++
k) {
1009 if (!match)
return false;
1011 for (
unsigned int m = 0;
m != aMustFailNoex.size(); ++
m) {
1013 for (
unsigned int k = 0;
k != bMustFailNoex.size(); ++
k) {
1014 if (
identical(aMustFailNoex[
m],bMustFailNoex[
k])) {
1019 if (!match)
return false;
1031 std::vector<bool>
x(n,
false);
1032 for (
unsigned int i = 0;
i != b.size(); ++
i) {
1033 if (b[
i].accept_state_ == PassOrFail) x[b[
i].pos_] =
true;
1040 std::vector<bool>
const&
b)
1042 if (a.size() != b.size())
return false;
1043 for (
unsigned int i = 0;
i != a.size(); ++
i) {
1044 if (a[
i] && b[
i])
return true;
1052 std::vector<bool>
const&
b)
1054 if (a.size() != b.size())
return false;
1056 bool aPresent =
false;
1057 bool aSubset =
true;
1058 for (
unsigned int i = 0;
i != a.size(); ++
i) {
1067 if (!aPresent)
return false;
1068 if (aSubset)
return true;
1071 bool bPresent =
false;
1072 bool bSubset =
true;
1073 for (
unsigned int i = 0;
i != b.size(); ++
i) {
1082 if (!bPresent)
return false;
1083 if (bSubset)
return true;
1091 std::vector<bool>
const&
b)
1093 assert(a.size() == b.size());
1094 std::vector<bool>
x(a.size());
1095 for (
unsigned int i = 0;
i != a.size(); ++
i) {
1096 x[
i] = a[
i] || b[
i];
1105 selector.
addOptional<std::vector<std::string> >(
"SelectEvents");
std::vector< Bits > all_must_fail_noex_
EventSelector(Strings const &pathspecs, Strings const &names)
T getParameter(std::string const &) const
void initPathNames(Strings const &pathNames)
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static bool selectionIsValid(Strings const &pathspec, Strings const &fullPathList)
std::vector< std::string > Strings
EventSelector::Strings Strings
Bits exception_acceptors_
HLTState
status of a trigger path
bool is_glob(std::string const &pattern)
std::vector< BitInfo > Bits
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
Bits conditional_acceptors_
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
Strings initPathSpecs(Strings const &pathSpecs)
T x() const
Cartesian x coordinate.
bool acceptAllBits(Bits const &b, HLTGlobalStatus const &tr) const
bool acceptEvent(TriggerResults const &)
std::vector< Bits > all_must_fail_
void reset()
Reset status for all paths.
unsigned int size() const
Get number of paths stored.
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
bool acceptOneBit(Bits const &b, HLTGlobalStatus const &tr, hlt::HLTState const &s=hlt::Ready) const
bool acceptTriggerPath(HLTPathStatus const &, BitInfo const &) const
static void fillDescription(ParameterSetDescription &desc)
hlt::HLTState state() const
get state of path
static bool overlapping(std::vector< bool > const &a, std::vector< bool > const &b)
static evtSel::OverlapResult testSelectionOverlap(Strings const &pathspec1, Strings const &pathspec2, Strings const &fullPathList)
bool selectionDecision(HLTGlobalStatus const &tr) const
static bool subset(std::vector< bool > const &a, std::vector< bool > const &b)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const ®exp)
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)
bool const results_from_current_process_
volatile std::atomic< bool > shutdown_flag false
std::shared_ptr< TriggerResults > maskTriggerResults(TriggerResults const &inputResults)
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
bool containsExceptions(HLTGlobalStatus const &tr) const
hlt::HLTState state(const unsigned int i) const
Get status of ith path.
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)