CMS 3D CMS Logo

MessageServicePSetValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Services
4 // Class : MessageServicePSetValidation
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: M. Fischler
10 // Created: Wed May 20 2009
11 //
12 // Change log
13 //
14 //
15 
16 // system include files
17 
18 #include <algorithm>
19 
20 // user include files
21 
23 
24 using namespace edm;
25 using namespace edm::service;
26 
27 namespace edm {
28  namespace service {
29 
31  messageLoggerPSet(pset);
32  return flaws.str();
33  } // operator() to validate the PSet passed in
34 
36  // Four types of material are allowed at the MessageLogger level:
37  // PSet lists (such as destinations or categories
38  // Suppression lists, such as SuppressInfo or debugModules
39  // General parameters, such as threshold or messageSummaryToJobReport
40  // Nested PSets, such as those for each destination
41 
42  // PSet lists
43 
44  psetLists(pset);
45 
46  // Suppression lists
47 
48  suppressionLists(pset);
49 
50  // No other vstrings
51 
52  vStringsCheck(pset, "MessageLogger");
53 
54  // General Parameters
55 
56  check<bool>(pset, "MessageLogger", "messageSummaryToJobReport");
57  std::string dumps = check<std::string>(pset, "MessageLogger", "generate_preconfiguration_message");
58  std::string thresh = check<std::string>(pset, "MessageLogger", "threshold");
59  if (!thresh.empty())
60  validateThreshold(thresh, "MessageLogger");
61  check<unsigned int>(pset, "MessageLogger", "waiting_threshold");
62 
63  // Nested PSets
64 
65  destinationPSets(pset);
66  defaultPSet(pset);
67  statisticsPSets(pset);
68  fwkJobReportPSets(pset);
69  categoryPSets(pset, "MessageLogger");
70 
71  // No other PSets -- unless they contain optionalPSet or placeholder=True
72 
73  noOtherPsets(pset);
74 
75  // Nothing else -- look for int, unsigned int, bool, float, double, string
76 
77  noneExcept<int>(pset, "MessageLogger", "int");
78  noneExcept<unsigned int>(pset, "MessageLogger", "unsigned int", "waiting_threshold");
79  noneExcept<bool>(pset, "MessageLogger", "bool", "messageSummaryToJobReport");
80  // Note - at this, the upper MessageLogger PSet level, the use of
81  // optionalPSet makes no sense, so we are OK letting that be a flaw
82  noneExcept<float>(pset, "MessageLogger", "float");
83  noneExcept<double>(pset, "MessageLogger", "double");
84  noneExcept<std::string>(pset, "MessageLogger", "string", "threshold", "generate_preconfiguration_message");
85 
86  // Append explanatory information if flaws were found
87 
88  if (!flaws.str().empty()) {
89  flaws << "\nThe above are from MessageLogger configuration validation.\n"
90  << "In most cases, these involve lines that the logger configuration code\n"
91  << "would not process, but which the cfg creator obviously meant to have "
92  << "effect.\n";
93  }
94 
95  } // messageLoggerPSet
96 
98  destinations = check<vString>(pset, "MessageLogger", "destinations");
99  noDuplicates(destinations, "MessageLogger", "destinations");
100  noKeywords(destinations, "MessageLogger", "destinations");
101  noNonPSetUsage(pset, destinations, "MessageLogger", "destinations");
102  // REMOVED: noCoutCerrClash(destinations,"MessageLogger", "destinations");
103 
104  statistics = check<vString>(pset, "MessageLogger", "statistics");
105  noDuplicates(statistics, "MessageLogger", "statistics");
106  noKeywords(statistics, "MessageLogger", "statistics");
107  noNonPSetUsage(pset, statistics, "MessageLogger", "statistics");
108 
109  fwkJobReports = check<vString>(pset, "MessageLogger", "fwkJobReports");
110  noDuplicates(fwkJobReports, "MessageLogger", "fwkJobReports");
111  noKeywords(fwkJobReports, "MessageLogger", "fwkJobReports");
112  noNonPSetUsage(pset, fwkJobReports, "MessageLogger", "fwkJobReports");
113  noDuplicates(fwkJobReports, destinations, "MessageLogger", "fwkJobReports", "destinations");
114  noDuplicates(fwkJobReports, statistics, "MessageLogger", "fwkJobReports", "statistics");
115 
116  categories = check<vString>(pset, "MessageLogger", "categories");
117  noDuplicates(categories, "MessageLogger", "categories");
118  noKeywords(categories, "MessageLogger", "categories");
119  noNonPSetUsage(pset, categories, "MessageLogger", "categories");
120  noDuplicates(categories, destinations, "MessageLogger", "categories", "destinations");
121  noDuplicates(categories, statistics, "MessageLogger", "categories", "statistics");
122  noDuplicates(categories, fwkJobReports, "MessageLogger", "categories", "fwkJobReports");
123 
124  messageIDs = check<vString>(pset, "MessageLogger", "messageIDs");
125  noDuplicates(messageIDs, "MessageLogger", "messageIDs");
126  noKeywords(messageIDs, "MessageLogger", "messageIDs");
127  noNonPSetUsage(pset, messageIDs, "MessageLogger", "messageIDs");
128  noDuplicates(messageIDs, destinations, "MessageLogger", "messageIDs", "destinations");
129  noDuplicates(messageIDs, statistics, "MessageLogger", "messageIDs", "statistics");
130  noDuplicates(messageIDs, fwkJobReports, "MessageLogger", "messageIDs", "fwkJobReports");
131  noDuplicates(messageIDs, fwkJobReports, "MessageLogger", "messageIDs", "categories");
132 
133  } // psetLists
134 
136  debugModules = check<vString>(pset, "MessageLogger", "debugModules");
137  bool dmStar = wildcard(debugModules);
138  if (dmStar && debugModules.size() != 1) {
139  flaws << "MessageLogger"
140  << " PSet: \n"
141  << "debugModules contains wildcard character *"
142  << " and also " << debugModules.size() - 1 << " other entries - * must be alone\n";
143  }
144  suppressDebug = check<vString>(pset, "MessageLogger", "suppressDebug");
145  if ((!suppressDebug.empty()) && (!dmStar)) {
146  flaws << "MessageLogger"
147  << " PSet: \n"
148  << "suppressDebug contains modules, but debugModules is not *\n"
149  << "Unless all the debugModules are enabled,\n"
150  << "suppressing specific modules is meaningless\n";
151  }
152  if (wildcard(suppressDebug)) {
153  flaws << "MessageLogger"
154  << " PSet: \n"
155  << "Use of wildcard (*) in suppressDebug is not supported\n"
156  << "By default, LogDebug is suppressed for all modules\n";
157  }
158  suppressInfo = check<vString>(pset, "MessageLogger", "suppressInfo");
159  if (wildcard(suppressInfo)) {
160  flaws << "MessageLogger"
161  << " PSet: \n"
162  << "Use of wildcard (*) in suppressInfo is not supported\n";
163  }
164  suppressWarning = check<vString>(pset, "MessageLogger", "suppressWarning");
165  if (wildcard(suppressWarning)) {
166  flaws << "MessageLogger"
167  << " PSet: \n"
168  << "Use of wildcard (*) in suppressWarning is not supported\n";
169  }
170  suppressError = check<vString>(pset, "MessageLogger", "suppressError");
171  if (wildcard(suppressError)) {
172  flaws << "MessageLogger"
173  << " PSet: \n"
174  << "Use of wildcard (*) in suppressError is not supported\n";
175  }
176 
177  } // suppressionLists
178 
180  std::string const& /*psetName*/) {
181  vString vStrings = pset.getParameterNamesForType<vString>(false);
182  vString::const_iterator end = vStrings.end();
183  for (vString::const_iterator i = vStrings.begin(); i != end; ++i) {
184  if (!allowedVstring(*i)) {
185  flaws << "MessageLogger"
186  << " PSet: \n"
187  << (*i) << " is used as a vstring, "
188  << "but no such vstring is recognized\n";
189  }
190  }
191  vStrings = pset.getParameterNamesForType<vString>(true);
192  end = vStrings.end();
193  for (vString::const_iterator i = vStrings.begin(); i != end; ++i) {
194  flaws << "MessageLogger"
195  << " PSet: \n"
196  << (*i) << " is used as a tracked vstring: "
197  << "tracked parameters not allowed here\n";
198  }
199  } // vStringsCheck
200 
202  if (s == "destinations")
203  return true;
204  if (s == "statistics")
205  return true;
206  if (s == "destinations")
207  return true;
208  if (s == "fwkJobReports")
209  return true;
210  if (s == "categories")
211  return true;
212  if (s == "messageIDs")
213  return true;
214  if (s == "debugModules")
215  return true;
216  if (s == "suppressInfo")
217  return true;
218  if (s == "suppressDebug")
219  return true;
220  if (s == "suppressWarning")
221  return true;
222  if (s == "suppressError")
223  return true;
224  return false;
225  } // allowedVstring
226 
228  std::string const& psetName) {
229  if (checkThreshold(thresh))
230  return true;
231  flaws << psetName << " PSet: \n"
232  << "threshold has value " << thresh << " which is not among {DEBUG, INFO, WARNING, ERROR}\n";
233  return false;
234  } // validateThreshold
235 
237  if (thresh == "WARNING")
238  return true;
239  if (thresh == "INFO")
240  return true;
241  if (thresh == "ERROR")
242  return true;
243  if (thresh == "DEBUG")
244  return true;
245  return false;
246  }
247 
249  std::string const& psetName,
250  std::string const& parameterLabel) {
251  vString::const_iterator end = v.end();
252  for (vString::const_iterator i = v.begin(); i != end; ++i) {
253  for (vString::const_iterator j = i + 1; j != end; ++j) {
254  if (*i == *j) {
255  flaws << psetName << " PSet: \n"
256  << "in vString " << parameterLabel << " duplication of the string " << *i << "\n";
257  }
258  }
259  }
260  } // noDuplicates(v)
261 
263  vString const& v2,
264  std::string const& psetName,
265  std::string const& p1,
266  std::string const& p2) {
267  vString::const_iterator end1 = v1.end();
268  vString::const_iterator end2 = v2.end();
269  for (vString::const_iterator i = v1.begin(); i != end1; ++i) {
270  for (vString::const_iterator j = v2.begin(); j != end2; ++j) {
271  if (*i == *j) {
272  flaws << psetName << " PSet: \n"
273  << "in vStrings " << p1 << " and " << p2 << " duplication of the string " << *i << "\n";
274  }
275  }
276  }
277  } // noDuplicates(v1,v2)
278 
280  std::string const& psetName,
281  std::string const& parameterLabel) {
282  vString::const_iterator end = v.end();
283  bool coutPresent = false;
284  bool cerrPresent = false;
285  for (vString::const_iterator i = v.begin(); i != end; ++i) {
286  if (*i == "cout")
287  coutPresent = true;
288  if (*i == "cerr")
289  cerrPresent = true;
290  }
291  if (coutPresent && cerrPresent) {
292  flaws << psetName << " PSet: \n"
293  << "vString " << parameterLabel << " has both cout and cerr \n";
294  }
295  } // noCoutCerrClash(v)
296 
298  std::string const& psetName,
299  std::string const& parameterLabel) {
300  vString::const_iterator end = v.end();
301  for (vString::const_iterator i = v.begin(); i != end; ++i) {
302  if (!keywordCheck(*i)) {
303  flaws << psetName << " PSet: \n"
304  << "vString " << parameterLabel << " should not contain the keyword " << *i << "\n";
305  }
306  }
307  } // noKeywords(v)
308 
310  if (word == "default")
311  return false;
312  if (word == "categories")
313  return false;
314  if (word == "messageIDs")
315  return false;
316  if (word == "fwkJobReports")
317  return false;
318  if (word == "destinations")
319  return false;
320  if (word == "statistics")
321  return false;
322  if (word == "debugModules")
323  return false;
324  if (word == "suppressInfo")
325  return false;
326  if (word == "suppressDebug")
327  return false;
328  if (word == "suppressWarning")
329  return false;
330  if (word == "suppressError")
331  return false;
332  if (word == "threshold")
333  return false;
334  if (word == "ERROR")
335  return false;
336  if (word == "WARNING")
337  return false;
338  if (word == "INFO")
339  return false;
340  if (word == "DEBUG")
341  return false;
342  if (word == "placeholder")
343  return false;
344  if (word == "limit")
345  return false;
346  if (word == "reportEvery")
347  return false;
348  if (word == "timespan")
349  return false;
350  if (word == "noLineBreaks")
351  return false;
352  if (word == "lineLength")
353  return false;
354  if (word == "noTimeStamps")
355  return false;
356  if (word == "output")
357  return false;
358  if (word == "filename")
359  return false;
360  if (word == "extension")
361  return false;
362  if (word == "reset")
363  return false;
364  if (word == "optionalPSet")
365  return false;
366  return true;
367  } // keywordCheck
368 
370  vString const& v,
371  std::string const& psetName,
372  std::string const& parameterLabel) {
373  disallowedParam<int>(pset, v, psetName, parameterLabel, "int");
374  disallowedParam<unsigned int>(pset, v, psetName, parameterLabel, "uint");
375  disallowedParam<bool>(pset, v, psetName, parameterLabel, "bool");
376  disallowedParam<float>(pset, v, psetName, parameterLabel, "float");
377  disallowedParam<double>(pset, v, psetName, parameterLabel, "double");
378  disallowedParam<std::string>(pset, v, psetName, parameterLabel, "string");
379  disallowedParam<std::vector<std::string> >(pset, v, psetName, parameterLabel, "vstring");
380  } // noNonPSetUsage
381 
383  vString const& params,
384  std::string const& psetName,
385  std::string const& parameterLabel,
386  std::string const& type) {
387  vString::const_iterator end1 = v.end();
388  vString::const_iterator end2 = params.end();
389  for (vString::const_iterator i = v.begin(); i != end1; ++i) {
390  for (vString::const_iterator j = params.begin(); j != end2; ++j) {
391  if (*i == *j) {
392  flaws << psetName << " PSet: \n"
393  << *i << " (listed in vstring " << parameterLabel << ")\n"
394  << "is used as a parameter of type " << type << " instead of as a PSet \n";
395  }
396  }
397  }
398 
399  } // noBadParams
400 
402  vString::const_iterator end = v.end();
403  for (vString::const_iterator i = v.begin(); i != end; ++i) {
404  if ((*i) == "*")
405  return true;
406  }
407  return false;
408  }
409 
411  vString psnames;
412  pset.getParameterSetNames(psnames, false);
413  vString::const_iterator end = psnames.end();
414  for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
415  if (lookForMatch(destinations, *i))
416  continue;
417  if (lookForMatch(statistics, *i))
418  continue;
419  if (lookForMatch(fwkJobReports, *i))
420  continue;
421  if (lookForMatch(categories, *i))
422  continue;
423  if (lookForMatch(messageIDs, *i))
424  continue;
425  if ((*i) == "default")
426  continue;
427  ParameterSet empty_PSet;
428  bool ok_optionalPSet = false;
429  try {
430  ParameterSet const& culprit = pset.getUntrackedParameterSet((*i), empty_PSet);
431  ok_optionalPSet = culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
432  ok_optionalPSet = culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
433  } catch (cms::Exception& e) {
434  }
435  if (ok_optionalPSet)
436  continue;
437  flaws << "MessageLogger "
438  << " PSet: \n"
439  << *i << " is an unrecognized name for a PSet\n";
440  }
441  psnames.clear();
442  unsigned int n = pset.getParameterSetNames(psnames, true);
443  if (n > 0) {
444  end = psnames.end();
445  for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
446  flaws << "MessageLogger "
447  << " PSet: \n"
448  << "PSet " << *i << " is tracked - not allowed\n";
449  }
450  }
451  }
452 
454  vString::const_iterator begin = v.begin();
455  vString::const_iterator end = v.end();
456  return (std::find(begin, end, s) != end);
457  }
458 
460  ParameterSet empty_PSet;
461  std::vector<std::string>::const_iterator end = destinations.end();
462  for (std::vector<std::string>::const_iterator i = destinations.begin(); i != end; ++i) {
463  ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
464  destinationPSet(d, *i);
465  }
466  } // destinationPSets
467 
469  std::string const& psetName) {
470  // Category PSets
471 
472  categoryPSets(pset, psetName);
473 
474  // No other PSets -- unless they contain optionalPSet or placeholder=True
475 
476  noNoncategoryPsets(pset, psetName);
477 
478  // General parameters
479 
480  check<bool>(pset, psetName, "placeholder");
481  std::string thresh = check<std::string>(pset, "psetName", "threshold");
482  if (!thresh.empty())
483  validateThreshold(thresh, psetName);
484  check<bool>(pset, psetName, "noLineBreaks");
485  check<int>(pset, psetName, "lineLength");
486  check<bool>(pset, psetName, "noTimeStamps");
487  std::string s = check<std::string>(pset, "psetName", "filename");
488  if ((s == "cerr") || (s == "cout")) {
489  flaws << psetName << " PSet: \n" << s << " is not allowed as a value of filename \n";
490  }
491  s = check<std::string>(pset, "psetName", "extension");
492  if ((s == "cerr") || (s == "cout")) {
493  flaws << psetName << " PSet: \n" << s << " is not allowed as a value of extension \n";
494  }
495  s = check<std::string>(pset, "psetName", "output");
496 
497  // No other parameters
498 
499  noneExcept<int>(pset, psetName, "int", "lineLength");
500 
501  vString okbool;
502  okbool.push_back("placeholder");
503  okbool.push_back("optionalPSet");
504  okbool.push_back("noLineBreaks");
505  okbool.push_back("noTimeStamps");
506  noneExcept<bool>(pset, psetName, "bool", okbool);
507  vString okstring;
508  okstring.push_back("threshold");
509  okstring.push_back("output");
510  okstring.push_back("filename");
511  okstring.push_back("extension");
512  noneExcept<std::string>(pset, psetName, "string", okstring);
513 
514  } // destinationPSet
515 
517  ParameterSet empty_PSet;
518  ParameterSet const& pset = main_pset.getUntrackedParameterSet("default", empty_PSet);
519  std::string psetName = "default (at MessageLogger main level)";
520 
521  // Category PSets
522 
523  categoryPSets(pset, psetName);
524 
525  // No other PSets -- unless they contain optionalPSet or placeholder=True
526 
527  noNoncategoryPsets(pset, psetName);
528 
529  // Parameters applying to the default category
530 
531  catInts(pset, psetName, "default");
532 
533  // General parameters
534 
535  check<bool>(pset, psetName, "placeholder");
536  std::string thresh = check<std::string>(pset, "psetName", "threshold");
537  if (!thresh.empty())
538  validateThreshold(thresh, psetName);
539  check<bool>(pset, psetName, "noLineBreaks");
540  check<int>(pset, psetName, "limit");
541  check<int>(pset, psetName, "reportEvery");
542  check<int>(pset, psetName, "timespan");
543  check<int>(pset, psetName, "lineLength");
544  check<bool>(pset, psetName, "noTimeStamps");
545 
546  // No other parameters
547  vString okint;
548  okint.push_back("limit");
549  okint.push_back("reportEvery");
550  okint.push_back("timespan");
551  okint.push_back("lineLength");
552  noneExcept<int>(pset, psetName, "int", okint);
553  vString okbool;
554  okbool.push_back("placeholder");
555  okbool.push_back("optionalPSet");
556  okbool.push_back("noLineBreaks");
557  okbool.push_back("noTimeStamps");
558  noneExcept<bool>(pset, psetName, "bool", okbool);
559  vString okstring;
560  okstring.push_back("threshold");
561  noneExcept<std::string>(pset, psetName, "string", okstring);
562 
563  } // defaultPSet
564 
566  ParameterSet empty_PSet;
567  std::vector<std::string>::const_iterator end = statistics.end();
568  for (std::vector<std::string>::const_iterator i = statistics.begin(); i != end; ++i) {
569  if (lookForMatch(destinations, *i))
570  continue;
571  ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
572  statisticsPSet(d, *i);
573  }
574  } // statisticsPSets
575 
577  std::string const& psetName) {
578  // Category PSets
579 
580  categoryPSets(pset, psetName);
581 
582  // No other PSets -- unless they contain optionalPSet or placeholder=True
583 
584  noNoncategoryPsets(pset, psetName);
585 
586  // General parameters
587 
588  std::string thresh = check<std::string>(pset, "psetName", "threshold");
589  if (!thresh.empty())
590  validateThreshold(thresh, psetName);
591  check<bool>(pset, psetName, "placeholder");
592  check<bool>(pset, psetName, "reset");
593  std::string s = check<std::string>(pset, "psetName", "filename");
594  if ((s == "cerr") || (s == "cout")) {
595  flaws << psetName << " PSet: \n" << s << " is not allowed as a value of filename \n";
596  }
597  s = check<std::string>(pset, "psetName", "extension");
598  if ((s == "cerr") || (s == "cout")) {
599  flaws << psetName << " PSet: \n" << s << " is not allowed as a value of extension \n";
600  }
601  s = check<std::string>(pset, "psetName", "output");
602 
603  // No other parameters
604 
605  noneExcept<int>(pset, psetName, "int");
606 
607  vString okbool;
608  okbool.push_back("placeholder");
609  okbool.push_back("optionalPSet");
610  okbool.push_back("reset");
611  noneExcept<bool>(pset, psetName, "bool", okbool);
612  vString okstring;
613  okstring.push_back("output");
614  okstring.push_back("filename");
615  okstring.push_back("extension");
616  okstring.push_back("threshold");
617  noneExcept<std::string>(pset, psetName, "string", okstring);
618 
619  } // statisticsPSet
620 
622  ParameterSet empty_PSet;
623  std::vector<std::string>::const_iterator end = fwkJobReports.end();
624  for (std::vector<std::string>::const_iterator i = fwkJobReports.begin(); i != end; ++i) {
625  ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
626  fwkJobReportPSet(d, *i);
627  }
628  } // fwkJobReportPSets
629 
631  std::string const& psetName) {
632  // Category PSets
633 
634  categoryPSets(pset, psetName);
635 
636  // No other PSets -- unless they contain optionalPSet or placeholder=True
637 
638  noNoncategoryPsets(pset, psetName);
639 
640  // General parameters
641 
642  check<bool>(pset, psetName, "placeholder");
643  std::string s = check<std::string>(pset, "psetName", "filename");
644  if ((s == "cerr") || (s == "cout")) {
645  flaws << psetName << " PSet: \n" << s << " is not allowed as a value of filename \n";
646  }
647  s = check<std::string>(pset, "psetName", "extension");
648  if ((s == "cerr") || (s == "cout")) {
649  flaws << psetName << " PSet: \n" << s << " is not allowed as a value of extension \n";
650  }
651  s = check<std::string>(pset, "psetName", "output");
652 
653  // No other parameters
654 
655  noneExcept<int>(pset, psetName, "int");
656 
657  vString okbool;
658  okbool.push_back("placeholder");
659  okbool.push_back("optionalPSet");
660  noneExcept<bool>(pset, psetName, "bool", okbool);
661  vString okstring;
662  okstring.push_back("output");
663  okstring.push_back("filename");
664  okstring.push_back("extension");
665  noneExcept<std::string>(pset, psetName, "string", okstring);
666 
667  } // fwkJobReportPSet
668 
670  std::string const& psetName) {
671  vString psnames;
672  pset.getParameterSetNames(psnames, false);
673  vString::const_iterator end = psnames.end();
674  for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
675  if (lookForMatch(categories, *i))
676  continue;
677  if (lookForMatch(messageIDs, *i))
678  continue;
679  if ((*i) == "default")
680  continue;
681  if ((*i) == "ERROR")
682  continue;
683  if ((*i) == "WARNING")
684  continue;
685  if ((*i) == "INFO")
686  continue;
687  if ((*i) == "DEBUG")
688  continue;
689  ParameterSet empty_PSet;
690  bool ok_optionalPSet = false;
691  try {
692  ParameterSet const& culprit = pset.getUntrackedParameterSet((*i), empty_PSet);
693  ok_optionalPSet = culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
694  ok_optionalPSet = culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
695  } catch (cms::Exception& e) {
696  }
697  if (ok_optionalPSet)
698  continue;
699  flaws << psetName << " PSet: \n" << *i << " is an unrecognized name for a PSet in this context \n";
700  }
701  psnames.clear();
702  unsigned int n = pset.getParameterSetNames(psnames, true);
703  if (n > 0) {
704  end = psnames.end();
705  for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
706  flaws << psetName << " PSet: \n"
707  << "PSet " << *i << " is tracked - not allowed\n";
708  }
709  }
710  } // noNoncategoryPsets
711 
713  std::string const& psetName) {
714  categoryPSet(pset, psetName, "ERROR");
715  categoryPSet(pset, psetName, "WARNING");
716  categoryPSet(pset, psetName, "INFO");
717  categoryPSet(pset, psetName, "DEBUG");
718  if (psetName != "MessageLogger")
719  categoryPSet(pset, psetName, "default");
720  // The above conditional is because default in the main level is treated
721  // as a set of defaults differnt from those of a simple category.
722  std::vector<std::string>::const_iterator end = categories.end();
723  for (std::vector<std::string>::const_iterator i = categories.begin(); i != end; ++i) {
724  categoryPSet(pset, psetName, *i);
725  }
726  } // categoryPSets
727 
729  std::string const& OuterPsetName,
730  std::string const& categoryName) {
731  if (pset.existsAs<ParameterSet>(categoryName, true)) {
732  flaws << OuterPsetName << " PSet: \n"
733  << "Category PSet " << categoryName << " is tracked - not allowed\n";
734  return;
735  }
736  ParameterSet empty_PSet;
737  ParameterSet const& c = pset.getUntrackedParameterSet(categoryName, empty_PSet);
738  std::string const& psetName(OuterPsetName);
739  catInts(c, psetName, categoryName);
740  catNone<unsigned int>(c, psetName, categoryName, "unsigned int");
741  catBoolRestriction(c, psetName, categoryName, "bool");
742  catNone<float>(c, psetName, categoryName, "float");
743  catNone<double>(c, psetName, categoryName, "double");
744  catNone<std::string>(c, psetName, categoryName, "string");
745  catNone<vString>(c, psetName, categoryName, "vSting");
746  catNoPSets(c, psetName, categoryName);
747  } // categoryPSet
748 
750  std::string const& psetName,
751  std::string const& categoryName) {
752  vString x = pset.getParameterNamesForType<int>(false);
753  vString::const_iterator end = x.end();
754  for (vString::const_iterator i = x.begin(); i != end; ++i) {
755  if (*i == "limit")
756  continue;
757  if (*i == "reportEvery")
758  continue;
759  if (*i == "timespan")
760  continue;
761  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
762  << (*i) << " is not an allowed parameter within a category PSet \n";
763  }
764  x = pset.getParameterNamesForType<int>(true);
765  end = x.end();
766  for (vString::const_iterator i = x.begin(); i != end; ++i) {
767  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
768  << (*i) << " is used as a tracked int \n"
769  << "Tracked parameters not allowed here \n";
770  }
771  } // catInts()
772 
774  std::string const& psetName,
775  std::string const& categoryName) {
776  vString psnames;
777  pset.getParameterSetNames(psnames, false);
778  vString::const_iterator end = psnames.end();
779  for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
780  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
781  << *i << " is used as a PSet\n"
782  << "PSets not allowed within a category PSet\n";
783  }
784  psnames.clear();
785  unsigned int n = pset.getParameterSetNames(psnames, true);
786  if (n > 0) {
787  end = psnames.end();
788  for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
789  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
790  << *i << " is used as a tracked PSet\n"
791  << "tracked parameters not permitted, and "
792  << "PSets not allowed within a category PSet\n";
793  }
794  }
795  } // catNoPSets
796 
798  std::string const& psetName,
799  std::string const& categoryName,
800  std::string const& type) {
801  vString x = pset.getParameterNamesForType<bool>(false);
802  vString::const_iterator end = x.end();
803  for (vString::const_iterator i = x.begin(); i != end; ++i) {
804  if (((*i) == "placeholder") || ((*i) == "optionalPSet"))
805  continue;
806  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
807  << (*i) << " is used as a " << type << "\n"
808  << "Usage of " << type << " is not recognized here\n";
809  }
810  x = pset.getParameterNamesForType<bool>(true);
811  end = x.end();
812  for (vString::const_iterator i = x.begin(); i != end; ++i) {
813  flaws << categoryName << " category PSet nested in " << psetName << " PSet: \n"
814  << (*i) << " is used as a tracked " << type << "\n"
815  << "Tracked parameters not allowed here, "
816  << " and even untracked it would not be recognized\n";
817  }
818  } // catBoolRestriction()
819 
820  } // end of namespace service
821 } // end of namespace edm
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
void statisticsPSet(ParameterSet const &pset, std::string const &psetName)
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
bool lookForMatch(vString const &v, std::string const &s)
void categoryPSets(ParameterSet const &pset, std::string const &psetName)
void destinationPSet(ParameterSet const &pset, std::string const &psetName)
void vStringsCheck(ParameterSet const &pset, std::string const &psetName)
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void noCoutCerrClash(vString const &v, std::string const &psetName, std::string const &parameterLabel)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:169
void fwkJobReportPSet(ParameterSet const &pset, std::string const &psetName)
void noKeywords(vString const &v, std::string const &psetName, std::string const &parameterLabel)
void noDuplicates(vString const &v, std::string const &psetName, std::string const &parameterLabel)
#define end
Definition: vmac.h:39
double p2[4]
Definition: TauolaWrapper.h:90
void catNoPSets(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName)
void noBadParams(vString const &v, vString const &params, std::string const &psetName, std::string const &parameterLabel, std::string const &type)
void noNonPSetUsage(ParameterSet const &pset, vString const &v, std::string const &psetName, std::string const &parameterLabel)
std::string operator()(ParameterSet const &pset)
bool validateThreshold(std::string const &thresh, std::string const &psetName)
void noNoncategoryPsets(ParameterSet const &pset, std::string const &psetName)
#define begin
Definition: vmac.h:32
HLT enums.
double p1[4]
Definition: TauolaWrapper.h:89
void catBoolRestriction(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName, std::string const &type)
void categoryPSet(ParameterSet const &pset, std::string const &OuterPsetName, std::string const &categoryName)
void catInts(ParameterSet const &pset, std::string const &psetName, std::string const &categoryName)
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const