CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/FWCore/ParameterSet/src/ParameterSet.cc

Go to the documentation of this file.
00001  // ----------------------------------------------------------------------
00002 //
00003 // definition of ParameterSet's function members
00004 // ----------------------------------------------------------------------
00005 
00006 // ----------------------------------------------------------------------
00007 // prerequisite source files and headers
00008 // ----------------------------------------------------------------------
00009 
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 #include "FWCore/ParameterSet/interface/Registry.h"
00014 #include "FWCore/ParameterSet/interface/split.h"
00015 #include "FWCore/Utilities/interface/Algorithms.h"
00016 #include "FWCore/Utilities/interface/Digest.h"
00017 #include "FWCore/Utilities/interface/EDMException.h"
00018 
00019 #include "boost/bind.hpp"
00020 
00021 #include <algorithm>
00022 #include <iostream>
00023 #include <sstream>
00024 #include <cassert>
00025 
00026 // ----------------------------------------------------------------------
00027 // class invariant checker
00028 // ----------------------------------------------------------------------
00029 
00030 namespace edm {
00031 
00032   void
00033   ParameterSet::invalidateRegistration(std::string const& nameOfTracked) const {
00034     // We have added a new parameter.  Invalidate the ID.
00035     if(isRegistered()) {
00036       id_ = ParameterSetID();
00037       if(!nameOfTracked.empty()) {
00038         // Give a warning (informational for now).
00039         LogInfo("ParameterSet")  << "Warning: You have added a new tracked parameter\n"
00040                                  <<  "'" << nameOfTracked << "' to a previously registered parameter set.\n"
00041                                  << "This is a bad idea because the new parameter(s) will not be recorded.\n"
00042                                  << "Use the forthcoming ParameterSetDescription facility instead.\n"
00043                                  << "A warning is given only for the first such parameter in a pset.\n";
00044       }
00045     }
00046     assert(!isRegistered());
00047   }
00048 
00049   // ----------------------------------------------------------------------
00050   // constructors
00051   // ----------------------------------------------------------------------
00052 
00053   ParameterSet::ParameterSet() :
00054     tbl_(),
00055     psetTable_(),
00056     vpsetTable_(),
00057     id_() {
00058   }
00059 
00060   // ----------------------------------------------------------------------
00061   // from coded string
00062 
00063   ParameterSet::ParameterSet(std::string const& code) :
00064     tbl_(),
00065     psetTable_(),
00066     vpsetTable_(),
00067     id_() {
00068     if(!fromString(code)) {
00069       throw Exception(errors::Configuration, "InvalidInput")
00070         << "The encoded configuration string "
00071         << "passed to a ParameterSet during construction is invalid:\n"
00072         << code;
00073     }
00074   }
00075 
00076   // ----------------------------------------------------------------------
00077   // from coded string and ID.  Will cause registration
00078 
00079   ParameterSet::ParameterSet(std::string const& code, ParameterSetID const& id) :
00080     tbl_(),
00081     psetTable_(),
00082     vpsetTable_(),
00083     id_(id) {
00084     if(!fromString(code)) {
00085       throw Exception(errors::Configuration, "InvalidInput")
00086         << "The encoded configuration string "
00087         << "passed to a ParameterSet during construction is invalid:\n"
00088         << code;
00089     }
00090     pset::Registry::instance()->insertMapped(*this);
00091   }
00092 
00093   ParameterSet::~ParameterSet() {}
00094 
00095   ParameterSet::ParameterSet(ParameterSet const& other)
00096   : tbl_(other.tbl_),
00097     psetTable_(other.psetTable_),
00098     vpsetTable_(other.vpsetTable_),
00099     id_(other.id_) {
00100   }
00101 
00102   ParameterSet& ParameterSet::operator=(ParameterSet const& other) {
00103     ParameterSet temp(other);
00104     swap(temp);
00105     return *this;
00106   }
00107 
00108   void ParameterSet::copyForModify(ParameterSet const& other) {
00109     ParameterSet temp(other);
00110     swap(temp);
00111     id_ = ParameterSetID();
00112   }
00113 
00114   void ParameterSet::swap(ParameterSet& other) {
00115     tbl_.swap(other.tbl_);
00116     psetTable_.swap(other.psetTable_);
00117     vpsetTable_.swap(other.vpsetTable_);
00118     id_.swap(other.id_);
00119   }
00120 
00121   ParameterSet const& ParameterSet::registerIt() {
00122     if(!isRegistered()) {
00123       calculateID();
00124       pset::Registry::instance()->insertMapped(*this);
00125     }
00126     return *this;
00127   }
00128 
00129   std::auto_ptr<ParameterSet> ParameterSet::popParameterSet(std::string const& name) {
00130     assert(!isRegistered());
00131     psettable::iterator it = psetTable_.find(name);
00132     assert(it != psetTable_.end());
00133     std::auto_ptr<ParameterSet> pset(new ParameterSet);
00134     std::swap(*pset, it->second.pset());
00135     psetTable_.erase(it);
00136     return pset;
00137   }
00138 
00139   void ParameterSet::eraseSimpleParameter(std::string const& name) {
00140     assert(!isRegistered());
00141     table::iterator it = tbl_.find(name);
00142     assert(it != tbl_.end());
00143     tbl_.erase(it);
00144   }
00145 
00146   void ParameterSet::eraseOrSetUntrackedParameterSet(std::string const& name) {
00147     assert(!isRegistered());
00148     psettable::iterator it = psetTable_.find(name);
00149     assert(it != psetTable_.end());
00150     ParameterSet& pset = it->second.pset();
00151     if (pset.isRegistered()) {
00152       it->second.setIsTracked(false);
00153     } else {
00154       psetTable_.erase(it);
00155     }
00156   }
00157 
00158   std::auto_ptr<std::vector<ParameterSet> > ParameterSet::popVParameterSet(std::string const& name) {
00159     assert(!isRegistered());
00160     vpsettable::iterator it = vpsetTable_.find(name);
00161     assert(it != vpsetTable_.end());
00162     std::auto_ptr<std::vector<ParameterSet> > vpset(new std::vector<ParameterSet>);
00163     std::swap(*vpset, it->second.vpset());
00164     vpsetTable_.erase(it);
00165     return vpset;
00166   }
00167 
00168   void ParameterSet::calculateID() {
00169     // make sure contained tracked psets are updated
00170     for(psettable::iterator i = psetTable_.begin(), e = psetTable_.end(); i != e; ++i) {
00171       if(!i->second.pset().isRegistered()) {
00172         i->second.pset().registerIt();
00173       }
00174       i->second.updateID();
00175     }
00176 
00177     // make sure contained tracked vpsets are updated
00178     for(vpsettable::iterator i = vpsetTable_.begin(), e = vpsetTable_.end(); i != e; ++i) {
00179       i->second.registerPsetsAndUpdateIDs();
00180     }
00181 //  The old, string base code is found below. Uncomment this and the assert to check whether
00182 //  there are discrepancies between old and new implementation.
00183 //    std::string stringrep;
00184 //    toString(stringrep);
00185 //    cms::Digest md5alg(stringrep);
00186 //    id_ = ParameterSetID(md5alg.digest().toString());
00187     cms::Digest newDigest;
00188     toDigest(newDigest);
00189     id_ = ParameterSetID(newDigest.digest().toString());
00190 //    assert(md5alg.digest().toString() == newDigest.digest().toString());
00191     assert(isRegistered());
00192   }
00193 
00194   // ----------------------------------------------------------------------
00195   // identification
00196   ParameterSetID
00197   ParameterSet::id() const {
00198     // checks if valid
00199     if(!isRegistered()) {
00200       throw Exception(errors::LogicError)
00201         << "ParameterSet::id() called prematurely\n"
00202         << "before ParameterSet::registerIt() has been called.\n";
00203     }
00204     return id_;
00205   }
00206 
00207   void ParameterSet::setID(ParameterSetID const& id) const {
00208     id_ = id;
00209   }
00210 
00211   // ----------------------------------------------------------------------
00212   // Entry-handling
00213   // ----------------------------------------------------------------------
00214 
00215   Entry const*
00216   ParameterSet::getEntryPointerOrThrow_(char const* name) const {
00217     return getEntryPointerOrThrow_(std::string(name));
00218   }
00219 
00220   Entry const*
00221   ParameterSet::getEntryPointerOrThrow_(std::string const& name) const {
00222     Entry const* result = retrieveUntracked(name);
00223     if(result == 0)
00224       throw Exception(errors::Configuration, "MissingParameter:")
00225         << "The required parameter '" << name
00226         << "' was not specified.\n";
00227     return result;
00228   }
00229 
00230   template<typename T, typename U> T first(std::pair<T, U> const& p) {
00231     return p.first;
00232   }
00233 
00234   template<typename T, typename U> U second(std::pair<T, U> const& p) {
00235     return p.second;
00236   }
00237 
00238   Entry const&
00239   ParameterSet::retrieve(char const* name) const {
00240     return retrieve(std::string(name));
00241   }
00242 
00243   Entry const&
00244   ParameterSet::retrieve(std::string const& name) const {
00245     table::const_iterator  it = tbl_.find(name);
00246     if(it == tbl_.end()) {
00247         throw Exception(errors::Configuration, "MissingParameter:")
00248           << "Parameter '" << name
00249           << "' not found.";
00250     }
00251     if(it->second.isTracked() == false) {
00252       if(name[0] == '@') {
00253         throw Exception(errors::Configuration, "StatusMismatch:")
00254           << "Framework Error:  Parameter '" << name
00255           << "' is incorrectly designated as tracked in the framework.";
00256       } else {
00257         throw Exception(errors::Configuration, "StatusMismatch:")
00258           << "Parameter '" << name
00259           << "' is designated as tracked in the code,\n"
00260           << "but is designated as untracked in the configuration file.\n"
00261           << "Please remove 'untracked' from the configuration file for parameter '"<< name << "'.";
00262       }
00263     }
00264     return it->second;
00265   }  // retrieve()
00266 
00267   Entry const*
00268   ParameterSet::retrieveUntracked(char const* name) const {
00269     return retrieveUntracked(std::string(name));
00270   }
00271 
00272   Entry const*
00273   ParameterSet::retrieveUntracked(std::string const& name) const {
00274     table::const_iterator  it = tbl_.find(name);
00275 
00276     if(it == tbl_.end()) return 0;
00277     if(it->second.isTracked()) {
00278       if(name[0] == '@') {
00279         throw Exception(errors::Configuration, "StatusMismatch:")
00280           << "Framework Error:  Parameter '" << name
00281           << "' is incorrectly designated as untracked in the framework.";
00282       } else {
00283         throw Exception(errors::Configuration, "StatusMismatch:")
00284           << "Parameter '" << name
00285           << "' is designated as untracked in the code,\n"
00286           << "but is not designated as untracked in the configuration file.\n"
00287           << "Please change the configuration file to 'untracked <type> " << name << "'.";
00288       }
00289     }
00290     return &it->second;
00291   }  // retrieve()
00292 
00293   ParameterSetEntry const&
00294   ParameterSet::retrieveParameterSet(std::string const& name) const {
00295     psettable::const_iterator it = psetTable_.find(name);
00296     if(it == psetTable_.end()) {
00297         throw Exception(errors::Configuration, "MissingParameter:")
00298           << "ParameterSet '" << name
00299           << "' not found.";
00300     }
00301     if(it->second.isTracked() == false) {
00302       if(name[0] == '@') {
00303         throw Exception(errors::Configuration, "StatusMismatch:")
00304           << "Framework Error:  ParameterSet '" << name
00305           << "' is incorrectly designated as tracked in the framework.";
00306       } else {
00307         throw Exception(errors::Configuration, "StatusMismatch:")
00308           << "ParameterSet '" << name
00309           << "' is designated as tracked in the code,\n"
00310           << "but is designated as untracked in the configuration file.\n"
00311           << "Please remove 'untracked' from the configuration file for parameter '"<< name << "'.";
00312       }
00313     }
00314     return it->second;
00315   }  // retrieve()
00316 
00317   ParameterSetEntry const*
00318   ParameterSet::retrieveUntrackedParameterSet(std::string const& name) const {
00319     psettable::const_iterator  it = psetTable_.find(name);
00320 
00321     if(it == psetTable_.end()) return 0;
00322     if(it->second.isTracked()) {
00323       if(name[0] == '@') {
00324         throw Exception(errors::Configuration, "StatusMismatch:")
00325           << "Framework Error:  ParameterSet '" << name
00326           << "' is incorrectly designated as untracked in the framework.";
00327       } else {
00328         throw Exception(errors::Configuration, "StatusMismatch:")
00329           << "ParameterSet '" << name
00330           << "' is designated as untracked in the code,\n"
00331           << "but is not designated as untracked in the configuration file.\n"
00332           << "Please change the configuration file to 'untracked <type> " << name << "'.";
00333       }
00334     }
00335     return &it->second;
00336   }  // retrieve()
00337 
00338   VParameterSetEntry const&
00339   ParameterSet::retrieveVParameterSet(std::string const& name) const {
00340     vpsettable::const_iterator it = vpsetTable_.find(name);
00341     if(it == vpsetTable_.end()) {
00342         throw Exception(errors::Configuration, "MissingParameter:")
00343           << "VParameterSet '" << name
00344           << "' not found.";
00345     }
00346     if(it->second.isTracked() == false) {
00347       throw Exception(errors::Configuration, "StatusMismatch:")
00348         << "VParameterSet '" << name
00349         << "' is designated as tracked in the code,\n"
00350         << "but is designated as untracked in the configuration file.\n"
00351         << "Please remove 'untracked' from the configuration file for parameter '"<< name << "'.";
00352     }
00353     return it->second;
00354   }  // retrieve()
00355 
00356   VParameterSetEntry const*
00357   ParameterSet::retrieveUntrackedVParameterSet(std::string const& name) const {
00358     vpsettable::const_iterator it = vpsetTable_.find(name);
00359 
00360     if(it == vpsetTable_.end()) return 0;
00361     if(it->second.isTracked()) {
00362       throw Exception(errors::Configuration, "StatusMismatch:")
00363         << "VParameterSet '" << name
00364         << "' is designated as untracked in the code,\n"
00365         << "but is not designated as untracked in the configuration file.\n"
00366         << "Please change the configuration file to 'untracked <type> " << name << "'.";
00367     }
00368     return &it->second;
00369   }  // retrieve()
00370 
00371   Entry const*
00372   ParameterSet::retrieveUnknown(char const* name) const {
00373     return retrieveUnknown(std::string(name));
00374   }
00375 
00376   Entry const*
00377   ParameterSet::retrieveUnknown(std::string const& name) const {
00378     table::const_iterator it = tbl_.find(name);
00379     if(it == tbl_.end()) {
00380       return 0;
00381     }
00382     return &it->second;
00383   }
00384 
00385   ParameterSetEntry const*
00386   ParameterSet::retrieveUnknownParameterSet(std::string const& name) const {
00387     psettable::const_iterator  it = psetTable_.find(name);
00388     if(it == psetTable_.end()) {
00389       return 0;
00390     }
00391     return &it->second;
00392   }
00393 
00394   VParameterSetEntry const*
00395   ParameterSet::retrieveUnknownVParameterSet(std::string const& name) const {
00396     vpsettable::const_iterator  it = vpsetTable_.find(name);
00397     if(it == vpsetTable_.end()) {
00398       return 0;
00399     }
00400     return &it->second;
00401   }
00402 
00403   // ----------------------------------------------------------------------
00404   // ----------------------------------------------------------------------
00405 
00406   std::string
00407   ParameterSet::getParameterAsString(std::string const& name) const {
00408     if(existsAs<ParameterSet>(name)) {
00409       return retrieveUnknownParameterSet(name)->toString();
00410     }
00411     else if(existsAs<std::vector<ParameterSet> >(name)) {
00412       return retrieveUnknownVParameterSet(name)->toString();
00413     }
00414     else if(exists(name)) {
00415       return retrieveUnknown(name)->toString();
00416     }
00417     else {
00418       throw Exception(errors::Configuration, "getParameterAsString")
00419        << "Cannot find parameter " << name  << " in " << *this;
00420     }
00421   }
00422 
00423   // ----------------------------------------------------------------------
00424   // ----------------------------------------------------------------------
00425 
00426   void
00427   ParameterSet::insert(bool okay_to_replace, char const* name, Entry const& value) {
00428     insert(okay_to_replace, std::string(name), value);
00429   }
00430 
00431   void
00432   ParameterSet::insert(bool okay_to_replace, std::string const& name, Entry const& value) {
00433     // We should probably get rid of 'okay_to_replace', which will
00434     // simplify the logic in this function.
00435     table::iterator  it = tbl_.find(name);
00436 
00437     if(it == tbl_.end())  {
00438       if(!tbl_.insert(std::make_pair(name, value)).second)
00439         throw Exception(errors::Configuration, "InsertFailure")
00440           << "cannot insert " << name
00441           << " into a ParameterSet\n";
00442     }
00443     else if(okay_to_replace)  {
00444       it->second = value;
00445     }
00446   }  // insert()
00447 
00448   void ParameterSet::insertParameterSet(bool okay_to_replace, std::string const& name, ParameterSetEntry const& entry) {
00449     // We should probably get rid of 'okay_to_replace', which will
00450     // simplify the logic in this function.
00451     psettable::iterator it = psetTable_.find(name);
00452 
00453     if(it == psetTable_.end()) {
00454       if(!psetTable_.insert(std::make_pair(name, entry)).second)
00455         throw Exception(errors::Configuration, "InsertFailure")
00456           << "cannot insert " << name
00457           << " into a ParameterSet\n";
00458     } else if(okay_to_replace) {
00459       it->second = entry;
00460     }
00461   }  // insert()
00462 
00463   void ParameterSet::insertVParameterSet(bool okay_to_replace, std::string const& name, VParameterSetEntry const& entry) {
00464     // We should probably get rid of 'okay_to_replace', which will
00465     // simplify the logic in this function.
00466     vpsettable::iterator it = vpsetTable_.find(name);
00467 
00468     if(it == vpsetTable_.end()) {
00469       if(!vpsetTable_.insert(std::make_pair(name, entry)).second)
00470         throw Exception(errors::Configuration, "InsertFailure")
00471           << "cannot insert " << name
00472           << " into a VParameterSet\n";
00473     } else if(okay_to_replace) {
00474       it->second = entry;
00475     }
00476   }  // insert()
00477 
00478   void
00479   ParameterSet::augment(ParameterSet const& from) {
00480     // This preemptive invalidation may be more agressive than necessary.
00481     invalidateRegistration(std::string());
00482     if(&from == this) {
00483       return;
00484     }
00485 
00486     for(table::const_iterator b = from.tbl_.begin(), e = from.tbl_.end(); b != e; ++b) {
00487       this->insert(false, b->first, b->second);
00488     }
00489     for(psettable::const_iterator b = from.psetTable_.begin(), e = from.psetTable_.end(); b != e; ++b) {
00490       this->insertParameterSet(false, b->first, b->second);
00491     }
00492     for(vpsettable::const_iterator b = from.vpsetTable_.begin(), e = from.vpsetTable_.end(); b != e; ++b) {
00493       this->insertVParameterSet(false, b->first, b->second);
00494     }
00495   }  // augment()
00496 
00497   void ParameterSet::copyFrom(ParameterSet const& from, std::string const& name) {
00498     invalidateRegistration(std::string());
00499     if(from.existsAs<ParameterSet>(name)) {
00500       this->insertParameterSet(false, name, *(from.retrieveUnknownParameterSet(name)));
00501     }
00502     else if(from.existsAs<std::vector<ParameterSet> >(name)) {
00503       this->insertVParameterSet(false, name, *(from.retrieveUnknownVParameterSet(name)));
00504     }
00505     else if(from.exists(name)) {
00506       this->insert(false, name, *(from.retrieveUnknown(name)));
00507     }
00508     else {
00509       throw Exception(errors::Configuration, "copyFrom")
00510        << "Cannot find parameter " << name  << " in " << from;
00511     }
00512   }
00513 
00514   ParameterSet*
00515   ParameterSet::getPSetForUpdate(std::string const& name, bool& isTracked) {
00516     assert(!isRegistered());
00517     isTracked = false;
00518     psettable::iterator it = psetTable_.find(name);
00519     if(it == psetTable_.end()) return 0;
00520     isTracked = it->second.isTracked();
00521     return &it->second.pset();
00522   }
00523 
00524   VParameterSetEntry*
00525   ParameterSet::getPSetVectorForUpdate(std::string const& name) {
00526     assert(!isRegistered());
00527     vpsettable::iterator it = vpsetTable_.find(name);
00528     if(it == vpsetTable_.end()) return 0;
00529     return &it->second;
00530   }
00531 
00532   // ----------------------------------------------------------------------
00533   // coding
00534   // ----------------------------------------------------------------------
00535 
00536   void
00537   ParameterSet::toString(std::string& rep) const {
00538     toStringImp(rep, false);
00539   }
00540 
00541   void
00542   ParameterSet::allToString(std::string& rep) const {
00543     toStringImp(rep, true);
00544   }
00545 
00546   void
00547   ParameterSet::toStringImp(std::string& rep, bool useAll) const {
00548     // make sure the PSets get filled
00549     if(empty()) {
00550       rep += "<>";
00551       return;
00552     }
00553     size_t size = 1;
00554     for(table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
00555       if(useAll || b->second.isTracked()) {
00556         size += 2;
00557         size += b->first.size();
00558         size += b->second.sizeOfString();
00559       }
00560     }
00561     for(psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
00562       if(useAll || b->second.isTracked()) {
00563         size += 2;
00564         size += b->first.size();
00565         size += b->first.size();
00566         size += b->first.size();
00567         size += sizeof(ParameterSetID);
00568       }
00569     }
00570     for(vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
00571       if(useAll || b->second.isTracked()) {
00572         size += 2;
00573         size += b->first.size();
00574         size += sizeof(ParameterSetID) * b->second.vpset().size();
00575       }
00576     }
00577 
00578     rep.reserve(rep.size()+size);
00579     rep += '<';
00580     std::string start;
00581     std::string const between(";");
00582     for(table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
00583       if(useAll || b->second.isTracked()) {
00584         rep += start;
00585         rep += b->first;
00586         rep += '=';
00587         b->second.toString(rep);
00588         start = between;
00589       }
00590     }
00591     for(psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
00592       if(useAll || b->second.isTracked()) {
00593         rep += start;
00594         rep += b->first;
00595         rep += '=';
00596         b->second.toString(rep);
00597         start = between;
00598       }
00599     }
00600     for(vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
00601       if(useAll || b->second.isTracked()) {
00602         rep += start;
00603         rep += b->first;
00604         rep += '=';
00605         b->second.toString(rep);
00606         start = between;
00607       }
00608     }
00609 
00610     rep += '>';
00611   }  // to_string()
00612 
00613   void
00614   ParameterSet::toDigest(cms::Digest &digest) const {
00615     digest.append("<", 1);
00616     bool started = false;
00617     for(table::const_iterator b = tbl_.begin(), e = tbl_.end(); b != e; ++b) {
00618       if(b->second.isTracked()) {
00619         if (started)
00620           digest.append(";", 1);
00621         digest.append(b->first);
00622         digest.append("=", 1);
00623         b->second.toDigest(digest);
00624         started = true;
00625       }
00626     }
00627     for(psettable::const_iterator b = psetTable_.begin(), e = psetTable_.end(); b != e; ++b) {
00628       if(b->second.isTracked()) {
00629         if (started)
00630           digest.append(";", 1);
00631         digest.append(b->first);
00632         digest.append("=", 1);
00633         b->second.toDigest(digest);
00634         started = true;
00635       }
00636     }
00637     for(vpsettable::const_iterator b = vpsetTable_.begin(), e = vpsetTable_.end(); b != e; ++b) {
00638       if(b->second.isTracked()) {
00639         if (started)
00640           digest.append(";", 1);
00641         digest.append(b->first);
00642         digest.append("=", 1);
00643         b->second.toDigest(digest);
00644       }
00645     }
00646 
00647     digest.append(">",1);
00648   }
00649 
00650   std::string
00651   ParameterSet::toString() const {
00652     std::string result;
00653     toString(result);
00654     return result;
00655   }
00656 
00657   // ----------------------------------------------------------------------
00658 
00659   bool
00660   ParameterSet::fromString(std::string const& from) {
00661     std::vector<std::string> temp;
00662     if(!split(std::back_inserter(temp), from, '<', ';', '>'))
00663       return false;
00664 
00665     tbl_.clear();  // precaution
00666     for(std::vector<std::string>::const_iterator b = temp.begin(), e = temp.end(); b != e; ++b) {
00667       // locate required name/value separator
00668       std::string::const_iterator q = find_in_all(*b, '=');
00669       if(q == b->end())
00670         return false;
00671 
00672       // form name unique to this ParameterSet
00673       std::string  name = std::string(b->begin(), q);
00674       if(tbl_.find(name) != tbl_.end())
00675         return false;
00676 
00677       std::string rep(q+1, b->end());
00678       // entries are generically of the form tracked-type-rep
00679       if(rep[0] == '-') {
00680       }
00681       if(rep[1] == 'Q') {
00682         ParameterSetEntry psetEntry(rep);
00683         if(!psetTable_.insert(std::make_pair(name, psetEntry)).second) {
00684           return false;
00685         }
00686       } else if(rep[1] == 'q') {
00687         VParameterSetEntry vpsetEntry(rep);
00688         if(!vpsetTable_.insert(std::make_pair(name, vpsetEntry)).second) {
00689           return false;
00690         }
00691       } else if(rep[1] == 'P') {
00692         Entry value(name, rep);
00693         ParameterSetEntry psetEntry(value.getPSet(), value.isTracked());
00694         if(!psetTable_.insert(std::make_pair(name, psetEntry)).second) {
00695           return false;
00696         }
00697       } else if(rep[1] == 'p') {
00698         Entry value(name, rep);
00699         VParameterSetEntry vpsetEntry(value.getVPSet(), value.isTracked());
00700         if(!vpsetTable_.insert(std::make_pair(name, vpsetEntry)).second) {
00701           return false;
00702         }
00703       } else {
00704         // form value and insert name/value pair
00705         Entry  value(name, rep);
00706         if(!tbl_.insert(std::make_pair(name, value)).second) {
00707           return false;
00708         }
00709       }
00710     }
00711 
00712     return true;
00713   }  // from_string()
00714 
00715   std::vector<FileInPath>::size_type
00716   ParameterSet::getAllFileInPaths(std::vector<FileInPath>& output) const {
00717     std::vector<FileInPath>::size_type count = 0;
00718     table::const_iterator it = tbl_.begin();
00719     table::const_iterator end = tbl_.end();
00720     while (it != end) {
00721         Entry const& e = it->second;
00722         if(e.typeCode() == 'F') {
00723             ++count;
00724             output.push_back(e.getFileInPath());
00725         }
00726         ++it;
00727     }
00728     return count;
00729   }
00730 
00731   std::vector<std::string>
00732   ParameterSet::getParameterNames() const {
00733     std::vector<std::string> returnValue;
00734     std::transform(tbl_.begin(), tbl_.end(), back_inserter(returnValue),
00735                    boost::bind(&std::pair<std::string const, Entry>::first, _1));
00736     std::transform(psetTable_.begin(), psetTable_.end(), back_inserter(returnValue),
00737                    boost::bind(&std::pair<std::string const, ParameterSetEntry>::first, _1));
00738     std::transform(vpsetTable_.begin(), vpsetTable_.end(), back_inserter(returnValue),
00739                    boost::bind(&std::pair<std::string const, VParameterSetEntry>::first, _1));
00740     return returnValue;
00741   }
00742 
00743   bool ParameterSet::exists(std::string const& parameterName) const {
00744     return(tbl_.find(parameterName) != tbl_.end() ||
00745      psetTable_.find(parameterName) != psetTable_.end() ||
00746     vpsetTable_.find(parameterName) != vpsetTable_.end());
00747   }
00748 
00749   ParameterSet
00750   ParameterSet::trackedPart() const {
00751     ParameterSet result;
00752     for(table::const_iterator tblItr = tbl_.begin(); tblItr != tbl_.end(); ++tblItr) {
00753       if(tblItr->second.isTracked()) {
00754         result.tbl_.insert(*tblItr);
00755       }
00756     }
00757     for(psettable::const_iterator psetItr = psetTable_.begin(); psetItr != psetTable_.end(); ++psetItr) {
00758       if(psetItr->second.isTracked()) {
00759         result.addParameter<ParameterSet>(psetItr->first, psetItr->second.pset().trackedPart());
00760       }
00761     }
00762     for(vpsettable::const_iterator vpsetItr = vpsetTable_.begin(); vpsetItr != vpsetTable_.end(); ++vpsetItr) {
00763       if(vpsetItr->second.isTracked()) {
00764         VParameterSet vresult;
00765         std::vector<ParameterSet> const& this_vpset = vpsetItr->second.vpset();
00766 
00767         typedef std::vector<ParameterSet>::const_iterator Iter;
00768         for (Iter i = this_vpset.begin(), e = this_vpset.end(); i != e; ++i) {
00769           vresult.push_back(i->trackedPart());
00770         }
00771         result.addParameter<VParameterSet>(vpsetItr->first, vresult);
00772       }
00773     }
00774     return result;
00775   }
00776 
00777   size_t
00778   ParameterSet::getParameterSetNames(std::vector<std::string>& output) {
00779     std::transform(psetTable_.begin(), psetTable_.end(), back_inserter(output),
00780                    boost::bind(&std::pair<std::string const, ParameterSetEntry>::first, _1));
00781     return output.size();
00782   }
00783 
00784   size_t
00785   ParameterSet::getParameterSetNames(std::vector<std::string>& output,
00786                                      bool trackiness) const {
00787     for(psettable::const_iterator psetItr = psetTable_.begin();
00788         psetItr != psetTable_.end(); ++psetItr) {
00789       if(psetItr->second.isTracked() == trackiness) {
00790         output.push_back(psetItr->first);
00791       }
00792     }
00793     return output.size();
00794   }
00795 
00796   size_t
00797   ParameterSet::getParameterSetVectorNames(std::vector<std::string>& output,
00798                                            bool trackiness) const {
00799     for(vpsettable::const_iterator vpsetItr = vpsetTable_.begin();
00800          vpsetItr != vpsetTable_.end(); ++vpsetItr) {
00801       if(vpsetItr->second.isTracked() == trackiness) {
00802         output.push_back(vpsetItr->first);
00803       }
00804     }
00805     return output.size();
00806   }
00807 
00808   size_t
00809   ParameterSet::getNamesByCode_(char code,
00810                                 bool trackiness,
00811                                 std::vector<std::string>& output) const {
00812     size_t count = 0;
00813     if(code == 'Q') {
00814       return getParameterSetNames(output, trackiness);
00815     }
00816     if(code == 'q') {
00817       return getParameterSetVectorNames(output, trackiness);
00818     }
00819     table::const_iterator it = tbl_.begin();
00820     table::const_iterator end = tbl_.end();
00821     while (it != end) {
00822       Entry const& e = it->second;
00823       if(e.typeCode() == code &&
00824           e.isTracked() == trackiness) { // if it is a vector of ParameterSet
00825           ++count;
00826           output.push_back(it->first); // save the name
00827       }
00828       ++it;
00829     }
00830     return count;
00831   }
00832 
00833   template<>
00834   std::vector<std::string> ParameterSet::getParameterNamesForType<FileInPath>(bool trackiness) const {
00835     std::vector<std::string> result;
00836     getNamesByCode_('F', trackiness, result);
00837     return result;
00838   }
00839 
00840   bool operator==(ParameterSet const& a, ParameterSet const& b) {
00841     if(a.isRegistered() && b.isRegistered()) {
00842       return (a.id() == b.id());
00843     }
00844     return isTransientEqual(a.trackedPart(), b.trackedPart());
00845   }
00846 
00847   bool isTransientEqual(ParameterSet const& a, ParameterSet const& b) {
00848     if(a.tbl().size() != b.tbl().size()) {
00849         return false;
00850     }
00851     if(a.psetTable().size() != b.psetTable().size()) {
00852         return false;
00853     }
00854     if(a.vpsetTable().size() != b.vpsetTable().size()) {
00855         return false;
00856     }
00857     typedef ParameterSet::table::const_iterator Ti;
00858     for (Ti i = a.tbl().begin(), e = a.tbl().end(),
00859             j = b.tbl().begin(), f = b.tbl().end();
00860             i != e && j != f; ++i, ++j) {
00861       if(*i != *j) {
00862         return false;
00863       }
00864     }
00865     typedef ParameterSet::psettable::const_iterator Pi;
00866     for (Pi i = a.psetTable().begin(), e = a.psetTable().end(),
00867             j = b.psetTable().begin(), f = b.psetTable().end();
00868             i != e && j != f; ++i, ++j) {
00869       if(i->first != j->first) {
00870         return false;
00871       }
00872       if(i->second.isTracked() != j->second.isTracked()) {
00873         return false;
00874       }
00875       if(!isTransientEqual(i->second.pset(), j->second.pset())) {
00876         return false;
00877       }
00878     }
00879     typedef ParameterSet::vpsettable::const_iterator PVi;
00880     for (PVi i = a.vpsetTable().begin(), e = a.vpsetTable().end(),
00881              j = b.vpsetTable().begin(), f = b.vpsetTable().end();
00882              i != e && j != f; ++i, ++j) {
00883       if(i->first != j->first) {
00884         return false;
00885       }
00886       if(i->second.isTracked() != j->second.isTracked()) {
00887         return false;
00888       }
00889       std::vector<ParameterSet> const& iv = i->second.vpset();
00890       std::vector<ParameterSet> const& jv = j->second.vpset();
00891       if(iv.size() != jv.size()) {
00892         return false;
00893       }
00894       for (size_t k = 0; k < iv.size(); ++k) {
00895         if(!isTransientEqual(iv[k], jv[k])) {
00896           return false;
00897         }
00898       }
00899     }
00900     return true;
00901   }
00902 
00903   std::string ParameterSet::dump() const {
00904     std::ostringstream os;
00905     os << "{" << std::endl;
00906     for(table::const_iterator i = tbl_.begin(), e = tbl_.end(); i != e; ++i) {
00907       // indent a bit
00908       os << "  " << i->first << ": " << i->second << std::endl;
00909     }
00910     for(psettable::const_iterator i = psetTable_.begin(), e = psetTable_.end(); i != e; ++i) {
00911       // indent a bit
00912       std::string n = i->first;
00913       ParameterSetEntry const& pe = i->second;
00914       os << "  " << n << ": " << pe <<  std::endl;
00915     }
00916     for(vpsettable::const_iterator i = vpsetTable_.begin(), e = vpsetTable_.end(); i != e; ++i) {
00917       // indent a bit
00918       std::string n = i->first;
00919       VParameterSetEntry const& pe = i->second;
00920       os << "  " << n << ": " << pe <<  std::endl;
00921     }
00922     os << "}";
00923     return os.str();
00924   }
00925 
00926   std::ostream& operator<<(std::ostream& os, ParameterSet const& pset) {
00927     os << pset.dump();
00928     return os;
00929   }
00930 
00931   // Free function to return a parameterSet given its ID.
00932   ParameterSet const&
00933   getParameterSet(ParameterSetID const& id) {
00934     ParameterSet const* result = 0;
00935     if(0 == (result = pset::Registry::instance()->getMapped(id))) {
00936       throw Exception(errors::Configuration, "MissingParameterSet:")
00937         << "Parameter Set ID '" << id << "' not found.";
00938     }
00939     return *result;
00940   }
00941 
00942   void ParameterSet::deprecatedInputTagWarning(std::string const& name,
00943                                                std::string const& label) const {
00944     LogWarning("Configuration") << "Warning:\n\tstring " << name
00945                                 << " = \"" << label
00946                                 << "\"\nis deprecated, "
00947                                 << "please update your config file to use\n\tInputTag "
00948                                 << name << " = " << label;
00949   }
00950 
00951   // specializations
00952   // ----------------------------------------------------------------------
00953   // Bool, vBool
00954 
00955   template<>
00956   bool
00957   ParameterSet::getParameter<bool>(std::string const& name) const {
00958     return retrieve(name).getBool();
00959   }
00960 
00961   // ----------------------------------------------------------------------
00962   // Int32, vInt32
00963 
00964   template<>
00965   int
00966   ParameterSet::getParameter<int>(std::string const& name) const {
00967     return retrieve(name).getInt32();
00968   }
00969 
00970   template<>
00971   std::vector<int>
00972   ParameterSet::getParameter<std::vector<int> >(std::string const& name) const {
00973     return retrieve(name).getVInt32();
00974   }
00975 
00976  // ----------------------------------------------------------------------
00977   // Int64, vInt64
00978 
00979   template<>
00980   long long
00981   ParameterSet::getParameter<long long>(std::string const& name) const {
00982     return retrieve(name).getInt64();
00983   }
00984 
00985   template<>
00986   std::vector<long long>
00987   ParameterSet::getParameter<std::vector<long long> >(std::string const& name) const {
00988     return retrieve(name).getVInt64();
00989   }
00990 
00991   // ----------------------------------------------------------------------
00992   // Uint32, vUint32
00993 
00994   template<>
00995   unsigned int
00996   ParameterSet::getParameter<unsigned int>(std::string const& name) const {
00997     return retrieve(name).getUInt32();
00998   }
00999 
01000   template<>
01001   std::vector<unsigned int>
01002   ParameterSet::getParameter<std::vector<unsigned int> >(std::string const& name) const {
01003     return retrieve(name).getVUInt32();
01004   }
01005 
01006   // ----------------------------------------------------------------------
01007   // Uint64, vUint64
01008 
01009   template<>
01010   unsigned long long
01011   ParameterSet::getParameter<unsigned long long>(std::string const& name) const {
01012     return retrieve(name).getUInt64();
01013   }
01014 
01015   template<>
01016   std::vector<unsigned long long>
01017   ParameterSet::getParameter<std::vector<unsigned long long> >(std::string const& name) const {
01018     return retrieve(name).getVUInt64();
01019   }
01020 
01021   // ----------------------------------------------------------------------
01022   // Double, vDouble
01023 
01024   template<>
01025   double
01026   ParameterSet::getParameter<double>(std::string const& name) const {
01027     return retrieve(name).getDouble();
01028   }
01029 
01030   template<>
01031   std::vector<double>
01032   ParameterSet::getParameter<std::vector<double> >(std::string const& name) const {
01033     return retrieve(name).getVDouble();
01034   }
01035 
01036   // ----------------------------------------------------------------------
01037   // String, vString
01038 
01039   template<>
01040   std::string
01041   ParameterSet::getParameter<std::string>(std::string const& name) const {
01042     return retrieve(name).getString();
01043   }
01044 
01045   template<>
01046   std::vector<std::string>
01047   ParameterSet::getParameter<std::vector<std::string> >(std::string const& name) const {
01048     return retrieve(name).getVString();
01049   }
01050 
01051   // ----------------------------------------------------------------------
01052   // FileInPath
01053 
01054   template<>
01055   FileInPath
01056   ParameterSet::getParameter<FileInPath>(std::string const& name) const {
01057     return retrieve(name).getFileInPath();
01058   }
01059 
01060   // ----------------------------------------------------------------------
01061   // InputTag
01062 
01063   template<>
01064   InputTag
01065   ParameterSet::getParameter<InputTag>(std::string const& name) const {
01066     Entry const& e_input = retrieve(name);
01067     switch (e_input.typeCode()) {
01068       case 't':   // InputTag
01069         return e_input.getInputTag();
01070       case 'S':   // string
01071         std::string const& label = e_input.getString();
01072         deprecatedInputTagWarning(name, label);
01073         return InputTag(label);
01074     }
01075     throw Exception(errors::Configuration, "ValueError") << "type of "
01076        << name << " is expected to be InputTag or string (deprecated)";
01077 
01078   }
01079 
01080   // ----------------------------------------------------------------------
01081   // VInputTag
01082 
01083   template<>
01084   std::vector<InputTag>
01085   ParameterSet::getParameter<std::vector<InputTag> >(std::string const& name) const {
01086     return retrieve(name).getVInputTag();
01087   }
01088 
01089    // ----------------------------------------------------------------------
01090    // ESInputTag
01091 
01092    template<>
01093    ESInputTag
01094    ParameterSet::getParameter<ESInputTag>(std::string const& name) const {
01095       return retrieve(name).getESInputTag();
01096    }
01097 
01098    // ----------------------------------------------------------------------
01099    // VESInputTag
01100 
01101    template<>
01102    std::vector<ESInputTag>
01103    ParameterSet::getParameter<std::vector<ESInputTag> >(std::string const& name) const {
01104       return retrieve(name).getVESInputTag();
01105    }
01106 
01107   // ----------------------------------------------------------------------
01108   // EventID
01109 
01110   template<>
01111   EventID
01112   ParameterSet::getParameter<EventID>(std::string const& name) const {
01113     return retrieve(name).getEventID();
01114   }
01115 
01116   // ----------------------------------------------------------------------
01117   // VEventID
01118 
01119   template<>
01120   std::vector<EventID>
01121   ParameterSet::getParameter<std::vector<EventID> >(std::string const& name) const {
01122     return retrieve(name).getVEventID();
01123   }
01124 
01125   // ----------------------------------------------------------------------
01126   // LuminosityBlockID
01127 
01128   template<>
01129   LuminosityBlockID
01130   ParameterSet::getParameter<LuminosityBlockID>(std::string const& name) const {
01131     return retrieve(name).getLuminosityBlockID();
01132   }
01133 
01134   // ----------------------------------------------------------------------
01135   // VLuminosityBlockID
01136 
01137   template<>
01138   std::vector<LuminosityBlockID>
01139   ParameterSet::getParameter<std::vector<LuminosityBlockID> >(std::string const& name) const {
01140     return retrieve(name).getVLuminosityBlockID();
01141   }
01142 
01143   // ----------------------------------------------------------------------
01144   // EventRange
01145 
01146   template<>
01147   EventRange
01148   ParameterSet::getParameter<EventRange>(std::string const& name) const {
01149     return retrieve(name).getEventRange();
01150   }
01151 
01152   // ----------------------------------------------------------------------
01153   // VEventRange
01154 
01155   template<>
01156   std::vector<EventRange>
01157   ParameterSet::getParameter<std::vector<EventRange> >(std::string const& name) const {
01158     return retrieve(name).getVEventRange();
01159   }
01160 
01161   // ----------------------------------------------------------------------
01162   // LuminosityBlockRange
01163 
01164   template<>
01165   LuminosityBlockRange
01166   ParameterSet::getParameter<LuminosityBlockRange>(std::string const& name) const {
01167     return retrieve(name).getLuminosityBlockRange();
01168   }
01169 
01170   // ----------------------------------------------------------------------
01171   // VLuminosityBlockRange
01172 
01173   template<>
01174   std::vector<LuminosityBlockRange>
01175   ParameterSet::getParameter<std::vector<LuminosityBlockRange> >(std::string const& name) const {
01176     return retrieve(name).getVLuminosityBlockRange();
01177   }
01178 
01179   // ----------------------------------------------------------------------
01180   // PSet, vPSet
01181 
01182   template<>
01183   ParameterSet
01184   ParameterSet::getParameter<ParameterSet>(std::string const& name) const {
01185     return getParameterSet(name);
01186   }
01187 
01188   template<>
01189   VParameterSet
01190   ParameterSet::getParameter<VParameterSet>(std::string const& name) const {
01191     return getParameterSetVector(name);
01192   }
01193 
01194   // untracked parameters
01195 
01196   // ----------------------------------------------------------------------
01197   // Bool, vBool
01198 
01199   template<>
01200   bool
01201   ParameterSet::getUntrackedParameter<bool>(std::string const& name, bool const& defaultValue) const {
01202     Entry const* entryPtr = retrieveUntracked(name);
01203     return entryPtr == 0 ? defaultValue : entryPtr->getBool();
01204   }
01205 
01206   template<>
01207   bool
01208   ParameterSet::getUntrackedParameter<bool>(std::string const& name) const {
01209     return getEntryPointerOrThrow_(name)->getBool();
01210   }
01211 
01212   // ----------------------------------------------------------------------
01213   // Int32, vInt32
01214 
01215   template<>
01216   int
01217   ParameterSet::getUntrackedParameter<int>(std::string const& name, int const& defaultValue) const {
01218     Entry const* entryPtr = retrieveUntracked(name);
01219     return entryPtr == 0 ? defaultValue : entryPtr->getInt32();
01220   }
01221 
01222   template<>
01223   int
01224   ParameterSet::getUntrackedParameter<int>(std::string const& name) const {
01225     return getEntryPointerOrThrow_(name)->getInt32();
01226   }
01227 
01228   template<>
01229   std::vector<int>
01230   ParameterSet::getUntrackedParameter<std::vector<int> >(std::string const& name, std::vector<int> const& defaultValue) const {
01231     Entry const* entryPtr = retrieveUntracked(name);
01232     return entryPtr == 0 ? defaultValue : entryPtr->getVInt32();
01233   }
01234 
01235   template<>
01236   std::vector<int>
01237   ParameterSet::getUntrackedParameter<std::vector<int> >(std::string const& name) const {
01238     return getEntryPointerOrThrow_(name)->getVInt32();
01239   }
01240 
01241   // ----------------------------------------------------------------------
01242   // Uint32, vUint32
01243 
01244   template<>
01245   unsigned int
01246   ParameterSet::getUntrackedParameter<unsigned int>(std::string const& name, unsigned int const& defaultValue) const {
01247     Entry const* entryPtr = retrieveUntracked(name);
01248     return entryPtr == 0 ? defaultValue : entryPtr->getUInt32();
01249   }
01250 
01251   template<>
01252   unsigned int
01253   ParameterSet::getUntrackedParameter<unsigned int>(std::string const& name) const {
01254     return getEntryPointerOrThrow_(name)->getUInt32();
01255   }
01256 
01257   template<>
01258   std::vector<unsigned int>
01259   ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(std::string const& name, std::vector<unsigned int> const& defaultValue) const {
01260     Entry const* entryPtr = retrieveUntracked(name);
01261     return entryPtr == 0 ? defaultValue : entryPtr->getVUInt32();
01262   }
01263 
01264   template<>
01265   std::vector<unsigned int>
01266   ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(std::string const& name) const {
01267     return getEntryPointerOrThrow_(name)->getVUInt32();
01268   }
01269 
01270   // ----------------------------------------------------------------------
01271   // Uint64, vUint64
01272 
01273   template<>
01274   unsigned long long
01275   ParameterSet::getUntrackedParameter<unsigned long long>(std::string const& name, unsigned long long const& defaultValue) const {
01276     Entry const* entryPtr = retrieveUntracked(name);
01277     return entryPtr == 0 ? defaultValue : entryPtr->getUInt64();
01278   }
01279 
01280   template<>
01281   unsigned long long
01282   ParameterSet::getUntrackedParameter<unsigned long long>(std::string const& name) const {
01283     return getEntryPointerOrThrow_(name)->getUInt64();
01284   }
01285 
01286   template<>
01287   std::vector<unsigned long long>
01288   ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(std::string const& name, std::vector<unsigned long long> const& defaultValue) const {
01289     Entry const* entryPtr = retrieveUntracked(name);
01290     return entryPtr == 0 ? defaultValue : entryPtr->getVUInt64();
01291   }
01292 
01293   template<>
01294   std::vector<unsigned long long>
01295   ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(std::string const& name) const {
01296     return getEntryPointerOrThrow_(name)->getVUInt64();
01297   }
01298 
01299   // ----------------------------------------------------------------------
01300   // Int64, Vint64
01301 
01302   template<>
01303   long long
01304   ParameterSet::getUntrackedParameter<long long>(std::string const& name, long long const& defaultValue) const {
01305     Entry const* entryPtr = retrieveUntracked(name);
01306     return entryPtr == 0 ? defaultValue : entryPtr->getInt64();
01307   }
01308 
01309   template<>
01310   long long
01311   ParameterSet::getUntrackedParameter<long long>(std::string const& name) const {
01312     return getEntryPointerOrThrow_(name)->getInt64();
01313   }
01314 
01315   template<>
01316   std::vector<long long>
01317   ParameterSet::getUntrackedParameter<std::vector<long long> >(std::string const& name, std::vector<long long> const& defaultValue) const {
01318     Entry const* entryPtr = retrieveUntracked(name);
01319     return entryPtr == 0 ? defaultValue : entryPtr->getVInt64();
01320   }
01321 
01322   template<>
01323   std::vector<long long>
01324   ParameterSet::getUntrackedParameter<std::vector<long long> >(std::string const& name) const {
01325     return getEntryPointerOrThrow_(name)->getVInt64();
01326   }
01327 
01328   // ----------------------------------------------------------------------
01329   // Double, vDouble
01330 
01331   template<>
01332   double
01333   ParameterSet::getUntrackedParameter<double>(std::string const& name, double const& defaultValue) const {
01334     Entry const* entryPtr = retrieveUntracked(name);
01335     return entryPtr == 0 ? defaultValue : entryPtr->getDouble();
01336   }
01337 
01338   template<>
01339   double
01340   ParameterSet::getUntrackedParameter<double>(std::string const& name) const {
01341     return getEntryPointerOrThrow_(name)->getDouble();
01342   }
01343 
01344   template<>
01345   std::vector<double>
01346   ParameterSet::getUntrackedParameter<std::vector<double> >(std::string const& name, std::vector<double> const& defaultValue) const {
01347     Entry const* entryPtr = retrieveUntracked(name); return entryPtr == 0 ? defaultValue : entryPtr->getVDouble();
01348   }
01349 
01350   template<>
01351   std::vector<double>
01352   ParameterSet::getUntrackedParameter<std::vector<double> >(std::string const& name) const {
01353     return getEntryPointerOrThrow_(name)->getVDouble();
01354   }
01355 
01356   // ----------------------------------------------------------------------
01357   // String, vString
01358 
01359   template<>
01360   std::string
01361   ParameterSet::getUntrackedParameter<std::string>(std::string const& name, std::string const& defaultValue) const {
01362     Entry const* entryPtr = retrieveUntracked(name);
01363     return entryPtr == 0 ? defaultValue : entryPtr->getString();
01364   }
01365 
01366   template<>
01367   std::string
01368   ParameterSet::getUntrackedParameter<std::string>(std::string const& name) const {
01369     return getEntryPointerOrThrow_(name)->getString();
01370   }
01371 
01372   template<>
01373   std::vector<std::string>
01374   ParameterSet::getUntrackedParameter<std::vector<std::string> >(std::string const& name, std::vector<std::string> const& defaultValue) const {
01375     Entry const* entryPtr = retrieveUntracked(name);
01376     return entryPtr == 0 ? defaultValue : entryPtr->getVString();
01377   }
01378 
01379   template<>
01380   std::vector<std::string>
01381   ParameterSet::getUntrackedParameter<std::vector<std::string> >(std::string const& name) const {
01382     return getEntryPointerOrThrow_(name)->getVString();
01383   }
01384 
01385   // ----------------------------------------------------------------------
01386   //  FileInPath
01387 
01388   template<>
01389   FileInPath
01390   ParameterSet::getUntrackedParameter<FileInPath>(std::string const& name, FileInPath const& defaultValue) const {
01391     Entry const* entryPtr = retrieveUntracked(name);
01392     return entryPtr == 0 ? defaultValue : entryPtr->getFileInPath();
01393   }
01394 
01395   template<>
01396   FileInPath
01397   ParameterSet::getUntrackedParameter<FileInPath>(std::string const& name) const {
01398     return getEntryPointerOrThrow_(name)->getFileInPath();
01399   }
01400 
01401   // ----------------------------------------------------------------------
01402   // InputTag, VInputTag
01403 
01404   template<>
01405   InputTag
01406   ParameterSet::getUntrackedParameter<InputTag>(std::string const& name, InputTag const& defaultValue) const {
01407     Entry const* entryPtr = retrieveUntracked(name);
01408     return entryPtr == 0 ? defaultValue : entryPtr->getInputTag();
01409   }
01410 
01411   template<>
01412   InputTag
01413   ParameterSet::getUntrackedParameter<InputTag>(std::string const& name) const {
01414     return getEntryPointerOrThrow_(name)->getInputTag();
01415   }
01416 
01417   template<>
01418   std::vector<InputTag>
01419   ParameterSet::getUntrackedParameter<std::vector<InputTag> >(std::string const& name,
01420                                       std::vector<InputTag> const& defaultValue) const {
01421     Entry const* entryPtr = retrieveUntracked(name);
01422     return entryPtr == 0 ? defaultValue : entryPtr->getVInputTag();
01423   }
01424 
01425   template<>
01426   std::vector<InputTag>
01427   ParameterSet::getUntrackedParameter<std::vector<InputTag> >(std::string const& name) const {
01428     return getEntryPointerOrThrow_(name)->getVInputTag();
01429   }
01430 
01431    // ----------------------------------------------------------------------
01432    // ESInputTag, VESInputTag
01433 
01434    template<>
01435    ESInputTag
01436    ParameterSet::getUntrackedParameter<ESInputTag>(std::string const& name, ESInputTag const& defaultValue) const {
01437       Entry const* entryPtr = retrieveUntracked(name);
01438       return entryPtr == 0 ? defaultValue : entryPtr->getESInputTag();
01439    }
01440 
01441    template<>
01442    ESInputTag
01443    ParameterSet::getUntrackedParameter<ESInputTag>(std::string const& name) const {
01444       return getEntryPointerOrThrow_(name)->getESInputTag();
01445    }
01446 
01447    template<>
01448    std::vector<ESInputTag>
01449    ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(std::string const& name,
01450                                                                std::vector<ESInputTag> const& defaultValue) const {
01451       Entry const* entryPtr = retrieveUntracked(name);
01452       return entryPtr == 0 ? defaultValue : entryPtr->getVESInputTag();
01453    }
01454 
01455    template<>
01456    std::vector<ESInputTag>
01457    ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(std::string const& name) const {
01458       return getEntryPointerOrThrow_(name)->getVESInputTag();
01459    }
01460 
01461   // ----------------------------------------------------------------------
01462   // EventID, VEventID
01463 
01464   template<>
01465   EventID
01466   ParameterSet::getUntrackedParameter<EventID>(std::string const& name, EventID const& defaultValue) const {
01467     Entry const* entryPtr = retrieveUntracked(name);
01468     return entryPtr == 0 ? defaultValue : entryPtr->getEventID();
01469   }
01470 
01471   template<>
01472   EventID
01473   ParameterSet::getUntrackedParameter<EventID>(std::string const& name) const {
01474     return getEntryPointerOrThrow_(name)->getEventID();
01475   }
01476 
01477   template<>
01478   std::vector<EventID>
01479   ParameterSet::getUntrackedParameter<std::vector<EventID> >(std::string const& name,
01480                                       std::vector<EventID> const& defaultValue) const {
01481     Entry const* entryPtr = retrieveUntracked(name);
01482     return entryPtr == 0 ? defaultValue : entryPtr->getVEventID();
01483   }
01484 
01485   template<>
01486   std::vector<EventID>
01487   ParameterSet::getUntrackedParameter<std::vector<EventID> >(std::string const& name) const {
01488     return getEntryPointerOrThrow_(name)->getVEventID();
01489   }
01490 
01491   // ----------------------------------------------------------------------
01492   // LuminosityBlockID, VLuminosityBlockID
01493 
01494   template<>
01495   LuminosityBlockID
01496   ParameterSet::getUntrackedParameter<LuminosityBlockID>(std::string const& name, LuminosityBlockID const& defaultValue) const {
01497     Entry const* entryPtr = retrieveUntracked(name);
01498     return entryPtr == 0 ? defaultValue : entryPtr->getLuminosityBlockID();
01499   }
01500 
01501   template<>
01502   LuminosityBlockID
01503   ParameterSet::getUntrackedParameter<LuminosityBlockID>(std::string const& name) const {
01504     return getEntryPointerOrThrow_(name)->getLuminosityBlockID();
01505   }
01506 
01507   template<>
01508   std::vector<LuminosityBlockID>
01509   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(std::string const& name,
01510                                       std::vector<LuminosityBlockID> const& defaultValue) const {
01511     Entry const* entryPtr = retrieveUntracked(name);
01512     return entryPtr == 0 ? defaultValue : entryPtr->getVLuminosityBlockID();
01513   }
01514 
01515   template<>
01516   std::vector<LuminosityBlockID>
01517   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(std::string const& name) const {
01518     return getEntryPointerOrThrow_(name)->getVLuminosityBlockID();
01519   }
01520 
01521   // ----------------------------------------------------------------------
01522   // EventRange, VEventRange
01523 
01524   template<>
01525   EventRange
01526   ParameterSet::getUntrackedParameter<EventRange>(std::string const& name, EventRange const& defaultValue) const {
01527     Entry const* entryPtr = retrieveUntracked(name);
01528     return entryPtr == 0 ? defaultValue : entryPtr->getEventRange();
01529   }
01530 
01531   template<>
01532   EventRange
01533   ParameterSet::getUntrackedParameter<EventRange>(std::string const& name) const {
01534     return getEntryPointerOrThrow_(name)->getEventRange();
01535   }
01536 
01537   template<>
01538   std::vector<EventRange>
01539   ParameterSet::getUntrackedParameter<std::vector<EventRange> >(std::string const& name,
01540                                       std::vector<EventRange> const& defaultValue) const {
01541     Entry const* entryPtr = retrieveUntracked(name);
01542     return entryPtr == 0 ? defaultValue : entryPtr->getVEventRange();
01543   }
01544 
01545   template<>
01546   std::vector<EventRange>
01547   ParameterSet::getUntrackedParameter<std::vector<EventRange> >(std::string const& name) const {
01548     return getEntryPointerOrThrow_(name)->getVEventRange();
01549   }
01550 
01551   // ----------------------------------------------------------------------
01552   // LuminosityBlockRange, VLuminosityBlockRange
01553 
01554   template<>
01555   LuminosityBlockRange
01556   ParameterSet::getUntrackedParameter<LuminosityBlockRange>(std::string const& name, LuminosityBlockRange const& defaultValue) const {
01557     Entry const* entryPtr = retrieveUntracked(name);
01558     return entryPtr == 0 ? defaultValue : entryPtr->getLuminosityBlockRange();
01559   }
01560 
01561   template<>
01562   LuminosityBlockRange
01563   ParameterSet::getUntrackedParameter<LuminosityBlockRange>(std::string const& name) const {
01564     return getEntryPointerOrThrow_(name)->getLuminosityBlockRange();
01565   }
01566 
01567   template<>
01568   std::vector<LuminosityBlockRange>
01569   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(std::string const& name,
01570                                       std::vector<LuminosityBlockRange> const& defaultValue) const {
01571     Entry const* entryPtr = retrieveUntracked(name);
01572     return entryPtr == 0 ? defaultValue : entryPtr->getVLuminosityBlockRange();
01573   }
01574 
01575   template<>
01576   std::vector<LuminosityBlockRange>
01577   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(std::string const& name) const {
01578     return getEntryPointerOrThrow_(name)->getVLuminosityBlockRange();
01579   }
01580 
01581   // specializations
01582   // ----------------------------------------------------------------------
01583   // Bool, vBool
01584 
01585   template<>
01586   bool
01587   ParameterSet::getParameter<bool>(char const* name) const {
01588     return retrieve(name).getBool();
01589   }
01590 
01591   // ----------------------------------------------------------------------
01592   // Int32, vInt32
01593 
01594   template<>
01595   int
01596   ParameterSet::getParameter<int>(char const* name) const {
01597     return retrieve(name).getInt32();
01598   }
01599 
01600   template<>
01601   std::vector<int>
01602   ParameterSet::getParameter<std::vector<int> >(char const* name) const {
01603     return retrieve(name).getVInt32();
01604   }
01605 
01606  // ----------------------------------------------------------------------
01607   // Int64, vInt64
01608 
01609   template<>
01610   long long
01611   ParameterSet::getParameter<long long>(char const* name) const {
01612     return retrieve(name).getInt64();
01613   }
01614 
01615   template<>
01616   std::vector<long long>
01617   ParameterSet::getParameter<std::vector<long long> >(char const* name) const {
01618     return retrieve(name).getVInt64();
01619   }
01620 
01621   // ----------------------------------------------------------------------
01622   // Uint32, vUint32
01623 
01624   template<>
01625   unsigned int
01626   ParameterSet::getParameter<unsigned int>(char const* name) const {
01627     return retrieve(name).getUInt32();
01628   }
01629 
01630   template<>
01631   std::vector<unsigned int>
01632   ParameterSet::getParameter<std::vector<unsigned int> >(char const* name) const {
01633     return retrieve(name).getVUInt32();
01634   }
01635 
01636   // ----------------------------------------------------------------------
01637   // Uint64, vUint64
01638 
01639   template<>
01640   unsigned long long
01641   ParameterSet::getParameter<unsigned long long>(char const* name) const {
01642     return retrieve(name).getUInt64();
01643   }
01644 
01645   template<>
01646   std::vector<unsigned long long>
01647   ParameterSet::getParameter<std::vector<unsigned long long> >(char const* name) const {
01648     return retrieve(name).getVUInt64();
01649   }
01650 
01651   // ----------------------------------------------------------------------
01652   // Double, vDouble
01653 
01654   template<>
01655   double
01656   ParameterSet::getParameter<double>(char const* name) const {
01657     return retrieve(name).getDouble();
01658   }
01659 
01660   template<>
01661   std::vector<double>
01662   ParameterSet::getParameter<std::vector<double> >(char const* name) const {
01663     return retrieve(name).getVDouble();
01664   }
01665 
01666   // ----------------------------------------------------------------------
01667   // String, vString
01668 
01669   template<>
01670   std::string
01671   ParameterSet::getParameter<std::string>(char const* name) const {
01672     return retrieve(name).getString();
01673   }
01674 
01675   template<>
01676   std::vector<std::string>
01677   ParameterSet::getParameter<std::vector<std::string> >(char const* name) const {
01678     return retrieve(name).getVString();
01679   }
01680 
01681   // ----------------------------------------------------------------------
01682   // FileInPath
01683 
01684   template<>
01685   FileInPath
01686   ParameterSet::getParameter<FileInPath>(char const* name) const {
01687     return retrieve(name).getFileInPath();
01688   }
01689 
01690   // ----------------------------------------------------------------------
01691   // InputTag
01692 
01693   template<>
01694   InputTag
01695   ParameterSet::getParameter<InputTag>(char const* name) const {
01696     Entry const& e_input = retrieve(name);
01697     switch (e_input.typeCode()) {
01698       case 't':   // InputTag
01699         return e_input.getInputTag();
01700       case 'S':   // string
01701         std::string const& label = e_input.getString();
01702         deprecatedInputTagWarning(name, label);
01703         return InputTag(label);
01704     }
01705     throw Exception(errors::Configuration, "ValueError") << "type of "
01706        << name << " is expected to be InputTag or string (deprecated)";
01707   }
01708 
01709   // ----------------------------------------------------------------------
01710   // VInputTag
01711 
01712   template<>
01713   std::vector<InputTag>
01714   ParameterSet::getParameter<std::vector<InputTag> >(char const* name) const {
01715     return retrieve(name).getVInputTag();
01716   }
01717 
01718    // ----------------------------------------------------------------------
01719    // ESInputTag
01720 
01721    template<>
01722    ESInputTag
01723    ParameterSet::getParameter<ESInputTag>(char const* name) const {
01724       return retrieve(name).getESInputTag();
01725    }
01726 
01727    // ----------------------------------------------------------------------
01728    // VESInputTag
01729 
01730    template<>
01731    std::vector<ESInputTag>
01732    ParameterSet::getParameter<std::vector<ESInputTag> >(char const* name) const {
01733       return retrieve(name).getVESInputTag();
01734    }
01735 
01736 
01737   // ----------------------------------------------------------------------
01738   // EventID
01739 
01740   template<>
01741   EventID
01742   ParameterSet::getParameter<EventID>(char const* name) const {
01743     return retrieve(name).getEventID();
01744   }
01745 
01746   // ----------------------------------------------------------------------
01747   // VEventID
01748 
01749   template<>
01750   std::vector<EventID>
01751   ParameterSet::getParameter<std::vector<EventID> >(char const* name) const {
01752     return retrieve(name).getVEventID();
01753   }
01754 
01755   // ----------------------------------------------------------------------
01756   // LuminosityBlockID
01757 
01758   template<>
01759   LuminosityBlockID
01760   ParameterSet::getParameter<LuminosityBlockID>(char const* name) const {
01761     return retrieve(name).getLuminosityBlockID();
01762   }
01763 
01764   // ----------------------------------------------------------------------
01765   // VLuminosityBlockID
01766 
01767   template<>
01768   std::vector<LuminosityBlockID>
01769   ParameterSet::getParameter<std::vector<LuminosityBlockID> >(char const* name) const {
01770     return retrieve(name).getVLuminosityBlockID();
01771   }
01772 
01773   // ----------------------------------------------------------------------
01774   // EventRange
01775 
01776   template<>
01777   EventRange
01778   ParameterSet::getParameter<EventRange>(char const* name) const {
01779     return retrieve(name).getEventRange();
01780   }
01781 
01782   // ----------------------------------------------------------------------
01783   // VEventRange
01784 
01785   template<>
01786   std::vector<EventRange>
01787   ParameterSet::getParameter<std::vector<EventRange> >(char const* name) const {
01788     return retrieve(name).getVEventRange();
01789   }
01790 
01791   // ----------------------------------------------------------------------
01792   // LuminosityBlockRange
01793 
01794   template<>
01795   LuminosityBlockRange
01796   ParameterSet::getParameter<LuminosityBlockRange>(char const* name) const {
01797     return retrieve(name).getLuminosityBlockRange();
01798   }
01799 
01800   // ----------------------------------------------------------------------
01801   // VLuminosityBlockRange
01802 
01803   template<>
01804   std::vector<LuminosityBlockRange>
01805   ParameterSet::getParameter<std::vector<LuminosityBlockRange> >(char const* name) const {
01806     return retrieve(name).getVLuminosityBlockRange();
01807   }
01808 
01809   // ----------------------------------------------------------------------
01810   // PSet, vPSet
01811 
01812   template<>
01813   ParameterSet
01814   ParameterSet::getParameter<ParameterSet>(char const* name) const {
01815     return getParameterSet(name);
01816   }
01817 
01818   template<>
01819   VParameterSet
01820   ParameterSet::getParameter<VParameterSet>(char const* name) const {
01821     return getParameterSetVector(name);
01822   }
01823 
01824   // untracked parameters
01825 
01826   // ----------------------------------------------------------------------
01827   // Bool, vBool
01828 
01829   template<>
01830   bool
01831   ParameterSet::getUntrackedParameter<bool>(char const* name, bool const& defaultValue) const {
01832     Entry const* entryPtr = retrieveUntracked(name);
01833     return entryPtr == 0 ? defaultValue : entryPtr->getBool();
01834   }
01835 
01836   template<>
01837   bool
01838   ParameterSet::getUntrackedParameter<bool>(char const* name) const {
01839     return getEntryPointerOrThrow_(name)->getBool();
01840   }
01841 
01842   // ----------------------------------------------------------------------
01843   // Int32, vInt32
01844 
01845   template<>
01846   int
01847   ParameterSet::getUntrackedParameter<int>(char const* name, int const& defaultValue) const {
01848     Entry const* entryPtr = retrieveUntracked(name);
01849     return entryPtr == 0 ? defaultValue : entryPtr->getInt32();
01850   }
01851 
01852   template<>
01853   int
01854   ParameterSet::getUntrackedParameter<int>(char const* name) const {
01855     return getEntryPointerOrThrow_(name)->getInt32();
01856   }
01857 
01858   template<>
01859   std::vector<int>
01860   ParameterSet::getUntrackedParameter<std::vector<int> >(char const* name, std::vector<int> const& defaultValue) const {
01861     Entry const* entryPtr = retrieveUntracked(name);
01862     return entryPtr == 0 ? defaultValue : entryPtr->getVInt32();
01863   }
01864 
01865   template<>
01866   std::vector<int>
01867   ParameterSet::getUntrackedParameter<std::vector<int> >(char const* name) const {
01868     return getEntryPointerOrThrow_(name)->getVInt32();
01869   }
01870 
01871   // ----------------------------------------------------------------------
01872   // Uint32, vUint32
01873 
01874   template<>
01875   unsigned int
01876   ParameterSet::getUntrackedParameter<unsigned int>(char const* name, unsigned int const& defaultValue) const {
01877     Entry const* entryPtr = retrieveUntracked(name);
01878     return entryPtr == 0 ? defaultValue : entryPtr->getUInt32();
01879   }
01880 
01881   template<>
01882   unsigned int
01883   ParameterSet::getUntrackedParameter<unsigned int>(char const* name) const {
01884     return getEntryPointerOrThrow_(name)->getUInt32();
01885   }
01886 
01887   template<>
01888   std::vector<unsigned int>
01889   ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(char const* name, std::vector<unsigned int> const& defaultValue) const {
01890     Entry const* entryPtr = retrieveUntracked(name);
01891     return entryPtr == 0 ? defaultValue : entryPtr->getVUInt32();
01892   }
01893 
01894   template<>
01895   std::vector<unsigned int>
01896   ParameterSet::getUntrackedParameter<std::vector<unsigned int> >(char const* name) const {
01897     return getEntryPointerOrThrow_(name)->getVUInt32();
01898   }
01899 
01900   // ----------------------------------------------------------------------
01901   // Uint64, vUint64
01902 
01903   template<>
01904   unsigned long long
01905   ParameterSet::getUntrackedParameter<unsigned long long>(char const* name, unsigned long long const& defaultValue) const {
01906     Entry const* entryPtr = retrieveUntracked(name);
01907     return entryPtr == 0 ? defaultValue : entryPtr->getUInt64();
01908   }
01909 
01910   template<>
01911   unsigned long long
01912   ParameterSet::getUntrackedParameter<unsigned long long>(char const* name) const {
01913     return getEntryPointerOrThrow_(name)->getUInt64();
01914   }
01915 
01916   template<>
01917   std::vector<unsigned long long>
01918   ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(char const* name, std::vector<unsigned long long> const& defaultValue) const {
01919     Entry const* entryPtr = retrieveUntracked(name);
01920     return entryPtr == 0 ? defaultValue : entryPtr->getVUInt64();
01921   }
01922 
01923   template<>
01924   std::vector<unsigned long long>
01925   ParameterSet::getUntrackedParameter<std::vector<unsigned long long> >(char const* name) const {
01926     return getEntryPointerOrThrow_(name)->getVUInt64();
01927   }
01928 
01929   // ----------------------------------------------------------------------
01930   // Int64, Vint64
01931 
01932   template<>
01933   long long
01934   ParameterSet::getUntrackedParameter<long long>(char const* name, long long const& defaultValue) const {
01935     Entry const* entryPtr = retrieveUntracked(name);
01936     return entryPtr == 0 ? defaultValue : entryPtr->getInt64();
01937   }
01938 
01939   template<>
01940   long long
01941   ParameterSet::getUntrackedParameter<long long>(char const* name) const {
01942     return getEntryPointerOrThrow_(name)->getInt64();
01943   }
01944 
01945   template<>
01946   std::vector<long long>
01947   ParameterSet::getUntrackedParameter<std::vector<long long> >(char const* name, std::vector<long long> const& defaultValue) const {
01948     Entry const* entryPtr = retrieveUntracked(name);
01949     return entryPtr == 0 ? defaultValue : entryPtr->getVInt64();
01950   }
01951 
01952   template<>
01953   std::vector<long long>
01954   ParameterSet::getUntrackedParameter<std::vector<long long> >(char const* name) const {
01955     return getEntryPointerOrThrow_(name)->getVInt64();
01956   }
01957 
01958   // ----------------------------------------------------------------------
01959   // Double, vDouble
01960 
01961   template<>
01962   double
01963   ParameterSet::getUntrackedParameter<double>(char const* name, double const& defaultValue) const {
01964     Entry const* entryPtr = retrieveUntracked(name);
01965     return entryPtr == 0 ? defaultValue : entryPtr->getDouble();
01966   }
01967 
01968   template<>
01969   double
01970   ParameterSet::getUntrackedParameter<double>(char const* name) const {
01971     return getEntryPointerOrThrow_(name)->getDouble();
01972   }
01973 
01974   template<>
01975   std::vector<double>
01976   ParameterSet::getUntrackedParameter<std::vector<double> >(char const* name, std::vector<double> const& defaultValue) const {
01977     Entry const* entryPtr = retrieveUntracked(name); return entryPtr == 0 ? defaultValue : entryPtr->getVDouble();
01978   }
01979 
01980   template<>
01981   std::vector<double>
01982   ParameterSet::getUntrackedParameter<std::vector<double> >(char const* name) const {
01983     return getEntryPointerOrThrow_(name)->getVDouble();
01984   }
01985 
01986   // ----------------------------------------------------------------------
01987   // String, vString
01988 
01989   template<>
01990   std::string
01991   ParameterSet::getUntrackedParameter<std::string>(char const* name, std::string const& defaultValue) const {
01992     Entry const* entryPtr = retrieveUntracked(name);
01993     return entryPtr == 0 ? defaultValue : entryPtr->getString();
01994   }
01995 
01996   template<>
01997   std::string
01998   ParameterSet::getUntrackedParameter<std::string>(char const* name) const {
01999     return getEntryPointerOrThrow_(name)->getString();
02000   }
02001 
02002   template<>
02003   std::vector<std::string>
02004   ParameterSet::getUntrackedParameter<std::vector<std::string> >(char const* name, std::vector<std::string> const& defaultValue) const {
02005     Entry const* entryPtr = retrieveUntracked(name);
02006     return entryPtr == 0 ? defaultValue : entryPtr->getVString();
02007   }
02008 
02009   template<>
02010   std::vector<std::string>
02011   ParameterSet::getUntrackedParameter<std::vector<std::string> >(char const* name) const {
02012     return getEntryPointerOrThrow_(name)->getVString();
02013   }
02014 
02015   // ----------------------------------------------------------------------
02016   //  FileInPath
02017 
02018   template<>
02019   FileInPath
02020   ParameterSet::getUntrackedParameter<FileInPath>(char const* name, FileInPath const& defaultValue) const {
02021     Entry const* entryPtr = retrieveUntracked(name);
02022     return entryPtr == 0 ? defaultValue : entryPtr->getFileInPath();
02023   }
02024 
02025   template<>
02026   FileInPath
02027   ParameterSet::getUntrackedParameter<FileInPath>(char const* name) const {
02028     return getEntryPointerOrThrow_(name)->getFileInPath();
02029   }
02030 
02031   // ----------------------------------------------------------------------
02032   // InputTag, VInputTag
02033 
02034   template<>
02035   InputTag
02036   ParameterSet::getUntrackedParameter<InputTag>(char const* name, InputTag const& defaultValue) const {
02037     Entry const* entryPtr = retrieveUntracked(name);
02038     return entryPtr == 0 ? defaultValue : entryPtr->getInputTag();
02039   }
02040 
02041   template<>
02042   InputTag
02043   ParameterSet::getUntrackedParameter<InputTag>(char const* name) const {
02044     return getEntryPointerOrThrow_(name)->getInputTag();
02045   }
02046 
02047   template<>
02048   std::vector<InputTag>
02049   ParameterSet::getUntrackedParameter<std::vector<InputTag> >(char const* name,
02050                                       std::vector<InputTag> const& defaultValue) const {
02051     Entry const* entryPtr = retrieveUntracked(name);
02052     return entryPtr == 0 ? defaultValue : entryPtr->getVInputTag();
02053   }
02054 
02055   template<>
02056   std::vector<InputTag>
02057   ParameterSet::getUntrackedParameter<std::vector<InputTag> >(char const* name) const {
02058     return getEntryPointerOrThrow_(name)->getVInputTag();
02059   }
02060 
02061    // ----------------------------------------------------------------------
02062    // ESInputTag, VESInputTag
02063 
02064    template<>
02065    ESInputTag
02066    ParameterSet::getUntrackedParameter<ESInputTag>(char const* name, ESInputTag const& defaultValue) const {
02067       Entry const* entryPtr = retrieveUntracked(name);
02068       return entryPtr == 0 ? defaultValue : entryPtr->getESInputTag();
02069    }
02070 
02071    template<>
02072    ESInputTag
02073    ParameterSet::getUntrackedParameter<ESInputTag>(char const* name) const {
02074       return getEntryPointerOrThrow_(name)->getESInputTag();
02075    }
02076 
02077    template<>
02078    std::vector<ESInputTag>
02079    ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(char const* name,
02080                                                                std::vector<ESInputTag> const& defaultValue) const {
02081       Entry const* entryPtr = retrieveUntracked(name);
02082       return entryPtr == 0 ? defaultValue : entryPtr->getVESInputTag();
02083    }
02084 
02085    template<>
02086    std::vector<ESInputTag>
02087    ParameterSet::getUntrackedParameter<std::vector<ESInputTag> >(char const* name) const {
02088       return getEntryPointerOrThrow_(name)->getVESInputTag();
02089    }
02090 
02091   // ----------------------------------------------------------------------
02092   // EventID, VEventID
02093 
02094   template<>
02095   EventID
02096   ParameterSet::getUntrackedParameter<EventID>(char const* name, EventID const& defaultValue) const {
02097     Entry const* entryPtr = retrieveUntracked(name);
02098     return entryPtr == 0 ? defaultValue : entryPtr->getEventID();
02099   }
02100 
02101   template<>
02102   EventID
02103   ParameterSet::getUntrackedParameter<EventID>(char const* name) const {
02104     return getEntryPointerOrThrow_(name)->getEventID();
02105   }
02106 
02107   template<>
02108   std::vector<EventID>
02109   ParameterSet::getUntrackedParameter<std::vector<EventID> >(char const* name,
02110                                       std::vector<EventID> const& defaultValue) const {
02111     Entry const* entryPtr = retrieveUntracked(name);
02112     return entryPtr == 0 ? defaultValue : entryPtr->getVEventID();
02113   }
02114 
02115   template<>
02116   std::vector<EventID>
02117   ParameterSet::getUntrackedParameter<std::vector<EventID> >(char const* name) const {
02118     return getEntryPointerOrThrow_(name)->getVEventID();
02119   }
02120 
02121   // ----------------------------------------------------------------------
02122   // LuminosityBlockID, VLuminosityBlockID
02123 
02124   template<>
02125   LuminosityBlockID
02126   ParameterSet::getUntrackedParameter<LuminosityBlockID>(char const* name, LuminosityBlockID const& defaultValue) const {
02127     Entry const* entryPtr = retrieveUntracked(name);
02128     return entryPtr == 0 ? defaultValue : entryPtr->getLuminosityBlockID();
02129   }
02130 
02131   template<>
02132   LuminosityBlockID
02133   ParameterSet::getUntrackedParameter<LuminosityBlockID>(char const* name) const {
02134     return getEntryPointerOrThrow_(name)->getLuminosityBlockID();
02135   }
02136 
02137   template<>
02138   std::vector<LuminosityBlockID>
02139   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(char const* name,
02140                                       std::vector<LuminosityBlockID> const& defaultValue) const {
02141     Entry const* entryPtr = retrieveUntracked(name);
02142     return entryPtr == 0 ? defaultValue : entryPtr->getVLuminosityBlockID();
02143   }
02144 
02145   template<>
02146   std::vector<LuminosityBlockID>
02147   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockID> >(char const* name) const {
02148     return getEntryPointerOrThrow_(name)->getVLuminosityBlockID();
02149   }
02150 
02151   // ----------------------------------------------------------------------
02152   // EventRange, VEventRange
02153 
02154   template<>
02155   EventRange
02156   ParameterSet::getUntrackedParameter<EventRange>(char const* name, EventRange const& defaultValue) const {
02157     Entry const* entryPtr = retrieveUntracked(name);
02158     return entryPtr == 0 ? defaultValue : entryPtr->getEventRange();
02159   }
02160 
02161   template<>
02162   EventRange
02163   ParameterSet::getUntrackedParameter<EventRange>(char const* name) const {
02164     return getEntryPointerOrThrow_(name)->getEventRange();
02165   }
02166 
02167   template<>
02168   std::vector<EventRange>
02169   ParameterSet::getUntrackedParameter<std::vector<EventRange> >(char const* name,
02170                                       std::vector<EventRange> const& defaultValue) const {
02171     Entry const* entryPtr = retrieveUntracked(name);
02172     return entryPtr == 0 ? defaultValue : entryPtr->getVEventRange();
02173   }
02174 
02175   template<>
02176   std::vector<EventRange>
02177   ParameterSet::getUntrackedParameter<std::vector<EventRange> >(char const* name) const {
02178     return getEntryPointerOrThrow_(name)->getVEventRange();
02179   }
02180 
02181   // ----------------------------------------------------------------------
02182   // LuminosityBlockRange, VLuminosityBlockRange
02183 
02184   template<>
02185   LuminosityBlockRange
02186   ParameterSet::getUntrackedParameter<LuminosityBlockRange>(char const* name, LuminosityBlockRange const& defaultValue) const {
02187     Entry const* entryPtr = retrieveUntracked(name);
02188     return entryPtr == 0 ? defaultValue : entryPtr->getLuminosityBlockRange();
02189   }
02190 
02191   template<>
02192   LuminosityBlockRange
02193   ParameterSet::getUntrackedParameter<LuminosityBlockRange>(char const* name) const {
02194     return getEntryPointerOrThrow_(name)->getLuminosityBlockRange();
02195   }
02196 
02197   template<>
02198   std::vector<LuminosityBlockRange>
02199   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(char const* name,
02200                                       std::vector<LuminosityBlockRange> const& defaultValue) const {
02201     Entry const* entryPtr = retrieveUntracked(name);
02202     return entryPtr == 0 ? defaultValue : entryPtr->getVLuminosityBlockRange();
02203   }
02204 
02205   template<>
02206   std::vector<LuminosityBlockRange>
02207   ParameterSet::getUntrackedParameter<std::vector<LuminosityBlockRange> >(char const* name) const {
02208     return getEntryPointerOrThrow_(name)->getVLuminosityBlockRange();
02209   }
02210 
02211   // ----------------------------------------------------------------------
02212   // PSet, vPSet
02213 
02214   template<>
02215   ParameterSet
02216   ParameterSet::getUntrackedParameter<ParameterSet>(char const* name, ParameterSet const& defaultValue) const {
02217     return getUntrackedParameterSet(name, defaultValue);
02218   }
02219 
02220   template<>
02221   VParameterSet
02222   ParameterSet::getUntrackedParameter<VParameterSet>(char const* name, VParameterSet const& defaultValue) const {
02223     return getUntrackedParameterSetVector(name, defaultValue);
02224   }
02225 
02226   template<>
02227   ParameterSet
02228   ParameterSet::getUntrackedParameter<ParameterSet>(std::string const& name, ParameterSet const& defaultValue) const {
02229     return getUntrackedParameterSet(name, defaultValue);
02230   }
02231 
02232   template<>
02233   VParameterSet
02234   ParameterSet::getUntrackedParameter<VParameterSet>(std::string const& name, VParameterSet const& defaultValue) const {
02235     return getUntrackedParameterSetVector(name, defaultValue);
02236   }
02237 
02238   template<>
02239   ParameterSet
02240   ParameterSet::getUntrackedParameter<ParameterSet>(char const* name) const {
02241     return getUntrackedParameterSet(name);
02242   }
02243 
02244   template<>
02245   VParameterSet
02246   ParameterSet::getUntrackedParameter<VParameterSet>(char const* name) const {
02247     return getUntrackedParameterSetVector(name);
02248   }
02249 
02250   template<>
02251   ParameterSet
02252   ParameterSet::getUntrackedParameter<ParameterSet>(std::string const& name) const {
02253     return getUntrackedParameterSet(name);
02254   }
02255 
02256   template<>
02257   VParameterSet
02258   ParameterSet::getUntrackedParameter<VParameterSet>(std::string const& name) const {
02259     return getUntrackedParameterSetVector(name);
02260   }
02261 
02262 //----------------------------------------------------------------------------------
02263 // specializations for addParameter and addUntrackedParameter
02264 
02265   template<>
02266   void
02267   ParameterSet::addParameter<ParameterSet>(std::string const& name, ParameterSet const& value) {
02268     invalidateRegistration(name);
02269     insertParameterSet(true, name, ParameterSetEntry(value, true));
02270   }
02271 
02272   template<>
02273   void
02274   ParameterSet::addParameter<VParameterSet>(std::string const& name, VParameterSet const& value) {
02275     invalidateRegistration(name);
02276     insertVParameterSet(true, name, VParameterSetEntry(value, true));
02277   }
02278 
02279   template<>
02280   void
02281   ParameterSet::addParameter<ParameterSet>(char const* name, ParameterSet const& value) {
02282     invalidateRegistration(name);
02283     insertParameterSet(true, name, ParameterSetEntry(value, true));
02284   }
02285 
02286   template<>
02287   void
02288   ParameterSet::addParameter<VParameterSet>(char const* name, VParameterSet const& value) {
02289     invalidateRegistration(name);
02290     insertVParameterSet(true, name, VParameterSetEntry(value, true));
02291   }
02292 
02293   template<>
02294   void
02295   ParameterSet::addUntrackedParameter<ParameterSet>(std::string const& name, ParameterSet const& value) {
02296     insertParameterSet(true, name, ParameterSetEntry(value, false));
02297   }
02298 
02299   template<>
02300   void
02301   ParameterSet::addUntrackedParameter<VParameterSet>(std::string const& name, VParameterSet const& value) {
02302     insertVParameterSet(true, name, VParameterSetEntry(value, false));
02303   }
02304 
02305   template<>
02306   void
02307   ParameterSet::addUntrackedParameter<ParameterSet>(char const* name, ParameterSet const& value) {
02308     insertParameterSet(true, name, ParameterSetEntry(value, false));
02309   }
02310 
02311   template<>
02312   void
02313   ParameterSet::addUntrackedParameter<VParameterSet>(char const* name, VParameterSet const& value) {
02314     insertVParameterSet(true, name, VParameterSetEntry(value, false));
02315   }
02316 
02317 //----------------------------------------------------------------------------------
02318 // specializations for getParameterNamesForType
02319 
02320   template<>
02321   std::vector<std::string>
02322   ParameterSet::getParameterNamesForType<ParameterSet>(bool trackiness) const {
02323     std::vector<std::string> output;
02324     getParameterSetNames(output, trackiness);
02325     return output;
02326   }
02327 
02328   template<>
02329   std::vector<std::string>
02330   ParameterSet::getParameterNamesForType<VParameterSet>(bool trackiness) const {
02331     std::vector<std::string> output;
02332     getParameterSetVectorNames(output, trackiness);
02333     return output;
02334   }
02335 
02336   ParameterSet const&
02337   ParameterSet::getParameterSet(std::string const& name) const {
02338     return retrieveParameterSet(name).pset();
02339   }
02340 
02341   ParameterSet const&
02342   ParameterSet::getParameterSet(char const* name) const {
02343     return retrieveParameterSet(name).pset();
02344   }
02345 
02346   ParameterSet const&
02347   ParameterSet::getUntrackedParameterSet(std::string const& name, ParameterSet const& defaultValue) const {
02348     return getUntrackedParameterSet(name.c_str(), defaultValue);
02349   }
02350 
02351   ParameterSet const&
02352   ParameterSet::getUntrackedParameterSet(char const* name, ParameterSet const& defaultValue) const {
02353     ParameterSetEntry const* entryPtr = retrieveUntrackedParameterSet(name);
02354     if(entryPtr == 0) {
02355       if(!defaultValue.isRegistered()) {
02356         const_cast<ParameterSet&>(defaultValue).registerIt();
02357       }
02358       return defaultValue;
02359     }
02360     return entryPtr->pset();
02361   }
02362 
02363   ParameterSet const&
02364   ParameterSet::getUntrackedParameterSet(std::string const& name) const {
02365     return getUntrackedParameterSet(name.c_str());
02366   }
02367 
02368   ParameterSet const&
02369   ParameterSet::getUntrackedParameterSet(char const* name) const {
02370     ParameterSetEntry const* result = retrieveUntrackedParameterSet(name);
02371     if(result == 0)
02372       throw Exception(errors::Configuration, "MissingParameter:")
02373         << "The required ParameterSet '" << name << "' was not specified.\n";
02374     return result->pset();
02375   }
02376 
02377   VParameterSet const&
02378   ParameterSet::getParameterSetVector(std::string const& name) const {
02379     return retrieveVParameterSet(name).vpset();
02380   }
02381 
02382   VParameterSet const&
02383   ParameterSet::getParameterSetVector(char const* name) const {
02384     return retrieveVParameterSet(name).vpset();
02385   }
02386 
02387   VParameterSet const&
02388   ParameterSet::getUntrackedParameterSetVector(std::string const& name, VParameterSet const& defaultValue) const {
02389     return getUntrackedParameterSetVector(name.c_str(), defaultValue);
02390   }
02391 
02392   VParameterSet const&
02393   ParameterSet::getUntrackedParameterSetVector(char const* name, VParameterSet const& defaultValue) const {
02394     VParameterSetEntry const* entryPtr = retrieveUntrackedVParameterSet(name);
02395     return entryPtr == 0 ? defaultValue : entryPtr->vpset();
02396   }
02397 
02398   VParameterSet const&
02399   ParameterSet::getUntrackedParameterSetVector(std::string const& name) const {
02400     return getUntrackedParameterSetVector(name.c_str());
02401   }
02402 
02403   VParameterSet const&
02404   ParameterSet::getUntrackedParameterSetVector(char const* name) const {
02405     VParameterSetEntry const* result = retrieveUntrackedVParameterSet(name);
02406     if(result == 0)
02407       throw Exception(errors::Configuration, "MissingParameter:")
02408         << "The required ParameterSetVector '" << name << "' was not specified.\n";
02409     return result->vpset();
02410   }
02411 
02412 //----------------------------------------------------------------------------------
02413   ParameterSet::Bool
02414   operator&&(ParameterSet::Bool a, ParameterSet::Bool b) {
02415     if(a == ParameterSet::False || b == ParameterSet::False) {
02416       return ParameterSet::False;
02417     } else if(a == ParameterSet::Unknown || b == ParameterSet::Unknown) {
02418       return ParameterSet::Unknown;
02419     }
02420     return ParameterSet::True;
02421   }
02422 
02423 
02424 } // namespace edm