13 #include <boost/regex.hpp> 41 using namespace boost;
66 return eventSelector_->acceptEvent(array_of_trigger_results, number_of_trigger_paths);
75 for (
int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
76 int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
79 tr[pathIndex] = pathStatus;
95 : op_(NonInit), trigBit_(-1) {
101 bool occurrences_ =
false;
106 static const size_t bopsSize_ = 2;
107 static const std::string binaryOperators_[bopsSize_] = {
"||",
"&&"};
109 for (
size_t opr = 0; opr < bopsSize_; opr++) {
110 bool exitloop_ =
false;
115 t_end_ = tmpStr.find(binaryOperators_[opr]);
117 std::cout <<
"offset: " << offset_ <<
" length: " << t_end_ <<
" string: " << tmpStr << std::endl;
119 if (t_end_ == std::string::npos) {
126 if (t_end_ == 0 || t_end_ + 2 >= str_.size())
130 size_t brackets_ = 0;
131 for (
size_t k = offset_;
k < t_end_;
k++) {
132 if (str_.at(
k) ==
'(') {
134 }
else if (str_.at(
k) ==
')') {
135 if (brackets_ == 0) {
142 if (brackets_ == 0) {
146 offset_ = t_end_ + 2;
150 for (
size_t k = offset_;
true;
k++) {
151 if (
k >= str_.size()) {
152 if (bracketcnt_ != 0)
161 if (
k >= t_end_ + 2 && bracketcnt_ == 0) {
163 size_t pos =
temp.find(binaryOperators_[opr]);
164 if (
pos == std::string::npos) {
172 for (
size_t s = 0;
s <
pos;
s++) {
176 }
else if (
temp.at(
pos) ==
')') {
188 offset_ =
k +
pos + 2;
190 if (offset_ >= str_.size())
196 if (str_.at(
k) ==
'(')
198 if (str_.at(
k) ==
')')
216 std::cout <<
"warning: empty element (will return true)" << std::endl;
220 if (str_.at(0) ==
'!') {
226 size_t beginBlock_ = str_.find(
'(');
227 size_t endBlock_ = str_.rfind(
')');
228 bool found_lbracket = (beginBlock_ != std::string::npos);
229 bool found_rbracket = (endBlock_ != std::string::npos);
231 if (found_lbracket != found_rbracket) {
233 }
else if (found_lbracket && found_rbracket) {
234 if (beginBlock_ >= endBlock_) {
237 if (beginBlock_ != 0 || endBlock_ != str_.size() - 1)
240 std::string next = str_.substr(beginBlock_ + 1, endBlock_ - beginBlock_ - 1);
245 }
else if (!found_lbracket && !found_rbracket)
247 bool ignore_if_missing =
true;
248 size_t chr_pos = str_.find(
'@');
249 if (chr_pos != std::string::npos) {
250 ignore_if_missing =
false;
251 str_ = str_.substr(0, chr_pos);
256 if (!ignore_if_missing)
260 std::cout <<
"TriggerSelector: Couldn't match any triggers from: " << str_ << std::endl
261 <<
" Node will not be added " << std::endl;
282 if (!
input.empty()) {
284 if (
pos != std::string::npos)
288 if (
pos != std::string::npos)
296 if (!
input.empty()) {
309 if (children_.empty()) {
310 if (op_ ==
OR || op_ == NOT)
312 if (op_ ==
AND || op_ == BR)
315 if (trigBit_ < 0 || (
unsigned int)trigBit_ >= trStatus.
size())
325 return !children_[0]->returnStatus(trStatus);
328 return children_[0]->returnStatus(trStatus);
332 for (
size_t i = 0;
i < children_.size();
i++)
335 }
else if (op_ ==
OR) {
337 for (
size_t i = 0;
i < children_.size();
i++)
342 <<
"Internal error: reached end of returnStatus(...), op:state = " << op_;
347 for (std::vector<TreeElement*>::iterator it = children_.begin(); it != children_.end(); it++)
static std::string trim(std::string input)
static std::string const input
static std::string makeXMLString(std::string const &input)
unsigned int size() const
Get number of paths stored.
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
TriggerSelector(Strings const &pathspecs, Strings const &names)
std::shared_ptr< TreeElement > masterElement_
TreeElement(std::string const &inputString, Strings const &tr, TreeElement *parentElement=nullptr)
void init(std::string const &path, Strings const &triggernames)
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const ®exp)
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
bool acceptEvent(edm::TriggerResults const &) const
std::shared_ptr< edm::EventSelector > eventSelector_
std::vector< TreeElement * > children_
std::vector< std::string > Strings