forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHLTGlobalStatus.h
118 lines (98 loc) · 3.58 KB
/
HLTGlobalStatus.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef DataFormats_Common_HLTGlobalStatus_h
#define DataFormats_Common_HLTGlobalStatus_h
/** \class edm::HLTGlobalStatus
*
*
* The HLT global status, summarising the status of the individual
* HLT triggers, is implemented as a vector of HLTPathStatus objects.
*
* If the user wants map-like indexing of HLT triggers through their
* names as key, s/he must use the TriggerNamesService.
*
*
* \author Martin Grunewald
*
*/
#include "DataFormats/Common/interface/HLTenums.h"
#include "DataFormats/Common/interface/HLTPathStatus.h"
#include <string>
#include <ostream>
#include <vector>
namespace edm {
class HLTGlobalStatus {
private:
/// Status of each HLT path
std::vector<HLTPathStatus> paths_;
public:
using size_type = decltype(paths_)::size_type;
/// Constructor - for n paths
HLTGlobalStatus(size_type n = 0) : paths_(n) {}
/// Get number of paths stored
auto size() const { return paths_.size(); }
/// Reset status for all paths
void reset() {
const auto n(size());
for (decltype(size()) i = 0; i != n; ++i)
paths_[i].reset();
}
// global "state" variables calculated on the fly!
/// Was at least one path run?
bool wasrun() const { return State(0); }
/// Has at least one path accepted the event?
bool accept() const { return State(1); }
/// Has any path encountered an error (exception)
bool error() const { return State(2); }
// accessors to ith element of paths_
const HLTPathStatus& at(size_type i) const { return paths_.at(i); }
HLTPathStatus& at(size_type i) { return paths_.at(i); }
const HLTPathStatus& operator[](size_type i) const { return paths_[i]; }
HLTPathStatus& operator[](size_type i) { return paths_[i]; }
/// Was ith path run?
bool wasrun(size_type i) const { return at(i).wasrun(); }
/// Has ith path accepted the event?
bool accept(size_type i) const { return at(i).accept(); }
/// Has ith path encountered an error (exception)?
bool error(size_type i) const { return at(i).error(); }
/// Get status of ith path
hlt::HLTState state(size_type i) const { return at(i).state(); }
/// Get index (slot position) of module giving the decision of the ith path
unsigned int index(size_type i) const { return at(i).index(); }
/// Reset the ith path
void reset(size_type i) { at(i).reset(); }
/// swap function
void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
private:
/// Global state variable calculated on the fly
bool State(unsigned int icase) const {
bool flags[3] = {false, false, false};
const auto n(size());
for (unsigned int i = 0; i != n; ++i) {
const hlt::HLTState s(state(i));
if (s != hlt::Ready) {
flags[0] = true; // at least one trigger was run
if (s == hlt::Pass) {
flags[1] = true; // at least one trigger accepted
} else if (s == hlt::Exception) {
flags[2] = true; // at least one trigger with error
}
}
}
return flags[icase];
}
};
/// Free swap function
inline void swap(HLTGlobalStatus& lhs, HLTGlobalStatus& rhs) { lhs.swap(rhs); }
/// Formatted printout of trigger table
inline std::ostream& operator<<(std::ostream& ost, const HLTGlobalStatus& hlt) {
std::vector<std::string> text(4);
text[0] = "n";
text[1] = "1";
text[2] = "0";
text[3] = "e";
const auto n(hlt.size());
for (unsigned int i = 0; i != n; ++i)
ost << text[hlt.state(i)];
return ost;
}
} // namespace edm
#endif // DataFormats_Common_HLTGlobalStatus_h