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  {
44  public:
45 
46  typedef std::vector<std::string> Strings;
47  typedef std::map<std::string, unsigned int> PosMap;
49 
50  explicit TriggerNamesService(ParameterSet const& proc_pset);
51  // Default copy, copy assignment, d'tor all do the right thing.
52 
53  // trigger names for the current process
54 
55  // Return the number of trigger paths in the current process.
56  size_type size() const { return trignames_.size(); }
57  Strings const& getTrigPaths() const { return trignames_; }
58  std::string const& getTrigPath(size_type const i) const { return trignames_.at(i);}
59  size_type findTrigPath(std::string const& name) const { return find(trigpos_,name);}
60 
61  // Get the ordered vector of trigger names that corresponds to the bits
62  // in the TriggerResults object. Unlike the other functions in this class,
63  // the next two functions will retrieve the names for previous processes.
64  // If the TriggerResults object is from the current process, this only
65  // works for modules in end paths, because the TriggerResults object is
66  // not created until the normal paths complete execution.
67  // Returns false if it fails to find the trigger path names.
69  Strings& trigPaths);
70 
71  // This is the same as the previous function except the value returned in
72  // the last argument indicates whether the results were retrieved from the
73  // ParameterSet registry. This will always be true except in old data where
74  // the trigger names were stored inside of the TriggerResults object.
75  bool getTrigPaths(TriggerResults const& triggerResults,
76  Strings& trigPaths,
77  bool& fromPSetRegistry);
78 
79  Strings const& getEndPaths() const { return end_names_; }
80  std::string const& getEndPath(size_type const i) const { return end_names_.at(i);}
81  size_type findEndPath(std::string const& name) const { return find(end_pos_,name);}
82 
83  Strings const& getTrigPathModules(std::string const& name) const {
84  return modulenames_.at(find(trigpos_,name));
85  }
86  Strings const& getTrigPathModules(size_type const i) const {
87  return modulenames_.at(i);
88  }
89  std::string const& getTrigPathModule (std::string const& name, size_type const j) const {
90  return (modulenames_.at(find(trigpos_,name))).at(j);
91  }
92  std::string const& getTrigPathModule (size_type const i, size_type const j) const {
93  return (modulenames_.at(i)).at(j);
94  }
95 
96  Strings const& getEndPathModules(std::string const& name) const {
97  return end_modulenames_.at(find(end_pos_,name));
98  }
99  Strings const& getEndPathModules(size_type const i) const {
100  return end_modulenames_.at(i);
101  }
102  std::string const& getEndPathModule (std::string const& name, size_type const j) const {
103  return (end_modulenames_.at(find(end_pos_,name))).at(j);
104  }
105  std::string const& getEndPathModule (size_type const i, size_type const j) const {
106  return (end_modulenames_.at(i)).at(j);
107  }
108 
109  size_type find (PosMap const& posmap, std::string const& name) const {
110  PosMap::const_iterator const pos(posmap.find(name));
111  if (pos == posmap.end()) {
112  return posmap.size();
113  } else {
114  return pos->second;
115  }
116  }
117 
118  std::string const& getProcessName() const { return process_name_; }
119  bool wantSummary() const { return wantSummary_; }
120 
121  // Parameter set containing the trigger paths
122  edm::ParameterSet const& getTriggerPSet() const { return trigger_pset_; }
123 
124  private:
125 
126  void loadPosMap(PosMap& posmap, Strings const& names) {
127  size_type const n(names.size());
128  for (size_type i = 0; i != n; ++i) {
129  posmap[names[i]] = i;
130  }
131  }
132 
134 
135  Strings trignames_;
136  PosMap trigpos_;
137  Strings end_names_;
138  PosMap end_pos_;
139 
140  std::vector<Strings> modulenames_; // modules on trigger paths
141  std::vector<Strings> end_modulenames_; // modules on endpaths
142 
145  };
146  }
147 }
148 
149 #endif
Strings const & getTrigPathModules(std::string const &name) const
std::string const & getProcessName() const
std::string const & getTrigPath(size_type const i) const
static const HistoName names[]
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
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