CMS 3D CMS Logo

SiStripConfObject.cc
Go to the documentation of this file.
2 #include <string>
3 
4 template <>
5 std::string SiStripConfObject::get<std::string>(const std::string& name) const {
6  std::string returnValue;
7  parMap::const_iterator it = parameters.find(name);
8  std::stringstream ss;
9  if (it != parameters.end()) {
10  ss << it->second;
11  ss >> returnValue;
12  } else {
13  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
14  }
15  return returnValue;
16 }
17 
18 template <>
19 bool SiStripConfObject::put<std::vector<int> >(const std::string& name, const std::vector<int>& inputValue) {
20  std::stringstream ss;
21  for (std::vector<int>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
22  ss << *elem << " ";
23  }
24  if (parameters.insert(std::make_pair(name, ss.str())).second)
25  return true;
26  return false;
27 }
28 
29 template <>
30 bool SiStripConfObject::update<std::vector<int> >(const std::string& name, const std::vector<int>& inputValue) {
31  parMap::iterator it = parameters.find(name);
32  if (it == parameters.end()) {
33  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
34  << "so cannot be updated to the vector of int of size'" << inputValue.size() << "'." << std::endl;
35  return false;
36  } else {
37  std::stringstream ss;
38  for (std::vector<int>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
39  ss << *elem << " ";
40  }
41  it->second = ss.str();
42  return true;
43  }
44 }
45 
46 template <>
47 std::vector<int> SiStripConfObject::get<std::vector<int> >(const std::string& name) const {
48  std::vector<int> returnValue;
49  parMap::const_iterator it = parameters.find(name);
50  std::stringstream ss;
51  if (it != parameters.end()) {
52  ss << it->second;
53  int elem;
54  while (ss >> elem)
55  returnValue.push_back(elem);
56  } else {
57  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
58  }
59  return returnValue;
60 }
61 
62 template <>
63 bool SiStripConfObject::put<std::vector<std::string> >(const std::string& name,
64  const std::vector<std::string>& inputValue) {
65  std::stringstream ss;
66  for (std::vector<std::string>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
67  ss << *elem << " ";
68  }
69  if (parameters.insert(std::make_pair(name, ss.str())).second)
70  return true;
71  return false;
72 }
73 
74 template <>
75 bool SiStripConfObject::update<std::vector<std::string> >(const std::string& name,
76  const std::vector<std::string>& inputValue) {
77  parMap::iterator it = parameters.find(name);
78  if (it == parameters.end()) {
79  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
80  << "so cannot be updated to the vector of std::string of size'" << inputValue.size() << "'." << std::endl;
81  return false;
82  } else {
83  std::stringstream ss;
84  for (std::vector<std::string>::const_iterator elem = inputValue.begin(); elem != inputValue.end(); ++elem) {
85  ss << *elem << " ";
86  }
87  it->second = ss.str();
88  return true;
89  }
90 }
91 
92 template <>
93 std::vector<std::string> SiStripConfObject::get<std::vector<std::string> >(const std::string& name) const {
94  std::vector<std::string> returnValue;
95  parMap::const_iterator it = parameters.find(name);
96  std::stringstream ss;
97  if (it != parameters.end()) {
98  ss << it->second;
100  while (ss >> elem)
101  returnValue.push_back(elem);
102  } else {
103  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
104  }
105  return returnValue;
106 }
107 
108 void SiStripConfObject::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
109  parMap::const_iterator it = parameters.begin();
110  for (; it != parameters.end(); ++it) {
111  ss << "parameter name = " << it->first << " value = " << it->second << std::endl;
112  }
113 }
114 
115 void SiStripConfObject::printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
116  printSummary(ss, trackerTopo);
117 }
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of parameters.
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of parameters.
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19