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 
22 
23 #include <vector>
24 #include <ostream>
25 
26 namespace edm
27 {
29 
30  private:
31 
33  std::vector<HLTPathStatus> paths_;
34 
35  public:
36 
38  HLTGlobalStatus(const unsigned int n=0) : paths_(n) {}
39 
41  unsigned int size() const { return paths_.size(); }
42 
44  void reset() {
45  const unsigned int n(size());
46  for (unsigned int i = 0; i != n; ++i) paths_[i].reset();
47  }
48 
49  // global "state" variables calculated on the fly!
50 
52  bool wasrun() const {return State(0);}
54  bool accept() const {return State(1);}
56  bool error() const {return State(2);}
57 
58  // get hold of individual elements, using safe indexing with "at" which throws!
59 
60  const HLTPathStatus& at (const unsigned int i) const { return paths_.at(i); }
61  HLTPathStatus& at (const unsigned int i) { return paths_.at(i); }
62  const HLTPathStatus& operator[](const unsigned int i) const { return paths_.at(i); }
63  HLTPathStatus& operator[](const unsigned int i) { return paths_.at(i); }
64 
66  bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
68  bool accept(const unsigned int i) const { return at(i).accept(); }
70  bool error(const unsigned int i) const { return at(i).error() ; }
71 
73  hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
75  unsigned int index(const unsigned int i) const { return at(i).index(); }
77  void reset(const unsigned int i) { at(i).reset(); }
79  void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
82  HLTGlobalStatus temp(rhs);
83  this->swap(temp);
84  return *this;
85  }
86 
87  private:
88 
90  bool State(unsigned int icase) const {
91  bool flags[3] = {false, false, false};
92  const unsigned int n(size());
93  for (unsigned int i = 0; i != n; ++i) {
94  const hlt::HLTState s(state(i));
95  if (s!=hlt::Ready) {
96  flags[0]=true; // at least one trigger was run
97  if (s==hlt::Pass) {
98  flags[1]=true; // at least one trigger accepted
99  } else if (s==hlt::Exception) {
100  flags[2]=true; // at least one trigger with error
101  }
102  }
103  }
104  return flags[icase];
105  }
106 
107  };
108 
110  inline
111  void
113  lhs.swap(rhs);
114  }
115 
117  inline std::ostream& operator <<(std::ostream& ost, const HLTGlobalStatus& hlt) {
118  std::vector<std::string> text(4); text[0]="n"; text[1]="1"; text[2]="0"; text[3]="e";
119  const unsigned int n(hlt.size());
120  for (unsigned int i = 0; i != n; ++i) ost << text.at(hlt.state(i));
121  return ost;
122  }
123 
124 }
125 
126 // The standard allows us to specialize std::swap for non-templates.
127 // This ensures that HLTGlobalStatus::swap() will be used in algorithms.
128 
129 namespace std {
130  template <> inline void swap(edm::HLTGlobalStatus& lhs, edm::HLTGlobalStatus& rhs) {
131  lhs.swap(rhs);
132  }
133 }
134 
135 #endif // DataFormats_Common_HLTGlobalStatus_h
136 
137 
138 
139 
int i
Definition: DBlmapReader.cc:9
bool wasrun() const
Was at least one path run?
not [yet] run
Definition: HLTenums.h:21
void reset()
reset this path
Definition: HLTPathStatus.h:58
bool wasrun() const
was this path run?
Definition: HLTPathStatus.h:61
void reset(const unsigned int i)
Reset the ith path.
HLTState
status of a trigger path
Definition: HLTenums.h:21
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:117
HLTPathStatus & operator[](const unsigned int i)
accept
Definition: HLTenums.h:22
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:54
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:65
bool accept() const
has this path accepted the event?
Definition: HLTPathStatus.h:63
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:56