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 
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
edm::service::TriggerNamesService::getEndPathModules
Strings const & getEndPathModules(std::string const &name) const
Definition: TriggerNamesService.h:87
edm::service::TriggerNamesService::getTrigPathModule
std::string const & getTrigPathModule(size_type const i, size_type const j) const
Definition: TriggerNamesService.h:83
service
Definition: service.py:1
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm
HLT enums.
Definition: AlignableModifier.h:19
pos
Definition: PixelAliasList.h:18
edm::service::TriggerNamesService::getTriggerPSet
edm::ParameterSet const & getTriggerPSet() const
Definition: TriggerNamesService.h:111
edm::service::TriggerNamesService::getProcessName
std::string const & getProcessName() const
Definition: TriggerNamesService.h:107
edm::service::TriggerNamesService::TriggerNamesService
TriggerNamesService(ParameterSet const &proc_pset)
Definition: TriggerNamesService.cc:18
edm::service::TriggerNamesService::end_modulenames_
std::vector< Strings > end_modulenames_
Definition: TriggerNamesService.h:129
edm::service::TriggerNamesService::size_type
PosMap::size_type size_type
Definition: TriggerNamesService.h:46
edm::service::TriggerNamesService::getTrigPathModules
Strings const & getTrigPathModules(std::string const &name) const
Definition: TriggerNamesService.h:78
edm::service::TriggerNamesService::trigpos_
PosMap trigpos_
Definition: TriggerNamesService.h:124
edm::service::TriggerNamesService::wantSummary
bool wantSummary() const
Definition: TriggerNamesService.h:108
edm::service::TriggerNamesService::Strings
std::vector< std::string > Strings
Definition: TriggerNamesService.h:44
edm::service::TriggerNamesService::wantSummary_
bool wantSummary_
Definition: TriggerNamesService.h:132
edm::service::TriggerNamesService::getEndPathModules
Strings const & getEndPathModules(size_type const i) const
Definition: TriggerNamesService.h:90
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::service::TriggerNamesService::loadPosMap
void loadPosMap(PosMap &posmap, Strings const &names)
Definition: TriggerNamesService.h:114
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
edm::service::TriggerNamesService::end_names_
Strings end_names_
Definition: TriggerNamesService.h:125
edm::service::TriggerNamesService::end_pos_
PosMap end_pos_
Definition: TriggerNamesService.h:126
edm::service::TriggerNamesService::PosMap
std::map< std::string, unsigned int > PosMap
Definition: TriggerNamesService.h:45
edm::service::TriggerNamesService::getEndPathModule
std::string const & getEndPathModule(size_type const i, size_type const j) const
Definition: TriggerNamesService.h:94
edm::service::TriggerNamesService::getTrigPathModules
Strings const & getTrigPathModules(size_type const i) const
Definition: TriggerNamesService.h:79
edm::ParameterSet
Definition: ParameterSet.h:47
edm::service::TriggerNamesService::size
size_type size() const
Definition: TriggerNamesService.h:54
edm::service::TriggerNamesService::trignames_
Strings trignames_
Definition: TriggerNamesService.h:123
edm::service::TriggerNamesService::getTrigPath
std::string const & getTrigPath(size_type const i) const
Definition: TriggerNamesService.h:56
edm::Strings
EventSelector::Strings Strings
Definition: EventSelector.cc:48
edm::service::TriggerNamesService::getEndPathModule
std::string const & getEndPathModule(std::string const &name, size_type const j) const
Definition: TriggerNamesService.h:91
edm::service::TriggerNamesService::findEndPath
size_type findEndPath(std::string const &name) const
Definition: TriggerNamesService.h:76
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::service::TriggerNamesService::getTrigPathModule
std::string const & getTrigPathModule(std::string const &name, size_type const j) const
Definition: TriggerNamesService.h:80
edm::service::TriggerNamesService
Definition: TriggerNamesService.h:42
edm::service::TriggerNamesService::find
size_type find(PosMap const &posmap, std::string const &name) const
Definition: TriggerNamesService.h:98
edm::service::TriggerNamesService::getTrigPaths
Strings const & getTrigPaths() const
Definition: TriggerNamesService.h:55
edm::service::TriggerNamesService::getEndPath
std::string const & getEndPath(size_type const i) const
Definition: TriggerNamesService.h:75
edm::service::TriggerNamesService::getEndPaths
Strings const & getEndPaths() const
Definition: TriggerNamesService.h:74
edm::triggerResults
static const std::string triggerResults("TriggerResults")
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::service::TriggerNamesService::trigger_pset_
edm::ParameterSet trigger_pset_
Definition: TriggerNamesService.h:121
ParameterSet.h
edm::service::TriggerNamesService::process_name_
std::string process_name_
Definition: TriggerNamesService.h:131
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HLTObjectsMonitor_cfi.TriggerResults
TriggerResults
Definition: HLTObjectsMonitor_cfi.py:9
edm::service::TriggerNamesService::modulenames_
std::vector< Strings > modulenames_
Definition: TriggerNamesService.h:128
edm::TriggerResults
Definition: TriggerResults.h:35
edm::service::TriggerNamesService::findTrigPath
size_type findTrigPath(std::string const &name) const
Definition: TriggerNamesService.h:57