CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
FWPSetCellEditor.cc File Reference
#include <boost/algorithm/string.hpp>
#include <sstream>
#include "KeySymbols.h"
#include "Fireworks/FWInterface/src/FWPSetCellEditor.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Fireworks/Core/interface/fwLog.h"
#include "FWCore/Utilities/interface/Parse.h"

Go to the source code of this file.

Functions

void editBoolParameter (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 
bool editESInputTag (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 
void editFileInPath (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 
bool editInputTag (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 
template<class T >
bool editNumericParameter (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 
void editStringParameter (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 
template<typename T >
void editVectorParameter (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 
bool editVInputTag (edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
 

Function Documentation

void editBoolParameter ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 56 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), fwLog, fwlog::kError, diffTwoXMLs::label, and x.

Referenced by FWPSetCellEditor::apply().

59 {
60  bool x = false;
61 
62  if (boost::iequals(value, "true")) {
63  x = true;
64  }
65  else if (boost::iequals(value, "false")){
66  x = false;
67  }
68  else {
69  fwLog(fwlog::kError) << "Invalid value. Possible values are true/false case insensitive." << std::endl;
70  return;
71  }
72  if (tracked)
73  ps.addParameter<bool>(label, x);
74  else
75  ps.addUntrackedParameter<bool>(label, x);
76 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
#define fwLog(_level_)
Definition: fwLog.h:51
Definition: DDAxes.h:10
bool editESInputTag ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 185 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), cmsPerfPublish::fail(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::tokenize().

Referenced by FWPSetCellEditor::apply().

188 {
189  std::vector<std::string> tokens = edm::tokenize(value, ":");
190  size_t nwords = tokens.size();
191 
192  bool fail;
193 
194  if ( nwords > 2 )
195  {
196  fail = true;
197  }
198  else
199  {
200  std::string it_module("");
201  std::string it_data("");
202 
203  if ( nwords > 0 )
204  it_module = tokens[0];
205  if ( nwords > 1 )
206  it_data = tokens[1];
207 
208  if ( tracked )
209  ps.addParameter(label, edm::ESInputTag(it_module, it_data));
210  else
211  ps.addUntrackedParameter(label, edm::ESInputTag(it_module, it_data));
212 
213  fail = false;
214  }
215 
216  return fail;
217 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
Definition: Parse.cc:57
void editFileInPath ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 79 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), and edm::ParameterSet::addUntrackedParameter().

Referenced by FWPSetCellEditor::apply().

82 {
83  if (tracked)
85  else
87 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
bool editInputTag ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 146 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), cmsPerfPublish::fail(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::tokenize().

Referenced by FWPSetCellEditor::apply().

149 {
150  std::vector<std::string> tokens = edm::tokenize(value, ":");
151  size_t nwords = tokens.size();
152 
153  bool fail;
154 
155  if ( nwords > 3 )
156  {
157  fail = true;
158  }
159  else
160  {
161  std::string it_label("");
162  std::string it_instance("");
163  std::string it_process("");
164 
165  if ( nwords > 0 )
166  it_label = tokens[0];
167  if ( nwords > 1 )
168  it_instance = tokens[1];
169  if ( nwords > 2 )
170  it_process = tokens[2];
171 
172  if ( tracked )
173  ps.addParameter(label, edm::InputTag(it_label, it_instance, it_process));
174  else
175  ps.addUntrackedParameter(label, edm::InputTag(it_label, it_instance, it_process));
176 
177  fail = false;
178  }
179 
180  return fail;
181 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
Definition: Parse.cc:57
template<class T >
bool editNumericParameter ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 27 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), cmsPerfPublish::fail(), and findQualityFiles::v.

30 {
31  std::stringstream str(value);
32  T v;
33  str >> v;
34  bool fail = str.fail();
35  if (tracked)
36  ps.addParameter(label, v);
37  else
39 
40  return fail;
41 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
long double T
void editStringParameter ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 44 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), and edm::ParameterSet::addUntrackedParameter().

Referenced by FWPSetCellEditor::apply().

47 {
48  if (tracked)
50  else
52 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
template<typename T >
void editVectorParameter ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 221 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), lst, AlCaHLTBitMon_QueryRunRegistry::string, and valueVector().

224 {
225  std::vector<T> valueVector;
226 
227  std::stringstream iss(value);
228  std::string vitem;
229 
230  size_t fst, lst;
231 
232  while (getline(iss, vitem, ','))
233  {
234  fst = vitem.find("[");
235  lst = vitem.find("]");
236 
237  if ( fst != std::string::npos )
238  vitem.erase(fst,1);
239  if ( lst != std::string::npos )
240  vitem.erase(lst,1);
241 
242  std::stringstream oss(vitem);
243  T on;
244  oss >> on;
245 
246  valueVector.push_back(on);
247  }
248 
249  if (tracked)
250  ps.addParameter(label, valueVector);
251  else
252  ps.addUntrackedParameter(label, valueVector);
253 }
void valueVector(const std::map< K, V > &extract, std::vector< V > &output)
Definition: Operators.h:43
int lst[30]
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
long double T
bool editVInputTag ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 91 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), cmsPerfPublish::fail(), lst, AlCaHLTBitMon_QueryRunRegistry::string, and edm::tokenize().

Referenced by FWPSetCellEditor::apply().

94 {
95  std::vector<edm::InputTag> inputTags;
96  std::stringstream iss(value);
97  std::string vitem;
98  bool fail = false;
99  size_t fst, lst;
100 
101  while (getline(iss, vitem, ','))
102  {
103  fst = vitem.find("[");
104  lst = vitem.find("]");
105 
106  if ( fst != std::string::npos )
107  vitem.erase(fst,1);
108  if ( lst != std::string::npos )
109  vitem.erase(lst,1);
110 
111  std::vector<std::string> tokens = edm::tokenize(vitem, ":");
112  size_t nwords = tokens.size();
113 
114  if ( nwords > 3 )
115  {
116  fail = true;
117  return fail;
118  }
119  else
120  {
121  std::string it_label("");
122  std::string it_instance("");
123  std::string it_process("");
124 
125  if ( nwords > 0 )
126  it_label = tokens[0];
127  if ( nwords > 1 )
128  it_instance = tokens[1];
129  if ( nwords > 2 )
130  it_process = tokens[2];
131 
132  inputTags.push_back(edm::InputTag(it_label, it_instance, it_process));
133  }
134  }
135 
136  if (tracked)
137  ps.addParameter(label, inputTags);
138  else
139  ps.addUntrackedParameter(label, inputTags);
140 
141  return fail;
142 }
int lst[30]
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
Definition: Parse.cc:57