CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
dqmservices::TriggerSelector::TreeElement Class Reference

Public Member Functions

TreeOperator op () const
 
TreeElementparent () const
 
bool returnStatus (edm::HLTGlobalStatus const &trStatus) const
 
 TreeElement (std::string const &inputString, Strings const &tr, TreeElement *parentElement=nullptr)
 
 ~TreeElement ()
 

Private Types

enum  TreeOperator {
  NonInit = 0, AND = 1, OR = 2, NOT = 3,
  BR = 4
}
 

Private Attributes

std::vector< TreeElement * > children_
 
TreeOperator op_
 
TreeElementparent_
 
int trigBit_
 

Detailed Description

Definition at line 100 of file TriggerSelector.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

dqmservices::TriggerSelector::TreeElement::TreeElement ( std::string const &  inputString,
Strings const &  tr,
TreeElement parentElement = nullptr 
)

Definition at line 140 of file TriggerSelector.cc.

References AND, BR, children_, edm::errors::Configuration, gather_cfg::cout, dqmservices::TriggerSelector::debug_, SoftLeptonByDistance_cfi::distance, Exception, gen::k, checklumidiff::l, patRefSel_triggerMatching_cfi::matches, GetRecoTauVFromDQM_MC_cff::next, NOT, op_, OR, parent_, edm::regexMatch(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, trigBit_, and dqmservices::TriggerSelector::trim().

143  : op_(NonInit), trigBit_(-1) {
144  std::string str_ = trim(inputString);
145  children_.clear();
146  parent_ = parentElement;
147 
148  size_t offset_ = 0;
149  bool occurrences_ = false;
150 
151  if (str_.empty())
153  << "Syntax Error (empty element)" << std::endl;
154 
155  static const size_t bopsSize_ = 2;
156  static const std::string binaryOperators_[bopsSize_] = {"||", "&&"};
157 
158  for (size_t opr = 0; opr < bopsSize_; opr++) {
159  bool exitloop_ = false;
160  while (!exitloop_) {
161  size_t t_end_;
162 
163  std::string tmpStr = str_.substr(offset_);
164  t_end_ = tmpStr.find(binaryOperators_[opr]);
165  if (debug_)
166  std::cout << "offset: " << offset_ << " length: " << t_end_
167  << " string: " << tmpStr << std::endl;
168 
169  if (t_end_ == std::string::npos) {
170  // right side element
171  if (occurrences_)
172  children_.push_back(new TreeElement(tmpStr, tr, this));
173  break;
174  }
175  t_end_ += offset_;
176  if (t_end_ == 0 || t_end_ + 2 >= str_.size())
178  << "Syntax Error (operator is not unary)\n";
179  else {
180  // count bracket in preceeding part
181  size_t brackets_ = 0;
182  for (size_t k = offset_; k < t_end_; k++) {
183  if (str_.at(k) == '(') {
184  brackets_++;
185  } else if (str_.at(k) == ')') {
186  if (brackets_ == 0) {
188  << "Syntax Error (brackets)\n";
189  } else {
190  brackets_--;
191  }
192  }
193  }
194  if (brackets_ == 0) {
195  std::string next = str_.substr(offset_, t_end_ - offset_);
196  children_.push_back(new TreeElement(next, tr, this));
197  occurrences_ = true;
198  offset_ = t_end_ + 2;
199  } else {
200  // operator is inside brackets, find another
201  int bracketcnt_ = 0;
202  for (size_t k = offset_; true; k++) {
203  if (k >= str_.size()) {
204  if (bracketcnt_ != 0)
206  << "Syntax Error (brackets)\n";
207  exitloop_ = true;
208  if (occurrences_) {
209  children_.push_back(
210  new TreeElement(str_.substr(offset_), tr, this));
211  }
212  break;
213  }
214  // look for another operator
215  if (k >= t_end_ + 2 && bracketcnt_ == 0) {
216  std::string temp = str_.substr(k);
217  size_t pos = temp.find(binaryOperators_[opr]);
218  if (pos == std::string::npos) {
219  exitloop_ = true;
220  if (occurrences_) {
221  children_.push_back(
222  new TreeElement(str_.substr(offset_), tr, this));
223  }
224  break;
225  } else {
226  int brcount_ = 0;
227  for (size_t s = 0; s < pos; s++) {
228  // counting check of brackets from last position to operator
229  if (temp.at(pos) == '(') {
230  brcount_++;
231  } else if (temp.at(pos) == ')') {
232  if (brcount_ == 0) {
234  << "Syntax error (brackets)\n";
235  } else {
236  brcount_--;
237  }
238  }
239  }
240  if (brcount_ != 0)
242  << "Syntax error (brackets)\n";
243 
244  children_.push_back(
245  new TreeElement(str_.substr(offset_, pos + k), tr, this));
246  offset_ = k + pos + 2;
247  occurrences_ = true;
248  if (offset_ >= str_.size())
250  << "Syntax Error (operator is not unary)\n";
251  break;
252  }
253  }
254 
255  if (str_.at(k) == '(') bracketcnt_++;
256  if (str_.at(k) == ')') bracketcnt_--;
257  }
258  }
259  }
260  }
261  if (occurrences_) {
262  if (opr == 0)
263  op_ = OR;
264  else
265  op_ = AND;
266  return;
267  }
268  }
269 
270  if (str_.empty()) {
271  op_ = AND;
272  if (debug_)
273  std::cout << "warning: empty element (will return true)" << std::endl;
274  return;
275  }
276 
277  if (str_.at(0) == '!') {
278  op_ = NOT;
279  std::string next = str_.substr(1);
280  children_.push_back(new TreeElement(next, tr, this));
281  return;
282  }
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);
287 
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";
295  }
296  if (beginBlock_ != 0 || endBlock_ != str_.size() - 1)
298  << "Syntax Error (invalid character)\n";
299 
300  std::string next =
301  str_.substr(beginBlock_ + 1, endBlock_ - beginBlock_ - 1);
302 
303  children_.push_back(new TreeElement(next, tr, this));
304  op_ = BR; // a bracket
305  return;
306  } else if (!found_lbracket &&
307  !found_rbracket) // assume single trigger or wildcard (parsing)
308  {
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);
314  }
315 
316  std::vector<Strings::const_iterator> matches = edm::regexMatch(tr, str_);
317  if (matches.empty()) {
318  if (!ignore_if_missing) // && !edm::is_glob(str_))
320  << "Trigger name (or match) not present" << std::endl;
321  else {
322  if (debug_)
323  std::cout << "TriggerSelector: Couldn't match any triggers from: "
324  << str_ << std::endl
325  << " Node will not be added " << std::endl;
326  op_ = OR;
327  return;
328  }
329  }
330  if (matches.size() == 1) {
331  // Single Trigger match
332  trigBit_ = distance(tr.begin(), matches[0]);
333  if (debug_) std::cout << "added trigger path: " << trigBit_ << std::endl;
334  return;
335  }
336  if (matches.size() > 1) {
337  op_ = OR;
338  for (size_t l = 0; l < matches.size(); l++)
339  children_.push_back(new TreeElement(*(matches[l]), tr, this));
340  }
341  }
342 }
static std::string trim(std::string input)
int k[5][pyjets_maxn]
TreeElement(std::string const &inputString, Strings const &tr, TreeElement *parentElement=nullptr)
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const &regexp)
Definition: RegexMatch.cc:26
std::vector< TreeElement * > children_
dqmservices::TriggerSelector::TreeElement::~TreeElement ( )

Definition at line 407 of file TriggerSelector.cc.

References children_.

407  {
408  for (std::vector<TreeElement*>::iterator it = children_.begin();
409  it != children_.end(); it++)
410  delete *it;
411  children_.clear();
412 }
std::vector< TreeElement * > children_

Member Function Documentation

TreeOperator dqmservices::TriggerSelector::TreeElement::op ( ) const
inline

Definition at line 121 of file TriggerSelector.h.

References op_.

121 { return op_; }
TreeElement* dqmservices::TriggerSelector::TreeElement::parent ( void  ) const
inline

Definition at line 126 of file TriggerSelector.h.

References parent_.

Referenced by Vispa.Gui.ConnectableWidget.ConnectableWidget::addMenuEntry(), Vispa.Views.LineDecayView.LineDecayContainer::applyFilter(), Vispa.Views.BoxDecayView.BoxDecayContainer::arrangeUsingRelations(), Vispa.Views.BoxDecayView.BoxDecayContainer::autolayoutAlgorithm(), Vispa.Gui.ZoomableScrollableWidgetOwner.ZoomableScrollableWidgetOwner::autosizeScrollArea(), Vispa.Views.BoxDecayView.BoxDecayContainer::autosizeScrollArea(), Vispa.Gui.PortWidget.PortWidget::connectionPoint(), Vispa.Main.StartupScreen.StartupScreen::createDescriptionWidget(), Vispa.Views.BoxDecayView.BoxDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.DecayLine::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::delete(), Vispa.Views.LineDecayView.DecayNode::delete(), Vispa.Views.LineDecayView.DecayLine::delete(), Vispa.Gui.VispaWidget.VispaWidget::delete(), Vispa.Gui.VispaWidget.VispaWidget::dragWidget(), Vispa.Share.ImageExporter.ImageExporter::exportImageDialog(), Vispa.Views.LineDecayView.DecayLine::extendedSize(), Vispa.Gui.VispaWidget.VispaWidget::keyPressEvent(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::leaveEvent(), Vispa.Gui.PortWidget.PortWidget::moduleParent(), Vispa.Gui.WidgetContainer.WidgetContainer::mouseDoubleClickEvent(), Vispa.Gui.VispaWidget.VispaWidget::mouseDoubleClickEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), Vispa.Views.LineDecayView.ParticleWidget::mousePressEvent(), Vispa.Views.LineDecayView.DecayNode::move(), Vispa.Views.LineDecayView.LineDecayContainer::noDecorationsMode(), Vispa.Views.LineDecayView.LineDecayContainer::operationId(), Vispa.Views.LineDecayView.DecayLine::paint(), Vispa.Gui.VispaWidget.VispaWidget::paintEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::positionizeMenuWidget(), Vispa.Views.LineDecayView.DecayLine::qtLineStyle(), Vispa.Views.WidgetView.WidgetView::restoreSelection(), Vispa.Views.WidgetView.WidgetView::select(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Views.LineDecayView.LineDecayContainer::sizeHint(), Vispa.Views.LineDecayView.LineDecayContainer::tabController(), Vispa.Views.BoxDecayView.BoxDecayContainer::toggleCollapsed(), Vispa.Views.LineDecayView.DecayNode::unite(), Vispa.Views.PropertyView.PropertyView::valueChanged(), Vispa.Views.BoxDecayView.BoxDecayContainer::widgetByObject(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDoubleClicked(), and Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDragged().

126 { return parent_; }
bool dqmservices::TriggerSelector::TreeElement::returnStatus ( edm::HLTGlobalStatus const &  trStatus) const

Definition at line 369 of file TriggerSelector.cc.

References AND, BR, children_, edm::errors::Configuration, Exception, mps_fire::i, NOT, op_, OR, edm::hlt::Pass, edm::HLTGlobalStatus::size(), mps_update::status, and trigBit_.

370  {
371  if (children_.empty()) {
372  if (op_ == OR || op_ == NOT) return false;
373  if (op_ == AND || op_ == BR) return true;
374 
375  if (trigBit_ < 0 || (unsigned int)trigBit_ >= trStatus.size())
377  << "Internal Error: array out of bounds " << std::endl;
378 
379  if ((trStatus[trigBit_]).state() == edm::hlt::Pass) return true;
380  // else if ((trStatus[trigBit]).state() == edm::hlt::Fail) return false;
381 
382  return false;
383  }
384  if (op_ == NOT) { // NEGATION
385  return !children_[0]->returnStatus(trStatus);
386  }
387  if (op_ == BR) { // BRACKET
388  return children_[0]->returnStatus(trStatus);
389  }
390  if (op_ == AND) { // AND
391  bool status = true;
392  for (size_t i = 0; i < children_.size(); i++)
393  status = status && children_[i]->returnStatus(trStatus);
394  return status;
395  } else if (op_ == OR) { // OR
396  bool status = false;
397  for (size_t i = 0; i < children_.size(); i++)
398  status = status || children_[i]->returnStatus(trStatus);
399  return status;
400  }
402  << "Internal error: reached end of returnStatus(...) op:state= " << op_
403  << std::endl;
404  return false;
405 }
accept
Definition: HLTenums.h:19
std::vector< TreeElement * > children_
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const

Member Data Documentation

std::vector<TreeElement*> dqmservices::TriggerSelector::TreeElement::children_
private

Definition at line 130 of file TriggerSelector.h.

Referenced by returnStatus(), TreeElement(), and ~TreeElement().

TreeOperator dqmservices::TriggerSelector::TreeElement::op_
private

Definition at line 131 of file TriggerSelector.h.

Referenced by op(), returnStatus(), and TreeElement().

TreeElement* dqmservices::TriggerSelector::TreeElement::parent_
private

Definition at line 129 of file TriggerSelector.h.

Referenced by parent(), and TreeElement().

int dqmservices::TriggerSelector::TreeElement::trigBit_
private

Definition at line 132 of file TriggerSelector.h.

Referenced by returnStatus(), and TreeElement().