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

◆ editBoolParameter()

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

Definition at line 49 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

49  {
50  bool x = false;
51 
52  if (boost::iequals(value, "true")) {
53  x = true;
54  } else if (boost::iequals(value, "false")) {
55  x = false;
56  } else {
57  fwLog(fwlog::kError) << "Invalid value. Possible values are true/false case insensitive." << std::endl;
58  return;
59  }
60  if (tracked)
61  ps.addParameter<bool>(label, x);
62  else
63  ps.addUntrackedParameter<bool>(label, x);
64 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
#define fwLog(_level_)
Definition: fwLog.h:45
float x

◆ editESInputTag()

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

Definition at line 157 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

157  {
158  std::vector<std::string> tokens = edm::tokenize(value, ":");
159  size_t nwords = tokens.size();
160 
161  bool fail;
162 
163  if (nwords > 2) {
164  fail = true;
165  } else {
166  std::string it_module("");
167  std::string it_data("");
168 
169  if (nwords > 0)
170  it_module = tokens[0];
171  if (nwords > 1)
172  it_data = tokens[1];
173 
174  if (tracked)
175  ps.addParameter(label, edm::ESInputTag(it_module, it_data));
176  else
177  ps.addUntrackedParameter(label, edm::ESInputTag(it_module, it_data));
178 
179  fail = false;
180  }
181 
182  return fail;
183 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
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:52

◆ editFileInPath()

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

Definition at line 67 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

67  {
68  if (tracked)
70  else
72 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193

◆ editInputTag()

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

Definition at line 124 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

124  {
125  std::vector<std::string> tokens = edm::tokenize(value, ":");
126  size_t nwords = tokens.size();
127 
128  bool fail;
129 
130  if (nwords > 3) {
131  fail = true;
132  } else {
133  std::string it_label("");
134  std::string it_instance("");
135  std::string it_process("");
136 
137  if (nwords > 0)
138  it_label = tokens[0];
139  if (nwords > 1)
140  it_instance = tokens[1];
141  if (nwords > 2)
142  it_process = tokens[2];
143 
144  if (tracked)
145  ps.addParameter(label, edm::InputTag(it_label, it_instance, it_process));
146  else
147  ps.addUntrackedParameter(label, edm::InputTag(it_label, it_instance, it_process));
148 
149  fail = false;
150  }
151 
152  return fail;
153 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
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:52

◆ editNumericParameter()

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(), label, str, and findQualityFiles::v.

26  {
27  std::stringstream str(value);
28  T v;
29  str >> v;
30  bool fail = str.fail();
31  if (tracked)
32  ps.addParameter(label, v);
33  else
35 
36  return fail;
37 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
#define str(s)
long double T

◆ editStringParameter()

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

Definition at line 40 of file FWPSetCellEditor.cc.

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

Referenced by FWPSetCellEditor::apply().

40  {
41  if (tracked)
43  else
45 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193

◆ editVectorParameter()

template<typename T >
void editVectorParameter ( edm::ParameterSet ps,
bool  tracked,
const std::string &  label,
const std::string &  value 
)

Definition at line 187 of file FWPSetCellEditor.cc.

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

187  {
188  std::vector<T> valueVector;
189 
190  std::stringstream iss(value);
191  std::string vitem;
192 
193  size_t fst, lst;
194 
195  while (getline(iss, vitem, ',')) {
196  fst = vitem.find('[');
197  lst = vitem.find(']');
198 
199  if (fst != std::string::npos)
200  vitem.erase(fst, 1);
201  if (lst != std::string::npos)
202  vitem.erase(lst, 1);
203 
204  std::stringstream oss(vitem);
205  T on;
206  oss >> on;
207 
208  valueVector.push_back(on);
209  }
210 
211  if (tracked)
212  ps.addParameter(label, valueVector);
213  else
214  ps.addUntrackedParameter(label, valueVector);
215 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
long double T

◆ editVInputTag()

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

Definition at line 76 of file FWPSetCellEditor.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), HLTMuonOfflineAnalyzer_cfi::inputTags, label, AlCaHLTBitMon_QueryRunRegistry::string, and edm::tokenize().

Referenced by FWPSetCellEditor::apply().

76  {
77  std::vector<edm::InputTag> inputTags;
78  std::stringstream iss(value);
79  std::string vitem;
80  bool fail = false;
81  size_t fst, lst;
82 
83  while (getline(iss, vitem, ',')) {
84  fst = vitem.find('[');
85  lst = vitem.find(']');
86 
87  if (fst != std::string::npos)
88  vitem.erase(fst, 1);
89  if (lst != std::string::npos)
90  vitem.erase(lst, 1);
91 
92  std::vector<std::string> tokens = edm::tokenize(vitem, ":");
93  size_t nwords = tokens.size();
94 
95  if (nwords > 3) {
96  fail = true;
97  return fail;
98  } else {
99  std::string it_label("");
100  std::string it_instance("");
101  std::string it_process("");
102 
103  if (nwords > 0)
104  it_label = tokens[0];
105  if (nwords > 1)
106  it_instance = tokens[1];
107  if (nwords > 2)
108  it_process = tokens[2];
109 
110  inputTags.push_back(edm::InputTag(it_label, it_instance, it_process));
111  }
112  }
113 
114  if (tracked)
116  else
118 
119  return fail;
120 }
char const * label
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
Definition: value.py:1
inputTags
All input tags are specified in this pset for convenience.
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
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:52