CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <vector>
11 #include <string>
12 
13 namespace dqmservices {
20  public:
21  typedef std::vector<std::string> Strings;
22 
27  TriggerSelector(Strings const& pathspecs, Strings const& names);
28 
34  TriggerSelector(edm::ParameterSet const& pset, Strings const& triggernames, bool old_ = false);
35 
39  TriggerSelector(std::string const& expression, Strings const& triggernames);
40 
42 
46  bool wantAll() const {
47  // if (useOld_) return eventSelector_->wantAll();
48  return acceptAll_;
49  }
50 
54  bool acceptEvent(edm::TriggerResults const&) const;
55 
56  /*
57  * Takes array of trigger results and a number of triggers in array and
58  * returns
59  * if it passes selection
60  */
61  bool acceptEvent(unsigned char const*, int) const;
62 
63  /*
64  * Returns if HLTGlobalStatus passes selection
65  */
66  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const { return masterElement_->returnStatus(trStatus); }
67 
68  /*
69  * Does XMl compatible formatting of the selection string
70  */
72 
73  /*
74  * Obsolete: Returns SelectedEvents vector from ParameterSet
75  */
76  static std::vector<std::string> getEventSelectionVString(edm::ParameterSet const& pset);
77 
78  private:
79  bool acceptAll_;
80 
81  /*
82  * Starts parsing selection string
83  */
84  void init(std::string const& path, Strings const& triggernames);
85 
86  /*
87  * Removes extra spaces from string
88  */
90 
91  /*
92  * Class used for storing internal representation of the selection string
93  */
94  class TreeElement {
95  enum TreeOperator { NonInit = 0, AND = 1, OR = 2, NOT = 3, BR = 4 };
96 
97  public:
98  /*
99  * Parser of selection string. Splits string into tokens and initializes new
100  * elements to parse them.
101  */
102  TreeElement(std::string const& inputString, Strings const& tr, TreeElement* parentElement = nullptr);
103  ~TreeElement();
104 
105  /*
106  * Returns selection status of current element calculated recursively from
107  * it's child elements
108  */
109  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const;
110 
111  /*
112  * Returns operator type of the element
113  */
114  TreeOperator op() const { return op_; }
115 
116  /*
117  * Returns parent element
118  */
119  TreeElement* parent() const { return parent_; }
120 
121  private:
123  std::vector<TreeElement*> children_;
125  int trigBit_;
126  };
127 
128  std::shared_ptr<TreeElement> masterElement_;
129 
130  // keep a copy of initialization string
132 
133  std::shared_ptr<edm::EventSelector> eventSelector_;
134  bool useOld_;
135 
136  static const bool debug_ = false;
137  };
138 } // namespace dqmservices
139 
140 #endif
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
static std::string trim(std::string input)
const std::string names[nVars_]
static std::string const input
Definition: EdmProvDump.cc:47
static std::string makeXMLString(std::string const &input)
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)
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