42 #include "boost/algorithm/string.hpp"
52 absolute_acceptors_(),
53 conditional_acceptors_(),
54 exception_acceptors_(),
56 all_must_fail_noex_(),
57 results_from_current_process_(
true),
58 psetID_initialized_(
false),
62 notStarPresent_(
false)
64 init(pathspecs, names);
69 absolute_acceptors_(),
70 conditional_acceptors_(),
71 exception_acceptors_(),
73 all_must_fail_noex_(),
74 results_from_current_process_(
false),
75 psetID_initialized_(
false),
79 notStarPresent_(
false)
86 absolute_acceptors_(),
87 conditional_acceptors_(),
88 exception_acceptors_(),
90 all_must_fail_noex_(),
91 results_from_current_process_(
true),
92 psetID_initialized_(
false),
96 notStarPresent_(
false)
103 init(paths, triggernames);
128 bool unrestricted_star =
false;
129 bool negated_star =
false;
130 bool exception_star =
false;
132 for (Strings::const_iterator
i(paths.begin()),
end(paths.end());
135 std::string pathSpecifier(*
i);
136 boost::erase_all(pathSpecifier,
" \t");
137 if (pathSpecifier ==
"*") unrestricted_star =
true;
138 if (pathSpecifier ==
"!*") negated_star =
true;
139 if (pathSpecifier ==
"exception@*") exception_star =
true;
141 std::string basePathSpec(pathSpecifier);
142 bool noex_demanded =
false;
144 and_noexception = pathSpecifier.find(
"&noexception");
145 if (and_noexception != std::string::npos) {
146 basePathSpec = pathSpecifier.substr(0,and_noexception);
147 noex_demanded =
true;
150 if (and_noex != std::string::npos) {
151 basePathSpec = pathSpecifier.substr(0,and_noexception);
152 noex_demanded =
true;
154 and_noexception = basePathSpec.find(
"&noexception");
155 and_noex = basePathSpec.find(
"&noex");
156 if (and_noexception != std::string::npos ||
157 and_noex != std::string::npos)
159 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
160 "to request a trigger name, but specifying &noexceptions twice\n"
161 <<
"The improper trigger name is: " << pathSpecifier <<
"\n";
163 std::string realname(basePathSpec);
164 bool negative_criterion =
false;
165 if (basePathSpec[0] ==
'!') {
166 negative_criterion =
true;
167 realname = basePathSpec.substr(1,std::string::npos);
169 bool exception_spec =
false;
170 if (realname.find(
"exception@") == 0) {
171 exception_spec =
true;
172 realname = realname.substr(10, std::string::npos);
175 if (negative_criterion && exception_spec)
177 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
178 "to request a trigger name starting with !exception@.\n"
179 "This is not supported.\n"
180 <<
"The improper trigger name is: " << pathSpecifier <<
"\n";
181 if (noex_demanded && exception_spec)
183 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
184 "to request a trigger name starting with exception@ "
185 "and also demanding no &exceptions.\n"
186 <<
"The improper trigger name is: " << pathSpecifier <<
"\n";
191 std::vector<Strings::const_iterator> matches =
194 if (matches.empty() && !
is_glob(realname))
197 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
198 "to request a trigger name that does not exist\n"
199 <<
"The unknown trigger name is: " << realname <<
"\n";
201 if (matches.empty() &&
is_glob(realname))
204 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
205 "to request a wildcarded trigger name that does not match any trigger \n"
206 <<
"The wildcarded trigger name is: " << realname <<
"\n";
209 if (!negative_criterion && !noex_demanded && !exception_spec) {
210 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
211 BitInfo bi(distance(triggernames.begin(),matches[
t]),
true);
214 }
else if (!negative_criterion && noex_demanded) {
215 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
216 BitInfo bi(distance(triggernames.begin(),matches[
t]),
true);
219 }
else if (exception_spec) {
220 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
221 BitInfo bi(distance(triggernames.begin(),matches[
t]),
true);
224 }
else if (negative_criterion && !noex_demanded) {
225 if (matches.empty()) {
227 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
228 "to request all fails on a set of trigger names that do not exist\n"
229 <<
"The problematic name is: " << pathSpecifier <<
"\n";
231 }
else if (matches.size() == 1) {
232 BitInfo bi(distance(triggernames.begin(),matches[0]),
false);
236 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
237 BitInfo bi(distance(triggernames.begin(),matches[
t]),
false);
239 mustfail.push_back(bi);
243 }
else if (negative_criterion && noex_demanded) {
244 if (matches.empty()) {
246 <<
"EventSelector::init, An OutputModule is using SelectEvents\n"
247 "to request all fails on a set of trigger names that do not exist\n"
248 <<
"The problematic name is: " << pathSpecifier <<
"\n";
250 }
else if (matches.size() == 1) {
251 BitInfo bi(distance(triggernames.begin(),matches[0]),
false);
255 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
256 BitInfo bi(distance(triggernames.begin(),matches[
t]),
false);
257 mustfail.push_back(bi);
264 if (unrestricted_star && negated_star && exception_star)
accept_all_ =
true;
288 bool fromPSetRegistry;
291 if (tns->getTrigPaths(tr, triggernames, fromPSetRegistry)) {
295 if (fromPSetRegistry) {
306 <<
"EventSelector::acceptEvent cannot find the trigger names for\n"
307 "a process for which the configuration has requested that the\n"
308 "OutputModule use TriggerResults to select events from. This should\n"
309 "be impossible, please send information to reproduce this problem to\n"
310 "the edm developers.\n";
324 int number_of_trigger_paths)
const
331 <<
"\nEventSelector.cc::acceptEvent, you are attempting to\n"
332 <<
"use a bit array for trigger results instead of the\n"
333 <<
"TriggerResults object for a previous process. This\n"
334 <<
"will not work and ought to be impossible\n";
343 for (
int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex)
345 int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
348 tr[pathIndex] = pathStatus;
368 bool exceptionPresent =
false;
369 bool exceptionsLookedFor =
false;
374 if (!exceptionPresent)
return true;
375 exceptionsLookedFor =
true;
389 return (!exceptionPresent);
418 Bits::const_iterator
i(b.begin());
419 Bits::const_iterator
e(b.end());
425 if (tr[
i->pos_].
state() == bstate)
return true;
436 Bits::const_iterator
i(b.begin());
437 Bits::const_iterator
e(b.end());
440 if (tr[
i->pos_].
state() != bstate)
return false;
461 Strings const& fullTriggerList)
466 if (pathspec.size() == 0)
472 for (
unsigned int idx = 0; idx < pathspec.size(); idx++)
475 workingList.push_back(pathspec[idx]);
487 unsigned int fullTriggerCount = fullTriggerList.size();
492 bool oneResultMatched =
false;
493 for (
unsigned int iPath = 0; iPath < fullTriggerCount; iPath++)
496 for (
int iState = static_cast<int>(
hlt::Pass);
500 sampleResults[iPath] =
HLTPathStatus(static_cast<hlt::HLTState>(iState), 0);
503 oneResultMatched =
true;
507 sampleResults.
reset(iPath);
510 if (oneResultMatched)
break;
516 if (!oneResultMatched) {
517 for (
unsigned int iPath = 0; iPath < fullTriggerCount; iPath++) {
521 oneResultMatched =
true;
528 if (!oneResultMatched)
558 Strings const& fullTriggerList)
577 unsigned int N = fullTriggerList.size();
590 std::vector< std::vector<bool> > aMustFail;
594 std::vector< std::vector<bool> > aMustFailNoex;
596 aMustFailNoex.push_back
610 std::vector< std::vector<bool> > bMustFail;
614 std::vector< std::vector<bool> > bMustFailNoex;
616 bMustFailNoex.push_back
620 std::vector<bool> aPass =
combine(aPassAbs, aPassCon);
621 std::vector<bool> bPass =
combine(bPassAbs, bPassCon);
622 std::vector<bool> aFail =
combine(aFailAbs, aFailCon);
623 std::vector<bool> bFail =
combine(bFailAbs, bFailCon);
633 for (
unsigned int f = 0;
f != aMustFail.size(); ++
f) {
636 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
637 overlap =
subset(aMustFail[f], bMustFail[
g]);
640 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
641 overlap =
subset(aMustFail[f], bMustFailNoex[
g]);
645 for (
unsigned int f = 0;
f != aMustFailNoex.size(); ++
f) {
648 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
649 overlap =
subset(aMustFailNoex[f], bMustFail[
g]);
652 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
653 overlap =
subset(aMustFailNoex[f], bMustFailNoex[
g]);
657 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
661 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
692 Strings const& fullTriggerList)
702 bool noOverlap =
true;
703 bool exactMatch =
true;
714 unsigned int fullTriggerCount = fullTriggerList.size();
715 HLTGlobalStatus hltGS(fullTriggerCount);
716 TriggerResults sampleResults(hltGS, fullTriggerList);
719 for (
unsigned int iPath = 0; iPath < fullTriggerCount; iPath++)
722 for (
int iState = static_cast<int>(
hlt::Pass);
726 sampleResults[iPath] =
727 HLTPathStatus(static_cast<hlt::HLTState>(iState), 0);
728 bool accept1 = selector1.wantAll() ||
729 selector1.acceptEvent(sampleResults);
730 bool accept2 = selector2.wantAll() ||
731 selector2.acceptEvent(sampleResults);
732 if (accept1 != accept2)
736 if (accept1 && accept2)
740 sampleResults.reset(iPath);
771 boost::shared_ptr<TriggerResults>
776 unsigned int N = fullTriggerCount;
777 if (fullTriggerCount != inputResults.
size())
780 <<
"EventSelector::maskTriggerResults, the TriggerResults\n"
781 <<
"size (" << inputResults.
size()
782 <<
") does not match the number of paths in the\n"
783 <<
"full trigger list (" << fullTriggerCount <<
").\n";
793 bool all_fail =
true;
794 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
801 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
811 bool all_fail =
true;
812 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
819 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
838 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
840 if (((aPassAbs[ipath]) && (s ==
hlt::Pass))
856 boost::shared_ptr<TriggerResults>
858 return maskedResults;
884 boost::shared_ptr<TriggerResults>
887 Strings const& fullTriggerList)
890 unsigned int fullTriggerCount = fullTriggerList.size();
891 if (fullTriggerCount != inputResults.
size())
894 <<
"EventSelector::maskTriggerResults, the TriggerResults\n"
895 <<
"size (" << inputResults.
size()
896 <<
") does not match the number of paths in the\n"
897 <<
"full trigger list (" << fullTriggerCount <<
").\n";
901 HLTGlobalStatus hltGS(fullTriggerCount);
902 boost::shared_ptr<TriggerResults>
903 maskedResults(
new TriggerResults(hltGS, inputResults.
parameterSetID()));
904 for (
unsigned int iPath = 0; iPath < fullTriggerCount; iPath++)
906 (*maskedResults)[iPath] = inputResults[iPath];
913 HLTGlobalStatus hltGS2(fullTriggerCount);
914 TriggerResults sampleResults(hltGS2, fullTriggerList);
917 for (
unsigned int iPath = 0; iPath < fullTriggerCount; iPath++)
919 sampleResults[iPath] = (*maskedResults)[iPath];
920 if (!selector.wantAll() && !selector.acceptEvent(sampleResults))
922 maskedResults->reset(iPath);
924 sampleResults.reset(iPath);
926 return maskedResults;
938 std::vector<std::string>
943 selection.push_back(
"*");
944 selection.push_back(
"!*");
945 selection.push_back(
"exception@*");
951 if (!selectEventsParamSet.
empty()) {
954 if (!path_specs.empty()) {
955 selection = path_specs;
965 unsigned int e = tr.
size();
966 for (
unsigned int i = 0;
i <
e; ++
i) {
976 std::vector<bool>
const&
b) {
977 unsigned int n = a.size();
978 if (n != b.size())
return false;
979 for (
unsigned int i=0;
i!=
n; ++
i) {
980 if (a[
i] != b[
i])
return false;
1008 std::vector< std::vector<bool> > aMustFail;
1012 std::vector< std::vector<bool> > aMustFailNoex;
1014 aMustFailNoex.push_back
1017 std::vector< std::vector<bool> > bMustFail;
1021 std::vector< std::vector<bool> > bMustFailNoex;
1023 bMustFailNoex.push_back
1027 for (
unsigned int m = 0;
m != aMustFail.size(); ++
m) {
1029 for (
unsigned int k = 0;
k != bMustFail.size(); ++
k) {
1035 if (!match)
return false;
1037 for (
unsigned int m = 0;
m != aMustFailNoex.size(); ++
m) {
1039 for (
unsigned int k = 0;
k != bMustFailNoex.size(); ++
k) {
1040 if (
identical(aMustFailNoex[
m],bMustFailNoex[
k])) {
1045 if (!match)
return false;
1057 std::vector<bool>
x(n,
false);
1058 for (
unsigned int i = 0;
i != b.size(); ++
i) {
1059 if (b[
i].accept_state_ == PassOrFail) x[b[
i].pos_] =
true;
1066 std::vector<bool>
const&
b)
1068 if (a.size() != b.size())
return false;
1069 for (
unsigned int i = 0;
i != a.size(); ++
i) {
1070 if (a[
i] && b[
i])
return true;
1078 std::vector<bool>
const&
b)
1080 if (a.size() != b.size())
return false;
1082 bool aPresent =
false;
1083 bool aSubset =
true;
1084 for (
unsigned int i = 0;
i != a.size(); ++
i) {
1093 if (!aPresent)
return false;
1094 if (aSubset)
return true;
1097 bool bPresent =
false;
1098 bool bSubset =
true;
1099 for (
unsigned int i = 0;
i != b.size(); ++
i) {
1108 if (!bPresent)
return false;
1109 if (bSubset)
return true;
1117 std::vector<bool>
const&
b)
1119 assert(a.size() == b.size());
1120 std::vector<bool>
x(a.size());
1121 for (
unsigned int i = 0;
i != a.size(); ++
i) {
1122 x[
i] = a[
i] || b[
i];
1131 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
T getUntrackedParameter(std::string const &, T const &) const
boost::shared_ptr< TriggerResults > maskTriggerResults(TriggerResults const &inputResults)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< std::string > Strings
static const HistoName names[]
Bits exception_acceptors_
HLTState
status of a trigger path
bool is_glob(std::string const &pattern)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName, BranchDescription::MatchMode m)
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)
bool acceptAllBits(Bits const &b, HLTGlobalStatus const &tr) const
bool results_from_current_process_
bool acceptEvent(TriggerResults const &)
std::vector< Bits > all_must_fail_
void init(Strings const &paths, Strings const &triggernames)
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)
static evtSel::OverlapResult testSelectionOverlap(Strings const &pathspec1, Strings const &pathspec2, Strings const &fullTriggerList)
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)
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, boost::regex const ®exp)
static bool selectionIsValid(Strings const &pathspec, Strings const &fullTriggerList)
hlt::HLTState state() const
get state of path
static bool overlapping(std::vector< bool > const &a, std::vector< bool > const &b)
bool selectionDecision(HLTGlobalStatus const &tr) const
static bool subset(std::vector< bool > const &a, std::vector< bool > const &b)
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)
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.