CMS 3D CMS Logo

TriggerSelector.h
Go to the documentation of this file.
1 #ifndef DQMServices_StreamerIO_TriggerSelector_h
2 #define DQMServices_StreamerIO_TriggerSelector_h
3 
9 
10 #include "boost/shared_ptr.hpp"
11 
12 #include <vector>
13 #include <string>
14 
15 namespace dqmservices {
22  public:
23  typedef std::vector<std::string> Strings;
24 
29  TriggerSelector(Strings const& pathspecs, Strings const& names);
30 
36  TriggerSelector(edm::ParameterSet const& pset, Strings const& triggernames,
37  bool old_ = false);
38 
42  TriggerSelector(std::string const& expression, Strings const& triggernames);
43 
45 
49  bool wantAll() const {
50  // if (useOld_) return eventSelector_->wantAll();
51  return acceptAll_;
52  }
53 
57  bool acceptEvent(edm::TriggerResults const&) const;
58 
59  /*
60  * Takes array of trigger results and a number of triggers in array and
61  * returns
62  * if it passes selection
63  */
64  bool acceptEvent(unsigned char const*, int) const;
65 
66  /*
67  * Returns if HLTGlobalStatus passes selection
68  */
69  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const {
70  return masterElement_->returnStatus(trStatus);
71  }
72 
73  /*
74  * Does XMl compatible formatting of the selection string
75  */
77 
78  /*
79  * Obsolete: Returns SelectedEvents vector from ParameterSet
80  */
81  static std::vector<std::string> getEventSelectionVString(
82  edm::ParameterSet const& pset);
83 
84  private:
85  bool acceptAll_;
86 
87  /*
88  * Starts parsing selection string
89  */
90  void init(std::string const& path, Strings const& triggernames);
91 
92  /*
93  * Removes extra spaces from string
94  */
95  static std::string trim(std::string input);
96 
97  /*
98  * Class used for storing internal representation of the selection string
99  */
100  class TreeElement {
101  enum TreeOperator { NonInit = 0, AND = 1, OR = 2, NOT = 3, BR = 4 };
102 
103  public:
104  /*
105  * Parser of selection string. Splits string into tokens and initializes new
106  * elements to parse them.
107  */
108  TreeElement(std::string const& inputString, Strings const& tr,
109  TreeElement* parentElement = nullptr);
110  ~TreeElement();
111 
112  /*
113  * Returns selection status of current element calculated recursively from
114  * it's child elements
115  */
116  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const;
117 
118  /*
119  * Returns operator type of the element
120  */
121  TreeOperator op() const { return op_; }
122 
123  /*
124  * Returns parent element
125  */
126  TreeElement* parent() const { return parent_; }
127 
128  private:
130  std::vector<TreeElement*> children_;
132  int trigBit_;
133  };
134 
135  boost::shared_ptr<TreeElement> masterElement_;
136 
137  // keep a copy of initialization string
139 
140  boost::shared_ptr<edm::EventSelector> eventSelector_;
141  bool useOld_;
142 
143  static const bool debug_ = false;
144 };
145 }
146 
147 #endif
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
static std::string trim(std::string input)
boost::shared_ptr< TreeElement > masterElement_
const std::string names[nVars_]
static std::string const input
Definition: EdmProvDump.cc:45
static std::string makeXMLString(std::string const &input)
TriggerSelector(Strings const &pathspecs, Strings const &names)
TreeElement(std::string const &inputString, Strings const &tr, TreeElement *parentElement=nullptr)
boost::shared_ptr< edm::EventSelector > eventSelector_
void init(std::string const &path, Strings const &triggernames)
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
bool acceptEvent(edm::TriggerResults const &) const
std::vector< TreeElement * > children_
std::vector< std::string > Strings
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const