CMS 3D CMS Logo

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