CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  $Id: TriggerNamesService.h,v 1.11 2011/12/02 08:33:02 fwyzard Exp $
10 
11  This service makes the trigger names available. They are provided
12  in the same order that the pass/fail status of these triggers is
13  recorded in the TriggerResults object. These trigger names are
14  the names of the paths that appear in the configuration (excluding
15  end paths). The order is the same as in the configuration.
16 
17  There are also accessors for the end path names.
18 
19  There are other accessors for other trigger related information from the
20  job configuration: the process name, whether a report on trigger results
21  was requested and the parameter set containing the list of trigger paths.
22 
23  Almost all the functions return information related to the current
24  process only. The second and third getTrigPaths functions are exceptions.
25  They will return the trigger path names from previous processes.
26 
27  Unit tests for parts of this class are in FWCore/Integration/run_SelectEvents.sh
28  and the code it invokes.
29 
30 */
31 
33 
34 #include <string>
35 #include <map>
36 #include <vector>
37 
38 namespace edm {
39 
40  class TriggerResults;
41 
42  namespace service {
44  {
45  public:
46 
47  typedef std::vector<std::string> Strings;
48  typedef std::map<std::string, unsigned int> PosMap;
50 
51  explicit TriggerNamesService(ParameterSet const& proc_pset);
52  // Default copy, copy assignment, d'tor all do the right thing.
53 
54  // trigger names for the current process
55 
56  // Return the number of trigger paths in the current process.
57  size_type size() const { return trignames_.size(); }
58  Strings const& getTrigPaths() const { return trignames_; }
59  std::string const& getTrigPath(size_type const i) const { return trignames_.at(i);}
60  size_type findTrigPath(std::string const& name) const { return find(trigpos_,name);}
61 
62  // Get the ordered vector of trigger names that corresponds to the bits
63  // in the TriggerResults object. Unlike the other functions in this class,
64  // the next two functions will retrieve the names for previous processes.
65  // If the TriggerResults object is from the current process, this only
66  // works for modules in end paths, because the TriggerResults object is
67  // not created until the normal paths complete execution.
68  // Returns false if it fails to find the trigger path names.
70  Strings& trigPaths);
71 
72  // This is the same as the previous function except the value returned in
73  // the last argument indicates whether the results were retrieved from the
74  // ParameterSet registry. This will always be true except in old data where
75  // the trigger names were stored inside of the TriggerResults object.
77  Strings& trigPaths,
78  bool& fromPSetRegistry);
79 
80  Strings const& getEndPaths() const { return end_names_; }
81  std::string const& getEndPath(size_type const i) const { return end_names_.at(i);}
82  size_type findEndPath(std::string const& name) const { return find(end_pos_,name);}
83 
84  Strings const& getTrigPathModules(std::string const& name) const {
85  return modulenames_.at(find(trigpos_,name));
86  }
87  Strings const& getTrigPathModules(size_type const i) const {
88  return modulenames_.at(i);
89  }
90  std::string const& getTrigPathModule (std::string const& name, size_type const j) const {
91  return (modulenames_.at(find(trigpos_,name))).at(j);
92  }
93  std::string const& getTrigPathModule (size_type const i, size_type const j) const {
94  return (modulenames_.at(i)).at(j);
95  }
96 
97  Strings const& getEndPathModules(std::string const& name) const {
98  return end_modulenames_.at(find(end_pos_,name));
99  }
100  Strings const& getEndPathModules(size_type const i) const {
101  return end_modulenames_.at(i);
102  }
103  std::string const& getEndPathModule (std::string const& name, size_type const j) const {
104  return (end_modulenames_.at(find(end_pos_,name))).at(j);
105  }
106  std::string const& getEndPathModule (size_type const i, size_type const j) const {
107  return (end_modulenames_.at(i)).at(j);
108  }
109 
110  size_type find (PosMap const& posmap, std::string const& name) const {
111  PosMap::const_iterator const pos(posmap.find(name));
112  if (pos == posmap.end()) {
113  return posmap.size();
114  } else {
115  return pos->second;
116  }
117  }
118 
119  void loadPosMap(PosMap& posmap, Strings const& names) {
120  size_type const n(names.size());
121  for (size_type i = 0; i != n; ++i) {
122  posmap[names[i]] = i;
123  }
124  }
125 
126  std::string const& getProcessName() const { return process_name_; }
127  bool wantSummary() const { return wantSummary_; }
128 
129  // Parameter set containing the trigger paths
130  edm::ParameterSet const& getTriggerPSet() const { return trigger_pset_; }
131 
132  private:
133 
135 
140 
141  std::vector<Strings> modulenames_; // modules on trigger paths
142  std::vector<Strings> end_modulenames_; // modules on endpaths
143 
144  std::string process_name_;
146  };
147  }
148 }
149 
150 #endif
int i
Definition: DBlmapReader.cc:9
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
Definition: MsgTools.h:18
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
int j
Definition: DBlmapReader.cc:9
Strings const & getTrigPathModules(size_type const i) const
size_type findEndPath(std::string const &name) const
std::map< std::string, unsigned int > PosMap
size_type find(PosMap const &posmap, std::string const &name) const
std::vector< Strings > end_modulenames_
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
list at
Definition: asciidump.py:428