-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
HLTGlobalStatus.h
139 lines (110 loc) · 4.14 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#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.
*
* $Date: 2007/12/21 22:46:50 $
* $Revision: 1.8 $
*
* \author Martin Grunewald
*
*/
#include "DataFormats/Common/interface/HLTenums.h"
#include "DataFormats/Common/interface/HLTPathStatus.h"
#include <vector>
#include <ostream>
namespace edm
{
class HLTGlobalStatus {
private:
/// Status of each HLT path
std::vector<HLTPathStatus> paths_;
public:
/// Constructor - for n paths
HLTGlobalStatus(const unsigned int n=0) : paths_(n) {}
/// Get number of paths stored
unsigned int size() const { return paths_.size(); }
/// Reset status for all paths
void reset() {
const unsigned int n(size());
for (unsigned int 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);}
// get hold of individual elements, using safe indexing with "at" which throws!
const HLTPathStatus& at (const unsigned int i) const { return paths_.at(i); }
HLTPathStatus& at (const unsigned int i) { return paths_.at(i); }
const HLTPathStatus& operator[](const unsigned int i) const { return paths_.at(i); }
HLTPathStatus& operator[](const unsigned int i) { return paths_.at(i); }
/// Was ith path run?
bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
/// Has ith path accepted the event?
bool accept(const unsigned int i) const { return at(i).accept(); }
/// Has ith path encountered an error (exception)?
bool error(const unsigned int i) const { return at(i).error() ; }
/// Get status of ith path
hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
/// Get index (slot position) of module giving the decision of the ith path
unsigned int index(const unsigned int i) const { return at(i).index(); }
/// Reset the ith path
void reset(const unsigned int i) { at(i).reset(); }
/// swap function
void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
/// copy assignment implemented with swap()
HLTGlobalStatus& operator=(HLTGlobalStatus const& rhs) {
HLTGlobalStatus temp(rhs);
this->swap(temp);
return *this;
}
private:
/// Global state variable calculated on the fly
bool State(unsigned int icase) const {
bool flags[3] = {false, false, false};
const unsigned int 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 tbale
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 unsigned int n(hlt.size());
for (unsigned int i = 0; i != n; ++i) ost << text.at(hlt.state(i));
return ost;
}
}
// The standard allows us to specialize std::swap for non-templates.
// This ensures that HLTGlobalStatus::swap() will be used in algorithms.
namespace std {
template <> inline void swap(edm::HLTGlobalStatus& lhs, edm::HLTGlobalStatus& rhs) {
lhs.swap(rhs);
}
}
#endif // DataFormats_Common_HLTGlobalStatus_h