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_); }
77 
78  private:
80  bool State(unsigned int icase) const {
81  bool flags[3] = {false, false, false};
82  const unsigned int n(size());
83  for (unsigned int i = 0; i != n; ++i) {
84  const hlt::HLTState s(state(i));
85  if (s != hlt::Ready) {
86  flags[0] = true; // at least one trigger was run
87  if (s == hlt::Pass) {
88  flags[1] = true; // at least one trigger accepted
89  } else if (s == hlt::Exception) {
90  flags[2] = true; // at least one trigger with error
91  }
92  }
93  }
94  return flags[icase];
95  }
96  };
97 
99  inline void swap(HLTGlobalStatus& lhs, HLTGlobalStatus& rhs) { lhs.swap(rhs); }
100 
102  inline std::ostream& operator<<(std::ostream& ost, const HLTGlobalStatus& hlt) {
103  std::vector<std::string> text(4);
104  text[0] = "n";
105  text[1] = "1";
106  text[2] = "0";
107  text[3] = "e";
108  const unsigned int n(hlt.size());
109  for (unsigned int i = 0; i != n; ++i)
110  ost << text[hlt.state(i)];
111  return ost;
112  }
113 
114 } // namespace edm
115 
116 #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
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:112
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 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.