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 
16 namespace edm {
17  namespace service {
18 
20 
21  trigger_pset_ =
22  pset.getParameterSet("@trigger_paths");
23 
24  trignames_ = trigger_pset_.getParameter<Strings>("@trigger_paths");
25  end_names_ = pset.getParameter<Strings>("@end_paths");
26 
27  ParameterSet defopts;
28  ParameterSet const& opts =
29  pset.getUntrackedParameterSet("options", defopts);
30  wantSummary_ =
31  opts.getUntrackedParameter("wantSummary", false);
32 
33  process_name_ = pset.getParameter<std::string>("@process_name");
34 
36  loadPosMap(end_pos_,end_names_);
37 
38  const unsigned int n(trignames_.size());
39  for(unsigned int i = 0; i != n; ++i) {
40  modulenames_.push_back(pset.getParameter<Strings>(trignames_[i]));
41  }
42  for(unsigned int i = 0; i != end_names_.size(); ++i) {
43  end_modulenames_.push_back(pset.getParameter<Strings>(end_names_[i]));
44  }
45  }
46 
47  bool
49  Strings& trigPaths,
50  bool& fromPSetRegistry) {
51 
52  // Get the parameter set containing the trigger names from the parameter set registry
53  // using the ID from TriggerResults as the key used to find it.
54  ParameterSet const* pset = nullptr;
55  pset::Registry const* psetRegistry = pset::Registry::instance();
56  if (nullptr != (pset = psetRegistry->getMapped(triggerResults.parameterSetID()))) {
57 
58  // Check to make sure the parameter set contains
59  // a Strings parameter named "trigger_paths".
60  // We do not want to throw an exception if it is not there
61  // for reasons of backward compatibility
62  Strings const& psetNames = pset->getParameterNamesForType<Strings>();
63  std::string name("@trigger_paths");
64  if (search_all(psetNames, name)) {
65  // It is there, get it
66  trigPaths = pset->getParameter<Strings>("@trigger_paths");
67 
68  // This should never happen
69  if (trigPaths.size() != triggerResults.size()) {
71  << "TriggerNamesService::getTrigPaths, Trigger names vector and\n"
72  "TriggerResults are different sizes. This should be impossible,\n"
73  "please send information to reproduce this problem to\n"
74  "the edm developers.\n";
75  }
76 
77  fromPSetRegistry = true;
78  return true;
79  }
80  }
81 
82  fromPSetRegistry = false;
83 
84  // In older versions of the code the the trigger names were stored
85  // inside of the TriggerResults object. This will provide backward
86  // compatibility.
87  if (triggerResults.size() == triggerResults.getTriggerNames().size()) {
88  trigPaths = triggerResults.getTriggerNames();
89  return true;
90  }
91 
92  return false;
93  }
94 
95  bool
97  Strings& trigPaths) {
98  bool dummy;
99  return getTrigPaths(triggerResults, trigPaths, dummy);
100  }
101  }
102 }
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:193
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:19
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:46
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:13