LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
TriggerNamesService_service.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // TriggerNamesService
4 //
5 // ======================================================================
6 
8 
11 #include "cetlib/container_algorithms.h"
12 #include "cetlib_except/exception.h"
14 
16 using namespace cet;
17 using namespace fhicl;
18 using namespace std;
19 
20 // ----------------------------------------------------------------------
21 
22 TriggerNamesService::TriggerNamesService(ParameterSet const& procPS,
23  Strings const& trigger_path_names)
24  : trignames_{trigger_path_names}
25  , process_name_{procPS.get<string>("process_name")}
26  , wantSummary_{procPS.get<bool>("services.scheduler.wantSummary", false)}
27 {
28  // Make and hold onto a parameter set for posterity.
29  trigger_pset_.put("trigger_paths", trignames_);
30  ParameterSetRegistry::put(trigger_pset_);
31 
32  auto const& physics = procPS.get<ParameterSet>("physics", {});
33  end_names_ = physics.get<Strings>("end_paths", {});
34 
35  auto assign_position = [](auto& posmap, size_type const i, auto const& name) {
36  posmap[name] = i;
37  };
38 
39  using namespace std::placeholders;
40  cet::for_all_with_index(
41  trignames_, std::bind(assign_position, std::ref(trigpos_), _1, _2));
42  cet::for_all_with_index(
43  end_names_, std::bind(assign_position, std::ref(end_pos_), _1, _2));
44 
45  cet::transform_all(
46  trignames_,
47  std::back_inserter(modulenames_),
48  [&physics](std::string const& par) { return physics.get<Strings>(par); });
49 } // c'tor
50 
51 // ----------------------------------------------------------------------
52 
53 bool
55  Strings& trigPaths) const
56 {
57  ParameterSet pset;
58  if (!ParameterSetRegistry::get(triggerResults.parameterSetID(), pset)) {
59  return false;
60  }
61  auto tmpPaths = pset.get<Strings>("trigger_paths", {});
62  if (tmpPaths.size() != triggerResults.size()) {
64  << "TriggerNamesService::getTrigPaths, Trigger names vector and\n"
65  "TriggerResults are different sizes. This should be impossible,\n"
66  "please send information to reproduce this problem to\n"
67  "the ART developers.\n";
68  }
69  std::swap(tmpPaths, trigPaths);
70  return true;
71 }
fhicl::ParameterSet trigger_pset_
Strings const & getTrigPaths() const
STL namespace.
std::vector< Strings > modulenames_
std::vector< std::string > Strings
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::size_t size() const
fhicl::ParameterSetID const & parameterSetID() const
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void put(std::string const &key)