LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::TriggerNamesService Class Reference

#include "TriggerNamesService.h"

Classes

struct  DataPerProcess
 

Public Member Functions

 TriggerNamesService (fhicl::ParameterSet const &trigger_paths_pset, fhicl::ParameterSet const &physics_pset)
 
TriggerResults const & triggerResults (Event const &e, std::string const &process_name="current_process") const
 
std::map< std::string, HLTPathStatuspathResults (Event const &e, std::string const &process_name="current_process") const
 
std::string const & getProcessName () const
 
std::vector< std::string > const & getTrigPaths () const
 
std::string const & getTrigPath (PathID const id) const
 
PathID findTrigPath (std::string const &name) const
 
std::vector< std::string > const & getTrigPathModules (std::string const &name) const
 
std::vector< std::string > const & getTrigPathModules (PathID id) const
 
size_t index_for (PathID id) const
 

Private Member Functions

size_t index_ (detail::entry_selector_t selector) const
 
DataPerProcess const & currentData_ () const
 

Private Attributes

std::map< std::string, DataPerProcessdataPerProcess_
 

Detailed Description

Definition at line 44 of file TriggerNamesService.h.

Constructor & Destructor Documentation

art::TriggerNamesService::TriggerNamesService ( fhicl::ParameterSet const &  trigger_paths_pset,
fhicl::ParameterSet const &  physics_pset 
)

Definition at line 71 of file TriggerNamesService_service.cc.

74  {
75  dataPerProcess_.try_emplace(
76  getProcessName(), data_for_process(trigger_paths_pset, physics_pset));
77  }
std::string const & getProcessName() const
std::map< std::string, DataPerProcess > dataPerProcess_

Member Function Documentation

DataPerProcess const & art::TriggerNamesService::currentData_ ( ) const
private

Definition at line 80 of file TriggerNamesService_service.cc.

81  {
82  return dataPerProcess_.at(getProcessName());
83  }
std::string const & getProcessName() const
std::map< std::string, DataPerProcess > dataPerProcess_
PathID art::TriggerNamesService::findTrigPath ( std::string const &  name) const
string const & art::TriggerNamesService::getProcessName ( ) const

Definition at line 137 of file TriggerNamesService_service.cc.

References instance.

138  {
139  return Globals::instance()->processName();
140  }
std::string const & processName() const
Definition: Globals.cc:48
static Globals * instance()
Definition: Globals.cc:17
string const & art::TriggerNamesService::getTrigPath ( PathID const  id) const

Definition at line 149 of file TriggerNamesService_service.cc.

References art::errors::OtherArt, and fhicl::to_string().

150  {
151  auto const i = index_for(id);
152  if (i == invalid_entry) {
154  << "A path name could not be found corresponding to path ID "
155  << to_string(id) << '\n';
156  }
157  return currentData_().triggerPathSpecs[i].name;
158  }
size_t index_for(PathID id) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
DataPerProcess const & currentData_() const
vector< string > const & art::TriggerNamesService::getTrigPathModules ( std::string const &  name) const

Definition at line 161 of file TriggerNamesService_service.cc.

162  {
163  auto const& modules = currentData_().moduleNames;
164  return modules.at(index_(for_(name)));
165  }
size_t index_(detail::entry_selector_t selector) const
std::vector< std::vector< std::string > > moduleNames
DataPerProcess const & currentData_() const
vector< string > const & art::TriggerNamesService::getTrigPathModules ( PathID  id) const

Definition at line 168 of file TriggerNamesService_service.cc.

169  {
170  auto const& modules = currentData_().moduleNames;
171  return modules.at(index_for(id));
172  }
size_t index_for(PathID id) const
std::vector< std::vector< std::string > > moduleNames
DataPerProcess const & currentData_() const
vector< string > const & art::TriggerNamesService::getTrigPaths ( ) const

Definition at line 143 of file TriggerNamesService_service.cc.

144  {
146  }
std::vector< std::string > triggerPathNames
DataPerProcess const & currentData_() const
size_t art::TriggerNamesService::index_ ( detail::entry_selector_t  selector) const
private

Definition at line 181 of file TriggerNamesService_service.cc.

References util::begin(), e, util::end(), and art::detail::path_specs().

182  {
183  auto const& path_specs = currentData_().triggerPathSpecs;
184 
185  auto const b = begin(path_specs);
186  auto const e = end(path_specs);
187  auto it = find_if(b, e, matched_entry);
188  if (it == e) {
189  return invalid_entry;
190  }
191  return distance(b, it);
192  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
std::vector< PathSpec > path_specs(std::vector< std::string > const &path_spec_strs)
Definition: PathSpec.cc:34
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
Float_t e
Definition: plot.C:35
DataPerProcess const & currentData_() const
size_t art::TriggerNamesService::index_for ( PathID  id) const

Definition at line 175 of file TriggerNamesService_service.cc.

176  {
177  return index_(for_(id));
178  }
size_t index_(detail::entry_selector_t selector) const
map< string, HLTPathStatus > art::TriggerNamesService::pathResults ( Event const &  e,
std::string const &  process_name = "current_process" 
) const

Definition at line 99 of file TriggerNamesService_service.cc.

References util::cend(), fhicl::ParameterSetRegistry::get(), art::ProcessHistory::getConfigurationForProcess(), n, art::Event::processHistory(), and util::size().

101  {
102  auto const& tr = triggerResults(e, process_name);
103  auto const& pname =
104  process_name == "current_process" ? getProcessName() : process_name;
105 
106  auto it = dataPerProcess_.find(process_name);
107  if (it == cend(dataPerProcess_)) {
108  auto config = e.processHistory().getConfigurationForProcess(pname);
109  if (not config) {
110  throw lookup_exception(pname)
111  << "Could not locate process configuration for the process '" << pname
112  << "'\n"
113  << "This can happen if the ParameterSets were dropped on input.\n"
114  << "Please contact artists@fnal.gov for guidance.\n";
115  }
116 
117  auto const& trigger_pset = ParameterSetRegistry::get(tr.parameterSetID());
118  auto const& pset = ParameterSetRegistry::get(config->parameterSetID());
119  auto data =
120  data_for_process(trigger_pset, pset.get<ParameterSet>("physics"));
121  it = dataPerProcess_.try_emplace(process_name, std::move(data)).first;
122  }
123 
124  auto const& names = it->second.triggerPathNames;
125  assert(size(names) == tr.size());
126 
127  map<string, HLTPathStatus> result;
128  for (size_t i = 0, n = tr.size(); i != n; ++i) {
129  result.try_emplace(names[i], tr.at(i));
130  }
131  return result;
132  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
std::string const & getProcessName() const
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
TriggerResults const & triggerResults(Event const &e, std::string const &process_name="current_process") const
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
Char_t n[5]
Float_t e
Definition: plot.C:35
std::map< std::string, DataPerProcess > dataPerProcess_
TriggerResults const & art::TriggerNamesService::triggerResults ( Event const &  e,
std::string const &  process_name = "current_process" 
) const

Definition at line 88 of file TriggerNamesService_service.cc.

References art::ProductRetriever::getHandle().

90  {
91  auto h = e.getHandle<TriggerResults>({"TriggerResults", "", process_name});
92  if (h) {
93  return *h;
94  }
95  throw lookup_exception(process_name) << *h.whyFailed();
96  }
Float_t e
Definition: plot.C:35

Member Data Documentation

std::map<std::string, DataPerProcess> art::TriggerNamesService::dataPerProcess_
mutableprivate

Definition at line 80 of file TriggerNamesService.h.


The documentation for this class was generated from the following files: