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 
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 namespace edm {
9  class EventSelector;
10  class HLTGlobalStatus;
11  class TriggerResults;
12 } // namespace edm
13 
14 namespace dqmservices {
21  public:
22  typedef std::vector<std::string> Strings;
23 
27  TriggerSelector(Strings const& pathspecs, Strings const& names);
28 
32  TriggerSelector(std::string const& expression, Strings const& triggernames);
33 
34  ~TriggerSelector() = default;
35 
39  bool wantAll() const { return acceptAll_; }
40 
44  bool acceptEvent(edm::TriggerResults const&) const;
45 
46  /*
47  * Takes array of trigger results and a number of triggers in array and
48  * returns
49  * if it passes selection
50  */
51  bool acceptEvent(unsigned char const*, int) const;
52 
53  /*
54  * Returns if HLTGlobalStatus passes selection
55  */
56  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const { return masterElement_->returnStatus(trStatus); }
57 
58  /*
59  * Does XMl compatible formatting of the selection string
60  */
62 
63  private:
64  bool acceptAll_;
65 
66  /*
67  * Starts parsing selection string
68  */
69  void init(std::string const& path, Strings const& triggernames);
70 
71  /*
72  * Removes extra spaces from string
73  */
75 
76  /*
77  * Class used for storing internal representation of the selection string
78  */
79  class TreeElement {
80  enum TreeOperator { NonInit = 0, AND = 1, OR = 2, NOT = 3, BR = 4 };
81 
82  public:
83  /*
84  * Parser of selection string. Splits string into tokens and initializes new
85  * elements to parse them.
86  */
87  TreeElement(std::string const& inputString, Strings const& tr, TreeElement* parentElement = nullptr);
88  ~TreeElement();
89 
90  /*
91  * Returns selection status of current element calculated recursively from
92  * it's child elements
93  */
94  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const;
95 
96  /*
97  * Returns operator type of the element
98  */
99  TreeOperator op() const { return op_; }
100 
101  /*
102  * Returns parent element
103  */
104  TreeElement* parent() const { return parent_; }
105 
106  private:
108  std::vector<TreeElement*> children_;
110  int trigBit_;
111  };
112 
113  std::shared_ptr<TreeElement> masterElement_;
114 
115  // keep a copy of initialization string
117 
118  std::shared_ptr<edm::EventSelector> eventSelector_;
119  bool useOld_;
120 
121  static const bool debug_ = false;
122  };
123 
124 } // namespace dqmservices
125 
126 #endif // DQMServices_StreamerIO_TriggerSelector_h
static std::string trim(std::string input)
const std::string names[nVars_]
static std::string const input
Definition: EdmProvDump.cc:50
static std::string makeXMLString(std::string const &input)
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
TriggerSelector(Strings const &pathspecs, Strings const &names)
std::shared_ptr< TreeElement > masterElement_
TreeElement(std::string const &inputString, Strings const &tr, TreeElement *parentElement=nullptr)
A selector of events.
Definition: EventSelector.h:16
void init(std::string const &path, Strings const &triggernames)
HLT enums.
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
bool acceptEvent(edm::TriggerResults const &) const
std::shared_ptr< edm::EventSelector > eventSelector_
std::vector< TreeElement * > children_
std::vector< std::string > Strings