File indexing completed on 2024-04-06 12:03:51
0001 #ifndef DataFormats_Common_HLTGlobalStatus_h
0002 #define DataFormats_Common_HLTGlobalStatus_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "DataFormats/Common/interface/HLTenums.h"
0019 #include "DataFormats/Common/interface/HLTPathStatus.h"
0020
0021 #include <string>
0022 #include <ostream>
0023 #include <vector>
0024
0025 namespace edm {
0026
0027 class HLTGlobalStatus {
0028 private:
0029
0030 std::vector<HLTPathStatus> paths_;
0031
0032 public:
0033
0034 HLTGlobalStatus(const unsigned int n = 0) : paths_(n) {}
0035
0036
0037 unsigned int size() const { return paths_.size(); }
0038
0039
0040 void reset() {
0041 const unsigned int n(size());
0042 for (unsigned int i = 0; i != n; ++i)
0043 paths_[i].reset();
0044 }
0045
0046
0047
0048
0049 bool wasrun() const { return State(0); }
0050
0051 bool accept() const { return State(1); }
0052
0053 bool error() const { return State(2); }
0054
0055
0056
0057 const HLTPathStatus& at(const unsigned int i) const { return paths_.at(i); }
0058 HLTPathStatus& at(const unsigned int i) { return paths_.at(i); }
0059 const HLTPathStatus& operator[](const unsigned int i) const { return paths_[i]; }
0060 HLTPathStatus& operator[](const unsigned int i) { return paths_[i]; }
0061
0062
0063 bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
0064
0065 bool accept(const unsigned int i) const { return at(i).accept(); }
0066
0067 bool error(const unsigned int i) const { return at(i).error(); }
0068
0069
0070 hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
0071
0072 unsigned int index(const unsigned int i) const { return at(i).index(); }
0073
0074 void reset(const unsigned int i) { at(i).reset(); }
0075
0076 void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
0077
0078 private:
0079
0080 bool State(unsigned int icase) const {
0081 bool flags[3] = {false, false, false};
0082 const unsigned int n(size());
0083 for (unsigned int i = 0; i != n; ++i) {
0084 const hlt::HLTState s(state(i));
0085 if (s != hlt::Ready) {
0086 flags[0] = true;
0087 if (s == hlt::Pass) {
0088 flags[1] = true;
0089 } else if (s == hlt::Exception) {
0090 flags[2] = true;
0091 }
0092 }
0093 }
0094 return flags[icase];
0095 }
0096 };
0097
0098
0099 inline void swap(HLTGlobalStatus& lhs, HLTGlobalStatus& rhs) { lhs.swap(rhs); }
0100
0101
0102 inline std::ostream& operator<<(std::ostream& ost, const HLTGlobalStatus& hlt) {
0103 std::vector<std::string> text(4);
0104 text[0] = "n";
0105 text[1] = "1";
0106 text[2] = "0";
0107 text[3] = "e";
0108 const unsigned int n(hlt.size());
0109 for (unsigned int i = 0; i != n; ++i)
0110 ost << text[hlt.state(i)];
0111 return ost;
0112 }
0113
0114 }
0115
0116 #endif