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
|
#ifndef HLTReco_HLTPrescaleTable_h
#define HLTReco_HLTPrescaleTable_h
/** \class trigger::HLTPrescaleTable
*
* The single EDProduct containing the HLT Prescale Table
*
*
* \author Martin Grunewald
*
*/
#include <map>
#include <string>
#include <vector>
#include <cassert>
namespace trigger {
/// The single EDProduct containing the HLT Prescale Table
class HLTPrescaleTable {
/// data members
private:
/// index number of default prescale set to use
unsigned int set_;
/// names of prescale sets
std::vector<std::string> labels_;
/// prescale sets keyed on trigger path name
std::map<std::string, std::vector<unsigned int> > table_;
/// consistency condition: all vectors must have the same length
///methods
public:
/// number of prescale sets available
unsigned int size() const { return labels_.size(); }
/// high-level user access method: prescale for given trigger path
unsigned int prescale(const std::string& trigger) const { return prescale(set_, trigger); }
/// high-level user access method: prescale for given trigger path
unsigned int prescale(unsigned int set, const std::string& trigger) const {
const std::map<std::string, std::vector<unsigned int> >::const_iterator it(table_.find(trigger));
if ((it == table_.end()) || (set >= it->second.size())) {
return 1;
} else {
return it->second[set];
}
}
/// default constructor
HLTPrescaleTable() : set_(0), labels_(), table_() {}
/// real constructor taking payload
HLTPrescaleTable(unsigned int set,
const std::vector<std::string>& labels,
const std::map<std::string, std::vector<unsigned int> >& table)
: set_(set), labels_(labels), table_(table) {
/// checking consistency
const unsigned int n(labels_.size());
assert((((set_ == 0) && (n == 0)) || (set_ < n)));
const std::map<std::string, std::vector<unsigned int> >::const_iterator ib(table_.begin());
const std::map<std::string, std::vector<unsigned int> >::const_iterator ie(table_.end());
for (std::map<std::string, std::vector<unsigned int> >::const_iterator it = ib; it != ie; ++it) {
assert(it->second.size() == n);
}
}
/// merge rule - just checking equality
bool isProductEqual(const HLTPrescaleTable& that) const {
return ((set() == that.set()) && (labels() == that.labels()) && (table() == that.table()));
}
/// low-level const accessors for data members
unsigned int set() const { return set_; }
const std::vector<std::string>& labels() const { return labels_; }
const std::map<std::string, std::vector<unsigned int> >& table() const { return table_; }
};
} // namespace trigger
#endif
|