8 #include <boost/regex.hpp> 23 Strings const& triggernames,
bool old_)
32 if (!config.
empty()) {
37 if (!myPath.empty()) {
38 init(myPath, triggernames);
64 init(
trim(expression), triggernames);
70 if (expression.empty()) {
74 if (expression.size() == 1 && expression.at(0) ==
'*')
81 using namespace boost;
83 temp = regex_replace(expression, regex(
".AND."),
"&&");
84 expression_ = regex_replace(temp, regex(
".and."),
"&&");
85 temp = regex_replace(
expression_, regex(
".OR."),
"||");
86 expression_ = regex_replace(temp, regex(
".or."),
"||");
112 int number_of_trigger_paths)
const {
115 number_of_trigger_paths);
123 for (
int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
124 int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
127 tr[pathIndex] = pathStatus;
143 : op_(NonInit), trigBit_(-1) {
149 bool occurrences_ =
false;
153 <<
"Syntax Error (empty element)" << std::endl;
155 static const size_t bopsSize_ = 2;
156 static const std::string binaryOperators_[bopsSize_] = {
"||",
"&&"};
158 for (
size_t opr = 0; opr < bopsSize_; opr++) {
159 bool exitloop_ =
false;
164 t_end_ = tmpStr.find(binaryOperators_[opr]);
166 std::cout <<
"offset: " << offset_ <<
" length: " << t_end_
167 <<
" string: " << tmpStr << std::endl;
169 if (t_end_ == std::string::npos) {
176 if (t_end_ == 0 || t_end_ + 2 >= str_.size())
178 <<
"Syntax Error (operator is not unary)\n";
181 size_t brackets_ = 0;
182 for (
size_t k = offset_;
k < t_end_;
k++) {
183 if (str_.at(
k) ==
'(') {
185 }
else if (str_.at(
k) ==
')') {
186 if (brackets_ == 0) {
188 <<
"Syntax Error (brackets)\n";
194 if (brackets_ == 0) {
198 offset_ = t_end_ + 2;
202 for (
size_t k = offset_;
true;
k++) {
203 if (
k >= str_.size()) {
204 if (bracketcnt_ != 0)
206 <<
"Syntax Error (brackets)\n";
215 if (
k >= t_end_ + 2 && bracketcnt_ == 0) {
217 size_t pos = temp.find(binaryOperators_[opr]);
218 if (pos == std::string::npos) {
227 for (
size_t s = 0;
s < pos;
s++) {
229 if (temp.at(pos) ==
'(') {
231 }
else if (temp.at(pos) ==
')') {
234 <<
"Syntax error (brackets)\n";
242 <<
"Syntax error (brackets)\n";
245 new TreeElement(str_.substr(offset_, pos +
k), tr,
this));
246 offset_ =
k + pos + 2;
248 if (offset_ >= str_.size())
250 <<
"Syntax Error (operator is not unary)\n";
255 if (str_.at(
k) ==
'(') bracketcnt_++;
256 if (str_.at(
k) ==
')') bracketcnt_--;
273 std::cout <<
"warning: empty element (will return true)" << std::endl;
277 if (str_.at(0) ==
'!') {
283 size_t beginBlock_ = str_.find(
'(');
284 size_t endBlock_ = str_.rfind(
')');
285 bool found_lbracket = (beginBlock_ != std::string::npos);
286 bool found_rbracket = (endBlock_ != std::string::npos);
288 if (found_lbracket != found_rbracket) {
290 <<
"Syntax Error (brackets)\n";
291 }
else if (found_lbracket && found_rbracket) {
292 if (beginBlock_ >= endBlock_) {
294 <<
"Syntax Error (brackets)\n";
296 if (beginBlock_ != 0 || endBlock_ != str_.size() - 1)
298 <<
"Syntax Error (invalid character)\n";
301 str_.substr(beginBlock_ + 1, endBlock_ - beginBlock_ - 1);
306 }
else if (!found_lbracket &&
309 bool ignore_if_missing =
true;
310 size_t chr_pos = str_.find(
"@");
311 if (chr_pos != std::string::npos) {
312 ignore_if_missing =
false;
313 str_ = str_.substr(0, chr_pos);
317 if (matches.empty()) {
318 if (!ignore_if_missing)
320 <<
"Trigger name (or match) not present" << std::endl;
323 std::cout <<
"TriggerSelector: Couldn't match any triggers from: " 325 <<
" Node will not be added " << std::endl;
330 if (matches.size() == 1) {
336 if (matches.size() > 1) {
338 for (
size_t l = 0;
l < matches.size();
l++)
345 if (!input.empty()) {
347 if (pos != std::string::npos) input.erase(0, pos);
349 pos = input.find_last_not_of(
" ");
350 if (pos != std::string::npos) input.erase(pos + 1);
357 if (!input.empty()) {
358 for (
size_t pos = 0;
pos < input.size();
pos++) {
359 char ch = input.at(
pos);
361 output.append(
"&");
363 output.append(1, ch);
377 <<
"Internal Error: array out of bounds " << std::endl;
385 return !
children_[0]->returnStatus(trStatus);
388 return children_[0]->returnStatus(trStatus);
395 }
else if (
op_ ==
OR) {
402 <<
"Internal error: reached end of returnStatus(...) op:state= " <<
op_ 408 for (std::vector<TreeElement*>::iterator it =
children_.begin();
T getParameter(std::string const &) const
static const HistoName names[]
static std::string trim(std::string input)
boost::shared_ptr< TreeElement > masterElement_
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)
boost::shared_ptr< edm::EventSelector > eventSelector_
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::vector< TreeElement * > children_
TreeElement(std::string const &inputString, Strings const &tr, TreeElement *parentElement=NULL)
std::vector< std::string > Strings
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const