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 <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 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 tbale.