File indexing completed on 2024-04-06 12:04:21
0001 #ifndef HLTReco_HLTPrescaleTable_h
0002 #define HLTReco_HLTPrescaleTable_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <map>
0014 #include <string>
0015 #include <vector>
0016 #include <cassert>
0017
0018 namespace trigger {
0019
0020 class HLTPrescaleTable {
0021
0022 private:
0023
0024 unsigned int set_;
0025
0026 std::vector<std::string> labels_;
0027
0028 std::map<std::string, std::vector<unsigned int> > table_;
0029
0030
0031
0032 public:
0033
0034 unsigned int size() const { return labels_.size(); }
0035
0036
0037 unsigned int prescale(const std::string& trigger) const { return prescale(set_, trigger); }
0038
0039
0040 unsigned int prescale(unsigned int set, const std::string& trigger) const {
0041 const std::map<std::string, std::vector<unsigned int> >::const_iterator it(table_.find(trigger));
0042 if ((it == table_.end()) || (set >= it->second.size())) {
0043 return 1;
0044 } else {
0045 return it->second[set];
0046 }
0047 }
0048
0049
0050 HLTPrescaleTable() : set_(0), labels_(), table_() {}
0051
0052
0053 HLTPrescaleTable(unsigned int set,
0054 const std::vector<std::string>& labels,
0055 const std::map<std::string, std::vector<unsigned int> >& table)
0056 : set_(set), labels_(labels), table_(table) {
0057
0058 const unsigned int n(labels_.size());
0059 assert((((set_ == 0) && (n == 0)) || (set_ < n)));
0060 const std::map<std::string, std::vector<unsigned int> >::const_iterator ib(table_.begin());
0061 const std::map<std::string, std::vector<unsigned int> >::const_iterator ie(table_.end());
0062 for (std::map<std::string, std::vector<unsigned int> >::const_iterator it = ib; it != ie; ++it) {
0063 assert(it->second.size() == n);
0064 }
0065 }
0066
0067
0068 bool isProductEqual(const HLTPrescaleTable& that) const {
0069 return ((set() == that.set()) && (labels() == that.labels()) && (table() == that.table()));
0070 }
0071
0072
0073 unsigned int set() const { return set_; }
0074 const std::vector<std::string>& labels() const { return labels_; }
0075 const std::map<std::string, std::vector<unsigned int> >& table() const { return table_; }
0076 };
0077 }
0078
0079 #endif