CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerSelector.h
Go to the documentation of this file.
1 // $Id: TriggerSelector.h,v 1.7 2011/03/07 15:31:32 mommsen Exp $
3 
4 #ifndef EventFilter_StorageManager_TriggerSelector_h
5 #define EventFilter_StorageManager_TriggerSelector_h
6 
12 
13 #include "boost/shared_ptr.hpp"
14 
15 #include <vector>
16 #include <string>
17 
18 namespace stor
19 {
20 
30  {
31  public:
32 
33  typedef std::vector<std::string> Strings;
34 
38  TriggerSelector(Strings const& pathspecs,
39  Strings const& names);
40 
46  Strings const& triggernames, bool old_ = false);
47 
51  TriggerSelector(std::string const& expression, Strings const& triggernames);
52 
54 
58  bool wantAll() const {
59  //if (useOld_) return eventSelector_->wantAll();
60  return acceptAll_;
61  }
62 
66  bool acceptEvent(edm::TriggerResults const&) const;
67 
68  /*
69  * Takes array of trigger results and a number of triggers in array and returns
70  * if it passes selection
71  */
72  bool acceptEvent(unsigned char const*, int) const;
73 
74  /*
75  * Returns if HLTGlobalStatus passes selection
76  */
77  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const {
78  return masterElement_->returnStatus(trStatus);
79  }
80 
81  /*
82  * Does XMl compatible formatting of the selection string
83  */
85 
86  /*
87  * Obsolete: Returns SelectedEvents vector from ParameterSet
88  */
89  static std::vector<std::string>
91 
92  private:
93 
94  bool acceptAll_;
95 
96  /*
97  * Starts parsing selection string
98  */
99  void init(std::string const& path, Strings const& triggernames);
100 
101  /*
102  * Removes extra spaces from string
103  */
105 
106  /*
107  * Class used for storing internal representation of the selection string
108  */
109  class TreeElement {
110 
112  NonInit = 0,
113  AND = 1,
114  OR = 2,
115  NOT = 3,
116  BR = 4
117  };
118 
119  public:
120 
121  /*
122  * Parser of selection string. Splits string into tokens and initializes new elements to parse them.
123  */
124  TreeElement(std::string const& inputString,Strings const& tr,TreeElement* parentElement = NULL);
125  ~TreeElement();
126 
127  /*
128  * Returns selection status of current element calculated recursively from it's child elements
129  */
130  bool returnStatus(edm::HLTGlobalStatus const& trStatus) const;
131 
132  /*
133  * Returns operator type of the element
134  */
135  TreeOperator op() const {return op_;}
136 
137  /*
138  * Returns parent element
139  */
140  TreeElement * parent() const {return parent_;}
141 
142  private:
143 
145  std::vector<TreeElement*> children_;
147  int trigBit_;
148  };
149 
150  boost::shared_ptr<TreeElement> masterElement_;
151 
152  //keep a copy of initialization string
154 
155  boost::shared_ptr<edm::EventSelector> eventSelector_;
156  bool useOld_;
157 
158  static const bool debug_ = false;
159 
160  };
161 
162  typedef boost::shared_ptr<TriggerSelector> TriggerSelectorPtr;
163 
164 } // namespace stor
165 
166 #endif // EventFilter_StorageManager_TriggerSelector_h
167 
168 
std::vector< TreeElement * > children_
static const HistoName names[]
void init(std::string const &path, Strings const &triggernames)
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
#define NULL
Definition: scimark2.h:8
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
std::vector< std::string > Strings
boost::shared_ptr< TreeElement > masterElement_
static const bool debug_
bool returnStatus(edm::HLTGlobalStatus const &trStatus) const
static std::string makeXMLString(std::string const &input)
bool acceptEvent(edm::TriggerResults const &) const
boost::shared_ptr< edm::EventSelector > eventSelector_
TriggerSelector(Strings const &pathspecs, Strings const &names)
static std::string trim(std::string input)
TreeElement(std::string const &inputString, Strings const &tr, TreeElement *parentElement=NULL)
boost::shared_ptr< TriggerSelector > TriggerSelectorPtr