CMS 3D CMS Logo

TriggerNamesService.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Implementation:
4 //
5 // Original Author: Jim Kowalkowski
6 //
7 
14 
15 namespace edm {
16  namespace service {
17 
19  trigger_pset_ = pset.getParameterSet("@trigger_paths");
20 
21  trignames_ = trigger_pset_.getParameter<Strings>("@trigger_paths");
22  end_names_ = pset.getParameter<Strings>("@end_paths");
23 
24  ParameterSet defopts;
25  ParameterSet const& opts = pset.getUntrackedParameterSet("options", defopts);
26  wantSummary_ = opts.getUntrackedParameter("wantSummary", false);
27 
28  process_name_ = pset.getParameter<std::string>("@process_name");
29 
31  loadPosMap(end_pos_, end_names_);
32 
33  const unsigned int n(trignames_.size());
34  for (unsigned int i = 0; i != n; ++i) {
35  modulenames_.push_back(pset.getParameter<Strings>(trignames_[i]));
36  }
37  for (unsigned int i = 0; i != end_names_.size(); ++i) {
38  end_modulenames_.push_back(pset.getParameter<Strings>(end_names_[i]));
39  }
40  }
41 
43  Strings& trigPaths,
44  bool& fromPSetRegistry) {
45  // Get the parameter set containing the trigger names from the parameter set registry
46  // using the ID from TriggerResults as the key used to find it.
47  ParameterSet const* pset = nullptr;
48  pset::Registry const* psetRegistry = pset::Registry::instance();
49  if (nullptr != (pset = psetRegistry->getMapped(triggerResults.parameterSetID()))) {
50  // Check to make sure the parameter set contains
51  // a Strings parameter named "trigger_paths".
52  // We do not want to throw an exception if it is not there
53  // for reasons of backward compatibility
54  Strings const& psetNames = pset->getParameterNamesForType<Strings>();
55  std::string name("@trigger_paths");
56  if (search_all(psetNames, name)) {
57  // It is there, get it
58  trigPaths = pset->getParameter<Strings>("@trigger_paths");
59 
60  // This should never happen
61  if (trigPaths.size() != triggerResults.size()) {
63  << "TriggerNamesService::getTrigPaths, Trigger names vector and\n"
64  "TriggerResults are different sizes. This should be impossible,\n"
65  "please send information to reproduce this problem to\n"
66  "the edm developers.\n";
67  }
68 
69  fromPSetRegistry = true;
70  return true;
71  }
72  }
73 
74  fromPSetRegistry = false;
75 
76  // In older versions of the code the the trigger names were stored
77  // inside of the TriggerResults object. This will provide backward
78  // compatibility.
79  if (triggerResults.size() == triggerResults.getTriggerNames().size()) {
80  trigPaths = triggerResults.getTriggerNames();
81  return true;
82  }
83 
84  return false;
85  }
86 
88  bool dummy;
89  return getTrigPaths(triggerResults, trigPaths, dummy);
90  }
91  } // namespace service
92 } // namespace edm
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > Strings
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void loadPosMap(PosMap &posmap, Strings const &names)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:169
const std::vector< std::string > & getTriggerNames() const
Obsolete.
unsigned int size() const
Get number of paths stored.
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
ParameterSet const & getParameterSet(std::string const &) const
static std::string const triggerResults("TriggerResults")
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:36
std::vector< Strings > end_modulenames_
HLT enums.
Strings const & getTrigPaths() const
TriggerNamesService(ParameterSet const &proc_pset)
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
static Registry * instance()
Definition: Registry.cc:12