CMS 3D CMS Logo

ParameterSet.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // definition of ParameterSet's function members
4 // ----------------------------------------------------------------------
5 
6 // ----------------------------------------------------------------------
7 // prerequisite source files and headers
8 // ----------------------------------------------------------------------
9 
11 
18 
20 
21 #include <algorithm>
22 #include <iostream>
23 #include <sstream>
24 #include <cassert>
25 
26 // ----------------------------------------------------------------------
27 // class invariant checker
28 // ----------------------------------------------------------------------
29 
30 namespace edm {
31 
32  namespace pset::exceptions {
33  void throwWrongNumberOfElements(std::string const& iName, size_t iExpected, size_t iGot) {
34  throw Exception(errors::Configuration) << "The parameter '" << iName << "' should have " << iExpected
35  << " elements, but has " << iGot << " elements in the configuration.\n";
36  }
37  } // namespace pset::exceptions
38 
40  // We have added a new parameter. Invalidate the ID.
41  if (isRegistered()) {
42  id_ = ParameterSetID();
43  if (!nameOfTracked.empty()) {
44  // Give a warning (informational for now).
45  LogInfo("ParameterSet") << "Warning: You have added a new tracked parameter\n"
46  << "'" << nameOfTracked << "' to a previously registered parameter set.\n"
47  << "This is a bad idea because the new parameter(s) will not be recorded.\n"
48  << "Use the forthcoming ParameterSetDescription facility instead.\n"
49  << "A warning is given only for the first such parameter in a pset.\n";
50  }
51  }
52  assert(!isRegistered());
53  }
54 
55  // ----------------------------------------------------------------------
56  // constructors
57  // ----------------------------------------------------------------------
58 
59  ParameterSet::ParameterSet() : tbl_(), psetTable_(), vpsetTable_(), id_() {}
60 
61  // ----------------------------------------------------------------------
62  // from coded string
63 
64  ParameterSet::ParameterSet(std::string const& code) : tbl_(), psetTable_(), vpsetTable_(), id_() {
65  if (!fromString(code)) {
66  throw Exception(errors::Configuration, "InvalidInput")
67  << "The encoded configuration string "
68  << "passed to a ParameterSet during construction is invalid:\n"
69  << code;
70  }
71  }
72 
73  // ----------------------------------------------------------------------
74  // from coded string and ID.
75 
77  : tbl_(), psetTable_(), vpsetTable_(), id_(id) {
78  if (!fromString(code)) {
79  throw Exception(errors::Configuration, "InvalidInput")
80  << "The encoded configuration string "
81  << "passed to a ParameterSet during construction is invalid:\n"
82  << code;
83  }
84  }
85 
87  // from coded string. Will cause registration
88  cms::Digest dg(rep);
89  edm::ParameterSetID psID(dg.digest().toString());
90  edm::ParameterSet ps(rep, psID);
92  }
93 
95  cms::Digest newDigest;
96  ParameterSet().toDigest(newDigest);
97  return ParameterSetID(newDigest.digest().toString());
98  }
99 
102  swap(temp);
103  id_ = ParameterSetID();
104  }
105 
107  tbl_.swap(other.tbl_);
108  psetTable_.swap(other.psetTable_);
109  vpsetTable_.swap(other.vpsetTable_);
110  id_.swap(other.id_);
111  }
112 
114  if (!isRegistered()) {
115  calculateID();
117  }
118  return *this;
119  }
120 
121  std::unique_ptr<ParameterSet> ParameterSet::popParameterSet(std::string const& name) {
122  assert(!isRegistered());
123  psettable::iterator it = psetTable_.find(name);
124  assert(it != psetTable_.end());
125  auto pset = std::make_unique<ParameterSet>();
126  std::swap(*pset, it->second.psetForUpdate());
127  psetTable_.erase(it);
128  return pset;
129  }
130 
132  assert(!isRegistered());
133  table::iterator it = tbl_.find(name);
134  assert(it != tbl_.end());
135  tbl_.erase(it);
136  }
137 
139  assert(!isRegistered());
140  psettable::iterator it = psetTable_.find(name);
141  assert(it != psetTable_.end());
142  ParameterSet& pset = it->second.psetForUpdate();
143  if (pset.isRegistered()) {
144  it->second.setIsTracked(false);
145  } else {
146  psetTable_.erase(it);
147  }
148  }
149 
150  std::vector<ParameterSet> ParameterSet::popVParameterSet(std::string const& name) {
151  assert(!isRegistered());
152  vpsettable::iterator it = vpsetTable_.find(name);
153  assert(it != vpsetTable_.end());
154  std::vector<ParameterSet> vpset;
155  std::swap(vpset, it->second.vpsetForUpdate());
156  vpsetTable_.erase(it);
157  return vpset;
158  }
159 
161  // make sure contained tracked psets are updated
162  for (auto& item : psetTable_) {
163  ParameterSet& pset = item.second.psetForUpdate();
164  if (!pset.isRegistered()) {
165  pset.registerIt();
166  }
167  item.second.updateID();
168  }
169 
170  // make sure contained tracked vpsets are updated
171  for (vpsettable::iterator i = vpsetTable_.begin(), e = vpsetTable_.end(); i != e; ++i) {
172  i->second.registerPsetsAndUpdateIDs();
173  }
174  // The old, string base code is found below. Uncomment this and the assert to check whether
175  // there are discrepancies between old and new implementation.
176  // std::string stringrep;
177  // toString(stringrep);
178  // cms::Digest md5alg(stringrep);
179  // id_ = ParameterSetID(md5alg.digest().toString());
180  cms::Digest newDigest;
181  toDigest(newDigest);
182  id_ = ParameterSetID(newDigest.digest().toString());
183  // assert(md5alg.digest().toString() == newDigest.digest().toString());
184  assert(isRegistered());
185  }
186 
187  // ----------------------------------------------------------------------
188  // identification
190  // checks if valid
191  if (!isRegistered()) {
192  throw Exception(errors::LogicError) << "ParameterSet::id() called prematurely\n"
193  << "before ParameterSet::registerIt() has been called.\n";
194  }
195  return id_;
196  }
197 
198  void ParameterSet::setID(ParameterSetID const& id) { id_ = id; }
199 
200  // ----------------------------------------------------------------------
201  // Entry-handling
202  // ----------------------------------------------------------------------
203 
206  }
207 
210  if (result == nullptr)
211  throw Exception(errors::Configuration, "MissingParameter:")
212  << "The required parameter '" << name << "' was not specified.\n";
213  return result;
214  }
215 
216  template <typename T, typename U>
217  T first(std::pair<T, U> const& p) {
218  return p.first;
219  }
220 
221  template <typename T, typename U>
222  U second(std::pair<T, U> const& p) {
223  return p.second;
224  }
225 
226  Entry const& ParameterSet::retrieve(char const* name) const { return retrieve(std::string(name)); }
227 
229  table::const_iterator it = tbl_.find(name);
230  if (it == tbl_.end()) {
231  throw Exception(errors::Configuration, "MissingParameter:") << "Parameter '" << name << "' not found.";
232  }
233  if (it->second.isTracked() == false) {
234  if (name[0] == '@') {
235  throw Exception(errors::Configuration, "StatusMismatch:")
236  << "Framework Error: Parameter '" << name << "' is incorrectly designated as tracked in the framework.";
237  } else {
238  throw Exception(errors::Configuration, "StatusMismatch:")
239  << "Parameter '" << name << "' is designated as tracked in the code,\n"
240  << "but is designated as untracked in the configuration file.\n"
241  << "Please remove 'untracked' from the configuration file for parameter '" << name << "'.";
242  }
243  }
244  return it->second;
245  } // retrieve()
246 
248 
250  table::const_iterator it = tbl_.find(name);
251 
252  if (it == tbl_.end())
253  return nullptr;
254  if (it->second.isTracked()) {
255  if (name[0] == '@') {
256  throw Exception(errors::Configuration, "StatusMismatch:")
257  << "Framework Error: Parameter '" << name << "' is incorrectly designated as untracked in the framework.";
258  } else {
259  throw Exception(errors::Configuration, "StatusMismatch:")
260  << "Parameter '" << name << "' is designated as untracked in the code,\n"
261  << "but is not designated as untracked in the configuration file.\n"
262  << "Please change the configuration file to 'untracked <type> " << name << "'.";
263  }
264  }
265  return &it->second;
266  } // retrieve()
267 
269  psettable::const_iterator it = psetTable_.find(name);
270  if (it == psetTable_.end()) {
271  throw Exception(errors::Configuration, "MissingParameter:") << "ParameterSet '" << name << "' not found.";
272  }
273  if (it->second.isTracked() == false) {
274  if (name[0] == '@') {
275  throw Exception(errors::Configuration, "StatusMismatch:")
276  << "Framework Error: ParameterSet '" << name << "' is incorrectly designated as tracked in the framework.";
277  } else {
278  throw Exception(errors::Configuration, "StatusMismatch:")
279  << "ParameterSet '" << name << "' is designated as tracked in the code,\n"
280  << "but is designated as untracked in the configuration file.\n"
281  << "Please remove 'untracked' from the configuration file for parameter '" << name << "'.";
282  }
283  }
284  return it->second;
285  } // retrieve()
286 
288  psettable::const_iterator it = psetTable_.find(name);
289 
290  if (it == psetTable_.end())
291  return nullptr;
292  if (it->second.isTracked()) {
293  if (name[0] == '@') {
294  throw Exception(errors::Configuration, "StatusMismatch:")
295  << "Framework Error: ParameterSet '" << name
296  << "' is incorrectly designated as untracked in the framework.";
297  } else {
298  throw Exception(errors::Configuration, "StatusMismatch:")
299  << "ParameterSet '" << name << "' is designated as untracked in the code,\n"
300  << "but is not designated as untracked in the configuration file.\n"
301  << "Please change the configuration file to 'untracked <type> " << name << "'.";
302  }
303  }
304  return &it->second;
305  } // retrieve()
306 
308  vpsettable::const_iterator it = vpsetTable_.find(name);
309  if (it == vpsetTable_.end()) {
310  throw Exception(errors::Configuration, "MissingParameter:") << "VParameterSet '" << name << "' not found.";
311  }
312  if (it->second.isTracked() == false) {
313  throw Exception(errors::Configuration, "StatusMismatch:")
314  << "VParameterSet '" << name << "' is designated as tracked in the code,\n"
315  << "but is designated as untracked in the configuration file.\n"
316  << "Please remove 'untracked' from the configuration file for parameter '" << name << "'.";
317  }
318  return it->second;
319  } // retrieve()
320 
322  vpsettable::const_iterator it = vpsetTable_.find(name);
323 
324  if (it == vpsetTable_.end())
325  return nullptr;
326  if (it->second.isTracked()) {
327  throw Exception(errors::Configuration, "StatusMismatch:")
328  << "VParameterSet '" << name << "' is designated as untracked in the code,\n"
329  << "but is not designated as untracked in the configuration file.\n"
330  << "Please change the configuration file to 'untracked <type> " << name << "'.";
331  }
332  return &it->second;
333  } // retrieve()
334 
335  Entry const* ParameterSet::retrieveUnknown(char const* name) const { return retrieveUnknown(std::string(name)); }
336 
338  table::const_iterator it = tbl_.find(name);
339  if (it == tbl_.end()) {
340  return nullptr;
341  }
342  return &it->second;
343  }
344 
346  psettable::const_iterator it = psetTable_.find(name);
347  if (it == psetTable_.end()) {
348  return nullptr;
349  }
350  return &it->second;
351  }
352 
354  vpsettable::const_iterator it = vpsetTable_.find(name);
355  if (it == vpsetTable_.end()) {
356  return nullptr;
357  }
358  return &it->second;
359  }
360 
361  // ----------------------------------------------------------------------
362  // ----------------------------------------------------------------------
363 
365  if (existsAs<ParameterSet>(name)) {
367  } else if (existsAs<std::vector<ParameterSet> >(name)) {
369  } else if (exists(name)) {
370  return retrieveUnknown(name)->toString();
371  } else {
372  throw Exception(errors::Configuration, "getParameterAsString")
373  << "Cannot find parameter " << name << " in " << *this;
374  }
375  }
376 
377  // ----------------------------------------------------------------------
378  // ----------------------------------------------------------------------
379 
380  void ParameterSet::insert(bool okay_to_replace, char const* name, Entry const& value) {
381  insert(okay_to_replace, std::string(name), value);
382  }
383 
384  void ParameterSet::insert(bool okay_to_replace, std::string const& name, Entry const& value) {
385  // We should probably get rid of 'okay_to_replace', which will
386  // simplify the logic in this function.
387  table::iterator it = tbl_.find(name);
388 
389  if (it == tbl_.end()) {
390  if (!tbl_.insert(std::make_pair(name, value)).second)
391  throw Exception(errors::Configuration, "InsertFailure") << "cannot insert " << name << " into a ParameterSet\n";
392  } else if (okay_to_replace) {
393  it->second = value;
394  }
395  } // insert()
396 
397  void ParameterSet::insertParameterSet(bool okay_to_replace, std::string const& name, ParameterSetEntry const& entry) {
398  // We should probably get rid of 'okay_to_replace', which will
399  // simplify the logic in this function.
400  psettable::iterator it = psetTable_.find(name);
401 
402  if (it == psetTable_.end()) {
403  if (!psetTable_.insert(std::make_pair(name, entry)).second)
404  throw Exception(errors::Configuration, "InsertFailure") << "cannot insert " << name << " into a ParameterSet\n";
405  } else if (okay_to_replace) {
406  it->second = entry;
407  }
408  } // insert()
409 
410  void ParameterSet::insertVParameterSet(bool okay_to_replace,
411  std::string const& name,
412  VParameterSetEntry const& entry) {
413  // We should probably get rid of 'okay_to_replace', which will
414  // simplify the logic in this function.
415  vpsettable::iterator it = vpsetTable_.find(name);
416 
417  if (it == vpsetTable_.end()) {
418  if (!vpsetTable_.insert(std::make_pair(name, entry)).second)
419  throw Exception(errors::Configuration, "InsertFailure")
420  << "cannot insert " << name << " into a VParameterSet\n";
421  } else if (okay_to_replace) {
422  it->second = entry;
423  }
424  } // insert()
425 
427  // This preemptive invalidation may be more agressive than necessary.
429  if (&from == this) {
430  return;
431  }
432 
433  for (table::const_iterator b = from.tbl_.begin(), e = from.tbl_.end(); b != e; ++b) {
434  this->insert(false, b->first, b->second);
435  }
436  for (psettable::const_iterator b = from.psetTable_.begin(), e = from.psetTable_.end(); b != e; ++b) {
437  this->insertParameterSet(false, b->first, b->second);
438  }
439  for (vpsettable::const_iterator b = from.vpsetTable_.begin(), e = from.vpsetTable_.end(); b != e; ++b) {
440  this->insertVParameterSet(false, b->first, b->second);
441  }
442  } // augment()
443 
446  if (from.existsAs<ParameterSet>(name)) {
447  this->insertParameterSet(false, name, *(from.retrieveUnknownParameterSet(name)));
448  } else if (from.existsAs<std::vector<ParameterSet> >(name)) {
449  this->insertVParameterSet(false, name, *(from.retrieveUnknownVParameterSet(name)));
450  } else if (from.exists(name)) {
451  this->insert(false, name, *(from.retrieveUnknown(name)));
452  } else {
453  throw Exception(errors::Configuration, "copyFrom") << "Cannot find parameter " << name << " in " << from;
454  }
455  }
456 
458  assert(!isRegistered());
459  isTracked = false;
460  psettable::iterator it = psetTable_.find(name);
461  if (it == psetTable_.end())
462  return nullptr;
463  isTracked = it->second.isTracked();
464  return &it->second.psetForUpdate();
465  }
466 
468  assert(!isRegistered());
469  vpsettable::iterator it = vpsetTable_.find(name);
470  if (it == vpsetTable_.end())
471  return nullptr;
472  return &it->second;
473  }
474 
475  // ----------------------------------------------------------------------
476  // coding
477  // ----------------------------------------------------------------------
478 
480 
482 
483  void ParameterSet::toStringImp(std::string& rep, bool useAll) const {
484  // make sure the PSets get filled
485  if (empty()) {
486  rep += "<>";
487  return;
488  }
489  size_t size = 1;
490  for (table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
491  if (useAll || b->second.isTracked()) {
492  size += 2;
493  size += b->first.size();
494  size += b->second.sizeOfString();
495  }
496  }
497  for (psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
498  if (useAll || b->second.isTracked()) {
499  size += 2;
500  size += b->first.size();
501  size += b->first.size();
502  size += b->first.size();
503  size += sizeof(ParameterSetID);
504  }
505  }
506  for (vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
507  if (useAll || b->second.isTracked()) {
508  size += 2;
509  size += b->first.size();
510  size += sizeof(ParameterSetID) * b->second.vpset().size();
511  }
512  }
513 
514  rep.reserve(rep.size() + size);
515  rep += '<';
517  std::string const between(";");
518  for (table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
519  if (useAll || b->second.isTracked()) {
520  rep += start;
521  rep += b->first;
522  rep += '=';
523  b->second.toString(rep);
524  start = between;
525  }
526  }
527  for (psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
528  if (useAll || b->second.isTracked()) {
529  rep += start;
530  rep += b->first;
531  rep += '=';
532  b->second.toString(rep);
533  start = between;
534  }
535  }
536  for (vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
537  if (useAll || b->second.isTracked()) {
538  rep += start;
539  rep += b->first;
540  rep += '=';
541  b->second.toString(rep);
542  start = between;
543  }
544  }
545 
546  rep += '>';
547  } // to_string()
548 
549  void ParameterSet::toDigest(cms::Digest& digest) const {
550  digest.append("<", 1);
551  bool started = false;
552  for (table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
553  if (b->second.isTracked()) {
554  if (started)
555  digest.append(";", 1);
556  digest.append(b->first);
557  digest.append("=", 1);
558  b->second.toDigest(digest);
559  started = true;
560  }
561  }
562  for (psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
563  if (b->second.isTracked()) {
564  if (started)
565  digest.append(";", 1);
566  digest.append(b->first);
567  digest.append("=", 1);
568  b->second.toDigest(digest);
569  started = true;
570  }
571  }
572  for (vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
573  if (b->second.isTracked()) {
574  if (started)
575  digest.append(";", 1);
576  digest.append(b->first);
577  digest.append("=", 1);
578  b->second.toDigest(digest);
579  }
580  }
581 
582  digest.append(">", 1);
583  }
584 
587  toString(result);
588  return result;
589  }
590 
591  // ----------------------------------------------------------------------
592 
594  std::vector<std::string> temp;
595  if (!split(std::back_inserter(temp), from, '<', ';', '>'))
596  return false;
597 
598  tbl_.clear(); // precaution
599  for (std::vector<std::string>::const_iterator b = temp.begin(), e = temp.end(); b != e; ++b) {
600  // locate required name/value separator
601  std::string::const_iterator q = find_in_all(*b, '=');
602  if (q == b->end())
603  return false;
604 
605  // form name unique to this ParameterSet
606  std::string name = std::string(b->begin(), q);
607  if (tbl_.find(name) != tbl_.end())
608  return false;
609 
610  std::string rep(q + 1, b->end());
611  // entries are generically of the form tracked-type-rep
612  if (rep[0] == '-') {
613  }
614  if (rep[1] == 'Q') {
615  ParameterSetEntry psetEntry(rep);
616  if (!psetTable_.insert(std::make_pair(name, psetEntry)).second) {
617  return false;
618  }
619  } else if (rep[1] == 'q') {
620  VParameterSetEntry vpsetEntry(rep);
621  if (!vpsetTable_.insert(std::make_pair(name, vpsetEntry)).second) {
622  return false;
623  }
624  } else if (rep[1] == 'P') {
625  Entry value(name, rep);
626  ParameterSetEntry psetEntry(value.getPSet(), value.isTracked());
627  if (!psetTable_.insert(std::make_pair(name, psetEntry)).second) {
628  return false;
629  }
630  } else if (rep[1] == 'p') {
631  Entry value(name, rep);
632  VParameterSetEntry vpsetEntry(value.getVPSet(), value.isTracked());
633  if (!vpsetTable_.insert(std::make_pair(name, vpsetEntry)).second) {
634  return false;
635  }
636  } else {
637  // form value and insert name/value pair
638  Entry value(name, rep);
639  if (!tbl_.insert(std::make_pair(name, value)).second) {
640  return false;
641  }
642  }
643  }
644 
645  return true;
646  } // from_string()
647 
650  table::const_iterator it = tbl_.begin();
651  table::const_iterator end = tbl_.end();
652  while (it != end) {
653  Entry const& e = it->second;
654  if (e.typeCode() == 'F') {
655  ++count;
656  output.push_back(e.getFileInPath());
657  }
658  ++it;
659  }
660  return count;
661  }
662 
663  std::vector<std::string> ParameterSet::getParameterNames() const {
664  using std::placeholders::_1;
665  std::vector<std::string> returnValue;
666  std::transform(tbl_.begin(),
667  tbl_.end(),
668  back_inserter(returnValue),
670  std::transform(psetTable_.begin(),
671  psetTable_.end(),
672  back_inserter(returnValue),
674  std::transform(vpsetTable_.begin(),
675  vpsetTable_.end(),
676  back_inserter(returnValue),
678  return returnValue;
679  }
680 
681  bool ParameterSet::exists(std::string const& parameterName) const {
682  return (tbl_.find(parameterName) != tbl_.end() || psetTable_.find(parameterName) != psetTable_.end() ||
683  vpsetTable_.find(parameterName) != vpsetTable_.end());
684  }
685 
688  for (table::const_iterator tblItr = tbl_.begin(); tblItr != tbl_.end(); ++tblItr) {
689  if (tblItr->second.isTracked()) {
690  result.tbl_.insert(*tblItr);
691  }
692  }
693  for (psettable::const_iterator psetItr = psetTable_.begin(); psetItr != psetTable_.end(); ++psetItr) {
694  if (psetItr->second.isTracked()) {
695  result.addParameter<ParameterSet>(psetItr->first, psetItr->second.pset().trackedPart());
696  }
697  }
698  for (vpsettable::const_iterator vpsetItr = vpsetTable_.begin(); vpsetItr != vpsetTable_.end(); ++vpsetItr) {
699  if (vpsetItr->second.isTracked()) {
700  VParameterSet vresult;
701  std::vector<ParameterSet> const& this_vpset = vpsetItr->second.vpset();
702 
703  typedef std::vector<ParameterSet>::const_iterator Iter;
704  for (Iter i = this_vpset.begin(), e = this_vpset.end(); i != e; ++i) {
705  vresult.push_back(i->trackedPart());
706  }
707  result.addParameter<VParameterSet>(vpsetItr->first, vresult);
708  }
709  }
710  return result;
711  }
712 
713  /*
714  // Comment out unneeded function
715  size_t
716  ParameterSet::getAllParameterSetNames(std::vector<std::string>& output) const {
717  using std::placeholders::_1;
718  std::transform(psetTable_.begin(), psetTable_.end(), back_inserter(output),
719  std::bind(&std::pair<std::string const, ParameterSetEntry>::first, _1));
720  return output.size();
721  }
722 */
723 
724  size_t ParameterSet::getParameterSetNames(std::vector<std::string>& output, bool trackiness) const {
725  for (psettable::const_iterator psetItr = psetTable_.begin(); psetItr != psetTable_.end(); ++psetItr) {
726  if (psetItr->second.isTracked() == trackiness) {
727  output.push_back(psetItr->first);
728  }
729  }
730  return output.size();
731  }
732 
733  size_t ParameterSet::getParameterSetVectorNames(std::vector<std::string>& output, bool trackiness) const {
734  for (vpsettable::const_iterator vpsetItr = vpsetTable_.begin(); vpsetItr != vpsetTable_.end(); ++vpsetItr) {
735  if (vpsetItr->second.isTracked() == trackiness) {
736  output.push_back(vpsetItr->first);
737  }
738  }
739  return output.size();
740  }
741 
742  size_t ParameterSet::getNamesByCode_(char code, bool trackiness, std::vector<std::string>& output) const {
743  size_t count = 0;
744  if (code == 'Q') {
745  return getParameterSetNames(output, trackiness);
746  }
747  if (code == 'q') {
748  return getParameterSetVectorNames(output, trackiness);
749  }
750  table::const_iterator it = tbl_.begin();
751  table::const_iterator end = tbl_.end();
752  while (it != end) {
753  Entry const& e = it->second;
754  if (e.typeCode() == code && e.isTracked() == trackiness) { // if it is a vector of ParameterSet
755  ++count;
756  output.push_back(it->first); // save the name
757  }
758  ++it;
759  }
760  return count;
761  }
762 
763  template <>
764  std::vector<std::string> ParameterSet::getParameterNamesForType<FileInPath>(bool trackiness) const {
765  std::vector<std::string> result;
766  getNamesByCode_('F', trackiness, result);
767  return result;
768  }
769 
770  bool operator==(ParameterSet const& a, ParameterSet const& b) {
771  if (a.isRegistered() && b.isRegistered()) {
772  return (a.id() == b.id());
773  }
774  return isTransientEqual(a.trackedPart(), b.trackedPart());
775  }
776 
778  if (a.tbl().size() != b.tbl().size()) {
779  return false;
780  }
781  if (a.psetTable().size() != b.psetTable().size()) {
782  return false;
783  }
784  if (a.vpsetTable().size() != b.vpsetTable().size()) {
785  return false;
786  }
787  typedef ParameterSet::table::const_iterator Ti;
788  for (Ti i = a.tbl().begin(), e = a.tbl().end(), j = b.tbl().begin(), f = b.tbl().end(); i != e && j != f;
789  ++i, ++j) {
790  if (*i != *j) {
791  return false;
792  }
793  }
794  typedef ParameterSet::psettable::const_iterator Pi;
795  for (Pi i = a.psetTable().begin(), e = a.psetTable().end(), j = b.psetTable().begin(), f = b.psetTable().end();
796  i != e && j != f;
797  ++i, ++j) {
798  if (i->first != j->first) {
799  return false;
800  }
801  if (i->second.isTracked() != j->second.isTracked()) {
802  return false;
803  }
804  if (!isTransientEqual(i->second.pset(), j->second.pset())) {
805  return false;
806  }
807  }
808  typedef ParameterSet::vpsettable::const_iterator PVi;
809  for (PVi i = a.vpsetTable().begin(), e = a.vpsetTable().end(), j = b.vpsetTable().begin(), f = b.vpsetTable().end();
810  i != e && j != f;
811  ++i, ++j) {
812  if (i->first != j->first) {
813  return false;
814  }
815  if (i->second.isTracked() != j->second.isTracked()) {
816  return false;
817  }
818  std::vector<ParameterSet> const& iv = i->second.vpset();
819  std::vector<ParameterSet> const& jv = j->second.vpset();
820  if (iv.size() != jv.size()) {
821  return false;
822  }
823  for (size_t k = 0; k < iv.size(); ++k) {
824  if (!isTransientEqual(iv[k], jv[k])) {
825  return false;
826  }
827  }
828  }
829  return true;
830  }
831 
832  std::string ParameterSet::dump(unsigned int indent) const {
833  std::ostringstream os;
834  // indent a bit
836  os << "{" << std::endl;
837  for (table::const_iterator i = tbl_.begin(), e = tbl_.end(); i != e; ++i) {
838  os << indentation << " " << i->first << ": " << i->second << std::endl;
839  }
840  for (psettable::const_iterator i = psetTable_.begin(), e = psetTable_.end(); i != e; ++i) {
841  // indent a bit
842  std::string n = i->first;
843  ParameterSetEntry const& pe = i->second;
844  os << indentation << " " << n << ": " << pe.dump(indent + 2) << std::endl;
845  }
846  for (vpsettable::const_iterator i = vpsetTable_.begin(), e = vpsetTable_.end(); i != e; ++i) {
847  // indent a bit
848  std::string n = i->first;
849  VParameterSetEntry const& pe = i->second;
850  os << indentation << " " << n << ": " << pe.dump(indent + 2) << std::endl;
851  }
852  os << indentation << "}";
853  return os.str();
854  }
855 
856  std::ostream& operator<<(std::ostream& os, ParameterSet const& pset) {
857  os << pset.dump();
858  return os;
859  }
860 
861  // Free function to return a parameterSet given its ID.
863  ParameterSet const* result = nullptr;
864  if (nullptr == (result = pset::Registry::instance()->getMapped(id))) {
865  throw Exception(errors::LogicError, "MissingParameterSet:") << "Parameter Set ID '" << id << "' not found.";
866  }
867  return *result;
868  }
869 
871  return getParameterSet(moduleDescription.mainParameterSetID());
872  }
873 
875  LogWarning("Configuration") << "Warning:\n\tstring " << name << " = \"" << label << "\"\nis deprecated, "
876  << "please update your config file to use\n\tInputTag " << name << " = " << label;
877  }
878 
879  // specializations
880  // ----------------------------------------------------------------------
881  // Bool, vBool
882 
883  template <>
884  bool ParameterSet::getParameter<bool>(std::string const& name) const {
885  return retrieve(name).getBool();
886  }
887 
888  // ----------------------------------------------------------------------
889  // Int32, vInt32
890 
891  template <>
892  int ParameterSet::getParameter<int>(std::string const& name) const {
893  return retrieve(name).getInt32();
894  }
895 
896  template <>
897  std::vector<int> ParameterSet::getParameter<std::vector<int> >(std::string const& name) const {
898  return retrieve(name).getVInt32();
899  }
900 
901  // ----------------------------------------------------------------------
902  // Int64, vInt64
903 
904  template <>
905  long long ParameterSet::getParameter<long long>(std::string const& name) const {
906  return retrieve(name).getInt64();
907  }
908 
909  template <>
910  std::vector<long long> ParameterSet::getParameter<std::vector<long long> >(std::string const& name) const {
911  return retrieve(name).getVInt64();
912  }
913 
914  // ----------------------------------------------------------------------
915  // Uint32, vUint32
916 
917  template <>
918  unsigned int ParameterSet::getParameter<unsigned int>(std::string const& name) const {
919  return retrieve(name).getUInt32();
920  }
921 
922  template <>
923  std::vector<unsigned int> ParameterSet::getParameter<std::vector<unsigned int> >(std::string const& name) const {
924  return retrieve(name).getVUInt32();
925  }
926 
927  // ----------------------------------------------------------------------
928  // Uint64, vUint64
929 
930  template <>
931  unsigned long long ParameterSet::getParameter<unsigned long long>(std::string const& name) const {
932  return retrieve(name).getUInt64();
933  }
934 
935  template <>
936  std::vector<unsigned long long> ParameterSet::getParameter<std::vector<unsigned long long> >(
937  std::string const& name) const {
938  return retrieve(name).getVUInt64();
939  }
940 
941  // ----------------------------------------------------------------------
942  // Double, vDouble
943 
944  template <>
945  double ParameterSet::getParameter<double>(std::string const& name) const {
946  return retrieve(name).getDouble();
947  }
948 
949  template <>
950  std::vector<double> ParameterSet::getParameter<std::vector<double> >(std::string const& name) const {
951  return retrieve(name).getVDouble();
952  }
953 
954  // ----------------------------------------------------------------------
955  // String, vString
956 
957  template <>
958  std::string ParameterSet::getParameter<std::string>(std::string const& name) const {
959  return retrieve(name).getString();
960  }
961 
962  template <>
963  std::vector<std::string> ParameterSet::getParameter<std::vector<std::string> >(std::string const& name) const {
964  return retrieve(name).getVString();
965  }
966 
967  // ----------------------------------------------------------------------
968  // FileInPath
969 
970  template <>
971  FileInPath ParameterSet::getParameter<FileInPath>(std::string const& name) const {
972  return retrieve(name).getFileInPath();
973  }
974 
975  // ----------------------------------------------------------------------
976  // InputTag
977 
978  template <>
979  InputTag ParameterSet::getParameter<InputTag>(std::string const& name) const {
980  Entry const& e_input = retrieve(name);
981  switch (e_input.typeCode()) {
982  case 't': // InputTag
983  return e_input.getInputTag();
984  case 'S': // string
985  std::string const& label = e_input.getString();
987  return InputTag(label);
988  }
989  throw Exception(errors::Configuration, "ValueError")
990  << "type of " << name << " is expected to be InputTag or string (deprecated)";
991  }
992 
993  // ----------------------------------------------------------------------
994  // VInputTag
995 
996  template <>
997  std::vector<InputTag> ParameterSet::getParameter<std::vector<InputTag> >(std::string const& name) const {
998  return retrieve(name).getVInputTag();
999  }
1000 
1001  // ----------------------------------------------------------------------
1002  // ESInputTag
1003 
1004  template <>
1005  ESInputTag ParameterSet::getParameter<ESInputTag>(std::string const& name) const {
1006  return retrieve(name).getESInputTag();
1007  }
1008 
1009  // ----------------------------------------------------------------------
1010  // VESInputTag
1011 
1012  template <>
1013  std::vector<ESInputTag> ParameterSet::getParameter<std::vector<ESInputTag> >(std::string const& name) const {
1014  return retrieve(name).getVESInputTag();
1015  }
1016 
1017  // ----------------------------------------------------------------------
1018  // EventID
1019 
1020  template <>
1021  EventID ParameterSet::getParameter<EventID>(std::string const& name) const {
1022  return retrieve(name).getEventID();
1023  }
1024 
1025  // ----------------------------------------------------------------------
1026  // VEventID
1027 
1028  template <>
1029  std::vector<EventID> ParameterSet::getParameter<std::vector<EventID> >(std::string const& name) const {
1030  return retrieve(name).getVEventID();
1031  }
1032 
1033  // ----------------------------------------------------------------------
1034  // LuminosityBlockID
1035 
1036  template <>
1037  LuminosityBlockID ParameterSet::getParameter<LuminosityBlockID>(std::string const& name) const {
1039  }
1040 
1041  // ----------------------------------------------------------------------
1042  // VLuminosityBlockID
1043 
1044  template <>
1045  std::vector<LuminosityBlockID> ParameterSet::getParameter<std::vector<LuminosityBlockID> >(
1046  std::string const& name) const {
1047  return retrieve(name).getVLuminosityBlockID();
1048  }
1049 
1050  // ----------------------------------------------------------------------
1051  // EventRange
1052 
1053  template <>
1054  EventRange ParameterSet::getParameter<EventRange>(std::string const& name) const {
1055  return retrieve(name).getEventRange();
1056  }
1057 
1058  // ----------------------------------------------------------------------
1059  // VEventRange
1060 
1061  template <>
1062  std::vector<EventRange> ParameterSet::getParameter<std::vector<EventRange> >(std::string const& name) const {
1063  return retrieve(name).getVEventRange();
1064  }
1065 
1066  // ----------------------------------------------------------------------
1067  // LuminosityBlockRange
1068 
1069  template <>
1070  LuminosityBlockRange ParameterSet::getParameter<LuminosityBlockRange>(std::string const& name) const {
1072  }
1073 
1074  // ----------------------------------------------------------------------
1075  // VLuminosityBlockRange
1076 
1077  template <>
1078  std::vector<LuminosityBlockRange> ParameterSet::getParameter<std::vector<LuminosityBlockRange> >(
1079  std::string const& name) const {
1080  return retrieve(name).getVLuminosityBlockRange();
1081  }
1082 
1083  // ----------------------------------------------------------------------
1084  // PSet, vPSet
1085 
1086  template <>
1087  ParameterSet ParameterSet::getParameter<ParameterSet>(std::string const& name) const {
1088  return getParameterSet(name);
1089  }
1090 
1091  template <>
1092  VParameterSet ParameterSet::getParameter<VParameterSet>(std::string const& name) const {
1093  return getParameterSetVector(name);
1094  }
1095 
1096  // untracked parameters
1097 
1098  // ----------------------------------------------------------------------
1099  // Bool, vBool
1100 
1101  template <>
1102  bool ParameterSet::getUntrackedParameter<bool>(std::string const& name, bool const& defaultValue) const {
1103  Entry const* entryPtr = retrieveUntracked(name);
1104  return entryPtr == nullptr ? defaultValue : entryPtr->getBool();
1105  }
1106 
1107  template <>
1108  bool ParameterSet::getUntrackedParameter<bool>(std::string const& name) const {
1110  }
1111 
1112  // ----------------------------------------------------------------------
1113  // Int32, vInt32
1114 
1115  template <>
1116  int ParameterSet::getUntrackedParameter<int>(std::string const& name, int const& defaultValue) const {
1117  Entry const* entryPtr = retrieveUntracked(name);
1118  return entryPtr == nullptr ? defaultValue : entryPtr->getInt32();
1119  }
1120 
1121  template <>
1122  int ParameterSet::getUntrackedParameter<int>(std::string const& name) const {
1124  }
1125 
1126  template <>
1127  std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(std::string const& name,
1128  std::vector<int> const& defaultValue) const {
1129  Entry const* entryPtr = retrieveUntracked(name);
1130  return entryPtr == nullptr ? defaultValue : entryPtr->getVInt32();
1131  }
1132 
1133  template <>
1134  std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(std::string const& name) const {
1135  return getEntryPointerOrThrow_(name)->getVInt32();
1136  }
1137 
1138  // ----------------------------------------------------------------------
1139  // Uint32, vUint32
1140 
1141  template <>
1142  unsigned int ParameterSet::getUntrackedParameter<unsigned int>(std::string const& name,
1143  unsigned int const& defaultValue) const {
1144  Entry const* entryPtr = retrieveUntracked(name);
1145  return entryPtr == nullptr ? defaultValue : entryPtr->getUInt32();
1146  }
1147 
1148  template <>
1149  unsigned int ParameterSet::getUntrackedParameter<unsigned int>(std::string const& name) const {
1151  }
1152 
1153  template <>
1154  std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(
1155  std::string const& name, std::vector<unsigned int> const& defaultValue) const {
1156  Entry const* entryPtr = retrieveUntracked(name);
1157  return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt32();
1158  }
1159 
1160  template <>
1161  std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(
1162  std::string const& name) const {
1163  return getEntryPointerOrThrow_(name)->getVUInt32();
1164  }
1165 
1166  // ----------------------------------------------------------------------
1167  // Uint64, vUint64
1168 
1169  template <>
1170  unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(
1171  std::string const& name, unsigned long long const& defaultValue) const {
1172  Entry const* entryPtr = retrieveUntracked(name);
1173  return entryPtr == nullptr ? defaultValue : entryPtr->getUInt64();
1174  }
1175 
1176  template <>
1177  unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(std::string const& name) const {
1179  }
1180 
1181  template <>
1182  std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1183  std::string const& name, std::vector<unsigned long long> const& defaultValue) const {
1184  Entry const* entryPtr = retrieveUntracked(name);
1185  return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt64();
1186  }
1187 
1188  template <>
1189  std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1190  std::string const& name) const {
1191  return getEntryPointerOrThrow_(name)->getVUInt64();
1192  }
1193 
1194  // ----------------------------------------------------------------------
1195  // Int64, Vint64
1196 
1197  template <>
1198  long long ParameterSet::getUntrackedParameter<long long>(std::string const& name,
1199  long long const& defaultValue) const {
1200  Entry const* entryPtr = retrieveUntracked(name);
1201  return entryPtr == nullptr ? defaultValue : entryPtr->getInt64();
1202  }
1203 
1204  template <>
1205  long long ParameterSet::getUntrackedParameter<long long>(std::string const& name) const {
1207  }
1208 
1209  template <>
1210  std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(
1211  std::string const& name, std::vector<long long> const& defaultValue) const {
1212  Entry const* entryPtr = retrieveUntracked(name);
1213  return entryPtr == nullptr ? defaultValue : entryPtr->getVInt64();
1214  }
1215 
1216  template <>
1217  std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(std::string const& name) const {
1218  return getEntryPointerOrThrow_(name)->getVInt64();
1219  }
1220 
1221  // ----------------------------------------------------------------------
1222  // Double, vDouble
1223 
1224  template <>
1225  double ParameterSet::getUntrackedParameter<double>(std::string const& name, double const& defaultValue) const {
1226  Entry const* entryPtr = retrieveUntracked(name);
1227  return entryPtr == nullptr ? defaultValue : entryPtr->getDouble();
1228  }
1229 
1230  template <>
1231  double ParameterSet::getUntrackedParameter<double>(std::string const& name) const {
1233  }
1234 
1235  template <>
1236  std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(
1237  std::string const& name, std::vector<double> const& defaultValue) const {
1238  Entry const* entryPtr = retrieveUntracked(name);
1239  return entryPtr == nullptr ? defaultValue : entryPtr->getVDouble();
1240  }
1241 
1242  template <>
1243  std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(std::string const& name) const {
1244  return getEntryPointerOrThrow_(name)->getVDouble();
1245  }
1246 
1247  // ----------------------------------------------------------------------
1248  // String, vString
1249 
1250  template <>
1251  std::string ParameterSet::getUntrackedParameter<std::string>(std::string const& name,
1252  std::string const& defaultValue) const {
1253  Entry const* entryPtr = retrieveUntracked(name);
1254  return entryPtr == nullptr ? defaultValue : entryPtr->getString();
1255  }
1256 
1257  template <>
1258  std::string ParameterSet::getUntrackedParameter<std::string>(std::string const& name) const {
1259  return getEntryPointerOrThrow_(name)->getString();
1260  }
1261 
1262  template <>
1263  std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(
1264  std::string const& name, std::vector<std::string> const& defaultValue) const {
1265  Entry const* entryPtr = retrieveUntracked(name);
1266  return entryPtr == nullptr ? defaultValue : entryPtr->getVString();
1267  }
1268 
1269  template <>
1270  std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(
1271  std::string const& name) const {
1272  return getEntryPointerOrThrow_(name)->getVString();
1273  }
1274 
1275  // ----------------------------------------------------------------------
1276  // FileInPath
1277 
1278  template <>
1279  FileInPath ParameterSet::getUntrackedParameter<FileInPath>(std::string const& name,
1280  FileInPath const& defaultValue) const {
1281  Entry const* entryPtr = retrieveUntracked(name);
1282  return entryPtr == nullptr ? defaultValue : entryPtr->getFileInPath();
1283  }
1284 
1285  template <>
1286  FileInPath ParameterSet::getUntrackedParameter<FileInPath>(std::string const& name) const {
1288  }
1289 
1290  // ----------------------------------------------------------------------
1291  // InputTag, VInputTag
1292 
1293  template <>
1294  InputTag ParameterSet::getUntrackedParameter<InputTag>(std::string const& name, InputTag const& defaultValue) const {
1295  Entry const* entryPtr = retrieveUntracked(name);
1296  return entryPtr == nullptr ? defaultValue : entryPtr->getInputTag();
1297  }
1298 
1299  template <>
1300  InputTag ParameterSet::getUntrackedParameter<InputTag>(std::string const& name) const {
1302  }
1303 
1304  template <>
1305  std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(
1306  std::string const& name, std::vector<InputTag> const& defaultValue) const {
1307  Entry const* entryPtr = retrieveUntracked(name);
1308  return entryPtr == nullptr ? defaultValue : entryPtr->getVInputTag();
1309  }
1310 
1311  template <>
1312  std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(std::string const& name) const {
1313  return getEntryPointerOrThrow_(name)->getVInputTag();
1314  }
1315 
1316  // ----------------------------------------------------------------------
1317  // ESInputTag, VESInputTag
1318 
1319  template <>
1320  ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(std::string const& name,
1321  ESInputTag const& defaultValue) const {
1322  Entry const* entryPtr = retrieveUntracked(name);
1323  return entryPtr == nullptr ? defaultValue : entryPtr->getESInputTag();
1324  }
1325 
1326  template <>
1327  ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(std::string const& name) const {
1329  }
1330 
1331  template <>
1332  std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(
1333  std::string const& name, std::vector<ESInputTag> const& defaultValue) const {
1334  Entry const* entryPtr = retrieveUntracked(name);
1335  return entryPtr == nullptr ? defaultValue : entryPtr->getVESInputTag();
1336  }
1337 
1338  template <>
1339  std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(std::string const& name) const {
1340  return getEntryPointerOrThrow_(name)->getVESInputTag();
1341  }
1342 
1343  // ----------------------------------------------------------------------
1344  // EventID, VEventID
1345 
1346  template <>
1347  EventID ParameterSet::getUntrackedParameter<EventID>(std::string const& name, EventID const& defaultValue) const {
1348  Entry const* entryPtr = retrieveUntracked(name);
1349  return entryPtr == nullptr ? defaultValue : entryPtr->getEventID();
1350  }
1351 
1352  template <>
1353  EventID ParameterSet::getUntrackedParameter<EventID>(std::string const& name) const {
1355  }
1356 
1357  template <>
1358  std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(
1359  std::string const& name, std::vector<EventID> const& defaultValue) const {
1360  Entry const* entryPtr = retrieveUntracked(name);
1361  return entryPtr == nullptr ? defaultValue : entryPtr->getVEventID();
1362  }
1363 
1364  template <>
1365  std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(std::string const& name) const {
1366  return getEntryPointerOrThrow_(name)->getVEventID();
1367  }
1368 
1369  // ----------------------------------------------------------------------
1370  // LuminosityBlockID, VLuminosityBlockID
1371 
1372  template <>
1373  LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(
1374  std::string const& name, LuminosityBlockID const& defaultValue) const {
1375  Entry const* entryPtr = retrieveUntracked(name);
1376  return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockID();
1377  }
1378 
1379  template <>
1380  LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(std::string const& name) const {
1382  }
1383 
1384  template <>
1385  std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
1386  std::string const& name, std::vector<LuminosityBlockID> const& defaultValue) const {
1387  Entry const* entryPtr = retrieveUntracked(name);
1388  return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockID();
1389  }
1390 
1391  template <>
1392  std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
1393  std::string const& name) const {
1394  return getEntryPointerOrThrow_(name)->getVLuminosityBlockID();
1395  }
1396 
1397  // ----------------------------------------------------------------------
1398  // EventRange, VEventRange
1399 
1400  template <>
1401  EventRange ParameterSet::getUntrackedParameter<EventRange>(std::string const& name,
1402  EventRange const& defaultValue) const {
1403  Entry const* entryPtr = retrieveUntracked(name);
1404  return entryPtr == nullptr ? defaultValue : entryPtr->getEventRange();
1405  }
1406 
1407  template <>
1408  EventRange ParameterSet::getUntrackedParameter<EventRange>(std::string const& name) const {
1410  }
1411 
1412  template <>
1413  std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(
1414  std::string const& name, std::vector<EventRange> const& defaultValue) const {
1415  Entry const* entryPtr = retrieveUntracked(name);
1416  return entryPtr == nullptr ? defaultValue : entryPtr->getVEventRange();
1417  }
1418 
1419  template <>
1420  std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(std::string const& name) const {
1421  return getEntryPointerOrThrow_(name)->getVEventRange();
1422  }
1423 
1424  // ----------------------------------------------------------------------
1425  // LuminosityBlockRange, VLuminosityBlockRange
1426 
1427  template <>
1428  LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(
1429  std::string const& name, LuminosityBlockRange const& defaultValue) const {
1430  Entry const* entryPtr = retrieveUntracked(name);
1431  return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockRange();
1432  }
1433 
1434  template <>
1435  LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(std::string const& name) const {
1437  }
1438 
1439  template <>
1440  std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
1441  std::string const& name, std::vector<LuminosityBlockRange> const& defaultValue) const {
1442  Entry const* entryPtr = retrieveUntracked(name);
1443  return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockRange();
1444  }
1445 
1446  template <>
1447  std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
1448  std::string const& name) const {
1449  return getEntryPointerOrThrow_(name)->getVLuminosityBlockRange();
1450  }
1451 
1452  // specializations
1453  // ----------------------------------------------------------------------
1454  // Bool, vBool
1455 
1456  template <>
1457  bool ParameterSet::getParameter<bool>(char const* name) const {
1458  return retrieve(name).getBool();
1459  }
1460 
1461  // ----------------------------------------------------------------------
1462  // Int32, vInt32
1463 
1464  template <>
1465  int ParameterSet::getParameter<int>(char const* name) const {
1466  return retrieve(name).getInt32();
1467  }
1468 
1469  template <>
1470  std::vector<int> ParameterSet::getParameter<std::vector<int> >(char const* name) const {
1471  return retrieve(name).getVInt32();
1472  }
1473 
1474  // ----------------------------------------------------------------------
1475  // Int64, vInt64
1476 
1477  template <>
1478  long long ParameterSet::getParameter<long long>(char const* name) const {
1479  return retrieve(name).getInt64();
1480  }
1481 
1482  template <>
1483  std::vector<long long> ParameterSet::getParameter<std::vector<long long> >(char const* name) const {
1484  return retrieve(name).getVInt64();
1485  }
1486 
1487  // ----------------------------------------------------------------------
1488  // Uint32, vUint32
1489 
1490  template <>
1491  unsigned int ParameterSet::getParameter<unsigned int>(char const* name) const {
1492  return retrieve(name).getUInt32();
1493  }
1494 
1495  template <>
1496  std::vector<unsigned int> ParameterSet::getParameter<std::vector<unsigned int> >(char const* name) const {
1497  return retrieve(name).getVUInt32();
1498  }
1499 
1500  // ----------------------------------------------------------------------
1501  // Uint64, vUint64
1502 
1503  template <>
1504  unsigned long long ParameterSet::getParameter<unsigned long long>(char const* name) const {
1505  return retrieve(name).getUInt64();
1506  }
1507 
1508  template <>
1509  std::vector<unsigned long long> ParameterSet::getParameter<std::vector<unsigned long long> >(char const* name) const {
1510  return retrieve(name).getVUInt64();
1511  }
1512 
1513  // ----------------------------------------------------------------------
1514  // Double, vDouble
1515 
1516  template <>
1517  double ParameterSet::getParameter<double>(char const* name) const {
1518  return retrieve(name).getDouble();
1519  }
1520 
1521  template <>
1522  std::vector<double> ParameterSet::getParameter<std::vector<double> >(char const* name) const {
1523  return retrieve(name).getVDouble();
1524  }
1525 
1526  // ----------------------------------------------------------------------
1527  // String, vString
1528 
1529  template <>
1530  std::string ParameterSet::getParameter<std::string>(char const* name) const {
1531  return retrieve(name).getString();
1532  }
1533 
1534  template <>
1535  std::vector<std::string> ParameterSet::getParameter<std::vector<std::string> >(char const* name) const {
1536  return retrieve(name).getVString();
1537  }
1538 
1539  // ----------------------------------------------------------------------
1540  // FileInPath
1541 
1542  template <>
1543  FileInPath ParameterSet::getParameter<FileInPath>(char const* name) const {
1544  return retrieve(name).getFileInPath();
1545  }
1546 
1547  // ----------------------------------------------------------------------
1548  // InputTag
1549 
1550  template <>
1551  InputTag ParameterSet::getParameter<InputTag>(char const* name) const {
1552  Entry const& e_input = retrieve(name);
1553  switch (e_input.typeCode()) {
1554  case 't': // InputTag
1555  return e_input.getInputTag();
1556  case 'S': // string
1557  std::string const& label = e_input.getString();
1559  return InputTag(label);
1560  }
1561  throw Exception(errors::Configuration, "ValueError")
1562  << "type of " << name << " is expected to be InputTag or string (deprecated)";
1563  }
1564 
1565  // ----------------------------------------------------------------------
1566  // VInputTag
1567 
1568  template <>
1569  std::vector<InputTag> ParameterSet::getParameter<std::vector<InputTag> >(char const* name) const {
1570  return retrieve(name).getVInputTag();
1571  }
1572 
1573  // ----------------------------------------------------------------------
1574  // ESInputTag
1575 
1576  template <>
1577  ESInputTag ParameterSet::getParameter<ESInputTag>(char const* name) const {
1578  return retrieve(name).getESInputTag();
1579  }
1580 
1581  // ----------------------------------------------------------------------
1582  // VESInputTag
1583 
1584  template <>
1585  std::vector<ESInputTag> ParameterSet::getParameter<std::vector<ESInputTag> >(char const* name) const {
1586  return retrieve(name).getVESInputTag();
1587  }
1588 
1589  // ----------------------------------------------------------------------
1590  // EventID
1591 
1592  template <>
1593  EventID ParameterSet::getParameter<EventID>(char const* name) const {
1594  return retrieve(name).getEventID();
1595  }
1596 
1597  // ----------------------------------------------------------------------
1598  // VEventID
1599 
1600  template <>
1601  std::vector<EventID> ParameterSet::getParameter<std::vector<EventID> >(char const* name) const {
1602  return retrieve(name).getVEventID();
1603  }
1604 
1605  // ----------------------------------------------------------------------
1606  // LuminosityBlockID
1607 
1608  template <>
1609  LuminosityBlockID ParameterSet::getParameter<LuminosityBlockID>(char const* name) const {
1611  }
1612 
1613  // ----------------------------------------------------------------------
1614  // VLuminosityBlockID
1615 
1616  template <>
1617  std::vector<LuminosityBlockID> ParameterSet::getParameter<std::vector<LuminosityBlockID> >(char const* name) const {
1618  return retrieve(name).getVLuminosityBlockID();
1619  }
1620 
1621  // ----------------------------------------------------------------------
1622  // EventRange
1623 
1624  template <>
1625  EventRange ParameterSet::getParameter<EventRange>(char const* name) const {
1626  return retrieve(name).getEventRange();
1627  }
1628 
1629  // ----------------------------------------------------------------------
1630  // VEventRange
1631 
1632  template <>
1633  std::vector<EventRange> ParameterSet::getParameter<std::vector<EventRange> >(char const* name) const {
1634  return retrieve(name).getVEventRange();
1635  }
1636 
1637  // ----------------------------------------------------------------------
1638  // LuminosityBlockRange
1639 
1640  template <>
1641  LuminosityBlockRange ParameterSet::getParameter<LuminosityBlockRange>(char const* name) const {
1643  }
1644 
1645  // ----------------------------------------------------------------------
1646  // VLuminosityBlockRange
1647 
1648  template <>
1649  std::vector<LuminosityBlockRange> ParameterSet::getParameter<std::vector<LuminosityBlockRange> >(
1650  char const* name) const {
1651  return retrieve(name).getVLuminosityBlockRange();
1652  }
1653 
1654  // ----------------------------------------------------------------------
1655  // PSet, vPSet
1656 
1657  template <>
1658  ParameterSet ParameterSet::getParameter<ParameterSet>(char const* name) const {
1659  return getParameterSet(name);
1660  }
1661 
1662  template <>
1663  VParameterSet ParameterSet::getParameter<VParameterSet>(char const* name) const {
1664  return getParameterSetVector(name);
1665  }
1666 
1667  // untracked parameters
1668 
1669  // ----------------------------------------------------------------------
1670  // Bool, vBool
1671 
1672  template <>
1673  bool ParameterSet::getUntrackedParameter<bool>(char const* name, bool const& defaultValue) const {
1674  Entry const* entryPtr = retrieveUntracked(name);
1675  return entryPtr == nullptr ? defaultValue : entryPtr->getBool();
1676  }
1677 
1678  template <>
1679  bool ParameterSet::getUntrackedParameter<bool>(char const* name) const {
1681  }
1682 
1683  // ----------------------------------------------------------------------
1684  // Int32, vInt32
1685 
1686  template <>
1687  int ParameterSet::getUntrackedParameter<int>(char const* name, int const& defaultValue) const {
1688  Entry const* entryPtr = retrieveUntracked(name);
1689  return entryPtr == nullptr ? defaultValue : entryPtr->getInt32();
1690  }
1691 
1692  template <>
1693  int ParameterSet::getUntrackedParameter<int>(char const* name) const {
1695  }
1696 
1697  template <>
1698  std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(char const* name,
1699  std::vector<int> const& defaultValue) const {
1700  Entry const* entryPtr = retrieveUntracked(name);
1701  return entryPtr == nullptr ? defaultValue : entryPtr->getVInt32();
1702  }
1703 
1704  template <>
1705  std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(char const* name) const {
1706  return getEntryPointerOrThrow_(name)->getVInt32();
1707  }
1708 
1709  // ----------------------------------------------------------------------
1710  // Uint32, vUint32
1711 
1712  template <>
1713  unsigned int ParameterSet::getUntrackedParameter<unsigned int>(char const* name,
1714  unsigned int const& defaultValue) const {
1715  Entry const* entryPtr = retrieveUntracked(name);
1716  return entryPtr == nullptr ? defaultValue : entryPtr->getUInt32();
1717  }
1718 
1719  template <>
1720  unsigned int ParameterSet::getUntrackedParameter<unsigned int>(char const* name) const {
1722  }
1723 
1724  template <>
1725  std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(
1726  char const* name, std::vector<unsigned int> const& defaultValue) const {
1727  Entry const* entryPtr = retrieveUntracked(name);
1728  return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt32();
1729  }
1730 
1731  template <>
1732  std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(char const* name) const {
1733  return getEntryPointerOrThrow_(name)->getVUInt32();
1734  }
1735 
1736  // ----------------------------------------------------------------------
1737  // Uint64, vUint64
1738 
1739  template <>
1740  unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(
1741  char const* name, unsigned long long const& defaultValue) const {
1742  Entry const* entryPtr = retrieveUntracked(name);
1743  return entryPtr == nullptr ? defaultValue : entryPtr->getUInt64();
1744  }
1745 
1746  template <>
1747  unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(char const* name) const {
1749  }
1750 
1751  template <>
1752  std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1753  char const* name, std::vector<unsigned long long> const& defaultValue) const {
1754  Entry const* entryPtr = retrieveUntracked(name);
1755  return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt64();
1756  }
1757 
1758  template <>
1759  std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1760  char const* name) const {
1761  return getEntryPointerOrThrow_(name)->getVUInt64();
1762  }
1763 
1764  // ----------------------------------------------------------------------
1765  // Int64, Vint64
1766 
1767  template <>
1768  long long ParameterSet::getUntrackedParameter<long long>(char const* name, long long const& defaultValue) const {
1769  Entry const* entryPtr = retrieveUntracked(name);
1770  return entryPtr == nullptr ? defaultValue : entryPtr->getInt64();
1771  }
1772 
1773  template <>
1774  long long ParameterSet::getUntrackedParameter<long long>(char const* name) const {
1776  }
1777 
1778  template <>
1779  std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(
1780  char const* name, std::vector<long long> const& defaultValue) const {
1781  Entry const* entryPtr = retrieveUntracked(name);
1782  return entryPtr == nullptr ? defaultValue : entryPtr->getVInt64();
1783  }
1784 
1785  template <>
1786  std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(char const* name) const {
1787  return getEntryPointerOrThrow_(name)->getVInt64();
1788  }
1789 
1790  // ----------------------------------------------------------------------
1791  // Double, vDouble
1792 
1793  template <>
1794  double ParameterSet::getUntrackedParameter<double>(char const* name, double const& defaultValue) const {
1795  Entry const* entryPtr = retrieveUntracked(name);
1796  return entryPtr == nullptr ? defaultValue : entryPtr->getDouble();
1797  }
1798 
1799  template <>
1800  double ParameterSet::getUntrackedParameter<double>(char const* name) const {
1802  }
1803 
1804  template <>
1805  std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(
1806  char const* name, std::vector<double> const& defaultValue) const {
1807  Entry const* entryPtr = retrieveUntracked(name);
1808  return entryPtr == nullptr ? defaultValue : entryPtr->getVDouble();
1809  }
1810 
1811  template <>
1812  std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(char const* name) const {
1813  return getEntryPointerOrThrow_(name)->getVDouble();
1814  }
1815 
1816  // ----------------------------------------------------------------------
1817  // String, vString
1818 
1819  template <>
1820  std::string ParameterSet::getUntrackedParameter<std::string>(char const* name,
1821  std::string const& defaultValue) const {
1822  Entry const* entryPtr = retrieveUntracked(name);
1823  return entryPtr == nullptr ? defaultValue : entryPtr->getString();
1824  }
1825 
1826  template <>
1827  std::string ParameterSet::getUntrackedParameter<std::string>(char const* name) const {
1828  return getEntryPointerOrThrow_(name)->getString();
1829  }
1830 
1831  template <>
1832  std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(
1833  char const* name, std::vector<std::string> const& defaultValue) const {
1834  Entry const* entryPtr = retrieveUntracked(name);
1835  return entryPtr == nullptr ? defaultValue : entryPtr->getVString();
1836  }
1837 
1838  template <>
1839  std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(char const* name) const {
1840  return getEntryPointerOrThrow_(name)->getVString();
1841  }
1842 
1843  // ----------------------------------------------------------------------
1844  // FileInPath
1845 
1846  template <>
1847  FileInPath ParameterSet::getUntrackedParameter<FileInPath>(char const* name, FileInPath const& defaultValue) const {
1848  Entry const* entryPtr = retrieveUntracked(name);
1849  return entryPtr == nullptr ? defaultValue : entryPtr->getFileInPath();
1850  }
1851 
1852  template <>
1853  FileInPath ParameterSet::getUntrackedParameter<FileInPath>(char const* name) const {
1855  }
1856 
1857  // ----------------------------------------------------------------------
1858  // InputTag, VInputTag
1859 
1860  template <>
1861  InputTag ParameterSet::getUntrackedParameter<InputTag>(char const* name, InputTag const& defaultValue) const {
1862  Entry const* entryPtr = retrieveUntracked(name);
1863  return entryPtr == nullptr ? defaultValue : entryPtr->getInputTag();
1864  }
1865 
1866  template <>
1867  InputTag ParameterSet::getUntrackedParameter<InputTag>(char const* name) const {
1869  }
1870 
1871  template <>
1872  std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(
1873  char const* name, std::vector<InputTag> const& defaultValue) const {
1874  Entry const* entryPtr = retrieveUntracked(name);
1875  return entryPtr == nullptr ? defaultValue : entryPtr->getVInputTag();
1876  }
1877 
1878  template <>
1879  std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(char const* name) const {
1880  return getEntryPointerOrThrow_(name)->getVInputTag();
1881  }
1882 
1883  // ----------------------------------------------------------------------
1884  // ESInputTag, VESInputTag
1885 
1886  template <>
1887  ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(char const* name, ESInputTag const& defaultValue) const {
1888  Entry const* entryPtr = retrieveUntracked(name);
1889  return entryPtr == nullptr ? defaultValue : entryPtr->getESInputTag();
1890  }
1891 
1892  template <>
1893  ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(char const* name) const {
1895  }
1896 
1897  template <>
1898  std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(
1899  char const* name, std::vector<ESInputTag> const& defaultValue) const {
1900  Entry const* entryPtr = retrieveUntracked(name);
1901  return entryPtr == nullptr ? defaultValue : entryPtr->getVESInputTag();
1902  }
1903 
1904  template <>
1905  std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(char const* name) const {
1906  return getEntryPointerOrThrow_(name)->getVESInputTag();
1907  }
1908 
1909  // ----------------------------------------------------------------------
1910  // EventID, VEventID
1911 
1912  template <>
1913  EventID ParameterSet::getUntrackedParameter<EventID>(char const* name, EventID const& defaultValue) const {
1914  Entry const* entryPtr = retrieveUntracked(name);
1915  return entryPtr == nullptr ? defaultValue : entryPtr->getEventID();
1916  }
1917 
1918  template <>
1919  EventID ParameterSet::getUntrackedParameter<EventID>(char const* name) const {
1921  }
1922 
1923  template <>
1924  std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(
1925  char const* name, std::vector<EventID> const& defaultValue) const {
1926  Entry const* entryPtr = retrieveUntracked(name);
1927  return entryPtr == nullptr ? defaultValue : entryPtr->getVEventID();
1928  }
1929 
1930  template <>
1931  std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(char const* name) const {
1932  return getEntryPointerOrThrow_(name)->getVEventID();
1933  }
1934 
1935  // ----------------------------------------------------------------------
1936  // LuminosityBlockID, VLuminosityBlockID
1937 
1938  template <>
1939  LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(
1940  char const* name, LuminosityBlockID const& defaultValue) const {
1941  Entry const* entryPtr = retrieveUntracked(name);
1942  return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockID();
1943  }
1944 
1945  template <>
1946  LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(char const* name) const {
1948  }
1949 
1950  template <>
1951  std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
1952  char const* name, std::vector<LuminosityBlockID> const& defaultValue) const {
1953  Entry const* entryPtr = retrieveUntracked(name);
1954  return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockID();
1955  }
1956 
1957  template <>
1958  std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
1959  char const* name) const {
1960  return getEntryPointerOrThrow_(name)->getVLuminosityBlockID();
1961  }
1962 
1963  // ----------------------------------------------------------------------
1964  // EventRange, VEventRange
1965 
1966  template <>
1967  EventRange ParameterSet::getUntrackedParameter<EventRange>(char const* name, EventRange const& defaultValue) const {
1968  Entry const* entryPtr = retrieveUntracked(name);
1969  return entryPtr == nullptr ? defaultValue : entryPtr->getEventRange();
1970  }
1971 
1972  template <>
1973  EventRange ParameterSet::getUntrackedParameter<EventRange>(char const* name) const {
1975  }
1976 
1977  template <>
1978  std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(
1979  char const* name, std::vector<EventRange> const& defaultValue) const {
1980  Entry const* entryPtr = retrieveUntracked(name);
1981  return entryPtr == nullptr ? defaultValue : entryPtr->getVEventRange();
1982  }
1983 
1984  template <>
1985  std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(char const* name) const {
1986  return getEntryPointerOrThrow_(name)->getVEventRange();
1987  }
1988 
1989  // ----------------------------------------------------------------------
1990  // LuminosityBlockRange, VLuminosityBlockRange
1991 
1992  template <>
1993  LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(
1994  char const* name, LuminosityBlockRange const& defaultValue) const {
1995  Entry const* entryPtr = retrieveUntracked(name);
1996  return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockRange();
1997  }
1998 
1999  template <>
2000  LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(char const* name) const {
2002  }
2003 
2004  template <>
2005  std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
2006  char const* name, std::vector<LuminosityBlockRange> const& defaultValue) const {
2007  Entry const* entryPtr = retrieveUntracked(name);
2008  return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockRange();
2009  }
2010 
2011  template <>
2012  std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
2013  char const* name) const {
2014  return getEntryPointerOrThrow_(name)->getVLuminosityBlockRange();
2015  }
2016 
2017  // ----------------------------------------------------------------------
2018  // PSet, vPSet
2019 
2020  template <>
2021  ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(char const* name,
2022  ParameterSet const& defaultValue) const {
2023  return getUntrackedParameterSet(name, defaultValue);
2024  }
2025 
2026  template <>
2027  VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(char const* name,
2028  VParameterSet const& defaultValue) const {
2029  return getUntrackedParameterSetVector(name, defaultValue);
2030  }
2031 
2032  template <>
2033  ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(std::string const& name,
2034  ParameterSet const& defaultValue) const {
2035  return getUntrackedParameterSet(name, defaultValue);
2036  }
2037 
2038  template <>
2039  VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(std::string const& name,
2040  VParameterSet const& defaultValue) const {
2041  return getUntrackedParameterSetVector(name, defaultValue);
2042  }
2043 
2044  template <>
2045  ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(char const* name) const {
2047  }
2048 
2049  template <>
2050  VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(char const* name) const {
2052  }
2053 
2054  template <>
2055  ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(std::string const& name) const {
2057  }
2058 
2059  template <>
2060  VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(std::string const& name) const {
2062  }
2063 
2064  //----------------------------------------------------------------------------------
2065  // specializations for addParameter and addUntrackedParameter
2066 
2067  template <>
2068  void ParameterSet::addParameter<ParameterSet>(std::string const& name, ParameterSet const& value) {
2071  }
2072 
2073  template <>
2074  void ParameterSet::addParameter<VParameterSet>(std::string const& name, VParameterSet const& value) {
2077  }
2078 
2079  template <>
2080  void ParameterSet::addParameter<ParameterSet>(char const* name, ParameterSet const& value) {
2083  }
2084 
2085  template <>
2086  void ParameterSet::addParameter<VParameterSet>(char const* name, VParameterSet const& value) {
2089  }
2090 
2091  template <>
2092  void ParameterSet::addUntrackedParameter<ParameterSet>(std::string const& name, ParameterSet const& value) {
2094  }
2095 
2096  template <>
2097  void ParameterSet::addUntrackedParameter<VParameterSet>(std::string const& name, VParameterSet const& value) {
2099  }
2100 
2101  template <>
2102  void ParameterSet::addUntrackedParameter<ParameterSet>(char const* name, ParameterSet const& value) {
2104  }
2105 
2106  template <>
2107  void ParameterSet::addUntrackedParameter<VParameterSet>(char const* name, VParameterSet const& value) {
2109  }
2110 
2111  //----------------------------------------------------------------------------------
2112  // specializations for getParameterNamesForType
2113 
2114  template <>
2115  std::vector<std::string> ParameterSet::getParameterNamesForType<ParameterSet>(bool trackiness) const {
2116  std::vector<std::string> output;
2117  getParameterSetNames(output, trackiness);
2118  return output;
2119  }
2120 
2121  template <>
2122  std::vector<std::string> ParameterSet::getParameterNamesForType<VParameterSet>(bool trackiness) const {
2123  std::vector<std::string> output;
2124  getParameterSetVectorNames(output, trackiness);
2125  return output;
2126  }
2127 
2129  return retrieveParameterSet(name).pset();
2130  }
2131 
2133  return retrieveParameterSet(name).pset();
2134  }
2135 
2137  return getUntrackedParameterSet(name.c_str(), defaultValue);
2138  }
2139 
2140  ParameterSet ParameterSet::getUntrackedParameterSet(char const* name, ParameterSet const& defaultValue) const {
2142  if (entryPtr == nullptr) {
2143  return defaultValue;
2144  }
2145  return entryPtr->pset();
2146  }
2147 
2149  return getUntrackedParameterSet(name.c_str());
2150  }
2151 
2154  if (result == nullptr)
2155  throw Exception(errors::Configuration, "MissingParameter:")
2156  << "The required ParameterSet '" << name << "' was not specified.\n";
2157  return result->pset();
2158  }
2159 
2161  return retrieveVParameterSet(name).vpset();
2162  }
2163 
2165  return retrieveVParameterSet(name).vpset();
2166  }
2167 
2169  VParameterSet const& defaultValue) const {
2170  return getUntrackedParameterSetVector(name.c_str(), defaultValue);
2171  }
2172 
2174  VParameterSet const& defaultValue) const {
2176  return entryPtr == nullptr ? defaultValue : entryPtr->vpset();
2177  }
2178 
2180  return getUntrackedParameterSetVector(name.c_str());
2181  }
2182 
2185  if (result == nullptr)
2186  throw Exception(errors::Configuration, "MissingParameter:")
2187  << "The required ParameterSetVector '" << name << "' was not specified.\n";
2188  return result->vpset();
2189  }
2190 } // namespace edm
edm::ParameterSet::registerIt
ParameterSet const & registerIt()
Definition: ParameterSet.cc:113
edm::ParameterSetID
Hash< ParameterSetType > ParameterSetID
Definition: ParameterSetID.h:21
edm::pset::Registry::instance
static Registry * instance()
Definition: Registry.cc:12
edm::ParameterSet::copyFrom
void copyFrom(ParameterSet const &from, std::string const &name)
Definition: ParameterSet.cc:444
edm::Entry::getEventRange
EventRange getEventRange() const
Definition: Entry.cc:1069
cms::Digest::append
void append(std::string const &s)
Definition: Digest.cc:161
edm::ParameterSet::psetTable_
psettable psetTable_
Definition: ParameterSet.h:266
edm::ParameterSet::tbl_
table tbl_
Definition: ParameterSet.h:265
edm::ParameterSet::insertParameterSet
void insertParameterSet(bool okay_to_replace, std::string const &name, ParameterSetEntry const &entry)
Definition: ParameterSet.cc:397
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
start
Definition: start.py:1
edm::ParameterSet::registerFromString
static void registerFromString(std::string const &rep)
Definition: ParameterSet.cc:86
edm::ParameterSet::getParameterSetVectorNames
size_t getParameterSetVectorNames(std::vector< std::string > &output, bool trackiness=true) const
Definition: ParameterSet.cc:733
MessageLogger.h
edm::ParameterSet::retrieve
Entry const & retrieve(char const *) const
Definition: ParameterSet.cc:226
edm::Entry::getDouble
double getDouble() const
Definition: Entry.cc:890
edm::find_in_all
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:26
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::ParameterSet::calculateID
void calculateID()
Definition: ParameterSet.cc:160
edm::Entry::getInt64
long long getInt64() const
Definition: Entry.cc:818
edm::ParameterSet::getUntrackedParameterSetVector
VParameterSet getUntrackedParameterSetVector(std::string const &name, VParameterSet const &defaultValue) const
Definition: ParameterSet.cc:2168
edm::Hash::swap
void swap(Hash< I > &other)
Definition: Hash.h:181
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
edm::VParameterSetEntry::dump
std::string dump(unsigned int indent=0) const
Definition: VParameterSetEntry.cc:119
cms::Digest::digest
MD5Result digest()
Definition: Digest.cc:171
edm::ParameterSet::getUntrackedParameterSet
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Definition: ParameterSet.cc:2136
edm::errors::LogicError
Definition: EDMException.h:37
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::ParameterSet::eraseOrSetUntrackedParameterSet
void eraseOrSetUntrackedParameterSet(std::string const &name)
Definition: ParameterSet.cc:138
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSet::toString
std::string toString() const
Definition: ParameterSet.cc:585
mps_splice.entry
entry
Definition: mps_splice.py:68
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
edm::Entry::getVDouble
std::vector< double > getVDouble() const
Definition: Entry.cc:902
edm::Entry::getVLuminosityBlockRange
std::vector< LuminosityBlockRange > getVLuminosityBlockRange() const
Definition: Entry.cc:1057
edm::Entry::typeCode
char typeCode() const
Definition: Entry.h:176
edm::Entry::getUInt64
unsigned long long getUInt64() const
Definition: Entry.cc:866
edm::Entry::getVUInt32
std::vector< unsigned > getVUInt32() const
Definition: Entry.cc:854
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::Entry::getVEventRange
std::vector< EventRange > getVEventRange() const
Definition: Entry.cc:1081
edm::ParameterSet::getNamesByCode_
size_t getNamesByCode_(char code, bool trackiness, std::vector< std::string > &output) const
Definition: ParameterSet.cc:742
Algorithms.h
split.h
cms::cuda::assert
assert(be >=bs)
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
edm::ParameterSet::augment
void augment(ParameterSet const &from)
Definition: ParameterSet.cc:426
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
edm::getProcessParameterSetContainingModule
ParameterSet const & getProcessParameterSetContainingModule(ModuleDescription const &moduleDescription)
Definition: ParameterSet.cc:870
edm::ParameterSet::emptyParameterSetID
static ParameterSetID emptyParameterSetID()
Definition: ParameterSet.cc:94
edm::ParameterSet::copyForModify
void copyForModify(ParameterSet const &other)
Definition: ParameterSet.cc:100
edm::ParameterSet::id
ParameterSetID id() const
Definition: ParameterSet.cc:189
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::ParameterSet::setID
void setID(ParameterSetID const &id)
Definition: ParameterSet.cc:198
edm::ParameterSet::id_
ParameterSetID id_
Definition: ParameterSet.h:272
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::Entry::getVInt32
std::vector< int > getVInt32() const
Definition: Entry.cc:806
edm::Entry::getLuminosityBlockID
LuminosityBlockID getLuminosityBlockID() const
Definition: Entry.cc:1022
edm::Entry::getInt32
int getInt32() const
Definition: Entry.cc:794
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::VParameterSetEntry::vpset
std::vector< ParameterSet > const & vpset() const
returns the VPSet
Definition: VParameterSetEntry.cc:67
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::Entry::getVESInputTag
std::vector< ESInputTag > getVESInputTag() const
Definition: Entry.cc:986
ModuleDescription.h
edm::first
T first(std::pair< T, U > const &p)
Definition: ParameterSet.cc:217
edm::Entry::getVInputTag
std::vector< InputTag > getVInputTag() const
Definition: Entry.cc:962
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
EDMException.h
edm::FileInPath
Definition: FileInPath.h:61
edm::ParameterSet::popParameterSet
std::unique_ptr< ParameterSet > popParameterSet(std::string const &name)
Definition: ParameterSet.cc:121
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
cms::Digest
Definition: Digest.h:46
edm::operator==
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
Definition: debugging_allocator.h:72
edm::Entry::getUInt32
unsigned getUInt32() const
Definition: Entry.cc:842
edm::ParameterSet::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSet.cc:832
edm::ParameterSet::insert
void insert(bool ok_to_replace, char const *, Entry const &)
Definition: ParameterSet.cc:380
edm::ParameterSet::retrieveUntrackedParameterSet
ParameterSetEntry const * retrieveUntrackedParameterSet(std::string const &) const
Definition: ParameterSet.cc:287
mps_fire.end
end
Definition: mps_fire.py:242
edm::ParameterSet::getEntryPointerOrThrow_
Entry const * getEntryPointerOrThrow_(std::string const &name) const
Definition: ParameterSet.cc:208
edm::ParameterSet::retrieveVParameterSet
VParameterSetEntry const & retrieveVParameterSet(std::string const &) const
Definition: ParameterSet.cc:307
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
edm::Hash< ParameterSetType >
trackingPlots.other
other
Definition: trackingPlots.py:1464
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
b
double b
Definition: hdecay.h:118
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
edm::Entry::getString
std::string getString() const
Definition: Entry.cc:914
edm::ParameterSet::retrieveUntracked
Entry const * retrieveUntracked(char const *) const
Definition: ParameterSet.cc:247
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::Entry::getESInputTag
ESInputTag getESInputTag() const
Definition: Entry.cc:974
edm::ParameterSet::retrieveUnknownVParameterSet
VParameterSetEntry const * retrieveUnknownVParameterSet(std::string const &) const
Definition: ParameterSet.cc:353
edm::ParameterSet::eraseSimpleParameter
void eraseSimpleParameter(std::string const &name)
Definition: ParameterSet.cc:131
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
edm::ParameterSet::ParameterSet
ParameterSet()
Definition: ParameterSet.cc:59
edm::ParameterSet
Definition: ParameterSet.h:47
edm::ParameterSet::getAllFileInPaths
std::vector< FileInPath >::size_type getAllFileInPaths(std::vector< FileInPath > &output) const
Definition: ParameterSet.cc:648
a
double a
Definition: hdecay.h:119
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::Entry::getFileInPath
FileInPath getFileInPath() const
Definition: Entry.cc:938
edm::ParameterSet::insertVParameterSet
void insertVParameterSet(bool okay_to_replace, std::string const &name, VParameterSetEntry const &entry)
Definition: ParameterSet.cc:410
edm::ParameterSet::invalidateRegistration
void invalidateRegistration(std::string const &nameOfTracked)
Definition: ParameterSet.cc:39
edm::ParameterSet::getParameterNames
std::vector< std::string > getParameterNames() const
Definition: ParameterSet.cc:663
edm::Entry::getVEventID
std::vector< EventID > getVEventID() const
Definition: Entry.cc:1010
edm::Entry::getEventID
EventID getEventID() const
Definition: Entry.cc:998
edm::ParameterSet::retrieveUnknown
Entry const * retrieveUnknown(char const *) const
Definition: ParameterSet.cc:335
value
Definition: value.py:1
cuy.rep
rep
Definition: cuy.py:1189
edm::Entry::toString
std::string toString() const
Definition: Entry.cc:755
edm::ParameterSet::popVParameterSet
std::vector< ParameterSet > popVParameterSet(std::string const &name)
Definition: ParameterSet.cc:150
edm::ParameterSet::fromString
bool fromString(std::string const &)
Definition: ParameterSet.cc:593
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
edm::Entry::getBool
bool getBool() const
Definition: Entry.cc:782
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::Entry::getVUInt64
std::vector< unsigned long long > getVUInt64() const
Definition: Entry.cc:878
edm::ParameterSet::getParameterAsString
std::string getParameterAsString(std::string const &name) const
Definition: ParameterSet.cc:364
edm::ParameterSet::isRegistered
bool isRegistered() const
Definition: ParameterSet.h:71
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet::toDigest
void toDigest(cms::Digest &digest) const
Definition: ParameterSet.cc:549
edm::ParameterSet::swap
void swap(ParameterSet &other)
Definition: ParameterSet.cc:106
edm::pset::Registry::insertMapped
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
edm::isTransientEqual
bool isTransientEqual(ParameterSet const &a, ParameterSet const &b)
Definition: ParameterSet.cc:777
Registry.h
Digest.h
edm::getParameterSet
ParameterSet const & getParameterSet(ParameterSetID const &id)
Definition: ParameterSet.cc:862
edm::ModuleDescription::mainParameterSetID
ParameterSetID const & mainParameterSetID() const
Definition: ModuleDescription.cc:53
edm::ParameterSetEntry::toString
std::string toString() const
Definition: ParameterSetEntry.cc:53
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ParameterSet::deprecatedInputTagWarning
void deprecatedInputTagWarning(std::string const &name, std::string const &label) const
Definition: ParameterSet.cc:874
relativeConstraints.value
value
Definition: relativeConstraints.py:53
edm::Entry::getLuminosityBlockRange
LuminosityBlockRange getLuminosityBlockRange() const
Definition: Entry.cc:1045
Exception
Definition: hltDiff.cc:245
edm::ParameterSetEntry::pset
ParameterSet const & pset() const
returns the PSet
Definition: ParameterSetEntry.cc:59
edm::ParameterSet::trackedPart
ParameterSet trackedPart() const
Definition: ParameterSet.cc:686
edm::ParameterSet::retrieveUnknownParameterSet
ParameterSetEntry const * retrieveUnknownParameterSet(std::string const &) const
Definition: ParameterSet.cc:345
util.rrClient.indent
indent
Definition: rrClient.py:41
edm::VParameterSetEntry
Definition: VParameterSetEntry.h:24
edm::VParameterSetEntry::toString
std::string toString() const
Definition: VParameterSetEntry.cc:61
edm::Entry::getVInt64
std::vector< long long > getVInt64() const
Definition: Entry.cc:830
edm::Entry::getInputTag
InputTag getInputTag() const
Definition: Entry.cc:950
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::ParameterSetEntry
Definition: ParameterSetEntry.h:23
edm::ParameterSet::vpsetTable_
vpsettable vpsetTable_
Definition: ParameterSet.h:267
edm::ParameterSet::toStringImp
void toStringImp(std::string &, bool useAll) const
Definition: ParameterSet.cc:483
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
edm::ParameterSet::getParameterSetVector
VParameterSet const & getParameterSetVector(std::string const &name) const
Definition: ParameterSet.cc:2160
mps_fire.result
result
Definition: mps_fire.py:311
edm::Entry::getVString
std::vector< std::string > getVString() const
Definition: Entry.cc:926
edm::Entry::getVLuminosityBlockID
std::vector< LuminosityBlockID > getVLuminosityBlockID() const
Definition: Entry.cc:1034
command_line.start
start
Definition: command_line.py:167
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
cms::MD5Result::toString
std::string toString() const
Definition: Digest.cc:95
edm::EventID
Definition: EventID.h:31
edm::ParameterSetEntry::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSetEntry.cc:85
edm::EventRange
Definition: EventRange.h:31
edm::ParameterSet::getPSetForUpdate
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
Definition: ParameterSet.cc:457
edm::ParameterSet::allToString
void allToString(std::string &result) const
Definition: ParameterSet.cc:481
edm::ParameterSet::getPSetVectorForUpdate
VParameterSetEntry * getPSetVectorForUpdate(std::string const &name)
Definition: ParameterSet.cc:467
edm::errors::Configuration
Definition: EDMException.h:36
edm::Entry
Definition: Entry.h:40
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::ParameterSet::empty
bool empty() const
Definition: ParameterSet.h:201
edm::pset::exceptions::throwWrongNumberOfElements
void throwWrongNumberOfElements(std::string const &iParameterName, size_t iExpected, size_t iGot)
Definition: ParameterSet.cc:33
edm::ParameterSet::retrieveParameterSet
ParameterSetEntry const & retrieveParameterSet(std::string const &) const
Definition: ParameterSet.cc:268
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
edm::split
bool split(OutIter result, std::string const &string_to_split, char first, char sep, char last)
Definition: split.h:68
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::ParameterSet::retrieveUntrackedVParameterSet
VParameterSetEntry const * retrieveUntrackedVParameterSet(std::string const &) const
Definition: ParameterSet.cc:321
edm::LuminosityBlockRange
Definition: LuminosityBlockRange.h:32
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::ParameterSet::getParameterSetNames
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
Definition: ParameterSet.cc:724