CMS 3D CMS Logo

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 55 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

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

Definition at line 184 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

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

Definition at line 78 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

81 {
82  if (tracked)
84  else
86 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:143
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:207
bool editInputTag ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 145 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

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

Definition at line 26 of file FWPSetCellEditor.cc.

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

29 {
30  std::stringstream str(value);
31  T v;
32  str >> v;
33  bool fail = str.fail();
34  if (tracked)
35  ps.addParameter(label, v);
36  else
38 
39  return fail;
40 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:143
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:207
def fail(errstr="")
#define str(s)
long double T
void editStringParameter ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 43 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

46 {
47  if (tracked)
49  else
51 }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:143
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:207
template<typename T >
void editVectorParameter ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 220 of file FWPSetCellEditor.cc.

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

223 {
224  std::vector<T> valueVector;
225 
226  std::stringstream iss(value);
227  std::string vitem;
228 
229  size_t fst, lst;
230 
231  while (getline(iss, vitem, ','))
232  {
233  fst = vitem.find("[");
234  lst = vitem.find("]");
235 
236  if ( fst != std::string::npos )
237  vitem.erase(fst,1);
238  if ( lst != std::string::npos )
239  vitem.erase(lst,1);
240 
241  std::stringstream oss(vitem);
242  T on;
243  oss >> on;
244 
245  valueVector.push_back(on);
246  }
247 
248  if (tracked)
249  ps.addParameter(label, valueVector);
250  else
251  ps.addUntrackedParameter(label, valueVector);
252 }
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:143
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:207
long double T
bool editVInputTag ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 90 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

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