CMS 3D CMS Logo

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 <string>
22 #include <ostream>
23 #include <vector>
24 
25 namespace edm {
26 
28  private:
30  std::vector<HLTPathStatus> paths_;
31 
32  public:
34  HLTGlobalStatus(const unsigned int n = 0) : paths_(n) {}
35 
37  unsigned int size() const { return paths_.size(); }
38 
40  void reset() {
41  const unsigned int n(size());
42  for (unsigned int i = 0; i != n; ++i)
43  paths_[i].reset();
44  }
45 
46  // global "state" variables calculated on the fly!
47 
49  bool wasrun() const { return State(0); }
51  bool accept() const { return State(1); }
53  bool error() const { return State(2); }
54 
55  // accessors to ith element of paths_
56 
57  const HLTPathStatus& at(const unsigned int i) const { return paths_.at(i); }
58  HLTPathStatus& at(const unsigned int i) { return paths_.at(i); }
59  const HLTPathStatus& operator[](const unsigned int i) const { return paths_[i]; }
60  HLTPathStatus& operator[](const unsigned int i) { return paths_[i]; }
61 
63  bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
65  bool accept(const unsigned int i) const { return at(i).accept(); }
67  bool error(const unsigned int i) const { return at(i).error(); }
68 
70  hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
72  unsigned int index(const unsigned int i) const { return at(i).index(); }
74  void reset(const unsigned int i) { at(i).reset(); }
76  void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
79  HLTGlobalStatus temp(rhs);
80  this->swap(temp);
81  return *this;
82  }
83 
84  private:
86  bool State(unsigned int icase) const {
87  bool flags[3] = {false, false, false};
88  const unsigned int n(size());
89  for (unsigned int i = 0; i != n; ++i) {
90  const hlt::HLTState s(state(i));
91  if (s != hlt::Ready) {
92  flags[0] = true; // at least one trigger was run
93  if (s == hlt::Pass) {
94  flags[1] = true; // at least one trigger accepted
95  } else if (s == hlt::Exception) {
96  flags[2] = true; // at least one trigger with error
97  }
98  }
99  }
100  return flags[icase];
101  }
102  };
103 
105  inline void swap(HLTGlobalStatus& lhs, HLTGlobalStatus& rhs) { lhs.swap(rhs); }
106 
108  inline std::ostream& operator<<(std::ostream& ost, const HLTGlobalStatus& hlt) {
109  std::vector<std::string> text(4);
110  text[0] = "n";
111  text[1] = "1";
112  text[2] = "0";
113  text[3] = "e";
114  const unsigned int n(hlt.size());
115  for (unsigned int i = 0; i != n; ++i)
116  ost << text[hlt.state(i)];
117  return ost;
118  }
119 
120 } // namespace edm
121 
122 // The standard allows us to specialize std::swap for non-templates.
123 // This ensures that HLTGlobalStatus::swap() will be used in algorithms.
124 
125 namespace std {
126  template <>
128  lhs.swap(rhs);
129  }
130 } // namespace std
131 
132 #endif // DataFormats_Common_HLTGlobalStatus_h
bool error(const unsigned int i) const
Has ith path encountered an error (exception)?
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
bool accept() const
Has at least one path accepted the event?
hlt::HLTState state(const unsigned int i) const
Get status of ith path.
not [yet] run
Definition: HLTenums.h:17
bool error() const
Has any path encountered an error (exception)
void reset()
reset this path
Definition: HLTPathStatus.h:54
void reset(const unsigned int i)
Reset the ith path.
HLTState
status of a trigger path
Definition: HLTenums.h:16
HLTGlobalStatus & operator=(HLTGlobalStatus const &rhs)
copy assignment implemented with swap()
unsigned int index() const
Definition: HLTPathStatus.h:52
bool accept(const unsigned int i) const
Has ith path accepted the event?
const HLTPathStatus & at(const unsigned int i) const
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
HLTPathStatus & operator[](const unsigned int i)
bool wasrun() const
Was at least one path run?
unsigned int size() const
Get number of paths stored.
bool error() const
has this path encountered an error (exception)?
Definition: HLTPathStatus.h:61
accept
Definition: HLTenums.h:18
bool wasrun(const unsigned int i) const
Was ith path run?
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void reset()
Reset status for all paths.
bool accept() const
has this path accepted the event?
Definition: HLTPathStatus.h:59
void swap(HLTGlobalStatus &other)
swap function
std::vector< HLTPathStatus > paths_
Status of each HLT path.
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
bool wasrun() const
was this path run?
Definition: HLTPathStatus.h:57
const HLTPathStatus & operator[](const unsigned int i) const
HLT enums.
HLTGlobalStatus(const unsigned int n=0)
Constructor - for n paths.
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.