File indexing completed on 2024-04-06 12:12:06
0001 #ifndef FWCore_Framework_TriggerNamesService_h
0002 #define FWCore_Framework_TriggerNamesService_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032
0033 #include <string>
0034 #include <map>
0035 #include <vector>
0036 #include <unordered_set>
0037
0038 namespace edm {
0039
0040 class TriggerResults;
0041
0042 namespace service {
0043 class TriggerNamesService {
0044 public:
0045 typedef std::vector<std::string> Strings;
0046 typedef std::map<std::string, unsigned int> PosMap;
0047 typedef PosMap::size_type size_type;
0048
0049 explicit TriggerNamesService(ParameterSet const& proc_pset);
0050
0051
0052
0053
0054
0055 size_type size() const { return trignames_.size(); }
0056 Strings const& getTrigPaths() const { return trignames_; }
0057 std::string const& getTrigPath(size_type const i) const { return trignames_.at(i); }
0058 size_type findTrigPath(std::string const& name) const { return find(trigpos_, name); }
0059
0060
0061
0062
0063
0064
0065
0066
0067 bool getTrigPaths(TriggerResults const& triggerResults, Strings& trigPaths);
0068
0069
0070
0071
0072
0073 bool getTrigPaths(TriggerResults const& triggerResults, Strings& trigPaths, bool& fromPSetRegistry);
0074
0075 Strings const& getEndPaths() const { return end_names_; }
0076 std::string const& getEndPath(size_type const i) const { return end_names_.at(i); }
0077 size_type findEndPath(std::string const& name) const { return find(end_pos_, name); }
0078
0079 Strings const& getTrigPathModules(std::string const& name) const { return modulenames_.at(find(trigpos_, name)); }
0080 Strings const& getTrigPathModules(size_type const i) const { return modulenames_.at(i); }
0081 std::string const& getTrigPathModule(std::string const& name, size_type const j) const {
0082 return (modulenames_.at(find(trigpos_, name))).at(j);
0083 }
0084 std::string const& getTrigPathModule(size_type const i, size_type const j) const {
0085 return (modulenames_.at(i)).at(j);
0086 }
0087 Strings const& getEndPathModules(std::string const& name) const {
0088 return end_modulenames_.at(find(end_pos_, name));
0089 }
0090 Strings const& getEndPathModules(size_type const i) const { return end_modulenames_.at(i); }
0091 std::string const& getEndPathModule(std::string const& name, size_type const j) const {
0092 return (end_modulenames_.at(find(end_pos_, name))).at(j);
0093 }
0094 std::string const& getEndPathModule(size_type const i, size_type const j) const {
0095 return (end_modulenames_.at(i)).at(j);
0096 }
0097
0098 size_type find(PosMap const& posmap, std::string const& name) const {
0099 PosMap::const_iterator const pos(posmap.find(name));
0100 if (pos == posmap.end()) {
0101 return posmap.size();
0102 } else {
0103 return pos->second;
0104 }
0105 }
0106
0107 std::string const& getProcessName() const { return process_name_; }
0108 bool wantSummary() const { return wantSummary_; }
0109
0110
0111 edm::ParameterSet const& getTriggerPSet() const { return trigger_pset_; }
0112
0113 private:
0114 void loadPosMap(PosMap& posmap, Strings const& names) {
0115 size_type const n(names.size());
0116 for (size_type i = 0; i != n; ++i) {
0117 posmap[names[i]] = i;
0118 }
0119 }
0120
0121 edm::ParameterSet trigger_pset_;
0122
0123 Strings trignames_;
0124 PosMap trigpos_;
0125 Strings end_names_;
0126 PosMap end_pos_;
0127
0128 std::vector<Strings> modulenames_;
0129 std::vector<Strings> end_modulenames_;
0130
0131 std::string process_name_;
0132 bool wantSummary_;
0133 };
0134 }
0135 }
0136
0137 #endif