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 
37 namespace edm {
38 
39  class TriggerResults;
40 
41  namespace service {
43  public:
44  typedef std::vector<std::string> Strings;
45  typedef std::map<std::string, unsigned int> PosMap;
47 
48  explicit TriggerNamesService(ParameterSet const& proc_pset);
49  // Default copy, copy assignment, d'tor all do the right thing.
50 
51  // trigger names for the current process
52 
53  // Return the number of trigger paths in the current process.
54  size_type size() const { return trignames_.size(); }
55  Strings const& getTrigPaths() const { return trignames_; }
56  std::string const& getTrigPath(size_type const i) const { return trignames_.at(i); }
57  size_type findTrigPath(std::string const& name) const { return find(trigpos_, name); }
58 
59  // Get the ordered vector of trigger names that corresponds to the bits
60  // in the TriggerResults object. Unlike the other functions in this class,
61  // the next two functions will retrieve the names for previous processes.
62  // If the TriggerResults object is from the current process, this only
63  // works for modules in end paths, because the TriggerResults object is
64  // not created until the normal paths complete execution.
65  // Returns false if it fails to find the trigger path names.
66  bool getTrigPaths(TriggerResults const& triggerResults, Strings& trigPaths);
67 
68  // This is the same as the previous function except the value returned in
69  // the last argument indicates whether the results were retrieved from the
70  // ParameterSet registry. This will always be true except in old data where
71  // the trigger names were stored inside of the TriggerResults object.
72  bool getTrigPaths(TriggerResults const& triggerResults, Strings& trigPaths, bool& fromPSetRegistry);
73 
74  Strings const& getEndPaths() const { return end_names_; }
75  std::string const& getEndPath(size_type const i) const { return end_names_.at(i); }
76  size_type findEndPath(std::string const& name) const { return find(end_pos_, name); }
77 
78  Strings const& getTrigPathModules(std::string const& name) const { return modulenames_.at(find(trigpos_, name)); }
79  Strings const& getTrigPathModules(size_type const i) const { return modulenames_.at(i); }
80  std::string const& getTrigPathModule(std::string const& name, size_type const j) const {
81  return (modulenames_.at(find(trigpos_, name))).at(j);
82  }
83  std::string const& getTrigPathModule(size_type const i, size_type const j) const {
84  return (modulenames_.at(i)).at(j);
85  }
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 
123  Strings trignames_;
124  PosMap trigpos_;
125  Strings end_names_;
126  PosMap end_pos_;
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
Strings const & getTrigPathModules(std::string const &name) const
std::string const & getProcessName() const
std::string const & getTrigPath(size_type const i) const
Strings const & getEndPaths() const
std::string const & getEndPathModule(size_type const i, size_type const j) const
std::vector< std::string > Strings
Strings const & getEndPathModules(size_type const i) const
void loadPosMap(PosMap &posmap, Strings const &names)
uint16_t size_type
const std::string names[nVars_]
Strings const & getEndPathModules(std::string const &name) const
size_type findTrigPath(std::string const &name) const
std::string const & getEndPathModule(std::string const &name, size_type const j) const
Strings const & getTrigPathModules(size_type const i) const
size_type findEndPath(std::string const &name) const
std::map< std::string, unsigned int > PosMap
static std::string const triggerResults("TriggerResults")
size_type find(PosMap const &posmap, std::string const &name) const
std::vector< Strings > end_modulenames_
HLT enums.
std::string const & getEndPath(size_type const i) const
Strings const & getTrigPaths() const
TriggerNamesService(ParameterSet const &proc_pset)
edm::ParameterSet const & getTriggerPSet() const
std::string const & getTrigPathModule(std::string const &name, size_type const j) const
std::string const & getTrigPathModule(size_type const i, size_type const j) const