CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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
25 {
27 
28  private:
29 
31  std::vector<HLTPathStatus> paths_;
32 
33  public:
34 
36  HLTGlobalStatus(const unsigned int n=0) : paths_(n) {}
37 
39  unsigned int size() const { return paths_.size(); }
40 
42  void reset() {
43  const unsigned int n(size());
44  for (unsigned int i = 0; i != n; ++i) paths_[i].reset();
45  }
46 
47  // global "state" variables calculated on the fly!
48 
50  bool wasrun() const {return State(0);}
52  bool accept() const {return State(1);}
54  bool error() const {return State(2);}
55 
56  // get hold of individual elements, using safe indexing with "at" which throws!
57 
58  const HLTPathStatus& at (const unsigned int i) const { return paths_.at(i); }
59  HLTPathStatus& at (const unsigned int i) { return paths_.at(i); }
60  const HLTPathStatus& operator[](const unsigned int i) const { return paths_.at(i); }
61  HLTPathStatus& operator[](const unsigned int i) { return paths_.at(i); }
62 
64  bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
66  bool accept(const unsigned int i) const { return at(i).accept(); }
68  bool error(const unsigned int i) const { return at(i).error() ; }
69 
71  hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
73  unsigned int index(const unsigned int i) const { return at(i).index(); }
75  void reset(const unsigned int i) { at(i).reset(); }
77  void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
80  HLTGlobalStatus temp(rhs);
81  this->swap(temp);
82  return *this;
83  }
84 
85  private:
86 
88  bool State(unsigned int icase) const {
89  bool flags[3] = {false, false, false};
90  const unsigned int n(size());
91  for (unsigned int i = 0; i != n; ++i) {
92  const hlt::HLTState s(state(i));
93  if (s!=hlt::Ready) {
94  flags[0]=true; // at least one trigger was run
95  if (s==hlt::Pass) {
96  flags[1]=true; // at least one trigger accepted
97  } else if (s==hlt::Exception) {
98  flags[2]=true; // at least one trigger with error
99  }
100  }
101  }
102  return flags[icase];
103  }
104 
105  };
106 
108  inline
109  void
111  lhs.swap(rhs);
112  }
113 
115  inline std::ostream& operator <<(std::ostream& ost, const HLTGlobalStatus& hlt) {
116  std::vector<std::string> text(4); text[0]="n"; text[1]="1"; text[2]="0"; text[3]="e";
117  const unsigned int n(hlt.size());
118  for (unsigned int i = 0; i != n; ++i) ost << text.at(hlt.state(i));
119  return ost;
120  }
121 
122 }
123 
124 // The standard allows us to specialize std::swap for non-templates.
125 // This ensures that HLTGlobalStatus::swap() will be used in algorithms.
126 
127 namespace std {
128  template <> inline void swap(edm::HLTGlobalStatus& lhs, edm::HLTGlobalStatus& rhs) {
129  lhs.swap(rhs);
130  }
131 }
132 
133 #endif // DataFormats_Common_HLTGlobalStatus_h
134 
135 
136 
137 
int i
Definition: DBlmapReader.cc:9
bool wasrun() const
Was at least one path run?
not [yet] run
Definition: HLTenums.h:18
void reset()
reset this path
Definition: HLTPathStatus.h:55
bool wasrun() const
was this path run?
Definition: HLTPathStatus.h:58
void reset(const unsigned int i)
Reset the ith path.
HLTState
status of a trigger path
Definition: HLTenums.h:18
bool accept() const
Has at least one path accepted the event?
HLTGlobalStatus & operator=(HLTGlobalStatus const &rhs)
copy assignment implemented with swap()
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
HLTPathStatus & operator[](const unsigned int i)
accept
Definition: HLTenums.h:19
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:42
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:51
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:62
bool accept() const
has this path accepted the event?
Definition: HLTPathStatus.h:60
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
get index of module giving the status of this path
Definition: HLTPathStatus.h:53