CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HLTGlobalStatus.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_HLTGlobalStatus_h
2 #define DataFormats_Common_HLTGlobalStatus_h
3 
20 
21 #include <vector>
22 #include <ostream>
23 
24 namespace edm {
26  private:
28  std::vector<HLTPathStatus> paths_;
29 
30  public:
32  HLTGlobalStatus(const unsigned int n = 0) : paths_(n) {}
33 
35  unsigned int size() const { return paths_.size(); }
36 
38  void reset() {
39  const unsigned int n(size());
40  for (unsigned int i = 0; i != n; ++i)
41  paths_[i].reset();
42  }
43 
44  // global "state" variables calculated on the fly!
45 
47  bool wasrun() const { return State(0); }
49  bool accept() const { return State(1); }
51  bool error() const { return State(2); }
52 
53  // get hold of individual elements, using safe indexing with "at" which throws!
54 
55  const HLTPathStatus& at(const unsigned int i) const { return paths_.at(i); }
56  HLTPathStatus& at(const unsigned int i) { return paths_.at(i); }
57  const HLTPathStatus& operator[](const unsigned int i) const { return paths_.at(i); }
58  HLTPathStatus& operator[](const unsigned int i) { return paths_.at(i); }
59 
61  bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
63  bool accept(const unsigned int i) const { return at(i).accept(); }
65  bool error(const unsigned int i) const { return at(i).error(); }
66 
68  hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
70  unsigned int index(const unsigned int i) const { return at(i).index(); }
72  void reset(const unsigned int i) { at(i).reset(); }
74  void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
77  HLTGlobalStatus temp(rhs);
78  this->swap(temp);
79  return *this;
80  }
81 
82  private:
84  bool State(unsigned int icase) const {
85  bool flags[3] = {false, false, false};
86  const unsigned int n(size());
87  for (unsigned int i = 0; i != n; ++i) {
88  const hlt::HLTState s(state(i));
89  if (s != hlt::Ready) {
90  flags[0] = true; // at least one trigger was run
91  if (s == hlt::Pass) {
92  flags[1] = true; // at least one trigger accepted
93  } else if (s == hlt::Exception) {
94  flags[2] = true; // at least one trigger with error
95  }
96  }
97  }
98  return flags[icase];
99  }
100  };
101 
103  inline void swap(HLTGlobalStatus& lhs, HLTGlobalStatus& rhs) { lhs.swap(rhs); }
104 
106  inline std::ostream& operator<<(std::ostream& ost, const HLTGlobalStatus& hlt) {
107  std::vector<std::string> text(4);
108  text[0] = "n";
109  text[1] = "1";
110  text[2] = "0";
111  text[3] = "e";
112  const unsigned int n(hlt.size());
113  for (unsigned int i = 0; i != n; ++i)
114  ost << text.at(hlt.state(i));
115  return ost;
116  }
117 
118 } // namespace edm
119 
120 // The standard allows us to specialize std::swap for non-templates.
121 // This ensures that HLTGlobalStatus::swap() will be used in algorithms.
122 
123 namespace std {
124  template <>
126  lhs.swap(rhs);
127  }
128 } // namespace std
129 
130 #endif // DataFormats_Common_HLTGlobalStatus_h
bool wasrun() const
Was at least one path run?
not [yet] run
Definition: HLTenums.h:17
void reset()
reset this path
Definition: HLTPathStatus.h:54
bool wasrun() const
was this path run?
Definition: HLTPathStatus.h:57
void reset(const unsigned int i)
Reset the ith path.
HLTState
status of a trigger path
Definition: HLTenums.h:16
bool accept() const
Has at least one path accepted the event?
HLTGlobalStatus & operator=(HLTGlobalStatus const &rhs)
copy assignment implemented with swap()
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
HLTPathStatus & operator[](const unsigned int i)
accept
Definition: HLTenums.h:18
bool accept(const unsigned int i) const
Has ith path accepted the event?
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void reset()
Reset status for all paths.
unsigned int size() const
Get number of paths stored.
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
bool error(const unsigned int i) const
Has ith path encountered an error (exception)?
void swap(HLTGlobalStatus &other)
swap function
bool error() const
Has any path encountered an error (exception)
std::vector< HLTPathStatus > paths_
Status of each HLT path.
tuple text
Definition: runonSM.py:43
bool State(unsigned int icase) const
Global state variable calculated on the fly.
HLTPathStatus & at(const unsigned int i)
hlt::HLTState state() const
get state of path
Definition: HLTPathStatus.h:48
const HLTPathStatus & at(const unsigned int i) const
const HLTPathStatus & operator[](const unsigned int i) const
bool error() const
has this path encountered an error (exception)?
Definition: HLTPathStatus.h:61
bool accept() const
has this path accepted the event?
Definition: HLTPathStatus.h:59
HLTGlobalStatus(const unsigned int n=0)
Constructor - for n paths.
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
bool wasrun(const unsigned int i) const
Was ith path run?
hlt::HLTState state(const unsigned int i) const
Get status of ith path.
unsigned int index() const
Definition: HLTPathStatus.h:52