CMS 3D CMS Logo

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