LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
TriggerNamesService.h
Go to the documentation of this file.
1 #ifndef art_Framework_Services_System_TriggerNamesService_h
2 #define art_Framework_Services_System_TriggerNamesService_h
3 
4 // ======================================================================
5 //
6 // TriggerNamesService
7 //
8 // This service makes the trigger names available. They are provided in
9 // the same order that the pass/fail status of these triggers is recorded
10 // in the TriggerResults object. These trigger names are the names of
11 // the paths that appear in the configuration (excluding end paths). The
12 // order is the same as in the configuration.
13 //
14 // There are also accessors for the end path names.
15 //
16 // There are other accessors for other trigger related information from
17 // the job configuration: the process name, whether a report on trigger
18 // results was requested and the parameter set containing the list of
19 // trigger paths.
20 //
21 // Almost all the functions return information related to the current
22 // process only. The second getTrigPaths function is an exception.
23 // It will return the trigger path names from previous processes.
24 //
25 // ======================================================================
26 
28 #include "cetlib/container_algorithms.h"
29 #include "fhiclcpp/ParameterSet.h"
30 #include <map>
31 #include <string>
32 #include <vector>
33 
34 namespace art {
35  class TriggerResults;
36  class TriggerNamesService;
37 }
38 
39 // ----------------------------------------------------------------------
40 
42 public:
43  using Strings = std::vector<std::string>;
44  using PosMap = std::map<std::string, unsigned int>;
45  using size_type = PosMap::size_type;
46 
48  std::vector<std::string> const& triggerPathNames);
49 
50  // Trigger path information for the current process
51  size_type
52  size() const
53  {
54  return trignames_.size();
55  }
56  Strings const&
57  getTrigPaths() const
58  {
59  return trignames_;
60  }
61  std::string const&
62  getTrigPath(size_type const i) const
63  {
64  return trignames_.at(i);
65  }
66  size_type
67  findTrigPath(std::string const& name) const
68  {
69  return find(trigpos_, name);
70  }
71 
72  // Get the ordered vector of trigger names that corresponds to the
73  // bits in the TriggerResults object. Unlike the other functions in
74  // this class, the next two functions will retrieve the names for
75  // previous processes. If the TriggerResults object is from the
76  // current process, this only works for modules in end paths,
77  // because the TriggerResults object is not created until the normal
78  // paths complete execution. Returns false if it fails to find the
79  // trigger path names.
80  bool getTrigPaths(TriggerResults const& triggerResults,
81  Strings& trigPaths) const;
82 
83  auto getTrigPathModules(std::string const& name) const -> Strings const&;
84  auto getTrigPathModules(size_type const i) const -> Strings const&;
85  std::string const& getTrigPathModule(std::string const& name,
86  size_type const j) const;
87  std::string const& getTrigPathModule(size_type const i,
88  size_type const j) const;
89 
90  size_type
91  find(PosMap const& posmap, std::string const& name) const
92  {
93  auto const pos = posmap.find(name);
94  if (pos == posmap.cend()) {
95  return posmap.size();
96  } else {
97  return pos->second;
98  }
99  }
100 
101  std::string const&
103  {
104  return process_name_;
105  }
106  bool
107  wantSummary() const
108  {
109  return wantSummary_;
110  }
111 
112  // Parameter set containing the trigger paths
113  fhicl::ParameterSet const&
115  {
116  return trigger_pset_;
117  }
118 
119 private:
124 
125  fhicl::ParameterSet trigger_pset_{}; // Parameter set of trigger paths
126  // (used by TriggerResults
127  // objects).
128  std::vector<Strings> modulenames_{}; // Labels of modules on trigger paths
129 
130  std::string process_name_;
132 }; // TriggerNamesService
133 
134 // ======================================================================
135 // Implementation
136 inline auto
137 art::TriggerNamesService::getTrigPathModules(std::string const& name) const
138  -> Strings const&
139 {
140  return modulenames_.at(find(trigpos_, name));
141 }
142 
143 inline auto
145  -> Strings const&
146 {
147  return modulenames_.at(i);
148 }
149 
150 inline std::string const&
152  size_type const j) const
153 {
154  return modulenames_.at(find(trigpos_, name)).at(j);
155 }
156 
157 inline std::string const&
159  size_type const j) const
160 {
161  return modulenames_.at(i).at(j);
162 }
163 
164 // ======================================================================
165 
167 #endif /* art_Framework_Services_System_TriggerNamesService_h */
168 
169 // Local Variables:
170 // mode: c++
171 // End:
size_type find(PosMap const &posmap, std::string const &name) const
#define DECLARE_ART_SYSTEM_SERVICE(svc, scope)
fhicl::ParameterSet trigger_pset_
Strings const & getTrigPaths() const
size_type findTrigPath(std::string const &name) const
std::vector< Strings > modulenames_
std::vector< std::string > Strings
std::string const & getTrigPath(size_type const i) const
std::string const & getTrigPathModule(std::string const &name, size_type const j) const
auto getTrigPathModules(std::string const &name) const -> Strings const &
TriggerNamesService(fhicl::ParameterSet const &procPS, std::vector< std::string > const &triggerPathNames)
std::string const & getProcessName() const
HLT enums.
std::map< std::string, unsigned int > PosMap
fhicl::ParameterSet const & getTriggerPSet() const