Go to the documentation of this file.00001 #ifndef HLTReco_HLTPrescaleTable_h
00002 #define HLTReco_HLTPrescaleTable_h
00003
00015 #include <map>
00016 #include <string>
00017 #include <vector>
00018 #include <cassert>
00019
00020 namespace trigger
00021 {
00023 class HLTPrescaleTable {
00024
00026 private:
00028 unsigned int set_;
00030 std::vector<std::string> labels_;
00032 std::map<std::string,std::vector<unsigned int> > table_;
00034
00036 public:
00037
00039 unsigned int size() const {return labels_.size();}
00040
00042 unsigned int prescale(const std::string& trigger) const {
00043 return prescale(set_,trigger);
00044 }
00045
00047 unsigned int prescale(unsigned int set, const std::string& trigger) const {
00048 const std::map<std::string,std::vector<unsigned int> >::const_iterator it(table_.find(trigger));
00049 if ((it==table_.end()) || (set>=it->second.size())) {
00050 return 1;
00051 } else {
00052 return it->second[set];
00053 }
00054 }
00055
00057 HLTPrescaleTable(): set_(0), labels_(), table_() { }
00058
00060 HLTPrescaleTable(unsigned int set, const std::vector<std::string>& labels, const std::map<std::string,std::vector<unsigned int> >& table):
00061 set_(set), labels_(labels), table_(table) {
00063 const unsigned int n(labels_.size());
00064 assert((((set_==0)&&(n==0)) || (set_<n)));
00065 const std::map<std::string,std::vector<unsigned int> >::const_iterator ib(table_.begin());
00066 const std::map<std::string,std::vector<unsigned int> >::const_iterator ie(table_.end());
00067 for (std::map<std::string,std::vector<unsigned int> >::const_iterator it=ib; it!=ie; ++it) {
00068 assert (it->second.size()==n);
00069 }
00070 }
00071
00073 bool isProductEqual(const HLTPrescaleTable& that) const {
00074 return ((set()==that.set()) && (labels()==that.labels()) && (table()==that.table()));
00075 }
00076
00078 unsigned int set() const {return set_;}
00079 const std::vector<std::string>& labels() const {return labels_;}
00080 const std::map<std::string,std::vector<unsigned int> >& table() const {return table_;}
00081
00082 };
00083 }
00084
00085 #endif