Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:41

0001 #include "CondFormats/SiStripObjects/interface/SiStripConfObject.h"
0002 #include <string>
0003 
0004 template <>
0005 std::string SiStripConfObject::get<std::string>(const std::string& name) const {
0006   std::string returnValue;
0007   parMap::const_iterator it = parameters.find(name);
0008   std::stringstream ss;
0009   if (it != parameters.end()) {
0010     ss << it->second;
0011     ss >> returnValue;
0012   } else {
0013     std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
0014   }
0015   return returnValue;
0016 }
0017 
0018 template <>
0019 bool SiStripConfObject::put<std::vector<int> >(const std::string& name, const std::vector<int>& inputValue) {
0020   std::stringstream ss;
0021   for (std::vector<int>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
0022     ss << *elem << " ";
0023   }
0024   if (parameters.insert(std::make_pair(name, ss.str())).second)
0025     return true;
0026   return false;
0027 }
0028 
0029 template <>
0030 bool SiStripConfObject::update<std::vector<int> >(const std::string& name, const std::vector<int>& inputValue) {
0031   parMap::iterator it = parameters.find(name);
0032   if (it == parameters.end()) {
0033     std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
0034               << "so cannot be updated to the vector of int of size'" << inputValue.size() << "'." << std::endl;
0035     return false;
0036   } else {
0037     std::stringstream ss;
0038     for (std::vector<int>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
0039       ss << *elem << " ";
0040     }
0041     it->second = ss.str();
0042     return true;
0043   }
0044 }
0045 
0046 template <>
0047 std::vector<int> SiStripConfObject::get<std::vector<int> >(const std::string& name) const {
0048   std::vector<int> returnValue;
0049   parMap::const_iterator it = parameters.find(name);
0050   std::stringstream ss;
0051   if (it != parameters.end()) {
0052     ss << it->second;
0053     int elem;
0054     while (ss >> elem)
0055       returnValue.push_back(elem);
0056   } else {
0057     std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
0058   }
0059   return returnValue;
0060 }
0061 
0062 template <>
0063 bool SiStripConfObject::put<std::vector<std::string> >(const std::string& name,
0064                                                        const std::vector<std::string>& inputValue) {
0065   std::stringstream ss;
0066   for (std::vector<std::string>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
0067     ss << *elem << " ";
0068   }
0069   if (parameters.insert(std::make_pair(name, ss.str())).second)
0070     return true;
0071   return false;
0072 }
0073 
0074 template <>
0075 bool SiStripConfObject::update<std::vector<std::string> >(const std::string& name,
0076                                                           const std::vector<std::string>& inputValue) {
0077   parMap::iterator it = parameters.find(name);
0078   if (it == parameters.end()) {
0079     std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
0080               << "so cannot be updated to the vector of std::string of size'" << inputValue.size() << "'." << std::endl;
0081     return false;
0082   } else {
0083     std::stringstream ss;
0084     for (std::vector<std::string>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
0085       ss << *elem << " ";
0086     }
0087     it->second = ss.str();
0088     return true;
0089   }
0090 }
0091 
0092 template <>
0093 std::vector<std::string> SiStripConfObject::get<std::vector<std::string> >(const std::string& name) const {
0094   std::vector<std::string> returnValue;
0095   parMap::const_iterator it = parameters.find(name);
0096   std::stringstream ss;
0097   if (it != parameters.end()) {
0098     ss << it->second;
0099     std::string elem;
0100     while (ss >> elem)
0101       returnValue.push_back(elem);
0102   } else {
0103     std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
0104   }
0105   return returnValue;
0106 }
0107 
0108 void SiStripConfObject::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
0109   parMap::const_iterator it = parameters.begin();
0110   for (; it != parameters.end(); ++it) {
0111     ss << "parameter name = " << it->first << " value = " << it->second << std::endl;
0112   }
0113 }
0114 
0115 void SiStripConfObject::printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
0116   printSummary(ss, trackerTopo);
0117 }