CMS 3D CMS Logo

TriggerNamesService.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_TriggerNamesService_h
2 #define FWCore_Framework_TriggerNamesService_h
3 
4 // -*- C++ -*-
5 /*
6 
7  Original Author: Jim Kowalkowski 26-01-06
8 
9 
10  This service makes the trigger names available. They are provided
11  in the same order that the pass/fail status of these triggers is
12  recorded in the TriggerResults object. These trigger names are
13  the names of the paths that appear in the configuration (excluding
14  end paths). The order is the same as in the configuration.
15 
16  There are also accessors for the end path names.
17 
18  There are other accessors for other trigger related information from the
19  job configuration: the process name, whether a report on trigger results
20  was requested and the parameter set containing the list of trigger paths.
21 
22  Almost all the functions return information related to the current
23  process only. The second and third getTrigPaths functions are exceptions.
24  They will return the trigger path names from previous processes.
25 
26  Unit tests for parts of this class are in FWCore/Integration/run_SelectEvents.sh
27  and the code it invokes.
28 
29 */
30 
32 
33 #include <string>
34 #include <map>
35 #include <vector>
36 #include <unordered_set>
37 
38 namespace edm {
39 
40  class TriggerResults;
41 
42  namespace service {
44  public:
45  typedef std::vector<std::string> Strings;
46  typedef std::map<std::string, unsigned int> PosMap;
48 
49  explicit TriggerNamesService(ParameterSet const& proc_pset);
50  // Default copy, copy assignment, d'tor all do the right thing.
51 
52  // trigger names for the current process
53 
54  // Return the number of trigger paths in the current process.
55  size_type size() const { return trignames_.size(); }
56  Strings const& getTrigPaths() const { return trignames_; }
57  std::string const& getTrigPath(size_type const i) const { return trignames_.at(i); }
58  size_type findTrigPath(std::string const& name) const { return find(trigpos_, name); }
59 
60  // Get the ordered vector of trigger names that corresponds to the bits
61  // in the TriggerResults object. Unlike the other functions in this class,
62  // the next two functions will retrieve the names for previous processes.
63  // If the TriggerResults object is from the current process, this only
64  // works for modules in end paths, because the TriggerResults object is
65  // not created until the normal paths complete execution.
66  // Returns false if it fails to find the trigger path names.
67  bool getTrigPaths(TriggerResults const& triggerResults, Strings& trigPaths);
68 
69  // This is the same as the previous function except the value returned in
70  // the last argument indicates whether the results were retrieved from the
71  // ParameterSet registry. This will always be true except in old data where
72  // the trigger names were stored inside of the TriggerResults object.
73  bool getTrigPaths(TriggerResults const& triggerResults, Strings& trigPaths, bool& fromPSetRegistry);
74 
75  Strings const& getEndPaths() const { return end_names_; }
76  std::string const& getEndPath(size_type const i) const { return end_names_.at(i); }
77  size_type findEndPath(std::string const& name) const { return find(end_pos_, name); }
78 
79  Strings const& getTrigPathModules(std::string const& name) const { return modulenames_.at(find(trigpos_, name)); }
80  Strings const& getTrigPathModules(size_type const i) const { return modulenames_.at(i); }
81  std::string const& getTrigPathModule(std::string const& name, size_type const j) const {
82  return (modulenames_.at(find(trigpos_, name))).at(j);
83  }
84  std::string const& getTrigPathModule(size_type const i, size_type const j) const {
85  return (modulenames_.at(i)).at(j);
86  }
87  Strings const& getEndPathModules(std::string const& name) const {
88  return end_modulenames_.at(find(end_pos_, name));
89  }
90  Strings const& getEndPathModules(size_type const i) const { return end_modulenames_.at(i); }
91  std::string const& getEndPathModule(std::string const& name, size_type const j) const {
92  return (end_modulenames_.at(find(end_pos_, name))).at(j);
93  }
94  std::string const& getEndPathModule(size_type const i, size_type const j) const {
95  return (end_modulenames_.at(i)).at(j);
96  }
97 
98  size_type find(PosMap const& posmap, std::string const& name) const {
99  PosMap::const_iterator const pos(posmap.find(name));
100  if (pos == posmap.end()) {
101  return posmap.size();
102  } else {
103  return pos->second;
104  }
105  }
106 
107  std::string const& getProcessName() const { return process_name_; }
108  bool wantSummary() const { return wantSummary_; }
109 
110  // Parameter set containing the trigger paths
111  edm::ParameterSet const& getTriggerPSet() const { return trigger_pset_; }
112 
113  private:
114  void loadPosMap(PosMap& posmap, Strings const& names) {
115  size_type const n(names.size());
116  for (size_type i = 0; i != n; ++i) {
117  posmap[names[i]] = i;
118  }
119  }
120 
122 
127 
128  std::vector<Strings> modulenames_; // modules on trigger paths
129  std::vector<Strings> end_modulenames_; // modules on endpaths
130 
133  };
134  } // namespace service
135 } // namespace edm
136 
137 #endif
std::string const & getTrigPathModule(std::string const &name, size_type const j) const
Strings const & getTrigPathModules(size_type const i) const
EventSelector::Strings Strings
std::vector< std::string > Strings
size_type find(PosMap const &posmap, std::string const &name) const
void loadPosMap(PosMap &posmap, Strings const &names)
std::string const & getProcessName() const
uint16_t size_type
const std::string names[nVars_]
Strings const & getTrigPathModules(std::string const &name) const
std::string const & getEndPathModule(size_type const i, size_type const j) const
edm::ParameterSet const & getTriggerPSet() const
Strings const & getTrigPaths() const
Strings const & getEndPathModules(size_type const i) const
std::string const & getEndPath(size_type const i) const
Strings const & getEndPathModules(std::string const &name) const
std::map< std::string, unsigned int > PosMap
Strings const & getEndPaths() const
static std::string const triggerResults("TriggerResults")
std::vector< Strings > end_modulenames_
HLT enums.
size_type findTrigPath(std::string const &name) const
std::string const & getTrigPath(size_type const i) const
TriggerNamesService(ParameterSet const &proc_pset)
std::string const & getEndPathModule(std::string const &name, size_type const j) const
std::string const & getTrigPathModule(size_type const i, size_type const j) const
size_type findEndPath(std::string const &name) const