test
CMS 3D CMS Logo

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