CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWPSetCellEditor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWInterface
4 // Class : FWPSetCellEditor
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author:
10 // Created: Mon Feb 28 20:44:59 CET 2011
11 // $Id: FWPSetCellEditor.cc,v 1.1 2011/02/28 20:37:39 amraktad Exp $
12 //
13 
14 #include <sstream>
15 #include "KeySymbols.h"
16 
17 // user include files
21 
23 
24 //______________________________________________________________________________
25 
26 template <class T>
27 bool editNumericParameter(edm::ParameterSet &ps, bool tracked,
28  const std::string &label,
29  const std::string &value)
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
38  ps.addUntrackedParameter(label, v);
39 
40  return fail;
41 }
42 //______________________________________________________________________________
43 
44 void editStringParameter(edm::ParameterSet &ps, bool tracked,
45  const std::string &label,
46  const std::string &value)
47 {
48  if (tracked)
49  ps.addParameter(label, value);
50  else
51  ps.addUntrackedParameter(label, value);
52 }
53 
54 
55 //______________________________________________________________________________
56 void editFileInPath(edm::ParameterSet &ps, bool tracked,
57  const std::string &label,
58  const std::string &value)
59 {
60  if (tracked)
61  ps.addParameter(label, edm::FileInPath(value));
62  else
63  ps.addUntrackedParameter(label, edm::FileInPath(value));
64 }
65 
66 //______________________________________________________________________________
67 
68 bool editVInputTag(edm::ParameterSet &ps, bool tracked,
69  const std::string &label,
70  const std::string &value)
71 {
72  std::vector<edm::InputTag> inputTags;
73  std::stringstream iss(value);
74  std::string vitem;
75  bool fail = false;
76  size_t fst, lst;
77 
78  while (getline(iss, vitem, ','))
79  {
80  fst = vitem.find("[");
81  lst = vitem.find("]");
82 
83  if ( fst != std::string::npos )
84  vitem.erase(fst,1);
85  if ( lst != std::string::npos )
86  vitem.erase(lst,1);
87 
88  std::vector<std::string> tokens = edm::tokenize(vitem, ":");
89  size_t nwords = tokens.size();
90 
91  if ( nwords > 3 )
92  {
93  fail = true;
94  return fail;
95  }
96  else
97  {
98  std::string it_label("");
99  std::string it_instance("");
100  std::string it_process("");
101 
102  if ( nwords > 0 )
103  it_label = tokens[0];
104  if ( nwords > 1 )
105  it_instance = tokens[1];
106  if ( nwords > 2 )
107  it_process = tokens[2];
108 
109  inputTags.push_back(edm::InputTag(it_label, it_instance, it_process));
110  }
111  }
112 
113  if (tracked)
114  ps.addParameter(label, inputTags);
115  else
116  ps.addUntrackedParameter(label, inputTags);
117 
118  return fail;
119 }
120 
121 //______________________________________________________________________________
122 
123 bool editInputTag(edm::ParameterSet &ps, bool tracked,
124  const std::string &label,
125  const std::string &value)
126 {
127  std::vector<std::string> tokens = edm::tokenize(value, ":");
128  size_t nwords = tokens.size();
129 
130  bool fail;
131 
132  if ( nwords > 3 )
133  {
134  fail = true;
135  }
136  else
137  {
138  std::string it_label("");
139  std::string it_instance("");
140  std::string it_process("");
141 
142  if ( nwords > 0 )
143  it_label = tokens[0];
144  if ( nwords > 1 )
145  it_instance = tokens[1];
146  if ( nwords > 2 )
147  it_process = tokens[2];
148 
149  if ( tracked )
150  ps.addParameter(label, edm::InputTag(it_label, it_instance, it_process));
151  else
152  ps.addUntrackedParameter(label, edm::InputTag(it_label, it_instance, it_process));
153 
154  fail = false;
155  }
156 
157  return fail;
158 }
159 
160 //______________________________________________________________________________
161 
162 bool editESInputTag(edm::ParameterSet &ps, bool tracked,
163  const std::string &label,
164  const std::string &value)
165 {
166  std::vector<std::string> tokens = edm::tokenize(value, ":");
167  size_t nwords = tokens.size();
168 
169  bool fail;
170 
171  if ( nwords > 2 )
172  {
173  fail = true;
174  }
175  else
176  {
177  std::string it_module("");
178  std::string it_data("");
179 
180  if ( nwords > 0 )
181  it_module = tokens[0];
182  if ( nwords > 1 )
183  it_data = tokens[1];
184 
185  if ( tracked )
186  ps.addParameter(label, edm::ESInputTag(it_module, it_data));
187  else
188  ps.addUntrackedParameter(label, edm::ESInputTag(it_module, it_data));
189 
190  fail = false;
191  }
192 
193  return fail;
194 }
195 
196 //______________________________________________________________________________
197 template <typename T>
198 void editVectorParameter(edm::ParameterSet &ps, bool tracked,
199  const std::string &label,
200  const std::string &value)
201 {
202  std::vector<T> valueVector;
203 
204  std::stringstream iss(value);
205  std::string vitem;
206 
207  size_t fst, lst;
208 
209  while (getline(iss, vitem, ','))
210  {
211  fst = vitem.find("[");
212  lst = vitem.find("]");
213 
214  if ( fst != std::string::npos )
215  vitem.erase(fst,1);
216  if ( lst != std::string::npos )
217  vitem.erase(lst,1);
218 
219  std::stringstream oss(vitem);
220  T on;
221  oss >> on;
222 
223  valueVector.push_back(on);
224  }
225 
226  if (tracked)
227  ps.addParameter(label, valueVector);
228  else
229  ps.addUntrackedParameter(label, valueVector);
230 }
231 
232 //______________________________________________________________________________
233 
235 {
236  switch (data.type)
237  {
238  case 'I':
239  editNumericParameter<int32_t>(parent.pset, data.tracked, data.label, GetText());
240  break;
241  case 'U':
242  editNumericParameter<uint32_t>(parent.pset, data.tracked, data.label, GetText());
243  break;
244  case 'D':
245  editNumericParameter<double>(parent.pset, data.tracked, data.label, GetText());
246  break;
247  case 'L':
248  editNumericParameter<long long>(parent.pset, data.tracked, data.label, GetText());
249  break;
250  case 'X':
251  editNumericParameter<unsigned long long>(parent.pset, data.tracked, data.label, GetText());
252  break;
253  case 'S':
254  editStringParameter(parent.pset, data.tracked, data.label, GetText());
255  break;
256  case 'i':
257  editVectorParameter<int32_t>(parent.pset, data.tracked, data.label, GetText());
258  break;
259  case 'u':
260  editVectorParameter<uint32_t>(parent.pset, data.tracked, data.label, GetText());
261  break;
262  case 'l':
263  editVectorParameter<long long>(parent.pset, data.tracked, data.label, GetText());
264  break;
265  case 'x':
266  editVectorParameter<unsigned long long>(parent.pset, data.tracked, data.label, GetText());
267  break;
268  case 'd':
269  editVectorParameter<double>(parent.pset, data.tracked, data.label, GetText());
270  break;
271  case 's':
272  editVectorParameter<std::string>(parent.pset, data.tracked, data.label, GetText());
273  break;
274  case 't':
275  editInputTag(parent.pset, data.tracked, data.label, GetText());
276  break;
277  case 'g':
278  editESInputTag(parent.pset, data.tracked, data.label, GetText());
279  break;
280  case 'v':
281  editVInputTag(parent.pset, data.tracked, data.label, GetText());
282  break;
283  case 'F':
284  editFileInPath(parent.pset, data.tracked, data.label, GetText());
285  break;
286  default:
287  fwLog(fwlog::kError) << "unsupported parameter" << std::endl;
288  UnmapWindow();
289  return false;
290  }
291  return true;
292 }
293 
294 //______________________________________________________________________________
295 
297 {
298  UInt_t keysym = event->fCode;
299 
300  if (keysym == (UInt_t) gVirtualX->KeysymToKeycode(kKey_Escape))
301  {
302  TGFrame *p = dynamic_cast<TGFrame*>(const_cast<TGWindow*>(GetParent()));
303  while (p)
304  {
305  TGMainFrame *mp = dynamic_cast<TGMainFrame*>(p);
306  // printf("editor find parent %p, %s, %p\n", p, p->ClassName(), mp);
307  if (mp)
308  {
309  return mp->HandleKey(event);
310  }
311  p = dynamic_cast<TGFrame*>(const_cast<TGWindow*>(p->GetParent()));
312  }
313  }
314 
315  return TGTextEntry::HandleKey(event);
316 }
virtual bool HandleKey(Event_t *event)
bool editESInputTag(edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
list parent
Definition: dbtoconf.py:74
void editVectorParameter(edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
const std::string & label
Definition: MVAComputer.cc:186
void valueVector(const std::map< K, V > &extract, std::vector< V > &output)
Definition: Operators.h:43
void editStringParameter(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)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:139
bool apply(FWPSetTableManager::PSetData &data, FWPSetTableManager::PSetData &parent)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
unsigned int UInt_t
Definition: FUTypes.h:12
#define fwLog(_level_)
Definition: fwLog.h:51
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:203
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
bool editNumericParameter(edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
long double T
void editFileInPath(edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)
mathSSE::Vec4< T > v
bool editInputTag(edm::ParameterSet &ps, bool tracked, const std::string &label, const std::string &value)