8 #include <boost/regex.hpp> 30 if (!config.
empty()) {
34 if (!myPath.empty()) {
35 init(myPath, triggernames);
59 init(
trim(expression), triggernames);
64 if (expression.empty()) {
68 if (expression.size() == 1 && expression.at(0) ==
'*')
75 using namespace boost;
77 temp = regex_replace(expression, regex(
".AND."),
"&&");
78 expression_ = regex_replace(temp, regex(
".and."),
"&&");
79 temp = regex_replace(
expression_, regex(
".OR."),
"||");
80 expression_ = regex_replace(temp, regex(
".or."),
"||");
107 return eventSelector_->acceptEvent(array_of_trigger_results, number_of_trigger_paths);
116 for (
int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
117 int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
120 tr[pathIndex] = pathStatus;
136 : op_(NonInit), trigBit_(-1) {
142 bool occurrences_ =
false;
147 static const size_t bopsSize_ = 2;
148 static const std::string binaryOperators_[bopsSize_] = {
"||",
"&&"};
150 for (
size_t opr = 0; opr < bopsSize_; opr++) {
151 bool exitloop_ =
false;
156 t_end_ = tmpStr.find(binaryOperators_[opr]);
158 std::cout <<
"offset: " << offset_ <<
" length: " << t_end_ <<
" string: " << tmpStr << std::endl;
160 if (t_end_ == std::string::npos) {
167 if (t_end_ == 0 || t_end_ + 2 >= str_.size())
171 size_t brackets_ = 0;
172 for (
size_t k = offset_;
k < t_end_;
k++) {
173 if (str_.at(
k) ==
'(') {
175 }
else if (str_.at(
k) ==
')') {
176 if (brackets_ == 0) {
183 if (brackets_ == 0) {
187 offset_ = t_end_ + 2;
191 for (
size_t k = offset_;
true;
k++) {
192 if (
k >= str_.size()) {
193 if (bracketcnt_ != 0)
202 if (
k >= t_end_ + 2 && bracketcnt_ == 0) {
204 size_t pos = temp.find(binaryOperators_[opr]);
205 if (pos == std::string::npos) {
213 for (
size_t s = 0;
s < pos;
s++) {
215 if (temp.at(pos) ==
'(') {
217 }
else if (temp.at(pos) ==
')') {
229 offset_ =
k + pos + 2;
231 if (offset_ >= str_.size())
237 if (str_.at(
k) ==
'(')
239 if (str_.at(
k) ==
')')
257 std::cout <<
"warning: empty element (will return true)" << std::endl;
261 if (str_.at(0) ==
'!') {
267 size_t beginBlock_ = str_.find(
'(');
268 size_t endBlock_ = str_.rfind(
')');
269 bool found_lbracket = (beginBlock_ != std::string::npos);
270 bool found_rbracket = (endBlock_ != std::string::npos);
272 if (found_lbracket != found_rbracket) {
274 }
else if (found_lbracket && found_rbracket) {
275 if (beginBlock_ >= endBlock_) {
278 if (beginBlock_ != 0 || endBlock_ != str_.size() - 1)
281 std::string next = str_.substr(beginBlock_ + 1, endBlock_ - beginBlock_ - 1);
286 }
else if (!found_lbracket && !found_rbracket)
288 bool ignore_if_missing =
true;
289 size_t chr_pos = str_.find(
"@");
290 if (chr_pos != std::string::npos) {
291 ignore_if_missing =
false;
292 str_ = str_.substr(0, chr_pos);
296 if (matches.empty()) {
297 if (!ignore_if_missing)
301 std::cout <<
"TriggerSelector: Couldn't match any triggers from: " << str_ << std::endl
302 <<
" Node will not be added " << std::endl;
307 if (matches.size() == 1) {
314 if (matches.size() > 1) {
316 for (
size_t l = 0;
l < matches.size();
l++)
323 if (!input.empty()) {
325 if (pos != std::string::npos)
328 pos = input.find_last_not_of(
" ");
329 if (pos != std::string::npos)
330 input.erase(pos + 1);
337 if (!input.empty()) {
338 for (
size_t pos = 0;
pos < input.size();
pos++) {
339 char ch = input.at(
pos);
341 output.append(
"&");
343 output.append(1, ch);
366 return !
children_[0]->returnStatus(trStatus);
369 return children_[0]->returnStatus(trStatus);
376 }
else if (
op_ ==
OR) {
383 <<
"Internal error: reached end of returnStatus(...) op:state= " <<
op_ << std::endl;
388 for (std::vector<TreeElement*>::iterator it =
children_.begin(); it !=
children_.end(); it++)
T getParameter(std::string const &) const
static std::string trim(std::string input)
const std::string names[nVars_]
static std::string const input
static std::string makeXMLString(std::string const &input)
unsigned int size() const
Get number of paths stored.
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
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)
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
bool acceptEvent(edm::TriggerResults const &) const
std::shared_ptr< edm::EventSelector > eventSelector_
std::vector< TreeElement * > children_
std::vector< std::string > Strings
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const