Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:47:45

0001 // ----------------------------------------------------------------------
0002 //
0003 // definition of ParameterSet's function members
0004 // ----------------------------------------------------------------------
0005 
0006 // ----------------------------------------------------------------------
0007 // prerequisite source files and headers
0008 // ----------------------------------------------------------------------
0009 
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 #include "FWCore/ParameterSet/interface/Registry.h"
0014 #include "FWCore/ParameterSet/src/split.h"
0015 #include "FWCore/Utilities/interface/Algorithms.h"
0016 #include "FWCore/Utilities/interface/Digest.h"
0017 #include "FWCore/Utilities/interface/EDMException.h"
0018 
0019 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0020 
0021 #include <algorithm>
0022 #include <iostream>
0023 #include <sstream>
0024 #include <cassert>
0025 
0026 // ----------------------------------------------------------------------
0027 // class invariant checker
0028 // ----------------------------------------------------------------------
0029 
0030 namespace edm {
0031 
0032   namespace pset::exceptions {
0033     void throwWrongNumberOfElements(std::string const& iName, size_t iExpected, size_t iGot) {
0034       throw Exception(errors::Configuration) << "The parameter '" << iName << "' should have " << iExpected
0035                                              << " elements, but has " << iGot << " elements in the configuration.\n";
0036     }
0037   }  // namespace pset::exceptions
0038 
0039   void ParameterSet::invalidateRegistration(std::string const& nameOfTracked) {
0040     // We have added a new parameter.  Invalidate the ID.
0041     if (isRegistered()) {
0042       id_ = ParameterSetID();
0043       if (!nameOfTracked.empty()) {
0044         // Give a warning (informational for now).
0045         LogInfo("ParameterSet") << "Warning: You have added a new tracked parameter\n"
0046                                 << "'" << nameOfTracked << "' to a previously registered parameter set.\n"
0047                                 << "This is a bad idea because the new parameter(s) will not be recorded.\n"
0048                                 << "Use the forthcoming ParameterSetDescription facility instead.\n"
0049                                 << "A warning is given only for the first such parameter in a pset.\n";
0050       }
0051     }
0052     assert(!isRegistered());
0053   }
0054 
0055   // ----------------------------------------------------------------------
0056   // constructors
0057   // ----------------------------------------------------------------------
0058 
0059   ParameterSet::ParameterSet() : tbl_(), psetTable_(), vpsetTable_(), id_() {}
0060 
0061   // ----------------------------------------------------------------------
0062   // from coded string
0063 
0064   ParameterSet::ParameterSet(std::string_view code) : tbl_(), psetTable_(), vpsetTable_(), id_() {
0065     if (!fromString(code)) {
0066       throw Exception(errors::Configuration, "InvalidInput")
0067           << "The encoded configuration string "
0068           << "passed to a ParameterSet during construction is invalid:\n"
0069           << code;
0070     }
0071   }
0072 
0073   // ----------------------------------------------------------------------
0074   // from coded string and ID.
0075 
0076   ParameterSet::ParameterSet(std::string_view code, ParameterSetID const& id)
0077       : tbl_(), psetTable_(), vpsetTable_(), id_(id) {
0078     if (!fromString(code)) {
0079       throw Exception(errors::Configuration, "InvalidInput")
0080           << "The encoded configuration string "
0081           << "passed to a ParameterSet during construction is invalid:\n"
0082           << code;
0083     }
0084   }
0085 
0086   void ParameterSet::registerFromString(std::string const& rep) {
0087     // from coded string.  Will cause registration
0088     cms::Digest dg(rep);
0089     edm::ParameterSetID psID(dg.digest().toString());
0090     edm::ParameterSet ps(rep, psID);
0091     pset::Registry::instance()->insertMapped(ps);
0092   }
0093 
0094   ParameterSetID ParameterSet::emptyParameterSetID() {  // const
0095     cms::Digest newDigest;
0096     ParameterSet().toDigest(newDigest);
0097     return ParameterSetID(newDigest.digest().toString());
0098   }
0099 
0100   void ParameterSet::copyForModify(ParameterSet const& other) {
0101     ParameterSet temp(other);
0102     swap(temp);
0103     id_ = ParameterSetID();
0104   }
0105 
0106   void ParameterSet::swap(ParameterSet& other) {
0107     tbl_.swap(other.tbl_);
0108     psetTable_.swap(other.psetTable_);
0109     vpsetTable_.swap(other.vpsetTable_);
0110     id_.swap(other.id_);
0111   }
0112 
0113   ParameterSet const& ParameterSet::registerIt() {
0114     if (!isRegistered()) {
0115       calculateID();
0116       pset::Registry::instance()->insertMapped(*this);
0117     }
0118     return *this;
0119   }
0120 
0121   std::unique_ptr<ParameterSet> ParameterSet::popParameterSet(std::string const& name) {
0122     assert(!isRegistered());
0123     psettable::iterator it = psetTable_.find(name);
0124     assert(it != psetTable_.end());
0125     auto pset = std::make_unique<ParameterSet>();
0126     std::swap(*pset, it->second.psetForUpdate());
0127     psetTable_.erase(it);
0128     return pset;
0129   }
0130 
0131   void ParameterSet::eraseSimpleParameter(std::string const& name) {
0132     assert(!isRegistered());
0133     table::iterator it = tbl_.find(name);
0134     assert(it != tbl_.end());
0135     tbl_.erase(it);
0136   }
0137 
0138   void ParameterSet::eraseOrSetUntrackedParameterSet(std::string const& name) {
0139     assert(!isRegistered());
0140     psettable::iterator it = psetTable_.find(name);
0141     assert(it != psetTable_.end());
0142     ParameterSet& pset = it->second.psetForUpdate();
0143     if (pset.isRegistered()) {
0144       it->second.setIsTracked(false);
0145     } else {
0146       psetTable_.erase(it);
0147     }
0148   }
0149 
0150   std::vector<ParameterSet> ParameterSet::popVParameterSet(std::string const& name) {
0151     assert(!isRegistered());
0152     vpsettable::iterator it = vpsetTable_.find(name);
0153     assert(it != vpsetTable_.end());
0154     std::vector<ParameterSet> vpset;
0155     std::swap(vpset, it->second.vpsetForUpdate());
0156     vpsetTable_.erase(it);
0157     return vpset;
0158   }
0159 
0160   void ParameterSet::calculateID() {
0161     // make sure contained tracked psets are updated
0162     for (auto& item : psetTable_) {
0163       ParameterSet& pset = item.second.psetForUpdate();
0164       if (!pset.isRegistered()) {
0165         pset.registerIt();
0166       }
0167       item.second.updateID();
0168     }
0169 
0170     // make sure contained tracked vpsets are updated
0171     for (vpsettable::iterator i = vpsetTable_.begin(), e = vpsetTable_.end(); i != e; ++i) {
0172       i->second.registerPsetsAndUpdateIDs();
0173     }
0174     //  The old, string base code is found below. Uncomment this and the assert to check whether
0175     //  there are discrepancies between old and new implementation.
0176     //    std::string stringrep;
0177     //    toString(stringrep);
0178     //    cms::Digest md5alg(stringrep);
0179     //    id_ = ParameterSetID(md5alg.digest().toString());
0180     cms::Digest newDigest;
0181     toDigest(newDigest);
0182     id_ = ParameterSetID(newDigest.digest().toString());
0183     //    assert(md5alg.digest().toString() == newDigest.digest().toString());
0184     assert(isRegistered());
0185   }
0186 
0187   // ----------------------------------------------------------------------
0188   // identification
0189   ParameterSetID ParameterSet::id() const {
0190     // checks if valid
0191     if (!isRegistered()) {
0192       throw Exception(errors::LogicError) << "ParameterSet::id() called prematurely\n"
0193                                           << "before ParameterSet::registerIt() has been called.\n";
0194     }
0195     return id_;
0196   }
0197 
0198   void ParameterSet::setID(ParameterSetID const& id) { id_ = id; }
0199 
0200   // ----------------------------------------------------------------------
0201   // Entry-handling
0202   // ----------------------------------------------------------------------
0203 
0204   Entry const* ParameterSet::getEntryPointerOrThrow_(char const* name) const {
0205     return getEntryPointerOrThrow_(std::string(name));
0206   }
0207 
0208   Entry const* ParameterSet::getEntryPointerOrThrow_(std::string const& name) const {
0209     Entry const* result = retrieveUntracked(name);
0210     if (result == nullptr)
0211       throw Exception(errors::Configuration, "MissingParameter:")
0212           << "The required parameter '" << name << "' was not specified.\n";
0213     return result;
0214   }
0215 
0216   template <typename T, typename U>
0217   T first(std::pair<T, U> const& p) {
0218     return p.first;
0219   }
0220 
0221   template <typename T, typename U>
0222   U second(std::pair<T, U> const& p) {
0223     return p.second;
0224   }
0225 
0226   Entry const& ParameterSet::retrieve(char const* name) const { return retrieve(std::string(name)); }
0227 
0228   Entry const& ParameterSet::retrieve(std::string const& name) const {
0229     table::const_iterator it = tbl_.find(name);
0230     if (it == tbl_.end()) {
0231       throw Exception(errors::Configuration, "MissingParameter:") << "Parameter '" << name << "' not found.";
0232     }
0233     if (it->second.isTracked() == false) {
0234       if (name[0] == '@') {
0235         throw Exception(errors::Configuration, "StatusMismatch:")
0236             << "Framework Error:  Parameter '" << name << "' is incorrectly designated as tracked in the framework.";
0237       } else {
0238         throw Exception(errors::Configuration, "StatusMismatch:")
0239             << "Parameter '" << name << "' is designated as tracked in the code,\n"
0240             << "but is designated as untracked in the configuration file.\n"
0241             << "Please remove 'untracked' from the configuration file for parameter '" << name << "'.";
0242       }
0243     }
0244     return it->second;
0245   }  // retrieve()
0246 
0247   Entry const* ParameterSet::retrieveUntracked(char const* name) const { return retrieveUntracked(std::string(name)); }
0248 
0249   Entry const* ParameterSet::retrieveUntracked(std::string const& name) const {
0250     table::const_iterator it = tbl_.find(name);
0251 
0252     if (it == tbl_.end())
0253       return nullptr;
0254     if (it->second.isTracked()) {
0255       if (name[0] == '@') {
0256         throw Exception(errors::Configuration, "StatusMismatch:")
0257             << "Framework Error:  Parameter '" << name << "' is incorrectly designated as untracked in the framework.";
0258       } else {
0259         throw Exception(errors::Configuration, "StatusMismatch:")
0260             << "Parameter '" << name << "' is designated as untracked in the code,\n"
0261             << "but is not designated as untracked in the configuration file.\n"
0262             << "Please change the configuration file to 'untracked <type> " << name << "'.";
0263       }
0264     }
0265     return &it->second;
0266   }  // retrieve()
0267 
0268   ParameterSetEntry const& ParameterSet::retrieveParameterSet(std::string const& name) const {
0269     psettable::const_iterator it = psetTable_.find(name);
0270     if (it == psetTable_.end()) {
0271       throw Exception(errors::Configuration, "MissingParameter:") << "ParameterSet '" << name << "' not found.";
0272     }
0273     if (it->second.isTracked() == false) {
0274       if (name[0] == '@') {
0275         throw Exception(errors::Configuration, "StatusMismatch:")
0276             << "Framework Error:  ParameterSet '" << name << "' is incorrectly designated as tracked in the framework.";
0277       } else {
0278         throw Exception(errors::Configuration, "StatusMismatch:")
0279             << "ParameterSet '" << name << "' is designated as tracked in the code,\n"
0280             << "but is designated as untracked in the configuration file.\n"
0281             << "Please remove 'untracked' from the configuration file for parameter '" << name << "'.";
0282       }
0283     }
0284     return it->second;
0285   }  // retrieve()
0286 
0287   ParameterSetEntry const* ParameterSet::retrieveUntrackedParameterSet(std::string const& name) const {
0288     psettable::const_iterator it = psetTable_.find(name);
0289 
0290     if (it == psetTable_.end())
0291       return nullptr;
0292     if (it->second.isTracked()) {
0293       if (name[0] == '@') {
0294         throw Exception(errors::Configuration, "StatusMismatch:")
0295             << "Framework Error:  ParameterSet '" << name
0296             << "' is incorrectly designated as untracked in the framework.";
0297       } else {
0298         throw Exception(errors::Configuration, "StatusMismatch:")
0299             << "ParameterSet '" << name << "' is designated as untracked in the code,\n"
0300             << "but is not designated as untracked in the configuration file.\n"
0301             << "Please change the configuration file to 'untracked <type> " << name << "'.";
0302       }
0303     }
0304     return &it->second;
0305   }  // retrieve()
0306 
0307   VParameterSetEntry const& ParameterSet::retrieveVParameterSet(std::string const& name) const {
0308     vpsettable::const_iterator it = vpsetTable_.find(name);
0309     if (it == vpsetTable_.end()) {
0310       throw Exception(errors::Configuration, "MissingParameter:") << "VParameterSet '" << name << "' not found.";
0311     }
0312     if (it->second.isTracked() == false) {
0313       throw Exception(errors::Configuration, "StatusMismatch:")
0314           << "VParameterSet '" << name << "' is designated as tracked in the code,\n"
0315           << "but is designated as untracked in the configuration file.\n"
0316           << "Please remove 'untracked' from the configuration file for parameter '" << name << "'.";
0317     }
0318     return it->second;
0319   }  // retrieve()
0320 
0321   VParameterSetEntry const* ParameterSet::retrieveUntrackedVParameterSet(std::string const& name) const {
0322     vpsettable::const_iterator it = vpsetTable_.find(name);
0323 
0324     if (it == vpsetTable_.end())
0325       return nullptr;
0326     if (it->second.isTracked()) {
0327       throw Exception(errors::Configuration, "StatusMismatch:")
0328           << "VParameterSet '" << name << "' is designated as untracked in the code,\n"
0329           << "but is not designated as untracked in the configuration file.\n"
0330           << "Please change the configuration file to 'untracked <type> " << name << "'.";
0331     }
0332     return &it->second;
0333   }  // retrieve()
0334 
0335   Entry const* ParameterSet::retrieveUnknown(char const* name) const { return retrieveUnknown(std::string(name)); }
0336 
0337   Entry const* ParameterSet::retrieveUnknown(std::string const& name) const {
0338     table::const_iterator it = tbl_.find(name);
0339     if (it == tbl_.end()) {
0340       return nullptr;
0341     }
0342     return &it->second;
0343   }
0344 
0345   ParameterSetEntry const* ParameterSet::retrieveUnknownParameterSet(std::string const& name) const {
0346     psettable::const_iterator it = psetTable_.find(name);
0347     if (it == psetTable_.end()) {
0348       return nullptr;
0349     }
0350     return &it->second;
0351   }
0352 
0353   VParameterSetEntry const* ParameterSet::retrieveUnknownVParameterSet(std::string const& name) const {
0354     vpsettable::const_iterator it = vpsetTable_.find(name);
0355     if (it == vpsetTable_.end()) {
0356       return nullptr;
0357     }
0358     return &it->second;
0359   }
0360 
0361   // ----------------------------------------------------------------------
0362   // ----------------------------------------------------------------------
0363 
0364   std::string ParameterSet::getParameterAsString(std::string const& name) const {
0365     if (existsAs<ParameterSet>(name)) {
0366       return retrieveUnknownParameterSet(name)->toString();
0367     } else if (existsAs<std::vector<ParameterSet> >(name)) {
0368       return retrieveUnknownVParameterSet(name)->toString();
0369     } else if (exists(name)) {
0370       return retrieveUnknown(name)->toString();
0371     } else {
0372       throw Exception(errors::Configuration, "getParameterAsString")
0373           << "Cannot find parameter " << name << " in " << *this;
0374     }
0375   }
0376 
0377   // ----------------------------------------------------------------------
0378   // ----------------------------------------------------------------------
0379 
0380   void ParameterSet::insert(bool okay_to_replace, char const* name, Entry const& value) {
0381     insert(okay_to_replace, std::string(name), value);
0382   }
0383 
0384   void ParameterSet::insert(bool okay_to_replace, std::string const& name, Entry const& value) {
0385     // We should probably get rid of 'okay_to_replace', which will
0386     // simplify the logic in this function.
0387     table::iterator it = tbl_.find(name);
0388 
0389     if (it == tbl_.end()) {
0390       if (!tbl_.insert(std::make_pair(name, value)).second)
0391         throw Exception(errors::Configuration, "InsertFailure") << "cannot insert " << name << " into a ParameterSet\n";
0392     } else if (okay_to_replace) {
0393       it->second = value;
0394     }
0395   }  // insert()
0396 
0397   void ParameterSet::insertParameterSet(bool okay_to_replace, std::string const& name, ParameterSetEntry const& entry) {
0398     // We should probably get rid of 'okay_to_replace', which will
0399     // simplify the logic in this function.
0400     psettable::iterator it = psetTable_.find(name);
0401 
0402     if (it == psetTable_.end()) {
0403       if (!psetTable_.insert(std::make_pair(name, entry)).second)
0404         throw Exception(errors::Configuration, "InsertFailure") << "cannot insert " << name << " into a ParameterSet\n";
0405     } else if (okay_to_replace) {
0406       it->second = entry;
0407     }
0408   }  // insert()
0409 
0410   void ParameterSet::insertVParameterSet(bool okay_to_replace,
0411                                          std::string const& name,
0412                                          VParameterSetEntry const& entry) {
0413     // We should probably get rid of 'okay_to_replace', which will
0414     // simplify the logic in this function.
0415     vpsettable::iterator it = vpsetTable_.find(name);
0416 
0417     if (it == vpsetTable_.end()) {
0418       if (!vpsetTable_.insert(std::make_pair(name, entry)).second)
0419         throw Exception(errors::Configuration, "InsertFailure")
0420             << "cannot insert " << name << " into a VParameterSet\n";
0421     } else if (okay_to_replace) {
0422       it->second = entry;
0423     }
0424   }  // insert()
0425 
0426   void ParameterSet::augment(ParameterSet const& from) {
0427     // This preemptive invalidation may be more agressive than necessary.
0428     invalidateRegistration(std::string());
0429     if (&from == this) {
0430       return;
0431     }
0432 
0433     for (table::const_iterator b = from.tbl_.begin(), e = from.tbl_.end(); b != e; ++b) {
0434       this->insert(false, b->first, b->second);
0435     }
0436     for (psettable::const_iterator b = from.psetTable_.begin(), e = from.psetTable_.end(); b != e; ++b) {
0437       this->insertParameterSet(false, b->first, b->second);
0438     }
0439     for (vpsettable::const_iterator b = from.vpsetTable_.begin(), e = from.vpsetTable_.end(); b != e; ++b) {
0440       this->insertVParameterSet(false, b->first, b->second);
0441     }
0442   }  // augment()
0443 
0444   void ParameterSet::copyFrom(ParameterSet const& from, std::string const& name) {
0445     invalidateRegistration(std::string());
0446     if (from.existsAs<ParameterSet>(name)) {
0447       this->insertParameterSet(false, name, *(from.retrieveUnknownParameterSet(name)));
0448     } else if (from.existsAs<std::vector<ParameterSet> >(name)) {
0449       this->insertVParameterSet(false, name, *(from.retrieveUnknownVParameterSet(name)));
0450     } else if (from.exists(name)) {
0451       this->insert(false, name, *(from.retrieveUnknown(name)));
0452     } else {
0453       throw Exception(errors::Configuration, "copyFrom") << "Cannot find parameter " << name << " in " << from;
0454     }
0455   }
0456 
0457   ParameterSet* ParameterSet::getPSetForUpdate(std::string const& name, bool& isTracked) {
0458     assert(!isRegistered());
0459     isTracked = false;
0460     psettable::iterator it = psetTable_.find(name);
0461     if (it == psetTable_.end())
0462       return nullptr;
0463     isTracked = it->second.isTracked();
0464     return &it->second.psetForUpdate();
0465   }
0466 
0467   VParameterSetEntry* ParameterSet::getPSetVectorForUpdate(std::string const& name) {
0468     assert(!isRegistered());
0469     vpsettable::iterator it = vpsetTable_.find(name);
0470     if (it == vpsetTable_.end())
0471       return nullptr;
0472     return &it->second;
0473   }
0474 
0475   // ----------------------------------------------------------------------
0476   // coding
0477   // ----------------------------------------------------------------------
0478 
0479   void ParameterSet::toString(std::string& rep) const { toStringImp(rep, false); }
0480 
0481   void ParameterSet::allToString(std::string& rep) const { toStringImp(rep, true); }
0482 
0483   void ParameterSet::toStringImp(std::string& rep, bool useAll) const {
0484     // make sure the PSets get filled
0485     if (empty()) {
0486       rep += "<>";
0487       return;
0488     }
0489     size_t size = 1;
0490     for (table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
0491       if (useAll || b->second.isTracked()) {
0492         size += 2;
0493         size += b->first.size();
0494         size += b->second.sizeOfString();
0495       }
0496     }
0497     for (psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
0498       if (useAll || b->second.isTracked()) {
0499         size += 2;
0500         size += b->first.size();
0501         size += b->first.size();
0502         size += b->first.size();
0503         size += sizeof(ParameterSetID);
0504       }
0505     }
0506     for (vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
0507       if (useAll || b->second.isTracked()) {
0508         size += 2;
0509         size += b->first.size();
0510         size += sizeof(ParameterSetID) * b->second.vpset().size();
0511       }
0512     }
0513 
0514     rep.reserve(rep.size() + size);
0515     rep += '<';
0516     std::string start;
0517     std::string const between(";");
0518     for (table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
0519       if (useAll || b->second.isTracked()) {
0520         rep += start;
0521         rep += b->first;
0522         rep += '=';
0523         b->second.toString(rep);
0524         start = between;
0525       }
0526     }
0527     for (psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
0528       if (useAll || b->second.isTracked()) {
0529         rep += start;
0530         rep += b->first;
0531         rep += '=';
0532         b->second.toString(rep);
0533         start = between;
0534       }
0535     }
0536     for (vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
0537       if (useAll || b->second.isTracked()) {
0538         rep += start;
0539         rep += b->first;
0540         rep += '=';
0541         b->second.toString(rep);
0542         start = between;
0543       }
0544     }
0545 
0546     rep += '>';
0547   }  // to_string()
0548 
0549   void ParameterSet::toDigest(cms::Digest& digest) const {
0550     digest.append("<", 1);
0551     bool started = false;
0552     for (table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
0553       if (b->second.isTracked()) {
0554         if (started)
0555           digest.append(";", 1);
0556         digest.append(b->first);
0557         digest.append("=", 1);
0558         b->second.toDigest(digest);
0559         started = true;
0560       }
0561     }
0562     for (psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
0563       if (b->second.isTracked()) {
0564         if (started)
0565           digest.append(";", 1);
0566         digest.append(b->first);
0567         digest.append("=", 1);
0568         b->second.toDigest(digest);
0569         started = true;
0570       }
0571     }
0572     for (vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
0573       if (b->second.isTracked()) {
0574         if (started)
0575           digest.append(";", 1);
0576         digest.append(b->first);
0577         digest.append("=", 1);
0578         b->second.toDigest(digest);
0579       }
0580     }
0581 
0582     digest.append(">", 1);
0583   }
0584 
0585   std::string ParameterSet::toString() const {
0586     std::string result;
0587     toString(result);
0588     return result;
0589   }
0590 
0591   // ----------------------------------------------------------------------
0592 
0593   bool ParameterSet::fromString(std::string_view from) {
0594     if (from.size() < 2 or from.front() != '<' or from.back() != '>') {
0595       return false;
0596     }
0597 
0598     std::string_view remaining = from;
0599     remaining = remaining.substr(1, from.size() - 2);
0600 
0601     tbl_.clear();  // precaution
0602     while (not remaining.empty()) {
0603       // locate required name/value separator
0604       auto q = remaining.find_first_of('=');
0605       if (q == remaining.npos)
0606         return false;
0607       // form name unique to this ParameterSet
0608       auto name = remaining.substr(0, q);
0609       if (tbl_.find(name) != tbl_.end())
0610         return false;
0611 
0612       remaining = remaining.substr(q + 1);
0613       std::string_view rep = remaining.substr(0, remaining.find_first_of(';'));
0614       // entries are generically of the form tracked-type-rep
0615       if (rep[1] == 'Q') {
0616         ParameterSetEntry psetEntry(rep);
0617         if (!psetTable_.emplace(name, psetEntry).second) {
0618           return false;
0619         }
0620       } else if (rep[1] == 'q') {
0621         VParameterSetEntry vpsetEntry(rep);
0622         if (!vpsetTable_.emplace(name, vpsetEntry).second) {
0623           return false;
0624         }
0625       } else {
0626         // form value and insert name/value pair
0627         auto bounds = Entry::bounds(remaining, rep.size());
0628         if (bounds.empty()) {
0629           return false;
0630         }
0631         remaining = remaining.substr(bounds.size());
0632         if (not remaining.empty() and remaining.front() != ';') {
0633           return false;
0634         }
0635         Entry value(std::string(name), bounds);
0636         if (rep[1] == 'P') {
0637           ParameterSetEntry psetEntry(value.getPSet(), value.isTracked());
0638           if (!psetTable_.emplace(name, psetEntry).second) {
0639             return false;
0640           }
0641         } else if (rep[1] == 'p') {
0642           VParameterSetEntry vpsetEntry(value.getVPSet(), value.isTracked());
0643           if (!vpsetTable_.emplace(name, vpsetEntry).second) {
0644             return false;
0645           }
0646         } else {
0647           if (!tbl_.emplace(name, value).second) {
0648             return false;
0649           }
0650         }
0651       }
0652       auto newStart = remaining.find_first_of(';');
0653       if (newStart == remaining.npos)
0654         break;
0655       remaining = remaining.substr(newStart + 1);
0656     }
0657 
0658     return true;
0659   }  // from_string()
0660 
0661   // ----------------------------------------------------------------------
0662   std::string_view ParameterSet::extent(std::string_view from) {
0663     if (from.size() < 2 or from.front() != '<') {
0664       return {};
0665     }
0666 
0667     std::string_view remaining = from;
0668     remaining.remove_prefix(1);
0669     while (not remaining.empty() and remaining[0] != '>') {
0670       auto start_index = remaining.find_first_of('=');
0671       if (remaining.npos == start_index) {
0672         return {};
0673       }
0674       remaining.remove_prefix(start_index + 1);
0675       auto end_index = remaining.find_first_of(";>");
0676       if (remaining.npos == end_index) {
0677         return {};
0678       }
0679       auto bounds = edm::Entry::bounds(remaining, end_index);
0680       if (bounds.empty()) {
0681         return {};
0682       }
0683       remaining.remove_prefix(bounds.size());
0684       if (not remaining.empty() and remaining[0] == ';') {
0685         remaining.remove_prefix(1);
0686       }
0687     }
0688     if (remaining.empty()) {
0689       return {};
0690     }
0691     from.remove_suffix(remaining.size() - 1);
0692     return from;
0693   }
0694 
0695   // ----------------------------------------------------------------------
0696 
0697   std::vector<FileInPath>::size_type ParameterSet::getAllFileInPaths(std::vector<FileInPath>& output) const {
0698     std::vector<FileInPath>::size_type count = 0;
0699     table::const_iterator it = tbl_.begin();
0700     table::const_iterator end = tbl_.end();
0701     while (it != end) {
0702       Entry const& e = it->second;
0703       if (e.typeCode() == 'F') {
0704         ++count;
0705         output.push_back(e.getFileInPath());
0706       }
0707       ++it;
0708     }
0709     return count;
0710   }
0711 
0712   std::vector<std::string> ParameterSet::getParameterNames() const {
0713     using std::placeholders::_1;
0714     std::vector<std::string> returnValue;
0715     std::transform(tbl_.begin(),
0716                    tbl_.end(),
0717                    back_inserter(returnValue),
0718                    std::bind(&std::pair<std::string const, Entry>::first, _1));
0719     std::transform(psetTable_.begin(),
0720                    psetTable_.end(),
0721                    back_inserter(returnValue),
0722                    std::bind(&std::pair<std::string const, ParameterSetEntry>::first, _1));
0723     std::transform(vpsetTable_.begin(),
0724                    vpsetTable_.end(),
0725                    back_inserter(returnValue),
0726                    std::bind(&std::pair<std::string const, VParameterSetEntry>::first, _1));
0727     return returnValue;
0728   }
0729 
0730   bool ParameterSet::exists(std::string const& parameterName) const {
0731     return (tbl_.find(parameterName) != tbl_.end() || psetTable_.find(parameterName) != psetTable_.end() ||
0732             vpsetTable_.find(parameterName) != vpsetTable_.end());
0733   }
0734 
0735   ParameterSet ParameterSet::trackedPart() const {
0736     ParameterSet result;
0737     for (table::const_iterator tblItr = tbl_.begin(); tblItr != tbl_.end(); ++tblItr) {
0738       if (tblItr->second.isTracked()) {
0739         result.tbl_.insert(*tblItr);
0740       }
0741     }
0742     for (psettable::const_iterator psetItr = psetTable_.begin(); psetItr != psetTable_.end(); ++psetItr) {
0743       if (psetItr->second.isTracked()) {
0744         result.addParameter<ParameterSet>(psetItr->first, psetItr->second.pset().trackedPart());
0745       }
0746     }
0747     for (vpsettable::const_iterator vpsetItr = vpsetTable_.begin(); vpsetItr != vpsetTable_.end(); ++vpsetItr) {
0748       if (vpsetItr->second.isTracked()) {
0749         VParameterSet vresult;
0750         std::vector<ParameterSet> const& this_vpset = vpsetItr->second.vpset();
0751 
0752         typedef std::vector<ParameterSet>::const_iterator Iter;
0753         for (Iter i = this_vpset.begin(), e = this_vpset.end(); i != e; ++i) {
0754           vresult.push_back(i->trackedPart());
0755         }
0756         result.addParameter<VParameterSet>(vpsetItr->first, vresult);
0757       }
0758     }
0759     return result;
0760   }
0761 
0762   /*
0763   // Comment out unneeded function
0764   size_t
0765   ParameterSet::getAllParameterSetNames(std::vector<std::string>& output) const {
0766     using std::placeholders::_1;
0767     std::transform(psetTable_.begin(), psetTable_.end(), back_inserter(output),
0768                    std::bind(&std::pair<std::string const, ParameterSetEntry>::first, _1));
0769     return output.size();
0770   }
0771 */
0772 
0773   size_t ParameterSet::getParameterSetNames(std::vector<std::string>& output, bool trackiness) const {
0774     for (psettable::const_iterator psetItr = psetTable_.begin(); psetItr != psetTable_.end(); ++psetItr) {
0775       if (psetItr->second.isTracked() == trackiness) {
0776         output.push_back(psetItr->first);
0777       }
0778     }
0779     return output.size();
0780   }
0781 
0782   size_t ParameterSet::getParameterSetVectorNames(std::vector<std::string>& output, bool trackiness) const {
0783     for (vpsettable::const_iterator vpsetItr = vpsetTable_.begin(); vpsetItr != vpsetTable_.end(); ++vpsetItr) {
0784       if (vpsetItr->second.isTracked() == trackiness) {
0785         output.push_back(vpsetItr->first);
0786       }
0787     }
0788     return output.size();
0789   }
0790 
0791   size_t ParameterSet::getNamesByCode_(char code, bool trackiness, std::vector<std::string>& output) const {
0792     size_t count = 0;
0793     if (code == 'Q') {
0794       return getParameterSetNames(output, trackiness);
0795     }
0796     if (code == 'q') {
0797       return getParameterSetVectorNames(output, trackiness);
0798     }
0799     //deal with string encoding change by also looking for old code values
0800     if (code == 'z') {
0801       count += getNamesByCode_('s', trackiness, output);
0802     }
0803     if (code == 'Z') {
0804       count += getNamesByCode_('S', trackiness, output);
0805     }
0806     table::const_iterator it = tbl_.begin();
0807     table::const_iterator end = tbl_.end();
0808     while (it != end) {
0809       Entry const& e = it->second;
0810       if (e.typeCode() == code && e.isTracked() == trackiness) {  // if it is a vector of ParameterSet
0811         ++count;
0812         output.push_back(it->first);  // save the name
0813       }
0814       ++it;
0815     }
0816     return count;
0817   }
0818 
0819   template <>
0820   std::vector<std::string> ParameterSet::getParameterNamesForType<FileInPath>(bool trackiness) const {
0821     std::vector<std::string> result;
0822     getNamesByCode_('F', trackiness, result);
0823     return result;
0824   }
0825 
0826   bool operator==(ParameterSet const& a, ParameterSet const& b) {
0827     if (a.isRegistered() && b.isRegistered()) {
0828       return (a.id() == b.id());
0829     }
0830     return isTransientEqual(a.trackedPart(), b.trackedPart());
0831   }
0832 
0833   bool isTransientEqual(ParameterSet const& a, ParameterSet const& b) {
0834     if (a.tbl().size() != b.tbl().size()) {
0835       return false;
0836     }
0837     if (a.psetTable().size() != b.psetTable().size()) {
0838       return false;
0839     }
0840     if (a.vpsetTable().size() != b.vpsetTable().size()) {
0841       return false;
0842     }
0843     typedef ParameterSet::table::const_iterator Ti;
0844     for (Ti i = a.tbl().begin(), e = a.tbl().end(), j = b.tbl().begin(), f = b.tbl().end(); i != e && j != f;
0845          ++i, ++j) {
0846       if (*i != *j) {
0847         return false;
0848       }
0849     }
0850     typedef ParameterSet::psettable::const_iterator Pi;
0851     for (Pi i = a.psetTable().begin(), e = a.psetTable().end(), j = b.psetTable().begin(), f = b.psetTable().end();
0852          i != e && j != f;
0853          ++i, ++j) {
0854       if (i->first != j->first) {
0855         return false;
0856       }
0857       if (i->second.isTracked() != j->second.isTracked()) {
0858         return false;
0859       }
0860       if (!isTransientEqual(i->second.pset(), j->second.pset())) {
0861         return false;
0862       }
0863     }
0864     typedef ParameterSet::vpsettable::const_iterator PVi;
0865     for (PVi i = a.vpsetTable().begin(), e = a.vpsetTable().end(), j = b.vpsetTable().begin(), f = b.vpsetTable().end();
0866          i != e && j != f;
0867          ++i, ++j) {
0868       if (i->first != j->first) {
0869         return false;
0870       }
0871       if (i->second.isTracked() != j->second.isTracked()) {
0872         return false;
0873       }
0874       std::vector<ParameterSet> const& iv = i->second.vpset();
0875       std::vector<ParameterSet> const& jv = j->second.vpset();
0876       if (iv.size() != jv.size()) {
0877         return false;
0878       }
0879       for (size_t k = 0; k < iv.size(); ++k) {
0880         if (!isTransientEqual(iv[k], jv[k])) {
0881           return false;
0882         }
0883       }
0884     }
0885     return true;
0886   }
0887 
0888   std::string ParameterSet::dump(unsigned int indent) const {
0889     std::ostringstream os;
0890     // indent a bit
0891     std::string indentation(indent, ' ');
0892     os << "{" << std::endl;
0893     for (table::const_iterator i = tbl_.begin(), e = tbl_.end(); i != e; ++i) {
0894       os << indentation << "  " << i->first << ": " << i->second << std::endl;
0895     }
0896     for (psettable::const_iterator i = psetTable_.begin(), e = psetTable_.end(); i != e; ++i) {
0897       // indent a bit
0898       std::string n = i->first;
0899       ParameterSetEntry const& pe = i->second;
0900       os << indentation << "  " << n << ": " << pe.dump(indent + 2) << std::endl;
0901     }
0902     for (vpsettable::const_iterator i = vpsetTable_.begin(), e = vpsetTable_.end(); i != e; ++i) {
0903       // indent a bit
0904       std::string n = i->first;
0905       VParameterSetEntry const& pe = i->second;
0906       os << indentation << "  " << n << ": " << pe.dump(indent + 2) << std::endl;
0907     }
0908     os << indentation << "}";
0909     return os.str();
0910   }
0911 
0912   std::ostream& operator<<(std::ostream& os, ParameterSet const& pset) {
0913     os << pset.dump();
0914     return os;
0915   }
0916 
0917   // Free function to return a parameterSet given its ID.
0918   ParameterSet const& getParameterSet(ParameterSetID const& id) {
0919     ParameterSet const* result = nullptr;
0920     if (nullptr == (result = pset::Registry::instance()->getMapped(id))) {
0921       throw Exception(errors::LogicError, "MissingParameterSet:") << "Parameter Set ID '" << id << "' not found.";
0922     }
0923     return *result;
0924   }
0925 
0926   ParameterSet const& getProcessParameterSetContainingModule(ModuleDescription const& moduleDescription) {
0927     return getParameterSet(moduleDescription.mainParameterSetID());
0928   }
0929 
0930   void ParameterSet::deprecatedInputTagWarning(std::string const& name, std::string const& label) const {
0931     LogWarning("Configuration") << "Warning:\n\tstring " << name << " = \"" << label << "\"\nis deprecated, "
0932                                 << "please update your config file to use\n\tInputTag " << name << " = " << label;
0933   }
0934 
0935   // specializations
0936   // ----------------------------------------------------------------------
0937   // Bool, vBool
0938 
0939   template <>
0940   bool ParameterSet::getParameter<bool>(std::string const& name) const {
0941     return retrieve(name).getBool();
0942   }
0943 
0944   // ----------------------------------------------------------------------
0945   // Int32, vInt32
0946 
0947   template <>
0948   int ParameterSet::getParameter<int>(std::string const& name) const {
0949     return retrieve(name).getInt32();
0950   }
0951 
0952   template <>
0953   std::vector<int> ParameterSet::getParameter<std::vector<int> >(std::string const& name) const {
0954     return retrieve(name).getVInt32();
0955   }
0956 
0957   // ----------------------------------------------------------------------
0958   // Int64, vInt64
0959 
0960   template <>
0961   long long ParameterSet::getParameter<long long>(std::string const& name) const {
0962     return retrieve(name).getInt64();
0963   }
0964 
0965   template <>
0966   std::vector<long long> ParameterSet::getParameter<std::vector<long long> >(std::string const& name) const {
0967     return retrieve(name).getVInt64();
0968   }
0969 
0970   // ----------------------------------------------------------------------
0971   // Uint32, vUint32
0972 
0973   template <>
0974   unsigned int ParameterSet::getParameter<unsigned int>(std::string const& name) const {
0975     return retrieve(name).getUInt32();
0976   }
0977 
0978   template <>
0979   std::vector<unsigned int> ParameterSet::getParameter<std::vector<unsigned int> >(std::string const& name) const {
0980     return retrieve(name).getVUInt32();
0981   }
0982 
0983   // ----------------------------------------------------------------------
0984   // Uint64, vUint64
0985 
0986   template <>
0987   unsigned long long ParameterSet::getParameter<unsigned long long>(std::string const& name) const {
0988     return retrieve(name).getUInt64();
0989   }
0990 
0991   template <>
0992   std::vector<unsigned long long> ParameterSet::getParameter<std::vector<unsigned long long> >(
0993       std::string const& name) const {
0994     return retrieve(name).getVUInt64();
0995   }
0996 
0997   // ----------------------------------------------------------------------
0998   // Double, vDouble
0999 
1000   template <>
1001   double ParameterSet::getParameter<double>(std::string const& name) const {
1002     return retrieve(name).getDouble();
1003   }
1004 
1005   template <>
1006   std::vector<double> ParameterSet::getParameter<std::vector<double> >(std::string const& name) const {
1007     return retrieve(name).getVDouble();
1008   }
1009 
1010   // ----------------------------------------------------------------------
1011   // String, vString
1012 
1013   template <>
1014   std::string ParameterSet::getParameter<std::string>(std::string const& name) const {
1015     return retrieve(name).getString();
1016   }
1017 
1018   template <>
1019   std::vector<std::string> ParameterSet::getParameter<std::vector<std::string> >(std::string const& name) const {
1020     return retrieve(name).getVString();
1021   }
1022 
1023   // ----------------------------------------------------------------------
1024   // FileInPath
1025 
1026   template <>
1027   FileInPath ParameterSet::getParameter<FileInPath>(std::string const& name) const {
1028     return retrieve(name).getFileInPath();
1029   }
1030 
1031   // ----------------------------------------------------------------------
1032   // InputTag
1033 
1034   template <>
1035   InputTag ParameterSet::getParameter<InputTag>(std::string const& name) const {
1036     Entry const& e_input = retrieve(name);
1037     switch (e_input.typeCode()) {
1038       case 't':  // InputTag
1039       {
1040         return e_input.getInputTag();
1041       }
1042       case 'S':  // string Hex
1043       {
1044         std::string const& label = e_input.getString();
1045         deprecatedInputTagWarning(name, label);
1046         return InputTag(label);
1047       }
1048       case 'Z':  // string Raw
1049       {
1050         std::string const& label = e_input.getString();
1051         deprecatedInputTagWarning(name, label);
1052         return InputTag(label);
1053       }
1054     }
1055     throw Exception(errors::Configuration, "ValueError")
1056         << "type of " << name << " is expected to be InputTag or string (deprecated)";
1057   }
1058 
1059   // ----------------------------------------------------------------------
1060   // VInputTag
1061 
1062   template <>
1063   std::vector<InputTag> ParameterSet::getParameter<std::vector<InputTag> >(std::string const& name) const {
1064     return retrieve(name).getVInputTag();
1065   }
1066 
1067   // ----------------------------------------------------------------------
1068   // ESInputTag
1069 
1070   template <>
1071   ESInputTag ParameterSet::getParameter<ESInputTag>(std::string const& name) const {
1072     return retrieve(name).getESInputTag();
1073   }
1074 
1075   // ----------------------------------------------------------------------
1076   // VESInputTag
1077 
1078   template <>
1079   std::vector<ESInputTag> ParameterSet::getParameter<std::vector<ESInputTag> >(std::string const& name) const {
1080     return retrieve(name).getVESInputTag();
1081   }
1082 
1083   // ----------------------------------------------------------------------
1084   // EventID
1085 
1086   template <>
1087   EventID ParameterSet::getParameter<EventID>(std::string const& name) const {
1088     return retrieve(name).getEventID();
1089   }
1090 
1091   // ----------------------------------------------------------------------
1092   // VEventID
1093 
1094   template <>
1095   std::vector<EventID> ParameterSet::getParameter<std::vector<EventID> >(std::string const& name) const {
1096     return retrieve(name).getVEventID();
1097   }
1098 
1099   // ----------------------------------------------------------------------
1100   // LuminosityBlockID
1101 
1102   template <>
1103   LuminosityBlockID ParameterSet::getParameter<LuminosityBlockID>(std::string const& name) const {
1104     return retrieve(name).getLuminosityBlockID();
1105   }
1106 
1107   // ----------------------------------------------------------------------
1108   // VLuminosityBlockID
1109 
1110   template <>
1111   std::vector<LuminosityBlockID> ParameterSet::getParameter<std::vector<LuminosityBlockID> >(
1112       std::string const& name) const {
1113     return retrieve(name).getVLuminosityBlockID();
1114   }
1115 
1116   // ----------------------------------------------------------------------
1117   // EventRange
1118 
1119   template <>
1120   EventRange ParameterSet::getParameter<EventRange>(std::string const& name) const {
1121     return retrieve(name).getEventRange();
1122   }
1123 
1124   // ----------------------------------------------------------------------
1125   // VEventRange
1126 
1127   template <>
1128   std::vector<EventRange> ParameterSet::getParameter<std::vector<EventRange> >(std::string const& name) const {
1129     return retrieve(name).getVEventRange();
1130   }
1131 
1132   // ----------------------------------------------------------------------
1133   // LuminosityBlockRange
1134 
1135   template <>
1136   LuminosityBlockRange ParameterSet::getParameter<LuminosityBlockRange>(std::string const& name) const {
1137     return retrieve(name).getLuminosityBlockRange();
1138   }
1139 
1140   // ----------------------------------------------------------------------
1141   // VLuminosityBlockRange
1142 
1143   template <>
1144   std::vector<LuminosityBlockRange> ParameterSet::getParameter<std::vector<LuminosityBlockRange> >(
1145       std::string const& name) const {
1146     return retrieve(name).getVLuminosityBlockRange();
1147   }
1148 
1149   // ----------------------------------------------------------------------
1150   // PSet, vPSet
1151 
1152   template <>
1153   ParameterSet ParameterSet::getParameter<ParameterSet>(std::string const& name) const {
1154     return getParameterSet(name);
1155   }
1156 
1157   template <>
1158   VParameterSet ParameterSet::getParameter<VParameterSet>(std::string const& name) const {
1159     return getParameterSetVector(name);
1160   }
1161 
1162   // untracked parameters
1163 
1164   // ----------------------------------------------------------------------
1165   // Bool, vBool
1166 
1167   template <>
1168   bool ParameterSet::getUntrackedParameter<bool>(std::string const& name, bool const& defaultValue) const {
1169     Entry const* entryPtr = retrieveUntracked(name);
1170     return entryPtr == nullptr ? defaultValue : entryPtr->getBool();
1171   }
1172 
1173   template <>
1174   bool ParameterSet::getUntrackedParameter<bool>(std::string const& name) const {
1175     return getEntryPointerOrThrow_(name)->getBool();
1176   }
1177 
1178   // ----------------------------------------------------------------------
1179   // Int32, vInt32
1180 
1181   template <>
1182   int ParameterSet::getUntrackedParameter<int>(std::string const& name, int const& defaultValue) const {
1183     Entry const* entryPtr = retrieveUntracked(name);
1184     return entryPtr == nullptr ? defaultValue : entryPtr->getInt32();
1185   }
1186 
1187   template <>
1188   int ParameterSet::getUntrackedParameter<int>(std::string const& name) const {
1189     return getEntryPointerOrThrow_(name)->getInt32();
1190   }
1191 
1192   template <>
1193   std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(std::string const& name,
1194                                                                           std::vector<int> const& defaultValue) const {
1195     Entry const* entryPtr = retrieveUntracked(name);
1196     return entryPtr == nullptr ? defaultValue : entryPtr->getVInt32();
1197   }
1198 
1199   template <>
1200   std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(std::string const& name) const {
1201     return getEntryPointerOrThrow_(name)->getVInt32();
1202   }
1203 
1204   // ----------------------------------------------------------------------
1205   // Uint32, vUint32
1206 
1207   template <>
1208   unsigned int ParameterSet::getUntrackedParameter<unsigned int>(std::string const& name,
1209                                                                  unsigned int const& defaultValue) const {
1210     Entry const* entryPtr = retrieveUntracked(name);
1211     return entryPtr == nullptr ? defaultValue : entryPtr->getUInt32();
1212   }
1213 
1214   template <>
1215   unsigned int ParameterSet::getUntrackedParameter<unsigned int>(std::string const& name) const {
1216     return getEntryPointerOrThrow_(name)->getUInt32();
1217   }
1218 
1219   template <>
1220   std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(
1221       std::string const& name, std::vector<unsigned int> const& defaultValue) const {
1222     Entry const* entryPtr = retrieveUntracked(name);
1223     return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt32();
1224   }
1225 
1226   template <>
1227   std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(
1228       std::string const& name) const {
1229     return getEntryPointerOrThrow_(name)->getVUInt32();
1230   }
1231 
1232   // ----------------------------------------------------------------------
1233   // Uint64, vUint64
1234 
1235   template <>
1236   unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(
1237       std::string const& name, unsigned long long const& defaultValue) const {
1238     Entry const* entryPtr = retrieveUntracked(name);
1239     return entryPtr == nullptr ? defaultValue : entryPtr->getUInt64();
1240   }
1241 
1242   template <>
1243   unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(std::string const& name) const {
1244     return getEntryPointerOrThrow_(name)->getUInt64();
1245   }
1246 
1247   template <>
1248   std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1249       std::string const& name, std::vector<unsigned long long> const& defaultValue) const {
1250     Entry const* entryPtr = retrieveUntracked(name);
1251     return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt64();
1252   }
1253 
1254   template <>
1255   std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1256       std::string const& name) const {
1257     return getEntryPointerOrThrow_(name)->getVUInt64();
1258   }
1259 
1260   // ----------------------------------------------------------------------
1261   // Int64, Vint64
1262 
1263   template <>
1264   long long ParameterSet::getUntrackedParameter<long long>(std::string const& name,
1265                                                            long long const& defaultValue) const {
1266     Entry const* entryPtr = retrieveUntracked(name);
1267     return entryPtr == nullptr ? defaultValue : entryPtr->getInt64();
1268   }
1269 
1270   template <>
1271   long long ParameterSet::getUntrackedParameter<long long>(std::string const& name) const {
1272     return getEntryPointerOrThrow_(name)->getInt64();
1273   }
1274 
1275   template <>
1276   std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(
1277       std::string const& name, std::vector<long long> const& defaultValue) const {
1278     Entry const* entryPtr = retrieveUntracked(name);
1279     return entryPtr == nullptr ? defaultValue : entryPtr->getVInt64();
1280   }
1281 
1282   template <>
1283   std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(std::string const& name) const {
1284     return getEntryPointerOrThrow_(name)->getVInt64();
1285   }
1286 
1287   // ----------------------------------------------------------------------
1288   // Double, vDouble
1289 
1290   template <>
1291   double ParameterSet::getUntrackedParameter<double>(std::string const& name, double const& defaultValue) const {
1292     Entry const* entryPtr = retrieveUntracked(name);
1293     return entryPtr == nullptr ? defaultValue : entryPtr->getDouble();
1294   }
1295 
1296   template <>
1297   double ParameterSet::getUntrackedParameter<double>(std::string const& name) const {
1298     return getEntryPointerOrThrow_(name)->getDouble();
1299   }
1300 
1301   template <>
1302   std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(
1303       std::string const& name, std::vector<double> const& defaultValue) const {
1304     Entry const* entryPtr = retrieveUntracked(name);
1305     return entryPtr == nullptr ? defaultValue : entryPtr->getVDouble();
1306   }
1307 
1308   template <>
1309   std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(std::string const& name) const {
1310     return getEntryPointerOrThrow_(name)->getVDouble();
1311   }
1312 
1313   // ----------------------------------------------------------------------
1314   // String, vString
1315 
1316   template <>
1317   std::string ParameterSet::getUntrackedParameter<std::string>(std::string const& name,
1318                                                                std::string const& defaultValue) const {
1319     Entry const* entryPtr = retrieveUntracked(name);
1320     return entryPtr == nullptr ? defaultValue : entryPtr->getString();
1321   }
1322 
1323   template <>
1324   std::string ParameterSet::getUntrackedParameter<std::string>(std::string const& name) const {
1325     return getEntryPointerOrThrow_(name)->getString();
1326   }
1327 
1328   template <>
1329   std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(
1330       std::string const& name, std::vector<std::string> const& defaultValue) const {
1331     Entry const* entryPtr = retrieveUntracked(name);
1332     return entryPtr == nullptr ? defaultValue : entryPtr->getVString();
1333   }
1334 
1335   template <>
1336   std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(
1337       std::string const& name) const {
1338     return getEntryPointerOrThrow_(name)->getVString();
1339   }
1340 
1341   // ----------------------------------------------------------------------
1342   //  FileInPath
1343 
1344   template <>
1345   FileInPath ParameterSet::getUntrackedParameter<FileInPath>(std::string const& name,
1346                                                              FileInPath const& defaultValue) const {
1347     Entry const* entryPtr = retrieveUntracked(name);
1348     return entryPtr == nullptr ? defaultValue : entryPtr->getFileInPath();
1349   }
1350 
1351   template <>
1352   FileInPath ParameterSet::getUntrackedParameter<FileInPath>(std::string const& name) const {
1353     return getEntryPointerOrThrow_(name)->getFileInPath();
1354   }
1355 
1356   // ----------------------------------------------------------------------
1357   // InputTag, VInputTag
1358 
1359   template <>
1360   InputTag ParameterSet::getUntrackedParameter<InputTag>(std::string const& name, InputTag const& defaultValue) const {
1361     Entry const* entryPtr = retrieveUntracked(name);
1362     return entryPtr == nullptr ? defaultValue : entryPtr->getInputTag();
1363   }
1364 
1365   template <>
1366   InputTag ParameterSet::getUntrackedParameter<InputTag>(std::string const& name) const {
1367     return getEntryPointerOrThrow_(name)->getInputTag();
1368   }
1369 
1370   template <>
1371   std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(
1372       std::string const& name, std::vector<InputTag> const& defaultValue) const {
1373     Entry const* entryPtr = retrieveUntracked(name);
1374     return entryPtr == nullptr ? defaultValue : entryPtr->getVInputTag();
1375   }
1376 
1377   template <>
1378   std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(std::string const& name) const {
1379     return getEntryPointerOrThrow_(name)->getVInputTag();
1380   }
1381 
1382   // ----------------------------------------------------------------------
1383   // ESInputTag, VESInputTag
1384 
1385   template <>
1386   ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(std::string const& name,
1387                                                              ESInputTag const& defaultValue) const {
1388     Entry const* entryPtr = retrieveUntracked(name);
1389     return entryPtr == nullptr ? defaultValue : entryPtr->getESInputTag();
1390   }
1391 
1392   template <>
1393   ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(std::string const& name) const {
1394     return getEntryPointerOrThrow_(name)->getESInputTag();
1395   }
1396 
1397   template <>
1398   std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(
1399       std::string const& name, std::vector<ESInputTag> const& defaultValue) const {
1400     Entry const* entryPtr = retrieveUntracked(name);
1401     return entryPtr == nullptr ? defaultValue : entryPtr->getVESInputTag();
1402   }
1403 
1404   template <>
1405   std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(std::string const& name) const {
1406     return getEntryPointerOrThrow_(name)->getVESInputTag();
1407   }
1408 
1409   // ----------------------------------------------------------------------
1410   // EventID, VEventID
1411 
1412   template <>
1413   EventID ParameterSet::getUntrackedParameter<EventID>(std::string const& name, EventID const& defaultValue) const {
1414     Entry const* entryPtr = retrieveUntracked(name);
1415     return entryPtr == nullptr ? defaultValue : entryPtr->getEventID();
1416   }
1417 
1418   template <>
1419   EventID ParameterSet::getUntrackedParameter<EventID>(std::string const& name) const {
1420     return getEntryPointerOrThrow_(name)->getEventID();
1421   }
1422 
1423   template <>
1424   std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(
1425       std::string const& name, std::vector<EventID> const& defaultValue) const {
1426     Entry const* entryPtr = retrieveUntracked(name);
1427     return entryPtr == nullptr ? defaultValue : entryPtr->getVEventID();
1428   }
1429 
1430   template <>
1431   std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(std::string const& name) const {
1432     return getEntryPointerOrThrow_(name)->getVEventID();
1433   }
1434 
1435   // ----------------------------------------------------------------------
1436   // LuminosityBlockID, VLuminosityBlockID
1437 
1438   template <>
1439   LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(
1440       std::string const& name, LuminosityBlockID const& defaultValue) const {
1441     Entry const* entryPtr = retrieveUntracked(name);
1442     return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockID();
1443   }
1444 
1445   template <>
1446   LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(std::string const& name) const {
1447     return getEntryPointerOrThrow_(name)->getLuminosityBlockID();
1448   }
1449 
1450   template <>
1451   std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
1452       std::string const& name, std::vector<LuminosityBlockID> const& defaultValue) const {
1453     Entry const* entryPtr = retrieveUntracked(name);
1454     return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockID();
1455   }
1456 
1457   template <>
1458   std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
1459       std::string const& name) const {
1460     return getEntryPointerOrThrow_(name)->getVLuminosityBlockID();
1461   }
1462 
1463   // ----------------------------------------------------------------------
1464   // EventRange, VEventRange
1465 
1466   template <>
1467   EventRange ParameterSet::getUntrackedParameter<EventRange>(std::string const& name,
1468                                                              EventRange const& defaultValue) const {
1469     Entry const* entryPtr = retrieveUntracked(name);
1470     return entryPtr == nullptr ? defaultValue : entryPtr->getEventRange();
1471   }
1472 
1473   template <>
1474   EventRange ParameterSet::getUntrackedParameter<EventRange>(std::string const& name) const {
1475     return getEntryPointerOrThrow_(name)->getEventRange();
1476   }
1477 
1478   template <>
1479   std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(
1480       std::string const& name, std::vector<EventRange> const& defaultValue) const {
1481     Entry const* entryPtr = retrieveUntracked(name);
1482     return entryPtr == nullptr ? defaultValue : entryPtr->getVEventRange();
1483   }
1484 
1485   template <>
1486   std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(std::string const& name) const {
1487     return getEntryPointerOrThrow_(name)->getVEventRange();
1488   }
1489 
1490   // ----------------------------------------------------------------------
1491   // LuminosityBlockRange, VLuminosityBlockRange
1492 
1493   template <>
1494   LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(
1495       std::string const& name, LuminosityBlockRange const& defaultValue) const {
1496     Entry const* entryPtr = retrieveUntracked(name);
1497     return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockRange();
1498   }
1499 
1500   template <>
1501   LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(std::string const& name) const {
1502     return getEntryPointerOrThrow_(name)->getLuminosityBlockRange();
1503   }
1504 
1505   template <>
1506   std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
1507       std::string const& name, std::vector<LuminosityBlockRange> const& defaultValue) const {
1508     Entry const* entryPtr = retrieveUntracked(name);
1509     return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockRange();
1510   }
1511 
1512   template <>
1513   std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
1514       std::string const& name) const {
1515     return getEntryPointerOrThrow_(name)->getVLuminosityBlockRange();
1516   }
1517 
1518   // specializations
1519   // ----------------------------------------------------------------------
1520   // Bool, vBool
1521 
1522   template <>
1523   bool ParameterSet::getParameter<bool>(char const* name) const {
1524     return retrieve(name).getBool();
1525   }
1526 
1527   // ----------------------------------------------------------------------
1528   // Int32, vInt32
1529 
1530   template <>
1531   int ParameterSet::getParameter<int>(char const* name) const {
1532     return retrieve(name).getInt32();
1533   }
1534 
1535   template <>
1536   std::vector<int> ParameterSet::getParameter<std::vector<int> >(char const* name) const {
1537     return retrieve(name).getVInt32();
1538   }
1539 
1540   // ----------------------------------------------------------------------
1541   // Int64, vInt64
1542 
1543   template <>
1544   long long ParameterSet::getParameter<long long>(char const* name) const {
1545     return retrieve(name).getInt64();
1546   }
1547 
1548   template <>
1549   std::vector<long long> ParameterSet::getParameter<std::vector<long long> >(char const* name) const {
1550     return retrieve(name).getVInt64();
1551   }
1552 
1553   // ----------------------------------------------------------------------
1554   // Uint32, vUint32
1555 
1556   template <>
1557   unsigned int ParameterSet::getParameter<unsigned int>(char const* name) const {
1558     return retrieve(name).getUInt32();
1559   }
1560 
1561   template <>
1562   std::vector<unsigned int> ParameterSet::getParameter<std::vector<unsigned int> >(char const* name) const {
1563     return retrieve(name).getVUInt32();
1564   }
1565 
1566   // ----------------------------------------------------------------------
1567   // Uint64, vUint64
1568 
1569   template <>
1570   unsigned long long ParameterSet::getParameter<unsigned long long>(char const* name) const {
1571     return retrieve(name).getUInt64();
1572   }
1573 
1574   template <>
1575   std::vector<unsigned long long> ParameterSet::getParameter<std::vector<unsigned long long> >(char const* name) const {
1576     return retrieve(name).getVUInt64();
1577   }
1578 
1579   // ----------------------------------------------------------------------
1580   // Double, vDouble
1581 
1582   template <>
1583   double ParameterSet::getParameter<double>(char const* name) const {
1584     return retrieve(name).getDouble();
1585   }
1586 
1587   template <>
1588   std::vector<double> ParameterSet::getParameter<std::vector<double> >(char const* name) const {
1589     return retrieve(name).getVDouble();
1590   }
1591 
1592   // ----------------------------------------------------------------------
1593   // String, vString
1594 
1595   template <>
1596   std::string ParameterSet::getParameter<std::string>(char const* name) const {
1597     return retrieve(name).getString();
1598   }
1599 
1600   template <>
1601   std::vector<std::string> ParameterSet::getParameter<std::vector<std::string> >(char const* name) const {
1602     return retrieve(name).getVString();
1603   }
1604 
1605   // ----------------------------------------------------------------------
1606   // FileInPath
1607 
1608   template <>
1609   FileInPath ParameterSet::getParameter<FileInPath>(char const* name) const {
1610     return retrieve(name).getFileInPath();
1611   }
1612 
1613   // ----------------------------------------------------------------------
1614   // InputTag
1615 
1616   template <>
1617   InputTag ParameterSet::getParameter<InputTag>(char const* name) const {
1618     Entry const& e_input = retrieve(name);
1619     switch (e_input.typeCode()) {
1620       case 't':  // InputTag
1621       {
1622         return e_input.getInputTag();
1623       }
1624       case 'S':  // string Hex
1625       {
1626         std::string const& label = e_input.getString();
1627         deprecatedInputTagWarning(name, label);
1628         return InputTag(label);
1629       }
1630       case 'Z':  // string Raw
1631       {
1632         std::string const& label = e_input.getString();
1633         deprecatedInputTagWarning(name, label);
1634         return InputTag(label);
1635       }
1636     }
1637     throw Exception(errors::Configuration, "ValueError")
1638         << "type of " << name << " is expected to be InputTag or string (deprecated)";
1639   }
1640 
1641   // ----------------------------------------------------------------------
1642   // VInputTag
1643 
1644   template <>
1645   std::vector<InputTag> ParameterSet::getParameter<std::vector<InputTag> >(char const* name) const {
1646     return retrieve(name).getVInputTag();
1647   }
1648 
1649   // ----------------------------------------------------------------------
1650   // ESInputTag
1651 
1652   template <>
1653   ESInputTag ParameterSet::getParameter<ESInputTag>(char const* name) const {
1654     return retrieve(name).getESInputTag();
1655   }
1656 
1657   // ----------------------------------------------------------------------
1658   // VESInputTag
1659 
1660   template <>
1661   std::vector<ESInputTag> ParameterSet::getParameter<std::vector<ESInputTag> >(char const* name) const {
1662     return retrieve(name).getVESInputTag();
1663   }
1664 
1665   // ----------------------------------------------------------------------
1666   // EventID
1667 
1668   template <>
1669   EventID ParameterSet::getParameter<EventID>(char const* name) const {
1670     return retrieve(name).getEventID();
1671   }
1672 
1673   // ----------------------------------------------------------------------
1674   // VEventID
1675 
1676   template <>
1677   std::vector<EventID> ParameterSet::getParameter<std::vector<EventID> >(char const* name) const {
1678     return retrieve(name).getVEventID();
1679   }
1680 
1681   // ----------------------------------------------------------------------
1682   // LuminosityBlockID
1683 
1684   template <>
1685   LuminosityBlockID ParameterSet::getParameter<LuminosityBlockID>(char const* name) const {
1686     return retrieve(name).getLuminosityBlockID();
1687   }
1688 
1689   // ----------------------------------------------------------------------
1690   // VLuminosityBlockID
1691 
1692   template <>
1693   std::vector<LuminosityBlockID> ParameterSet::getParameter<std::vector<LuminosityBlockID> >(char const* name) const {
1694     return retrieve(name).getVLuminosityBlockID();
1695   }
1696 
1697   // ----------------------------------------------------------------------
1698   // EventRange
1699 
1700   template <>
1701   EventRange ParameterSet::getParameter<EventRange>(char const* name) const {
1702     return retrieve(name).getEventRange();
1703   }
1704 
1705   // ----------------------------------------------------------------------
1706   // VEventRange
1707 
1708   template <>
1709   std::vector<EventRange> ParameterSet::getParameter<std::vector<EventRange> >(char const* name) const {
1710     return retrieve(name).getVEventRange();
1711   }
1712 
1713   // ----------------------------------------------------------------------
1714   // LuminosityBlockRange
1715 
1716   template <>
1717   LuminosityBlockRange ParameterSet::getParameter<LuminosityBlockRange>(char const* name) const {
1718     return retrieve(name).getLuminosityBlockRange();
1719   }
1720 
1721   // ----------------------------------------------------------------------
1722   // VLuminosityBlockRange
1723 
1724   template <>
1725   std::vector<LuminosityBlockRange> ParameterSet::getParameter<std::vector<LuminosityBlockRange> >(
1726       char const* name) const {
1727     return retrieve(name).getVLuminosityBlockRange();
1728   }
1729 
1730   // ----------------------------------------------------------------------
1731   // PSet, vPSet
1732 
1733   template <>
1734   ParameterSet ParameterSet::getParameter<ParameterSet>(char const* name) const {
1735     return getParameterSet(name);
1736   }
1737 
1738   template <>
1739   VParameterSet ParameterSet::getParameter<VParameterSet>(char const* name) const {
1740     return getParameterSetVector(name);
1741   }
1742 
1743   // untracked parameters
1744 
1745   // ----------------------------------------------------------------------
1746   // Bool, vBool
1747 
1748   template <>
1749   bool ParameterSet::getUntrackedParameter<bool>(char const* name, bool const& defaultValue) const {
1750     Entry const* entryPtr = retrieveUntracked(name);
1751     return entryPtr == nullptr ? defaultValue : entryPtr->getBool();
1752   }
1753 
1754   template <>
1755   bool ParameterSet::getUntrackedParameter<bool>(char const* name) const {
1756     return getEntryPointerOrThrow_(name)->getBool();
1757   }
1758 
1759   // ----------------------------------------------------------------------
1760   // Int32, vInt32
1761 
1762   template <>
1763   int ParameterSet::getUntrackedParameter<int>(char const* name, int const& defaultValue) const {
1764     Entry const* entryPtr = retrieveUntracked(name);
1765     return entryPtr == nullptr ? defaultValue : entryPtr->getInt32();
1766   }
1767 
1768   template <>
1769   int ParameterSet::getUntrackedParameter<int>(char const* name) const {
1770     return getEntryPointerOrThrow_(name)->getInt32();
1771   }
1772 
1773   template <>
1774   std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(char const* name,
1775                                                                           std::vector<int> const& defaultValue) const {
1776     Entry const* entryPtr = retrieveUntracked(name);
1777     return entryPtr == nullptr ? defaultValue : entryPtr->getVInt32();
1778   }
1779 
1780   template <>
1781   std::vector<int> ParameterSet::getUntrackedParameter<std::vector<int> >(char const* name) const {
1782     return getEntryPointerOrThrow_(name)->getVInt32();
1783   }
1784 
1785   // ----------------------------------------------------------------------
1786   // Uint32, vUint32
1787 
1788   template <>
1789   unsigned int ParameterSet::getUntrackedParameter<unsigned int>(char const* name,
1790                                                                  unsigned int const& defaultValue) const {
1791     Entry const* entryPtr = retrieveUntracked(name);
1792     return entryPtr == nullptr ? defaultValue : entryPtr->getUInt32();
1793   }
1794 
1795   template <>
1796   unsigned int ParameterSet::getUntrackedParameter<unsigned int>(char const* name) const {
1797     return getEntryPointerOrThrow_(name)->getUInt32();
1798   }
1799 
1800   template <>
1801   std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(
1802       char const* name, std::vector<unsigned int> const& defaultValue) const {
1803     Entry const* entryPtr = retrieveUntracked(name);
1804     return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt32();
1805   }
1806 
1807   template <>
1808   std::vector<unsigned int> ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(char const* name) const {
1809     return getEntryPointerOrThrow_(name)->getVUInt32();
1810   }
1811 
1812   // ----------------------------------------------------------------------
1813   // Uint64, vUint64
1814 
1815   template <>
1816   unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(
1817       char const* name, unsigned long long const& defaultValue) const {
1818     Entry const* entryPtr = retrieveUntracked(name);
1819     return entryPtr == nullptr ? defaultValue : entryPtr->getUInt64();
1820   }
1821 
1822   template <>
1823   unsigned long long ParameterSet::getUntrackedParameter<unsigned long long>(char const* name) const {
1824     return getEntryPointerOrThrow_(name)->getUInt64();
1825   }
1826 
1827   template <>
1828   std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1829       char const* name, std::vector<unsigned long long> const& defaultValue) const {
1830     Entry const* entryPtr = retrieveUntracked(name);
1831     return entryPtr == nullptr ? defaultValue : entryPtr->getVUInt64();
1832   }
1833 
1834   template <>
1835   std::vector<unsigned long long> ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(
1836       char const* name) const {
1837     return getEntryPointerOrThrow_(name)->getVUInt64();
1838   }
1839 
1840   // ----------------------------------------------------------------------
1841   // Int64, Vint64
1842 
1843   template <>
1844   long long ParameterSet::getUntrackedParameter<long long>(char const* name, long long const& defaultValue) const {
1845     Entry const* entryPtr = retrieveUntracked(name);
1846     return entryPtr == nullptr ? defaultValue : entryPtr->getInt64();
1847   }
1848 
1849   template <>
1850   long long ParameterSet::getUntrackedParameter<long long>(char const* name) const {
1851     return getEntryPointerOrThrow_(name)->getInt64();
1852   }
1853 
1854   template <>
1855   std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(
1856       char const* name, std::vector<long long> const& defaultValue) const {
1857     Entry const* entryPtr = retrieveUntracked(name);
1858     return entryPtr == nullptr ? defaultValue : entryPtr->getVInt64();
1859   }
1860 
1861   template <>
1862   std::vector<long long> ParameterSet::getUntrackedParameter<std::vector<long long> >(char const* name) const {
1863     return getEntryPointerOrThrow_(name)->getVInt64();
1864   }
1865 
1866   // ----------------------------------------------------------------------
1867   // Double, vDouble
1868 
1869   template <>
1870   double ParameterSet::getUntrackedParameter<double>(char const* name, double const& defaultValue) const {
1871     Entry const* entryPtr = retrieveUntracked(name);
1872     return entryPtr == nullptr ? defaultValue : entryPtr->getDouble();
1873   }
1874 
1875   template <>
1876   double ParameterSet::getUntrackedParameter<double>(char const* name) const {
1877     return getEntryPointerOrThrow_(name)->getDouble();
1878   }
1879 
1880   template <>
1881   std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(
1882       char const* name, std::vector<double> const& defaultValue) const {
1883     Entry const* entryPtr = retrieveUntracked(name);
1884     return entryPtr == nullptr ? defaultValue : entryPtr->getVDouble();
1885   }
1886 
1887   template <>
1888   std::vector<double> ParameterSet::getUntrackedParameter<std::vector<double> >(char const* name) const {
1889     return getEntryPointerOrThrow_(name)->getVDouble();
1890   }
1891 
1892   // ----------------------------------------------------------------------
1893   // String, vString
1894 
1895   template <>
1896   std::string ParameterSet::getUntrackedParameter<std::string>(char const* name,
1897                                                                std::string const& defaultValue) const {
1898     Entry const* entryPtr = retrieveUntracked(name);
1899     return entryPtr == nullptr ? defaultValue : entryPtr->getString();
1900   }
1901 
1902   template <>
1903   std::string ParameterSet::getUntrackedParameter<std::string>(char const* name) const {
1904     return getEntryPointerOrThrow_(name)->getString();
1905   }
1906 
1907   template <>
1908   std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(
1909       char const* name, std::vector<std::string> const& defaultValue) const {
1910     Entry const* entryPtr = retrieveUntracked(name);
1911     return entryPtr == nullptr ? defaultValue : entryPtr->getVString();
1912   }
1913 
1914   template <>
1915   std::vector<std::string> ParameterSet::getUntrackedParameter<std::vector<std::string> >(char const* name) const {
1916     return getEntryPointerOrThrow_(name)->getVString();
1917   }
1918 
1919   // ----------------------------------------------------------------------
1920   //  FileInPath
1921 
1922   template <>
1923   FileInPath ParameterSet::getUntrackedParameter<FileInPath>(char const* name, FileInPath const& defaultValue) const {
1924     Entry const* entryPtr = retrieveUntracked(name);
1925     return entryPtr == nullptr ? defaultValue : entryPtr->getFileInPath();
1926   }
1927 
1928   template <>
1929   FileInPath ParameterSet::getUntrackedParameter<FileInPath>(char const* name) const {
1930     return getEntryPointerOrThrow_(name)->getFileInPath();
1931   }
1932 
1933   // ----------------------------------------------------------------------
1934   // InputTag, VInputTag
1935 
1936   template <>
1937   InputTag ParameterSet::getUntrackedParameter<InputTag>(char const* name, InputTag const& defaultValue) const {
1938     Entry const* entryPtr = retrieveUntracked(name);
1939     return entryPtr == nullptr ? defaultValue : entryPtr->getInputTag();
1940   }
1941 
1942   template <>
1943   InputTag ParameterSet::getUntrackedParameter<InputTag>(char const* name) const {
1944     return getEntryPointerOrThrow_(name)->getInputTag();
1945   }
1946 
1947   template <>
1948   std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(
1949       char const* name, std::vector<InputTag> const& defaultValue) const {
1950     Entry const* entryPtr = retrieveUntracked(name);
1951     return entryPtr == nullptr ? defaultValue : entryPtr->getVInputTag();
1952   }
1953 
1954   template <>
1955   std::vector<InputTag> ParameterSet::getUntrackedParameter<std::vector<InputTag> >(char const* name) const {
1956     return getEntryPointerOrThrow_(name)->getVInputTag();
1957   }
1958 
1959   // ----------------------------------------------------------------------
1960   // ESInputTag, VESInputTag
1961 
1962   template <>
1963   ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(char const* name, ESInputTag const& defaultValue) const {
1964     Entry const* entryPtr = retrieveUntracked(name);
1965     return entryPtr == nullptr ? defaultValue : entryPtr->getESInputTag();
1966   }
1967 
1968   template <>
1969   ESInputTag ParameterSet::getUntrackedParameter<ESInputTag>(char const* name) const {
1970     return getEntryPointerOrThrow_(name)->getESInputTag();
1971   }
1972 
1973   template <>
1974   std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(
1975       char const* name, std::vector<ESInputTag> const& defaultValue) const {
1976     Entry const* entryPtr = retrieveUntracked(name);
1977     return entryPtr == nullptr ? defaultValue : entryPtr->getVESInputTag();
1978   }
1979 
1980   template <>
1981   std::vector<ESInputTag> ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(char const* name) const {
1982     return getEntryPointerOrThrow_(name)->getVESInputTag();
1983   }
1984 
1985   // ----------------------------------------------------------------------
1986   // EventID, VEventID
1987 
1988   template <>
1989   EventID ParameterSet::getUntrackedParameter<EventID>(char const* name, EventID const& defaultValue) const {
1990     Entry const* entryPtr = retrieveUntracked(name);
1991     return entryPtr == nullptr ? defaultValue : entryPtr->getEventID();
1992   }
1993 
1994   template <>
1995   EventID ParameterSet::getUntrackedParameter<EventID>(char const* name) const {
1996     return getEntryPointerOrThrow_(name)->getEventID();
1997   }
1998 
1999   template <>
2000   std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(
2001       char const* name, std::vector<EventID> const& defaultValue) const {
2002     Entry const* entryPtr = retrieveUntracked(name);
2003     return entryPtr == nullptr ? defaultValue : entryPtr->getVEventID();
2004   }
2005 
2006   template <>
2007   std::vector<EventID> ParameterSet::getUntrackedParameter<std::vector<EventID> >(char const* name) const {
2008     return getEntryPointerOrThrow_(name)->getVEventID();
2009   }
2010 
2011   // ----------------------------------------------------------------------
2012   // LuminosityBlockID, VLuminosityBlockID
2013 
2014   template <>
2015   LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(
2016       char const* name, LuminosityBlockID const& defaultValue) const {
2017     Entry const* entryPtr = retrieveUntracked(name);
2018     return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockID();
2019   }
2020 
2021   template <>
2022   LuminosityBlockID ParameterSet::getUntrackedParameter<LuminosityBlockID>(char const* name) const {
2023     return getEntryPointerOrThrow_(name)->getLuminosityBlockID();
2024   }
2025 
2026   template <>
2027   std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
2028       char const* name, std::vector<LuminosityBlockID> const& defaultValue) const {
2029     Entry const* entryPtr = retrieveUntracked(name);
2030     return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockID();
2031   }
2032 
2033   template <>
2034   std::vector<LuminosityBlockID> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(
2035       char const* name) const {
2036     return getEntryPointerOrThrow_(name)->getVLuminosityBlockID();
2037   }
2038 
2039   // ----------------------------------------------------------------------
2040   // EventRange, VEventRange
2041 
2042   template <>
2043   EventRange ParameterSet::getUntrackedParameter<EventRange>(char const* name, EventRange const& defaultValue) const {
2044     Entry const* entryPtr = retrieveUntracked(name);
2045     return entryPtr == nullptr ? defaultValue : entryPtr->getEventRange();
2046   }
2047 
2048   template <>
2049   EventRange ParameterSet::getUntrackedParameter<EventRange>(char const* name) const {
2050     return getEntryPointerOrThrow_(name)->getEventRange();
2051   }
2052 
2053   template <>
2054   std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(
2055       char const* name, std::vector<EventRange> const& defaultValue) const {
2056     Entry const* entryPtr = retrieveUntracked(name);
2057     return entryPtr == nullptr ? defaultValue : entryPtr->getVEventRange();
2058   }
2059 
2060   template <>
2061   std::vector<EventRange> ParameterSet::getUntrackedParameter<std::vector<EventRange> >(char const* name) const {
2062     return getEntryPointerOrThrow_(name)->getVEventRange();
2063   }
2064 
2065   // ----------------------------------------------------------------------
2066   // LuminosityBlockRange, VLuminosityBlockRange
2067 
2068   template <>
2069   LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(
2070       char const* name, LuminosityBlockRange const& defaultValue) const {
2071     Entry const* entryPtr = retrieveUntracked(name);
2072     return entryPtr == nullptr ? defaultValue : entryPtr->getLuminosityBlockRange();
2073   }
2074 
2075   template <>
2076   LuminosityBlockRange ParameterSet::getUntrackedParameter<LuminosityBlockRange>(char const* name) const {
2077     return getEntryPointerOrThrow_(name)->getLuminosityBlockRange();
2078   }
2079 
2080   template <>
2081   std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
2082       char const* name, std::vector<LuminosityBlockRange> const& defaultValue) const {
2083     Entry const* entryPtr = retrieveUntracked(name);
2084     return entryPtr == nullptr ? defaultValue : entryPtr->getVLuminosityBlockRange();
2085   }
2086 
2087   template <>
2088   std::vector<LuminosityBlockRange> ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(
2089       char const* name) const {
2090     return getEntryPointerOrThrow_(name)->getVLuminosityBlockRange();
2091   }
2092 
2093   // ----------------------------------------------------------------------
2094   // PSet, vPSet
2095 
2096   template <>
2097   ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(char const* name,
2098                                                                  ParameterSet const& defaultValue) const {
2099     return getUntrackedParameterSet(name, defaultValue);
2100   }
2101 
2102   template <>
2103   VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(char const* name,
2104                                                                    VParameterSet const& defaultValue) const {
2105     return getUntrackedParameterSetVector(name, defaultValue);
2106   }
2107 
2108   template <>
2109   ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(std::string const& name,
2110                                                                  ParameterSet const& defaultValue) const {
2111     return getUntrackedParameterSet(name, defaultValue);
2112   }
2113 
2114   template <>
2115   VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(std::string const& name,
2116                                                                    VParameterSet const& defaultValue) const {
2117     return getUntrackedParameterSetVector(name, defaultValue);
2118   }
2119 
2120   template <>
2121   ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(char const* name) const {
2122     return getUntrackedParameterSet(name);
2123   }
2124 
2125   template <>
2126   VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(char const* name) const {
2127     return getUntrackedParameterSetVector(name);
2128   }
2129 
2130   template <>
2131   ParameterSet ParameterSet::getUntrackedParameter<ParameterSet>(std::string const& name) const {
2132     return getUntrackedParameterSet(name);
2133   }
2134 
2135   template <>
2136   VParameterSet ParameterSet::getUntrackedParameter<VParameterSet>(std::string const& name) const {
2137     return getUntrackedParameterSetVector(name);
2138   }
2139 
2140   //----------------------------------------------------------------------------------
2141   // specializations for addParameter and addUntrackedParameter
2142 
2143   template <>
2144   void ParameterSet::addParameter<ParameterSet>(std::string const& name, ParameterSet const& value) {
2145     invalidateRegistration(name);
2146     insertParameterSet(true, name, ParameterSetEntry(value, true));
2147   }
2148 
2149   template <>
2150   void ParameterSet::addParameter<VParameterSet>(std::string const& name, VParameterSet const& value) {
2151     invalidateRegistration(name);
2152     insertVParameterSet(true, name, VParameterSetEntry(value, true));
2153   }
2154 
2155   template <>
2156   void ParameterSet::addParameter<ParameterSet>(char const* name, ParameterSet const& value) {
2157     invalidateRegistration(name);
2158     insertParameterSet(true, name, ParameterSetEntry(value, true));
2159   }
2160 
2161   template <>
2162   void ParameterSet::addParameter<VParameterSet>(char const* name, VParameterSet const& value) {
2163     invalidateRegistration(name);
2164     insertVParameterSet(true, name, VParameterSetEntry(value, true));
2165   }
2166 
2167   template <>
2168   void ParameterSet::addUntrackedParameter<ParameterSet>(std::string const& name, ParameterSet const& value) {
2169     insertParameterSet(true, name, ParameterSetEntry(value, false));
2170   }
2171 
2172   template <>
2173   void ParameterSet::addUntrackedParameter<VParameterSet>(std::string const& name, VParameterSet const& value) {
2174     insertVParameterSet(true, name, VParameterSetEntry(value, false));
2175   }
2176 
2177   template <>
2178   void ParameterSet::addUntrackedParameter<ParameterSet>(char const* name, ParameterSet const& value) {
2179     insertParameterSet(true, name, ParameterSetEntry(value, false));
2180   }
2181 
2182   template <>
2183   void ParameterSet::addUntrackedParameter<VParameterSet>(char const* name, VParameterSet const& value) {
2184     insertVParameterSet(true, name, VParameterSetEntry(value, false));
2185   }
2186 
2187   //----------------------------------------------------------------------------------
2188   // specializations for getParameterNamesForType
2189 
2190   template <>
2191   std::vector<std::string> ParameterSet::getParameterNamesForType<ParameterSet>(bool trackiness) const {
2192     std::vector<std::string> output;
2193     getParameterSetNames(output, trackiness);
2194     return output;
2195   }
2196 
2197   template <>
2198   std::vector<std::string> ParameterSet::getParameterNamesForType<VParameterSet>(bool trackiness) const {
2199     std::vector<std::string> output;
2200     getParameterSetVectorNames(output, trackiness);
2201     return output;
2202   }
2203 
2204   ParameterSet const& ParameterSet::getParameterSet(std::string const& name) const {
2205     return retrieveParameterSet(name).pset();
2206   }
2207 
2208   ParameterSet const& ParameterSet::getParameterSet(char const* name) const {
2209     return retrieveParameterSet(name).pset();
2210   }
2211 
2212   ParameterSet ParameterSet::getUntrackedParameterSet(std::string const& name, ParameterSet const& defaultValue) const {
2213     return getUntrackedParameterSet(name.c_str(), defaultValue);
2214   }
2215 
2216   ParameterSet ParameterSet::getUntrackedParameterSet(char const* name, ParameterSet const& defaultValue) const {
2217     ParameterSetEntry const* entryPtr = retrieveUntrackedParameterSet(name);
2218     if (entryPtr == nullptr) {
2219       return defaultValue;
2220     }
2221     return entryPtr->pset();
2222   }
2223 
2224   ParameterSet const& ParameterSet::getUntrackedParameterSet(std::string const& name) const {
2225     return getUntrackedParameterSet(name.c_str());
2226   }
2227 
2228   ParameterSet const& ParameterSet::getUntrackedParameterSet(char const* name) const {
2229     ParameterSetEntry const* result = retrieveUntrackedParameterSet(name);
2230     if (result == nullptr)
2231       throw Exception(errors::Configuration, "MissingParameter:")
2232           << "The required ParameterSet '" << name << "' was not specified.\n";
2233     return result->pset();
2234   }
2235 
2236   VParameterSet const& ParameterSet::getParameterSetVector(std::string const& name) const {
2237     return retrieveVParameterSet(name).vpset();
2238   }
2239 
2240   VParameterSet const& ParameterSet::getParameterSetVector(char const* name) const {
2241     return retrieveVParameterSet(name).vpset();
2242   }
2243 
2244   VParameterSet ParameterSet::getUntrackedParameterSetVector(std::string const& name,
2245                                                              VParameterSet const& defaultValue) const {
2246     return getUntrackedParameterSetVector(name.c_str(), defaultValue);
2247   }
2248 
2249   VParameterSet ParameterSet::getUntrackedParameterSetVector(char const* name,
2250                                                              VParameterSet const& defaultValue) const {
2251     VParameterSetEntry const* entryPtr = retrieveUntrackedVParameterSet(name);
2252     return entryPtr == nullptr ? defaultValue : entryPtr->vpset();
2253   }
2254 
2255   VParameterSet const& ParameterSet::getUntrackedParameterSetVector(std::string const& name) const {
2256     return getUntrackedParameterSetVector(name.c_str());
2257   }
2258 
2259   VParameterSet const& ParameterSet::getUntrackedParameterSetVector(char const* name) const {
2260     VParameterSetEntry const* result = retrieveUntrackedVParameterSet(name);
2261     if (result == nullptr)
2262       throw Exception(errors::Configuration, "MissingParameter:")
2263           << "The required ParameterSetVector '" << name << "' was not specified.\n";
2264     return result->vpset();
2265   }
2266 }  // namespace edm