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