42 #include "boost/algorithm/string.hpp" 50 : pathspecs_(initPathSpecs(pathspecs)),
51 results_from_current_process_(
true),
52 accept_all_(initAcceptAll()),
53 absolute_acceptors_(),
54 conditional_acceptors_(),
55 exception_acceptors_(),
57 all_must_fail_noex_(),
90 Strings trimmedPathSpecs(pathSpecs);
91 for (
auto& pathspecifier : trimmedPathSpecs) {
92 boost::erase_all(pathspecifier,
" \t");
95 return trimmedPathSpecs;
104 bool unrestricted_star =
false;
105 bool negated_star =
false;
106 bool exception_star =
false;
108 for (
auto const& pathspecifier :
pathspecs_) {
109 if (pathspecifier ==
"*")
110 unrestricted_star =
true;
111 if (pathspecifier ==
"!*")
113 if (pathspecifier ==
"exception@*")
114 exception_star =
true;
116 return (unrestricted_star && negated_star && exception_star);
128 for (
auto const& pathspecifier :
pathspecs_) {
130 bool noex_demanded =
false;
132 if (and_noexception != std::string::npos) {
133 basePathSpec = pathspecifier.substr(0, and_noexception);
134 noex_demanded =
true;
137 if (and_noex != std::string::npos) {
138 basePathSpec = pathspecifier.substr(0, and_noexception);
139 noex_demanded =
true;
141 and_noexception = basePathSpec.find(
"&noexception");
142 and_noex = basePathSpec.find(
"&noex");
143 if (and_noexception != std::string::npos || and_noex != std::string::npos)
145 "to request a trigger name, but specifying &noexceptions twice\n" 146 <<
"The improper trigger name is: " << pathspecifier <<
"\n";
149 bool negative_criterion =
false;
150 if (basePathSpec[0] ==
'!') {
151 negative_criterion =
true;
152 realname = basePathSpec.substr(1, std::string::npos);
154 bool exception_spec =
false;
155 if (realname.find(
"exception@") == 0) {
156 exception_spec =
true;
157 realname = realname.substr(10, std::string::npos);
160 if (negative_criterion && exception_spec)
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)
167 "to request a trigger name starting with exception@ " 168 "and also demanding no &exceptions.\n" 169 <<
"The improper trigger name is: " << pathspecifier <<
"\n";
175 if (matches.empty() && !
is_glob(realname)) {
177 "to request a trigger name that does not exist\n" 178 <<
"The unknown trigger name is: " << realname <<
"\n";
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";
186 if (!negative_criterion && !noex_demanded && !exception_spec) {
187 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
191 }
else if (!negative_criterion && noex_demanded) {
192 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
196 }
else if (exception_spec) {
197 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
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";
208 }
else if (matches.size() == 1) {
213 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
216 mustfail.push_back(bi);
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";
227 }
else if (matches.size() == 1) {
232 for (
unsigned int t = 0;
t != matches.size(); ++
t) {
234 mustfail.push_back(bi);
254 bool fromPSetRegistry =
false;
256 if (tns->getTrigPaths(tr, pathNames, fromPSetRegistry)) {
258 if (fromPSetRegistry) {
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";
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";
301 for (
int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
302 int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
305 tr[pathIndex] = pathStatus;
324 bool exceptionPresent =
false;
325 bool exceptionsLookedFor =
false;
331 if (!exceptionPresent)
333 exceptionsLookedFor =
true;
344 if (!exceptionsLookedFor)
346 return (!exceptionPresent);
369 for (
auto const& bit : b) {
371 if (tr[bit.pos_].
state() == bstate)
380 for (
auto const& bit : b) {
382 if (tr[bit.pos_].
state() != bstate)
407 if (pathspecs.empty()) {
412 for (
unsigned int idx = 0;
idx < pathspecs.size();
idx++) {
414 workingList.push_back(pathspecs[
idx]);
425 unsigned int fullPathCount = fullPathList.size();
430 bool oneResultMatched =
false;
431 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
434 sampleResults[iPath] =
HLTPathStatus(static_cast<hlt::HLTState>(iState), 0);
436 oneResultMatched =
true;
440 sampleResults.
reset(iPath);
443 if (oneResultMatched)
450 if (!oneResultMatched) {
451 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
455 oneResultMatched =
true;
462 if (!oneResultMatched) {
502 unsigned int N = fullPathList.size();
510 std::vector<std::vector<bool> > aMustFail;
514 std::vector<std::vector<bool> > aMustFailNoex;
524 std::vector<std::vector<bool> > bMustFail;
528 std::vector<std::vector<bool> > bMustFailNoex;
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);
544 for (
unsigned int f = 0;
f != aMustFail.size(); ++
f) {
548 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
549 overlap =
subset(aMustFail[f], bMustFail[
g]);
553 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
554 overlap =
subset(aMustFail[f], bMustFailNoex[
g]);
559 for (
unsigned int f = 0;
f != aMustFailNoex.size(); ++
f) {
563 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
564 overlap =
subset(aMustFailNoex[f], bMustFail[
g]);
568 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
569 overlap =
subset(aMustFailNoex[f], bMustFailNoex[
g]);
574 for (
unsigned int g = 0;
g != bMustFail.size(); ++
g) {
579 for (
unsigned int g = 0;
g != bMustFailNoex.size(); ++
g) {
615 bool noOverlap =
true;
616 bool exactMatch =
true;
626 unsigned int fullPathCount = fullPathList.size();
631 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
634 sampleResults[iPath] =
HLTPathStatus(static_cast<hlt::HLTState>(iState), 0);
637 if (accept1 != accept2) {
640 if (accept1 && accept2) {
643 sampleResults.
reset(iPath);
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";
693 bool all_fail =
true;
694 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
695 if ((f[ipath]) && (inputResults[ipath].state() !=
hlt::Fail)) {
701 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
710 bool all_fail =
true;
711 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
712 if ((f[ipath]) && (inputResults[ipath].state() !=
hlt::Fail)) {
718 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
732 for (
unsigned int ipath = 0; ipath <
N; ++ipath) {
734 if (((aPassAbs[ipath]) && (s ==
hlt::Pass)) || ((aPassCon[ipath]) && (s ==
hlt::Pass)) ||
743 auto maskedResults = std::make_shared<TriggerResults>(
mask, inputResults.
parameterSetID());
744 return maskedResults;
770 unsigned int fullPathCount = fullPathList.size();
771 if (fullPathCount != inputResults.
size()) {
773 <<
"EventSelector::maskTriggerResults, the TriggerResults\n" 774 <<
"size (" << inputResults.
size() <<
") does not match the number of paths in the\n" 775 <<
"full trigger list (" << fullPathCount <<
").\n";
780 auto maskedResults = std::make_shared<TriggerResults>(hltGS, inputResults.
parameterSetID());
781 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
782 (*maskedResults)[iPath] = inputResults[iPath];
793 for (
unsigned int iPath = 0; iPath < fullPathCount; iPath++) {
794 sampleResults[iPath] = (*maskedResults)[iPath];
796 maskedResults->
reset(iPath);
798 sampleResults.
reset(iPath);
800 return maskedResults;
815 selection.push_back(
"*");
816 selection.push_back(
"!*");
817 selection.push_back(
"exception@*");
822 if (!selectEventsParamSet.
empty()) {
824 if (!path_specs.empty()) {
825 selection = path_specs;
834 unsigned int e = tr.
size();
835 for (
unsigned int i = 0;
i <
e; ++
i) {
845 unsigned int n = a.size();
848 for (
unsigned int i = 0;
i !=
n; ++
i) {
875 std::vector<std::vector<bool> > aMustFail;
879 std::vector<std::vector<bool> > aMustFailNoex;
883 std::vector<std::vector<bool> > bMustFail;
887 std::vector<std::vector<bool> > bMustFailNoex;
892 for (
unsigned int m = 0;
m != aMustFail.size(); ++
m) {
894 for (
unsigned int k = 0;
k != bMustFail.size(); ++
k) {
903 for (
unsigned int m = 0;
m != aMustFailNoex.size(); ++
m) {
905 for (
unsigned int k = 0;
k != bMustFailNoex.size(); ++
k) {
906 if (
identical(aMustFailNoex[
m], bMustFailNoex[
k])) {
920 std::vector<bool> x(n,
false);
921 for (
unsigned int i = 0;
i != b.size(); ++
i) {
922 if (b[
i].accept_state_ == PassOrFail)
930 if (a.size() != b.size())
932 for (
unsigned int i = 0;
i != a.size(); ++
i) {
942 if (a.size() != b.size())
945 bool aPresent =
false;
947 for (
unsigned int i = 0;
i != a.size(); ++
i) {
962 bool bPresent =
false;
964 for (
unsigned int i = 0;
i != b.size(); ++
i) {
983 assert(a.size() == b.size());
984 std::vector<bool> x(a.size());
985 for (
unsigned int i = 0;
i != a.size(); ++
i) {
994 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)
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)
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_
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)