File indexing completed on 2024-04-06 12:02:39
0001 #ifndef SiStripConfObject_h
0002 #define SiStripConfObject_h
0003
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005
0006 #include <iostream>
0007 #include <vector>
0008 #include <map>
0009 #include <algorithm>
0010 #include <iterator>
0011 #include <sstream>
0012
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015 class TrackerTopology;
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class SiStripConfObject {
0032 public:
0033 SiStripConfObject() {}
0034
0035 template <class valueType>
0036 bool put(const std::string& name, const valueType& inputValue) {
0037 std::stringstream ss;
0038 ss << inputValue;
0039 if (parameters.insert(std::make_pair(name, ss.str())).second)
0040 return true;
0041 return false;
0042 }
0043
0044
0045
0046
0047 template <class valueType>
0048 bool update(const std::string& name, const valueType& inputValue) {
0049 parMap::iterator it = parameters.find(name);
0050 if (it == parameters.end()) {
0051 std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
0052 << "so cannot be updated to '" << inputValue << "'." << std::endl;
0053 return false;
0054 } else {
0055 std::stringstream ss;
0056 ss << inputValue;
0057 it->second = ss.str();
0058 return true;
0059 }
0060 }
0061
0062 template <class valueType>
0063 valueType get(const std::string& name) const {
0064 valueType returnValue = 0;
0065 parMap::const_iterator it = parameters.find(name);
0066 std::stringstream ss;
0067 if (it != parameters.end()) {
0068 ss << it->second;
0069 ss >> returnValue;
0070 } else {
0071 std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
0072 }
0073 return returnValue;
0074 }
0075
0076 bool isParameter(const std::string& name) const { return (parameters.find(name) != parameters.end()); }
0077
0078
0079 void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0080
0081 void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0082
0083 typedef std::map<std::string, std::string> parMap;
0084
0085 parMap parameters;
0086
0087 COND_SERIALIZABLE;
0088 };
0089
0090 template <>
0091 std::string SiStripConfObject::get<std::string>(const std::string& name) const;
0092 template <>
0093 bool SiStripConfObject::put<std::vector<int> >(const std::string& name, const std::vector<int>& inputValue);
0094 template <>
0095 bool SiStripConfObject::update<std::vector<int> >(const std::string& name, const std::vector<int>& inputValue);
0096 template <>
0097 std::vector<int> SiStripConfObject::get<std::vector<int> >(const std::string& name) const;
0098 template <>
0099 bool SiStripConfObject::put<std::vector<std::string> >(const std::string& name,
0100 const std::vector<std::string>& inputValue);
0101 template <>
0102 bool SiStripConfObject::update<std::vector<std::string> >(const std::string& name,
0103 const std::vector<std::string>& inputValue);
0104 template <>
0105 std::vector<std::string> SiStripConfObject::get<std::vector<std::string> >(const std::string& name) const;
0106
0107 #endif