00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <algorithm>
00020
00021
00022
00023 #include "FWCore/MessageService/interface/MessageServicePSetValidation.h"
00024
00025 using namespace edm;
00026 using namespace edm::service;
00027
00028 namespace edm {
00029 namespace service {
00030
00031 std::string
00032 edm::service::MessageServicePSetValidation::
00033 operator() (ParameterSet const & pset)
00034 {
00035 messageLoggerPSet (pset);
00036 return flaws.str();
00037 }
00038
00039 void
00040 edm::service::MessageServicePSetValidation::
00041 messageLoggerPSet (ParameterSet const & pset)
00042 {
00043
00044
00045
00046
00047
00048
00049
00050
00051 psetLists(pset);
00052
00053
00054
00055 suppressionLists(pset);
00056
00057
00058
00059 vStringsCheck(pset, "MessageLogger");
00060
00061
00062
00063 check<bool>
00064 ( pset, "MessageLogger", "messageSummaryToJobReport" );
00065 std::string dumps = check<std::string>
00066 ( pset, "MessageLogger", "generate_preconfiguration_message" );
00067 std::string thresh = check<std::string>
00068 ( pset, "MessageLogger", "threshold" );
00069 if (!thresh.empty()) validateThreshold(thresh, "MessageLogger");
00070
00071
00072
00073 destinationPSets(pset);
00074 defaultPSet(pset);
00075 statisticsPSets(pset);
00076 fwkJobReportPSets(pset);
00077 categoryPSets(pset, "MessageLogger");
00078
00079
00080
00081 noOtherPsets (pset);
00082
00083
00084
00085 noneExcept <int> (pset, "MessageLogger", "int");
00086 noneExcept <unsigned int> (pset, "MessageLogger", "unsigned int");
00087 noneExcept <bool> (pset, "MessageLogger","bool","messageSummaryToJobReport");
00088
00089
00090 noneExcept <float> (pset, "MessageLogger","float");
00091 noneExcept <double> (pset, "MessageLogger","double");
00092 noneExcept <std::string> (pset, "MessageLogger","string",
00093 "threshold", "generate_preconfiguration_message");
00094
00095
00096
00097 if (!flaws.str().empty()) {
00098 flaws << "\nThe above are from MessageLogger configuration validation.\n"
00099 << "In most cases, these involve lines that the logger configuration code\n"
00100 << "would not process, but which the cfg creator obviously meant to have "
00101 << "effect.\n";
00102 }
00103
00104 }
00105
00106 void
00107 edm::service::MessageServicePSetValidation::
00108 psetLists ( ParameterSet const & pset )
00109 {
00110 destinations = check<vString>
00111 (pset, "MessageLogger", "destinations");
00112 noDuplicates(destinations,"MessageLogger", "destinations");
00113 noKeywords(destinations,"MessageLogger", "destinations");
00114 noNonPSetUsage(pset, destinations,"MessageLogger", "destinations");
00115
00116
00117 statistics = check<vString>
00118 (pset, "MessageLogger", "statistics");
00119 noDuplicates(statistics,"MessageLogger", "statistics");
00120 noKeywords(statistics,"MessageLogger", "statistics");
00121 noNonPSetUsage(pset, statistics,"MessageLogger", "statistics");
00122
00123 fwkJobReports = check<vString>
00124 (pset, "MessageLogger", "fwkJobReports");
00125 noDuplicates(fwkJobReports,"MessageLogger", "fwkJobReports");
00126 noKeywords(fwkJobReports,"MessageLogger", "fwkJobReports");
00127 noNonPSetUsage(pset, fwkJobReports,"MessageLogger", "fwkJobReports");
00128 noDuplicates(fwkJobReports,destinations,
00129 "MessageLogger", "fwkJobReports","destinations");
00130 noDuplicates(fwkJobReports,statistics,
00131 "MessageLogger", "fwkJobReports","statistics");
00132
00133 categories = check<vString>
00134 (pset, "MessageLogger", "categories");
00135 noDuplicates(categories,"MessageLogger", "categories");
00136 noKeywords(categories,"MessageLogger", "categories");
00137 noNonPSetUsage(pset, categories,"MessageLogger", "categories");
00138 noDuplicates(categories,destinations,
00139 "MessageLogger", "categories","destinations");
00140 noDuplicates(categories,statistics,
00141 "MessageLogger", "categories","statistics");
00142 noDuplicates(categories,fwkJobReports,
00143 "MessageLogger", "categories","fwkJobReports");
00144
00145 messageIDs = check<vString>
00146 (pset, "MessageLogger", "messageIDs");
00147 noDuplicates(messageIDs,"MessageLogger", "messageIDs");
00148 noKeywords(messageIDs,"MessageLogger", "messageIDs");
00149 noNonPSetUsage(pset, messageIDs,"MessageLogger", "messageIDs");
00150 noDuplicates(messageIDs,destinations,
00151 "MessageLogger", "messageIDs","destinations");
00152 noDuplicates(messageIDs,statistics,
00153 "MessageLogger", "messageIDs","statistics");
00154 noDuplicates(messageIDs,fwkJobReports,
00155 "MessageLogger", "messageIDs","fwkJobReports");
00156 noDuplicates(messageIDs,fwkJobReports,
00157 "MessageLogger", "messageIDs","categories");
00158
00159 }
00160
00161 void
00162 edm::service::MessageServicePSetValidation::
00163 suppressionLists ( ParameterSet const & pset )
00164 {
00165 debugModules = check<vString>
00166 (pset, "MessageLogger", "debugModules");
00167 bool dmStar = wildcard(debugModules);
00168 if ( dmStar && debugModules.size() != 1) {
00169 flaws << "MessageLogger" << " PSet: \n"
00170 << "debugModules contains wildcard character *"
00171 << " and also " << debugModules.size()-1
00172 << " other entries - * must be alone\n";
00173 }
00174 suppressDebug = check<vString>
00175 (pset, "MessageLogger", "suppressDebug");
00176 if ( (suppressDebug.size() > 0) && (!dmStar) ) {
00177 flaws << "MessageLogger" << " PSet: \n"
00178 << "suppressDebug contains modules, but debugModules is not *\n"
00179 << "Unless all the debugModules are enabled,\n"
00180 << "suppressing specific modules is meaningless\n";
00181 }
00182 if (wildcard(suppressDebug)) {
00183 flaws << "MessageLogger" << " PSet: \n"
00184 << "Use of wildcard (*) in suppressDebug is not supported\n"
00185 << "By default, LogDebug is suppressed for all modules\n";
00186 }
00187 suppressInfo = check<vString>
00188 (pset, "MessageLogger", "suppressInfo");
00189 if (wildcard(suppressInfo)) {
00190 flaws << "MessageLogger" << " PSet: \n"
00191 << "Use of wildcard (*) in suppressInfo is not supported\n";
00192 }
00193 suppressWarning = check<vString>
00194 (pset, "MessageLogger", "suppressWarning");
00195 if (wildcard(suppressWarning)) {
00196 flaws << "MessageLogger" << " PSet: \n"
00197 << "Use of wildcard (*) in suppressWarning is not supported\n";
00198 }
00199
00200 }
00201
00202
00203 void
00204 edm::service::MessageServicePSetValidation::
00205 vStringsCheck ( ParameterSet const & pset,std::string const & psetName )
00206 {
00207 vString vStrings = pset.getParameterNamesForType <vString> (false);
00208 vString::const_iterator end = vStrings.end();
00209 for ( vString::const_iterator i = vStrings.begin(); i != end; ++i ) {
00210 if ( !allowedVstring(*i) ) {
00211 flaws << "MessageLogger" << " PSet: \n"
00212 << (*i) << " is used as a vstring, "
00213 << "but no such vstring is recognized\n";
00214 }
00215 }
00216 vStrings = pset.getParameterNamesForType <vString> (true);
00217 end = vStrings.end();
00218 for ( vString::const_iterator i = vStrings.begin(); i != end; ++i ) {
00219 flaws << "MessageLogger" << " PSet: \n"
00220 << (*i) << " is used as a tracked vstring: "
00221 << "tracked parameters not allowed here\n";
00222 }
00223 }
00224
00225 bool
00226 edm::service::MessageServicePSetValidation::
00227 allowedVstring (std::string const & s)
00228 {
00229 if (s == "destinations") return true;
00230 if (s == "statistics") return true;
00231 if (s == "destinations") return true;
00232 if (s == "fwkJobReports") return true;
00233 if (s == "categories") return true;
00234 if (s == "messageIDs") return true;
00235 if (s == "debugModules") return true;
00236 if (s == "suppressInfo") return true;
00237 if (s == "suppressDebug") return true;
00238 if (s == "suppressWarning") return true;
00239 return false;
00240 }
00241
00242
00243
00244 bool
00245 edm::service::MessageServicePSetValidation::
00246 validateThreshold (std::string const & thresh, std::string const & psetName)
00247 {
00248 if (checkThreshold(thresh)) return true;
00249 flaws << psetName << " PSet: \n"
00250 << "threshold has value " << thresh
00251 << " which is not among {DEBUG, INFO, WARNING, ERROR}\n";
00252 return false;
00253 }
00254
00255 bool
00256 edm::service::MessageServicePSetValidation::
00257 checkThreshold (std::string const & thresh)
00258 {
00259 if (thresh == "WARNING") return true;
00260 if (thresh == "INFO") return true;
00261 if (thresh == "ERROR") return true;
00262 if (thresh == "DEBUG") return true;
00263 return false;
00264 }
00265
00266 void
00267 edm::service::MessageServicePSetValidation::
00268 noDuplicates(vString const & v, std::string const & psetName,
00269 std::string const & parameterLabel )
00270 {
00271 vString::const_iterator end = v.end();
00272 for (vString::const_iterator i = v.begin(); i != end; ++i) {
00273 for (vString::const_iterator j = i+1; j != end; ++j) {
00274 if ( *i == *j ) {
00275 flaws << psetName << " PSet: \n"
00276 << "in vString " << parameterLabel
00277 << " duplication of the string " << *i << "\n";
00278 }
00279 }
00280 }
00281 }
00282
00283 void
00284 edm::service::MessageServicePSetValidation::
00285 noDuplicates(vString const & v1, vString const & v2,
00286 std::string const & psetName,
00287 std::string const & p1, std::string const & p2 )
00288 {
00289 vString::const_iterator end1 = v1.end();
00290 vString::const_iterator end2 = v2.end();
00291 for (vString::const_iterator i = v1.begin(); i != end1; ++i) {
00292 for (vString::const_iterator j = v2.begin(); j != end2; ++j) {
00293 if ( *i == *j ) {
00294 flaws << psetName << " PSet: \n"
00295 << "in vStrings " << p1 << " and " << p2
00296 << " duplication of the string " << *i << "\n";
00297 }
00298 }
00299 }
00300 }
00301
00302 void
00303 edm::service::MessageServicePSetValidation::
00304 noCoutCerrClash(vString const & v, std::string const & psetName,
00305 std::string const & parameterLabel )
00306 {
00307 vString::const_iterator end = v.end();
00308 bool coutPresent = false;
00309 bool cerrPresent = false;
00310 for (vString::const_iterator i = v.begin(); i != end; ++i) {
00311 if ( *i == "cout" ) coutPresent = true;
00312 if ( *i == "cerr" ) cerrPresent = true;
00313 }
00314 if (coutPresent && cerrPresent) {
00315 flaws << psetName << " PSet: \n"
00316 << "vString " << parameterLabel
00317 << " has both cout and cerr \n";
00318 }
00319 }
00320
00321 void
00322 edm::service::MessageServicePSetValidation::
00323 noKeywords(vString const & v, std::string const & psetName,
00324 std::string const & parameterLabel )
00325 {
00326 vString::const_iterator end = v.end();
00327 for (vString::const_iterator i = v.begin(); i != end; ++i) {
00328 if (!keywordCheck(*i)) {
00329 flaws << psetName << " PSet: \n"
00330 << "vString " << parameterLabel
00331 << " should not contain the keyword " << *i << "\n";
00332 }
00333 }
00334 }
00335
00336 bool
00337 edm::service::MessageServicePSetValidation::
00338 keywordCheck(std::string const & word)
00339 {
00340 if (word == "default") return false;
00341 if (word == "categories") return false;
00342 if (word == "messageIDs") return false;
00343 if (word == "fwkJobReports") return false;
00344 if (word == "destinations") return false;
00345 if (word == "statistics") return false;
00346 if (word == "debugModules") return false;
00347 if (word == "suppressInfo") return false;
00348 if (word == "suppressDebug") return false;
00349 if (word == "suppressWarning")return false;
00350 if (word == "threshold") return false;
00351 if (word == "ERROR") return false;
00352 if (word == "WARNING") return false;
00353 if (word == "INFO") return false;
00354 if (word == "DEBUG") return false;
00355 if (word == "placeholder") return false;
00356 if (word == "limit") return false;
00357 if (word == "reportEvery") return false;
00358 if (word == "timespan") return false;
00359 if (word == "noLineBreaks") return false;
00360 if (word == "lineLength") return false;
00361 if (word == "noTimeStamps") return false;
00362 if (word == "output") return false;
00363 if (word == "filename") return false;
00364 if (word == "extension") return false;
00365 if (word == "reset") return false;
00366 if (word == "optionalPSet") return false;
00367 return true;
00368 }
00369
00370 void
00371 edm::service::MessageServicePSetValidation::
00372 noNonPSetUsage(ParameterSet const & pset ,
00373 vString const & v, std::string const & psetName,
00374 std::string const & parameterLabel )
00375 {
00376 disallowedParam <int> ( pset, v, psetName, parameterLabel, "int" );
00377 disallowedParam <unsigned int> ( pset, v, psetName, parameterLabel, "uint" );
00378 disallowedParam <bool> ( pset, v, psetName, parameterLabel, "bool" );
00379 disallowedParam <float> ( pset, v, psetName, parameterLabel, "float" );
00380 disallowedParam <double> ( pset, v, psetName, parameterLabel, "double" );
00381 disallowedParam <std::string> ( pset, v, psetName, parameterLabel, "string" );
00382 disallowedParam <std::vector<std::string> >
00383 ( pset, v, psetName, parameterLabel, "vstring" );
00384 }
00385
00386 void
00387 edm::service::MessageServicePSetValidation::
00388 noBadParams(vString const & v, vString const & params,
00389 std::string const & psetName,
00390 std::string const & parameterLabel,
00391 std::string const & type)
00392 {
00393 vString::const_iterator end1 = v.end();
00394 vString::const_iterator end2 = params.end();
00395 for (vString::const_iterator i = v.begin(); i != end1; ++i) {
00396 for (vString::const_iterator j = params.begin(); j != end2; ++j) {
00397 if ( *i == *j ) {
00398 flaws << psetName << " PSet: \n"
00399 << *i << " (listed in vstring " << parameterLabel << ")\n"
00400 << "is used as a parameter of type " << type
00401 << " instead of as a PSet \n";
00402 }
00403 }
00404 }
00405
00406 }
00407
00408 bool
00409 edm::service::MessageServicePSetValidation::
00410 wildcard(vString const & v)
00411 {
00412 vString::const_iterator end = v.end();
00413 for (vString::const_iterator i = v.begin(); i != end; ++i) {
00414 if ((*i) == "*") return true;
00415 }
00416 return false;
00417 }
00418
00419 void
00420 edm::service::MessageServicePSetValidation::
00421 noOtherPsets(ParameterSet const & pset)
00422 {
00423 vString psnames;
00424 pset.getParameterSetNames(psnames, false);
00425 vString::const_iterator end = psnames.end();
00426 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
00427 if ( lookForMatch (destinations, *i) ) continue;
00428 if ( lookForMatch (statistics, *i) ) continue;
00429 if ( lookForMatch (fwkJobReports, *i) ) continue;
00430 if ( lookForMatch (categories, *i) ) continue;
00431 if ( lookForMatch (messageIDs, *i) ) continue;
00432 if ( (*i) == "default" ) continue;
00433 ParameterSet empty_PSet;
00434 bool ok_optionalPSet = false;
00435 try {
00436 ParameterSet const& culprit =
00437 pset.getUntrackedParameterSet((*i),empty_PSet);
00438 ok_optionalPSet =
00439 culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
00440 ok_optionalPSet =
00441 culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
00442 } catch (cms::Exception& e) {
00443 }
00444 if (ok_optionalPSet) continue;
00445 flaws << "MessageLogger " << " PSet: \n"
00446 << *i << " is an unrecognized name for a PSet\n";
00447 }
00448 psnames.clear();
00449 unsigned int n = pset.getParameterSetNames(psnames, true);
00450 if ( n > 0 ) {
00451 end = psnames.end();
00452 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
00453 flaws << "MessageLogger " << " PSet: \n"
00454 << "PSet " << *i << " is tracked - not allowed\n";
00455 }
00456 }
00457 }
00458
00459 bool
00460 edm::service::MessageServicePSetValidation::
00461 lookForMatch(vString const & v, std::string const & s)
00462 {
00463 vString::const_iterator begin = v.begin();
00464 vString::const_iterator end = v.end();
00465 return ( std::find(begin, end, s) != end );
00466 }
00467
00468 void
00469 edm::service::MessageServicePSetValidation::
00470 destinationPSets(ParameterSet const & pset)
00471 {
00472 ParameterSet empty_PSet;
00473 std::vector<std::string>::const_iterator end = destinations.end();
00474 for ( std::vector<std::string>::const_iterator i = destinations.begin();
00475 i != end; ++i ) {
00476 ParameterSet const& d = pset.getUntrackedParameterSet(*i,empty_PSet);
00477 destinationPSet(d,*i);
00478 }
00479 }
00480
00481 void
00482 edm::service::MessageServicePSetValidation::
00483 destinationPSet(ParameterSet const & pset, std::string const & psetName)
00484 {
00485
00486
00487 categoryPSets (pset, psetName);
00488
00489
00490
00491 noNoncategoryPsets (pset, psetName);
00492
00493
00494
00495 check <bool> ( pset, psetName, "placeholder" );
00496 std::string thresh = check<std::string> ( pset, "psetName", "threshold" );
00497 if (!thresh.empty()) validateThreshold(thresh, psetName);
00498 check <bool> ( pset, psetName, "noLineBreaks" );
00499 check <int> ( pset, psetName, "lineLength" );
00500 check <bool> ( pset, psetName, "noTimeStamps" );
00501 std::string s = check<std::string> ( pset, "psetName", "filename" );
00502 if ( (s == "cerr") || (s == "cout") ) {
00503 flaws << psetName << " PSet: \n"
00504 << s << " is not allowed as a value of filename \n";
00505 }
00506 s = check<std::string> ( pset, "psetName", "extension" );
00507 if ( (s == "cerr") || (s == "cout") ) {
00508 flaws << psetName << " PSet: \n"
00509 << s << " is not allowed as a value of extension \n";
00510 }
00511 s = check<std::string> ( pset, "psetName", "output" );
00512
00513
00514
00515 noneExcept <int> (pset, psetName, "int", "lineLength");
00516
00517 vString okbool;
00518 okbool.push_back ("placeholder");
00519 okbool.push_back ("optionalPSet");
00520 okbool.push_back ("noLineBreaks");
00521 okbool.push_back ("noTimeStamps");
00522 noneExcept <bool> (pset, psetName, "bool", okbool);
00523 vString okstring;
00524 okstring.push_back ("threshold");
00525 okstring.push_back ("output");
00526 okstring.push_back ("filename");
00527 okstring.push_back ("extension");
00528 noneExcept <std::string> (pset, psetName, "string", okstring);
00529
00530 }
00531
00532 void
00533 edm::service::MessageServicePSetValidation::
00534 defaultPSet(ParameterSet const & main_pset)
00535 {
00536 ParameterSet empty_PSet;
00537 ParameterSet const& pset = main_pset.getUntrackedParameterSet("default",empty_PSet);
00538 std::string psetName = "default (at MessageLogger main level)";
00539
00540
00541
00542 categoryPSets (pset, psetName);
00543
00544
00545
00546 noNoncategoryPsets (pset, psetName);
00547
00548
00549
00550 catInts ( pset, psetName, "default" );
00551
00552
00553
00554 check <bool> ( pset, psetName, "placeholder" );
00555 std::string thresh = check<std::string> ( pset, "psetName", "threshold" );
00556 if (!thresh.empty()) validateThreshold(thresh, psetName);
00557 check <bool> ( pset, psetName, "noLineBreaks" );
00558 check <int> ( pset, psetName, "limit" );
00559 check <int> ( pset, psetName, "reportEvery" );
00560 check <int> ( pset, psetName, "timespan" );
00561 check <int> ( pset, psetName, "lineLength" );
00562 check <bool> ( pset, psetName, "noTimeStamps" );
00563
00564
00565 vString okint;
00566 okint.push_back("limit");
00567 okint.push_back("reportEvery");
00568 okint.push_back("timespan");
00569 okint.push_back("lineLength");
00570 noneExcept <int> (pset, psetName, "int", okint);
00571 vString okbool;
00572 okbool.push_back ("placeholder");
00573 okbool.push_back ("optionalPSet");
00574 okbool.push_back ("noLineBreaks");
00575 okbool.push_back ("noTimeStamps");
00576 noneExcept <bool> (pset, psetName, "bool", okbool);
00577 vString okstring;
00578 okstring.push_back ("threshold");
00579 noneExcept <std::string> (pset, psetName, "string", okstring);
00580
00581 }
00582
00583 void
00584 edm::service::MessageServicePSetValidation::
00585 statisticsPSets(ParameterSet const & pset)
00586 {
00587 ParameterSet empty_PSet;
00588 std::vector<std::string>::const_iterator end = statistics.end();
00589 for ( std::vector<std::string>::const_iterator i = statistics.begin();
00590 i != end; ++i ) {
00591 if (lookForMatch(destinations, *i)) continue;
00592 ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
00593 statisticsPSet(d,*i);
00594 }
00595 }
00596
00597 void
00598 edm::service::MessageServicePSetValidation::
00599 statisticsPSet(ParameterSet const & pset, std::string const & psetName)
00600 {
00601
00602
00603 categoryPSets (pset, psetName);
00604
00605
00606
00607 noNoncategoryPsets (pset, psetName);
00608
00609
00610
00611 std::string thresh = check<std::string> ( pset, "psetName", "threshold" );
00612 if (!thresh.empty()) validateThreshold(thresh, psetName);
00613 check <bool> ( pset, psetName, "placeholder" );
00614 check <bool> ( pset, psetName, "reset" );
00615 std::string s = check<std::string> ( pset, "psetName", "filename" );
00616 if ( (s == "cerr") || (s == "cout") ) {
00617 flaws << psetName << " PSet: \n"
00618 << s << " is not allowed as a value of filename \n";
00619 }
00620 s = check<std::string> ( pset, "psetName", "extension" );
00621 if ( (s == "cerr") || (s == "cout") ) {
00622 flaws << psetName << " PSet: \n"
00623 << s << " is not allowed as a value of extension \n";
00624 }
00625 s = check<std::string> ( pset, "psetName", "output" );
00626
00627
00628
00629 noneExcept <int> (pset, psetName, "int");
00630
00631 vString okbool;
00632 okbool.push_back ("placeholder");
00633 okbool.push_back ("optionalPSet");
00634 okbool.push_back ("reset");
00635 noneExcept <bool> (pset, psetName, "bool", okbool);
00636 vString okstring;
00637 okstring.push_back ("output");
00638 okstring.push_back ("filename");
00639 okstring.push_back ("extension");
00640 okstring.push_back ("threshold");
00641 noneExcept <std::string> (pset, psetName, "string", okstring);
00642
00643 }
00644
00645 void
00646 edm::service::MessageServicePSetValidation::
00647 fwkJobReportPSets(ParameterSet const & pset)
00648 {
00649 ParameterSet empty_PSet;
00650 std::vector<std::string>::const_iterator end = fwkJobReports.end();
00651 for ( std::vector<std::string>::const_iterator i = fwkJobReports.begin();
00652 i != end; ++i ) {
00653 ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
00654 fwkJobReportPSet(d,*i);
00655 }
00656 }
00657
00658 void
00659 edm::service::MessageServicePSetValidation::
00660 fwkJobReportPSet(ParameterSet const & pset, std::string const & psetName)
00661 {
00662
00663
00664 categoryPSets (pset, psetName);
00665
00666
00667
00668 noNoncategoryPsets (pset, psetName);
00669
00670
00671
00672 check <bool> ( pset, psetName, "placeholder" );
00673 std::string s = check<std::string> ( pset, "psetName", "filename" );
00674 if ( (s == "cerr") || (s == "cout") ) {
00675 flaws << psetName << " PSet: \n"
00676 << s << " is not allowed as a value of filename \n";
00677 }
00678 s = check<std::string> ( pset, "psetName", "extension" );
00679 if ( (s == "cerr") || (s == "cout") ) {
00680 flaws << psetName << " PSet: \n"
00681 << s << " is not allowed as a value of extension \n";
00682 }
00683 s = check<std::string> ( pset, "psetName", "output" );
00684
00685
00686
00687 noneExcept <int> (pset, psetName, "int");
00688
00689 vString okbool;
00690 okbool.push_back ("placeholder");
00691 okbool.push_back ("optionalPSet");
00692 noneExcept <bool> (pset, psetName, "bool", okbool);
00693 vString okstring;
00694 okstring.push_back ("output");
00695 okstring.push_back ("filename");
00696 okstring.push_back ("extension");
00697 noneExcept <std::string> (pset, psetName, "string", okstring);
00698
00699 }
00700
00701 void
00702 edm::service::MessageServicePSetValidation::
00703 noNoncategoryPsets(ParameterSet const & pset,std::string const & psetName)
00704 {
00705 vString psnames;
00706 pset.getParameterSetNames(psnames, false);
00707 vString::const_iterator end = psnames.end();
00708 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
00709 if ( lookForMatch (categories, *i) ) continue;
00710 if ( lookForMatch (messageIDs, *i) ) continue;
00711 if ( (*i) == "default" ) continue;
00712 if ( (*i) == "ERROR" ) continue;
00713 if ( (*i) == "WARNING" ) continue;
00714 if ( (*i) == "INFO" ) continue;
00715 if ( (*i) == "DEBUG" ) continue;
00716 ParameterSet empty_PSet;
00717 bool ok_optionalPSet = false;
00718 try {
00719 ParameterSet const& culprit =
00720 pset.getUntrackedParameterSet((*i),empty_PSet);
00721 ok_optionalPSet =
00722 culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
00723 ok_optionalPSet =
00724 culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
00725 } catch (cms::Exception& e) {
00726 }
00727 if (ok_optionalPSet) continue;
00728 flaws << psetName << " PSet: \n"
00729 << *i << " is an unrecognized name for a PSet in this context \n";
00730 }
00731 psnames.clear();
00732 unsigned int n = pset.getParameterSetNames(psnames, true);
00733 if ( n > 0 ) {
00734 end = psnames.end();
00735 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
00736 flaws << psetName << " PSet: \n"
00737 << "PSet " << *i << " is tracked - not allowed\n";
00738 }
00739 }
00740 }
00741
00742 void
00743 edm::service::MessageServicePSetValidation::
00744 categoryPSets(ParameterSet const & pset, std::string const & psetName )
00745 {
00746 categoryPSet (pset, psetName, "ERROR" );
00747 categoryPSet (pset, psetName, "WARNING");
00748 categoryPSet (pset, psetName, "INFO" ) ;
00749 categoryPSet (pset, psetName, "DEBUG" );
00750 if (psetName != "MessageLogger") categoryPSet (pset, psetName, "default");
00751
00752
00753 std::vector<std::string>::const_iterator end = categories.end();
00754 for (std::vector<std::string>::const_iterator i = categories.begin();
00755 i != end; ++i) {
00756 categoryPSet(pset, psetName, *i);
00757 }
00758 }
00759
00760 void
00761 edm::service::MessageServicePSetValidation::
00762 categoryPSet (ParameterSet const & pset,
00763 std::string const & OuterPsetName,
00764 std::string const & categoryName) {
00765 if (pset.existsAs<ParameterSet> (categoryName, true)) {
00766 flaws << OuterPsetName << " PSet: \n"
00767 << "Category PSet " << categoryName
00768 << " is tracked - not allowed\n";
00769 return;
00770 }
00771 ParameterSet empty_PSet;
00772 ParameterSet const& c = pset.getUntrackedParameterSet(categoryName,empty_PSet);
00773 std::string const & psetName(OuterPsetName);
00774 catInts ( c, psetName, categoryName );
00775 catNone <unsigned int> ( c, psetName, categoryName, "unsigned int" );
00776 catBoolRestriction ( c, psetName, categoryName, "bool" );
00777 catNone <float> ( c, psetName, categoryName, "float" );
00778 catNone <double> ( c, psetName, categoryName, "double" );
00779 catNone <std::string> ( c, psetName, categoryName, "string" );
00780 catNone <vString> ( c, psetName, categoryName, "vSting" );
00781 catNoPSets ( c, psetName, categoryName );
00782 }
00783
00784 void
00785 edm::service::MessageServicePSetValidation::
00786 catInts (ParameterSet const & pset,
00787 std::string const & psetName,
00788 std::string const & categoryName)
00789 {
00790 vString x = pset.getParameterNamesForType <int> (false);
00791 vString::const_iterator end = x.end();
00792 for ( vString::const_iterator i = x.begin(); i != end; ++i ) {
00793 if ( *i == "limit" ) continue;
00794 if ( *i == "reportEvery" ) continue;
00795 if ( *i == "timespan" ) continue;
00796 flaws << categoryName << " category PSet nested in "
00797 << psetName << " PSet: \n"
00798 << (*i) << " is not an allowed parameter within a category PSet \n";
00799 }
00800 x = pset.getParameterNamesForType <int> (true);
00801 end = x.end();
00802 for ( vString::const_iterator i = x.begin(); i != end; ++i ) {
00803 flaws << categoryName << " category PSet nested in "
00804 << psetName << " PSet: \n"
00805 << (*i) << " is used as a tracked int \n"
00806 << "Tracked parameters not allowed here \n";
00807 }
00808 }
00809
00810 void
00811 edm::service::MessageServicePSetValidation::
00812 catNoPSets (ParameterSet const & pset,
00813 std::string const & psetName,
00814 std::string const & categoryName)
00815 {
00816 vString psnames;
00817 pset.getParameterSetNames(psnames, false);
00818 vString::const_iterator end = psnames.end();
00819 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
00820 flaws << categoryName << " category PSet nested in "
00821 << psetName << " PSet: \n"
00822 << *i << " is used as a PSet\n"
00823 << "PSets not allowed within a category PSet\n";
00824 }
00825 psnames.clear();
00826 unsigned int n = pset.getParameterSetNames(psnames, true);
00827 if ( n > 0 ) {
00828 end = psnames.end();
00829 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
00830 flaws << categoryName << " category PSet nested in "
00831 << psetName << " PSet: \n"
00832 << *i << " is used as a tracked PSet\n"
00833 << "tracked parameters not permitted, and "
00834 << "PSets not allowed within a category PSet\n";
00835 }
00836 }
00837 }
00838
00839 void
00840 edm::service::MessageServicePSetValidation::
00841 catBoolRestriction (ParameterSet const & pset,
00842 std::string const & psetName,
00843 std::string const & categoryName,
00844 std::string const & type)
00845 {
00846 vString x = pset.getParameterNamesForType <bool> (false);
00847 vString::const_iterator end = x.end();
00848 for ( vString::const_iterator i = x.begin(); i != end; ++i ) {
00849 if ( ((*i) == "placeholder") || ((*i) == "optionalPSet") ) continue;
00850 flaws << categoryName << " category PSet nested in "
00851 << psetName << " PSet: \n"
00852 << (*i) << " is used as a " << type << "\n"
00853 << "Usage of " << type << " is not recognized here\n";
00854 }
00855 x = pset.getParameterNamesForType <bool> (true);
00856 end = x.end();
00857 for ( vString::const_iterator i = x.begin(); i != end; ++i ) {
00858 flaws << categoryName << " category PSet nested in "
00859 << psetName << " PSet: \n"
00860 << (*i) << " is used as a tracked " << type << "\n"
00861 << "Tracked parameters not allowed here, "
00862 <<" and even untracked it would not be recognized\n";
00863 }
00864 }
00865
00866
00867 }
00868 }