Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:40

0001 #ifndef HLTReco_HLTPrescaleTable_h
0002 #define HLTReco_HLTPrescaleTable_h
0003 
0004 /** \class trigger::HLTPrescaleTable
0005  *
0006  *  The single EDProduct containing the HLT Prescale Table
0007  *
0008  *
0009  *  \author Martin Grunewald
0010  *
0011  */
0012 
0013 #include <map>
0014 #include <string>
0015 #include <vector>
0016 #include <cassert>
0017 
0018 namespace trigger {
0019   /// The single EDProduct containing the HLT Prescale Table
0020   class HLTPrescaleTable {
0021     /// data members
0022   private:
0023     /// index number of default prescale set to use
0024     unsigned int set_;
0025     /// names of prescale sets
0026     std::vector<std::string> labels_;
0027     /// prescale sets keyed on trigger path name
0028     std::map<std::string, std::vector<unsigned int> > table_;
0029     /// consistency condition: all vectors must have the same length
0030 
0031     ///methods
0032   public:
0033     /// number of prescale sets available
0034     unsigned int size() const { return labels_.size(); }
0035 
0036     /// high-level user access method: prescale for given trigger path
0037     unsigned int prescale(const std::string& trigger) const { return prescale(set_, trigger); }
0038 
0039     /// high-level user access method: prescale for given trigger path
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     /// default constructor
0050     HLTPrescaleTable() : set_(0), labels_(), table_() {}
0051 
0052     /// real constructor taking payload
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       /// checking consistency
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     /// merge rule - just checking equality
0068     bool isProductEqual(const HLTPrescaleTable& that) const {
0069       return ((set() == that.set()) && (labels() == that.labels()) && (table() == that.table()));
0070     }
0071 
0072     /// low-level const accessors for data members
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 }  // namespace trigger
0078 
0079 #endif