File indexing completed on 2024-04-06 12:12:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <algorithm>
0017
0018
0019
0020 #include "MessageServicePSetValidation.h"
0021
0022 using namespace edm;
0023 using namespace edm::service;
0024
0025 namespace edm {
0026 namespace service {
0027
0028 std::string edm::service::MessageServicePSetValidation::operator()(ParameterSet const& pset) {
0029 messageLoggerPSet(pset);
0030 return flaws_.str();
0031 }
0032
0033 void edm::service::MessageServicePSetValidation::messageLoggerPSet(ParameterSet const& pset) {
0034
0035 if (pset.exists("files") or
0036 (not(pset.exists("destinations") or pset.existsAs<std::vector<std::string>>("statistics", true) or
0037 pset.existsAs<std::vector<std::string>>("statistics", false) or pset.exists("categories")))) {
0038 return;
0039 }
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 psetLists(pset);
0050
0051
0052
0053 suppressionLists(pset);
0054
0055
0056
0057 vStringsCheck(pset, "MessageLogger");
0058
0059
0060
0061 check<bool>(pset, "MessageLogger", "messageSummaryToJobReport");
0062 std::string dumps = check<std::string>(pset, "MessageLogger", "generate_preconfiguration_message");
0063 std::string thresh = check<std::string>(pset, "MessageLogger", "threshold");
0064 if (!thresh.empty())
0065 validateThreshold(thresh, "MessageLogger");
0066 check<unsigned int>(pset, "MessageLogger", "waiting_threshold");
0067
0068
0069
0070 destinationPSets(pset);
0071 defaultPSet(pset);
0072 statisticsPSets(pset);
0073 categoryPSets(pset, "MessageLogger");
0074
0075
0076
0077 noOtherPsets(pset);
0078
0079
0080
0081 noneExcept<int>(pset, "MessageLogger", "int");
0082 noneExcept<unsigned int>(pset, "MessageLogger", "unsigned int", "waiting_threshold");
0083 noneExcept<bool>(pset, "MessageLogger", "bool", "messageSummaryToJobReport");
0084
0085
0086 noneExcept<float>(pset, "MessageLogger", "float");
0087 noneExcept<double>(pset, "MessageLogger", "double");
0088 noneExcept<std::string>(pset, "MessageLogger", "string", "threshold", "generate_preconfiguration_message");
0089
0090
0091
0092 if (!flaws_.str().empty()) {
0093 flaws_ << "\nThe above are from MessageLogger configuration validation.\n"
0094 << "In most cases, these involve lines that the logger configuration code\n"
0095 << "would not process, but which the cfg creator obviously meant to have "
0096 << "effect.\n";
0097 }
0098
0099 }
0100
0101 void edm::service::MessageServicePSetValidation::psetLists(ParameterSet const& pset) {
0102 destinations_ = check<vString>(pset, "MessageLogger", "destinations");
0103 noDuplicates(destinations_, "MessageLogger", "destinations");
0104 noKeywords(destinations_, "MessageLogger", "destinations");
0105 noNonPSetUsage(pset, destinations_, "MessageLogger", "destinations");
0106
0107
0108 statistics_ = check<vString>(pset, "MessageLogger", "statistics");
0109 noDuplicates(statistics_, "MessageLogger", "statistics");
0110 noKeywords(statistics_, "MessageLogger", "statistics");
0111 noNonPSetUsage(pset, statistics_, "MessageLogger", "statistics");
0112
0113 categories_ = check<vString>(pset, "MessageLogger", "categories");
0114 noDuplicates(categories_, "MessageLogger", "categories");
0115 noKeywords(categories_, "MessageLogger", "categories");
0116 noNonPSetUsage(pset, categories_, "MessageLogger", "categories");
0117 noDuplicates(categories_, destinations_, "MessageLogger", "categories", "destinations");
0118 noDuplicates(categories_, statistics_, "MessageLogger", "categories", "statistics");
0119
0120 }
0121
0122 void edm::service::MessageServicePSetValidation::suppressionLists(ParameterSet const& pset) {
0123 debugModules_ = check<vString>(pset, "MessageLogger", "debugModules");
0124 bool dmStar = wildcard(debugModules_);
0125 if (dmStar && debugModules_.size() != 1) {
0126 flaws_ << "MessageLogger"
0127 << " PSet: \n"
0128 << "debugModules contains wildcard character *"
0129 << " and also " << debugModules_.size() - 1 << " other entries - * must be alone\n";
0130 }
0131 suppressDebug_ = check<vString>(pset, "MessageLogger", "suppressDebug");
0132 if ((!suppressDebug_.empty()) && (!dmStar)) {
0133 flaws_ << "MessageLogger"
0134 << " PSet: \n"
0135 << "suppressDebug contains modules, but debugModules is not *\n"
0136 << "Unless all the debugModules are enabled,\n"
0137 << "suppressing specific modules is meaningless\n";
0138 }
0139 if (wildcard(suppressDebug_)) {
0140 flaws_ << "MessageLogger"
0141 << " PSet: \n"
0142 << "Use of wildcard (*) in suppressDebug is not supported\n"
0143 << "By default, LogDebug is suppressed for all modules\n";
0144 }
0145 suppressInfo_ = check<vString>(pset, "MessageLogger", "suppressInfo");
0146 if (wildcard(suppressInfo_)) {
0147 flaws_ << "MessageLogger"
0148 << " PSet: \n"
0149 << "Use of wildcard (*) in suppressInfo is not supported\n";
0150 }
0151 suppressFwkInfo_ = check<vString>(pset, "MessageLogger", "suppressFwkInfo");
0152 if (wildcard(suppressFwkInfo_)) {
0153 flaws_ << "MessageLogger"
0154 << " PSet: \n"
0155 << "Use of wildcard (*) in suppressFwkInfo is not supported\n";
0156 }
0157 suppressWarning_ = check<vString>(pset, "MessageLogger", "suppressWarning");
0158 if (wildcard(suppressWarning_)) {
0159 flaws_ << "MessageLogger"
0160 << " PSet: \n"
0161 << "Use of wildcard (*) in suppressWarning is not supported\n";
0162 }
0163 suppressError_ = check<vString>(pset, "MessageLogger", "suppressError");
0164 if (wildcard(suppressError_)) {
0165 flaws_ << "MessageLogger"
0166 << " PSet: \n"
0167 << "Use of wildcard (*) in suppressError is not supported\n";
0168 }
0169
0170 }
0171
0172 void edm::service::MessageServicePSetValidation::vStringsCheck(ParameterSet const& pset,
0173 std::string const& ) {
0174 vString vStrings = pset.getParameterNamesForType<vString>(false);
0175 vString::const_iterator end = vStrings.end();
0176 for (vString::const_iterator i = vStrings.begin(); i != end; ++i) {
0177 if (!allowedVstring(*i)) {
0178 flaws_ << "MessageLogger"
0179 << " PSet: \n"
0180 << (*i) << " is used as a vstring, "
0181 << "but no such vstring is recognized\n";
0182 }
0183 }
0184 vStrings = pset.getParameterNamesForType<vString>(true);
0185 end = vStrings.end();
0186 for (vString::const_iterator i = vStrings.begin(); i != end; ++i) {
0187 flaws_ << "MessageLogger"
0188 << " PSet: \n"
0189 << (*i) << " is used as a tracked vstring: "
0190 << "tracked parameters not allowed here\n";
0191 }
0192 }
0193
0194 bool edm::service::MessageServicePSetValidation::allowedVstring(std::string const& s) {
0195 if (s == "destinations")
0196 return true;
0197 if (s == "statistics")
0198 return true;
0199 if (s == "destinations")
0200 return true;
0201 if (s == "categories")
0202 return true;
0203 if (s == "debugModules")
0204 return true;
0205 if (s == "suppressInfo")
0206 return true;
0207 if (s == "suppressFwkInfo")
0208 return true;
0209 if (s == "suppressDebug")
0210 return true;
0211 if (s == "suppressWarning")
0212 return true;
0213 if (s == "suppressError")
0214 return true;
0215 return false;
0216 }
0217
0218 bool edm::service::MessageServicePSetValidation::validateThreshold(std::string const& thresh,
0219 std::string const& psetName) {
0220 if (checkThreshold(thresh))
0221 return true;
0222 flaws_ << psetName << " PSet: \n"
0223 << "threshold has value " << thresh << " which is not among {DEBUG, INFO, FWKINFO, WARNING, ERROR}\n";
0224 return false;
0225 }
0226
0227 bool edm::service::MessageServicePSetValidation::checkThreshold(std::string const& thresh) {
0228 if (thresh == "WARNING")
0229 return true;
0230 if (thresh == "INFO")
0231 return true;
0232 if (thresh == "FWKINFO")
0233 return true;
0234 if (thresh == "ERROR")
0235 return true;
0236 if (thresh == "DEBUG")
0237 return true;
0238 return false;
0239 }
0240
0241 void edm::service::MessageServicePSetValidation::noDuplicates(vString const& v,
0242 std::string const& psetName,
0243 std::string const& parameterLabel) {
0244 vString::const_iterator end = v.end();
0245 for (vString::const_iterator i = v.begin(); i != end; ++i) {
0246 for (vString::const_iterator j = i + 1; j != end; ++j) {
0247 if (*i == *j) {
0248 flaws_ << psetName << " PSet: \n"
0249 << "in vString " << parameterLabel << " duplication of the string " << *i << "\n";
0250 }
0251 }
0252 }
0253 }
0254
0255 void edm::service::MessageServicePSetValidation::noDuplicates(vString const& v1,
0256 vString const& v2,
0257 std::string const& psetName,
0258 std::string const& p1,
0259 std::string const& p2) {
0260 vString::const_iterator end1 = v1.end();
0261 vString::const_iterator end2 = v2.end();
0262 for (vString::const_iterator i = v1.begin(); i != end1; ++i) {
0263 for (vString::const_iterator j = v2.begin(); j != end2; ++j) {
0264 if (*i == *j) {
0265 flaws_ << psetName << " PSet: \n"
0266 << "in vStrings " << p1 << " and " << p2 << " duplication of the string " << *i << "\n";
0267 }
0268 }
0269 }
0270 }
0271
0272 void edm::service::MessageServicePSetValidation::noCoutCerrClash(vString const& v,
0273 std::string const& psetName,
0274 std::string const& parameterLabel) {
0275 vString::const_iterator end = v.end();
0276 bool coutPresent = false;
0277 bool cerrPresent = false;
0278 for (vString::const_iterator i = v.begin(); i != end; ++i) {
0279 if (*i == "cout")
0280 coutPresent = true;
0281 if (*i == "cerr")
0282 cerrPresent = true;
0283 }
0284 if (coutPresent && cerrPresent) {
0285 flaws_ << psetName << " PSet: \n"
0286 << "vString " << parameterLabel << " has both cout and cerr \n";
0287 }
0288 }
0289
0290 void edm::service::MessageServicePSetValidation::noKeywords(vString const& v,
0291 std::string const& psetName,
0292 std::string const& parameterLabel) {
0293 vString::const_iterator end = v.end();
0294 for (vString::const_iterator i = v.begin(); i != end; ++i) {
0295 if (!keywordCheck(*i)) {
0296 flaws_ << psetName << " PSet: \n"
0297 << "vString " << parameterLabel << " should not contain the keyword " << *i << "\n";
0298 }
0299 }
0300 }
0301
0302 bool edm::service::MessageServicePSetValidation::keywordCheck(std::string const& word) {
0303 if (word == "default")
0304 return false;
0305 if (word == "categories")
0306 return false;
0307 if (word == "destinations")
0308 return false;
0309 if (word == "statistics")
0310 return false;
0311 if (word == "debugModules")
0312 return false;
0313 if (word == "suppressInfo")
0314 return false;
0315 if (word == "suppressFwkInfo")
0316 return false;
0317 if (word == "suppressDebug")
0318 return false;
0319 if (word == "suppressWarning")
0320 return false;
0321 if (word == "suppressError")
0322 return false;
0323 if (word == "threshold")
0324 return false;
0325 if (word == "ERROR")
0326 return false;
0327 if (word == "WARNING")
0328 return false;
0329 if (word == "FWKINFO")
0330 return false;
0331 if (word == "INFO")
0332 return false;
0333 if (word == "DEBUG")
0334 return false;
0335 if (word == "placeholder")
0336 return false;
0337 if (word == "limit")
0338 return false;
0339 if (word == "reportEvery")
0340 return false;
0341 if (word == "timespan")
0342 return false;
0343 if (word == "noLineBreaks")
0344 return false;
0345 if (word == "lineLength")
0346 return false;
0347 if (word == "noTimeStamps")
0348 return false;
0349 if (word == "output")
0350 return false;
0351 if (word == "filename")
0352 return false;
0353 if (word == "extension")
0354 return false;
0355 if (word == "reset")
0356 return false;
0357 if (word == "optionalPSet")
0358 return false;
0359 if (word == "enableStatistics")
0360 return false;
0361 if (word == "statisticsThreshold")
0362 return false;
0363 if (word == "resetStatistics")
0364 return false;
0365 return true;
0366 }
0367
0368 void edm::service::MessageServicePSetValidation::noNonPSetUsage(ParameterSet const& pset,
0369 vString const& v,
0370 std::string const& psetName,
0371 std::string const& parameterLabel) {
0372 disallowedParam<int>(pset, v, psetName, parameterLabel, "int");
0373 disallowedParam<unsigned int>(pset, v, psetName, parameterLabel, "uint");
0374 disallowedParam<bool>(pset, v, psetName, parameterLabel, "bool");
0375 disallowedParam<float>(pset, v, psetName, parameterLabel, "float");
0376 disallowedParam<double>(pset, v, psetName, parameterLabel, "double");
0377 disallowedParam<std::string>(pset, v, psetName, parameterLabel, "string");
0378 disallowedParam<std::vector<std::string>>(pset, v, psetName, parameterLabel, "vstring");
0379 }
0380
0381 void edm::service::MessageServicePSetValidation::noBadParams(vString const& v,
0382 vString const& params,
0383 std::string const& psetName,
0384 std::string const& parameterLabel,
0385 std::string const& type) {
0386 vString::const_iterator end1 = v.end();
0387 vString::const_iterator end2 = params.end();
0388 for (vString::const_iterator i = v.begin(); i != end1; ++i) {
0389 for (vString::const_iterator j = params.begin(); j != end2; ++j) {
0390 if (*i == *j) {
0391 flaws_ << psetName << " PSet: \n"
0392 << *i << " (listed in vstring " << parameterLabel << ")\n"
0393 << "is used as a parameter of type " << type << " instead of as a PSet \n";
0394 }
0395 }
0396 }
0397
0398 }
0399
0400 bool edm::service::MessageServicePSetValidation::wildcard(vString const& v) {
0401 vString::const_iterator end = v.end();
0402 for (vString::const_iterator i = v.begin(); i != end; ++i) {
0403 if ((*i) == "*")
0404 return true;
0405 }
0406 return false;
0407 }
0408
0409 void edm::service::MessageServicePSetValidation::noOtherPsets(ParameterSet const& pset) {
0410 vString psnames;
0411 pset.getParameterSetNames(psnames, false);
0412 vString::const_iterator end = psnames.end();
0413 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
0414 if (lookForMatch(destinations_, *i))
0415 continue;
0416 if (lookForMatch(statistics_, *i))
0417 continue;
0418 if (lookForMatch(categories_, *i))
0419 continue;
0420 if ((*i) == "default")
0421 continue;
0422 ParameterSet empty_PSet;
0423 bool ok_optionalPSet = false;
0424 try {
0425 ParameterSet const& culprit = pset.getUntrackedParameterSet((*i), empty_PSet);
0426 ok_optionalPSet = culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
0427 ok_optionalPSet = culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
0428 } catch (cms::Exception& e) {
0429 }
0430 if (ok_optionalPSet)
0431 continue;
0432 flaws_ << "MessageLogger "
0433 << " PSet: \n"
0434 << *i << " is an unrecognized name for a PSet\n";
0435 }
0436 psnames.clear();
0437 unsigned int n = pset.getParameterSetNames(psnames, true);
0438 if (n > 0) {
0439 end = psnames.end();
0440 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
0441 flaws_ << "MessageLogger "
0442 << " PSet: \n"
0443 << "PSet " << *i << " is tracked - not allowed\n";
0444 }
0445 }
0446 }
0447
0448 bool edm::service::MessageServicePSetValidation::lookForMatch(vString const& v, std::string const& s) {
0449 vString::const_iterator begin = v.begin();
0450 vString::const_iterator end = v.end();
0451 return (std::find(begin, end, s) != end);
0452 }
0453
0454 void edm::service::MessageServicePSetValidation::destinationPSets(ParameterSet const& pset) {
0455 ParameterSet empty_PSet;
0456 std::vector<std::string>::const_iterator end = destinations_.end();
0457 for (std::vector<std::string>::const_iterator i = destinations_.begin(); i != end; ++i) {
0458 ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
0459 destinationPSet(d, *i);
0460 }
0461 }
0462
0463 void edm::service::MessageServicePSetValidation::destinationPSet(ParameterSet const& pset,
0464 std::string const& psetName) {
0465
0466
0467 categoryPSets(pset, psetName);
0468
0469
0470
0471 noNoncategoryPsets(pset, psetName);
0472
0473
0474
0475 check<bool>(pset, psetName, "placeholder");
0476 {
0477 std::string thresh = check<std::string>(pset, "psetName", "statisticsThreshold");
0478 if (!thresh.empty())
0479 validateThreshold(thresh, psetName);
0480 }
0481 std::string thresh = check<std::string>(pset, "psetName", "threshold");
0482 if (!thresh.empty())
0483 validateThreshold(thresh, psetName);
0484 check<bool>(pset, psetName, "noLineBreaks");
0485 check<int>(pset, psetName, "lineLength");
0486 check<bool>(pset, psetName, "noTimeStamps");
0487 check<bool>(pset, psetName, "enableStatistics");
0488 check<bool>(pset, psetName, "resetStatistics");
0489 std::string s = check<std::string>(pset, "psetName", "filename");
0490 if ((s == "cerr") || (s == "cout")) {
0491 flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of filename \n";
0492 }
0493 s = check<std::string>(pset, "psetName", "extension");
0494 if ((s == "cerr") || (s == "cout")) {
0495 flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of extension \n";
0496 }
0497 s = check<std::string>(pset, "psetName", "output");
0498
0499
0500
0501 noneExcept<int>(pset, psetName, "int", "lineLength");
0502
0503 vString okbool;
0504 okbool.push_back("placeholder");
0505 okbool.push_back("optionalPSet");
0506 okbool.push_back("noLineBreaks");
0507 okbool.push_back("noTimeStamps");
0508 okbool.push_back("enableStatistics");
0509 okbool.push_back("resetStatistics");
0510 noneExcept<bool>(pset, psetName, "bool", okbool);
0511 vString okstring;
0512 okstring.push_back("statisticsThreshold");
0513 okstring.push_back("threshold");
0514 okstring.push_back("output");
0515 okstring.push_back("filename");
0516 okstring.push_back("extension");
0517 noneExcept<std::string>(pset, psetName, "string", okstring);
0518
0519 }
0520
0521 void edm::service::MessageServicePSetValidation::defaultPSet(ParameterSet const& main_pset) {
0522 ParameterSet empty_PSet;
0523 ParameterSet const& pset = main_pset.getUntrackedParameterSet("default", empty_PSet);
0524 std::string psetName = "default (at MessageLogger main level)";
0525
0526
0527
0528 categoryPSets(pset, psetName);
0529
0530
0531
0532 noNoncategoryPsets(pset, psetName);
0533
0534
0535
0536 catInts(pset, psetName, "default");
0537
0538
0539
0540 check<bool>(pset, psetName, "placeholder");
0541 std::string thresh = check<std::string>(pset, "psetName", "threshold");
0542 if (!thresh.empty())
0543 validateThreshold(thresh, psetName);
0544 check<bool>(pset, psetName, "noLineBreaks");
0545 check<int>(pset, psetName, "limit");
0546 check<int>(pset, psetName, "reportEvery");
0547 check<int>(pset, psetName, "timespan");
0548 check<int>(pset, psetName, "lineLength");
0549 check<bool>(pset, psetName, "noTimeStamps");
0550
0551
0552 vString okint;
0553 okint.push_back("limit");
0554 okint.push_back("reportEvery");
0555 okint.push_back("timespan");
0556 okint.push_back("lineLength");
0557 noneExcept<int>(pset, psetName, "int", okint);
0558 vString okbool;
0559 okbool.push_back("placeholder");
0560 okbool.push_back("optionalPSet");
0561 okbool.push_back("noLineBreaks");
0562 okbool.push_back("noTimeStamps");
0563 noneExcept<bool>(pset, psetName, "bool", okbool);
0564 vString okstring;
0565 okstring.push_back("threshold");
0566 noneExcept<std::string>(pset, psetName, "string", okstring);
0567
0568 }
0569
0570 void edm::service::MessageServicePSetValidation::statisticsPSets(ParameterSet const& pset) {
0571 ParameterSet empty_PSet;
0572 std::vector<std::string>::const_iterator end = statistics_.end();
0573 for (std::vector<std::string>::const_iterator i = statistics_.begin(); i != end; ++i) {
0574 if (lookForMatch(destinations_, *i))
0575 continue;
0576 ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
0577 statisticsPSet(d, *i);
0578 }
0579 }
0580
0581 void edm::service::MessageServicePSetValidation::statisticsPSet(ParameterSet const& pset,
0582 std::string const& psetName) {
0583
0584
0585 categoryPSets(pset, psetName);
0586
0587
0588
0589 noNoncategoryPsets(pset, psetName);
0590
0591
0592
0593 std::string thresh = check<std::string>(pset, "psetName", "threshold");
0594 if (!thresh.empty())
0595 validateThreshold(thresh, psetName);
0596 check<bool>(pset, psetName, "placeholder");
0597 check<bool>(pset, psetName, "reset");
0598 std::string s = check<std::string>(pset, "psetName", "filename");
0599 if ((s == "cerr") || (s == "cout")) {
0600 flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of filename \n";
0601 }
0602 s = check<std::string>(pset, "psetName", "extension");
0603 if ((s == "cerr") || (s == "cout")) {
0604 flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of extension \n";
0605 }
0606 s = check<std::string>(pset, "psetName", "output");
0607
0608
0609
0610 noneExcept<int>(pset, psetName, "int");
0611
0612 vString okbool;
0613 okbool.push_back("placeholder");
0614 okbool.push_back("optionalPSet");
0615 okbool.push_back("reset");
0616 noneExcept<bool>(pset, psetName, "bool", okbool);
0617 vString okstring;
0618 okstring.push_back("output");
0619 okstring.push_back("filename");
0620 okstring.push_back("extension");
0621 okstring.push_back("threshold");
0622 noneExcept<std::string>(pset, psetName, "string", okstring);
0623
0624 }
0625
0626 void edm::service::MessageServicePSetValidation::noNoncategoryPsets(ParameterSet const& pset,
0627 std::string const& psetName) {
0628 vString psnames;
0629 pset.getParameterSetNames(psnames, false);
0630 vString::const_iterator end = psnames.end();
0631 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
0632 if (lookForMatch(categories_, *i))
0633 continue;
0634 if ((*i) == "default")
0635 continue;
0636 if ((*i) == "ERROR")
0637 continue;
0638 if ((*i) == "WARNING")
0639 continue;
0640 if ((*i) == "FWKINFO")
0641 continue;
0642 if ((*i) == "INFO")
0643 continue;
0644 if ((*i) == "DEBUG")
0645 continue;
0646 ParameterSet empty_PSet;
0647 bool ok_optionalPSet = false;
0648 try {
0649 ParameterSet const& culprit = pset.getUntrackedParameterSet((*i), empty_PSet);
0650 ok_optionalPSet = culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
0651 ok_optionalPSet = culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
0652 } catch (cms::Exception& e) {
0653 }
0654 if (ok_optionalPSet)
0655 continue;
0656 flaws_ << psetName << " PSet: \n" << *i << " is an unrecognized name for a PSet in this context \n";
0657 }
0658 psnames.clear();
0659 unsigned int n = pset.getParameterSetNames(psnames, true);
0660 if (n > 0) {
0661 end = psnames.end();
0662 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
0663 flaws_ << psetName << " PSet: \n"
0664 << "PSet " << *i << " is tracked - not allowed\n";
0665 }
0666 }
0667 }
0668
0669 void edm::service::MessageServicePSetValidation::categoryPSets(ParameterSet const& pset,
0670 std::string const& psetName) {
0671 categoryPSet(pset, psetName, "ERROR");
0672 categoryPSet(pset, psetName, "WARNING");
0673 categoryPSet(pset, psetName, "FWKINFO");
0674 categoryPSet(pset, psetName, "INFO");
0675 categoryPSet(pset, psetName, "DEBUG");
0676 if (psetName != "MessageLogger")
0677 categoryPSet(pset, psetName, "default");
0678
0679
0680 std::vector<std::string>::const_iterator end = categories_.end();
0681 for (std::vector<std::string>::const_iterator i = categories_.begin(); i != end; ++i) {
0682 categoryPSet(pset, psetName, *i);
0683 }
0684 }
0685
0686 void edm::service::MessageServicePSetValidation::categoryPSet(ParameterSet const& pset,
0687 std::string const& OuterPsetName,
0688 std::string const& categoryName) {
0689 if (pset.existsAs<ParameterSet>(categoryName, true)) {
0690 flaws_ << OuterPsetName << " PSet: \n"
0691 << "Category PSet " << categoryName << " is tracked - not allowed\n";
0692 return;
0693 }
0694 ParameterSet empty_PSet;
0695 ParameterSet const& c = pset.getUntrackedParameterSet(categoryName, empty_PSet);
0696 std::string const& psetName(OuterPsetName);
0697 catInts(c, psetName, categoryName);
0698 catNone<unsigned int>(c, psetName, categoryName, "unsigned int");
0699 catBoolRestriction(c, psetName, categoryName, "bool");
0700 catNone<float>(c, psetName, categoryName, "float");
0701 catNone<double>(c, psetName, categoryName, "double");
0702 catNone<std::string>(c, psetName, categoryName, "string");
0703 catNone<vString>(c, psetName, categoryName, "vSting");
0704 catNoPSets(c, psetName, categoryName);
0705 }
0706
0707 void edm::service::MessageServicePSetValidation::catInts(ParameterSet const& pset,
0708 std::string const& psetName,
0709 std::string const& categoryName) {
0710 vString x = pset.getParameterNamesForType<int>(false);
0711 vString::const_iterator end = x.end();
0712 for (vString::const_iterator i = x.begin(); i != end; ++i) {
0713 if (*i == "limit")
0714 continue;
0715 if (*i == "reportEvery")
0716 continue;
0717 if (*i == "timespan")
0718 continue;
0719 flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
0720 << (*i) << " is not an allowed parameter within a category PSet \n";
0721 }
0722 x = pset.getParameterNamesForType<int>(true);
0723 end = x.end();
0724 for (vString::const_iterator i = x.begin(); i != end; ++i) {
0725 flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
0726 << (*i) << " is used as a tracked int \n"
0727 << "Tracked parameters not allowed here \n";
0728 }
0729 }
0730
0731 void edm::service::MessageServicePSetValidation::catNoPSets(ParameterSet const& pset,
0732 std::string const& psetName,
0733 std::string const& categoryName) {
0734 vString psnames;
0735 pset.getParameterSetNames(psnames, false);
0736 vString::const_iterator end = psnames.end();
0737 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
0738 flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
0739 << *i << " is used as a PSet\n"
0740 << "PSets not allowed within a category PSet\n";
0741 }
0742 psnames.clear();
0743 unsigned int n = pset.getParameterSetNames(psnames, true);
0744 if (n > 0) {
0745 end = psnames.end();
0746 for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
0747 flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
0748 << *i << " is used as a tracked PSet\n"
0749 << "tracked parameters not permitted, and "
0750 << "PSets not allowed within a category PSet\n";
0751 }
0752 }
0753 }
0754
0755 void edm::service::MessageServicePSetValidation::catBoolRestriction(ParameterSet const& pset,
0756 std::string const& psetName,
0757 std::string const& categoryName,
0758 std::string const& type) {
0759 vString x = pset.getParameterNamesForType<bool>(false);
0760 vString::const_iterator end = x.end();
0761 for (vString::const_iterator i = x.begin(); i != end; ++i) {
0762 if (((*i) == "placeholder") || ((*i) == "optionalPSet"))
0763 continue;
0764 flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
0765 << (*i) << " is used as a " << type << "\n"
0766 << "Usage of " << type << " is not recognized here\n";
0767 }
0768 x = pset.getParameterNamesForType<bool>(true);
0769 end = x.end();
0770 for (vString::const_iterator i = x.begin(); i != end; ++i) {
0771 flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
0772 << (*i) << " is used as a tracked " << type << "\n"
0773 << "Tracked parameters not allowed here, "
0774 << " and even untracked it would not be recognized\n";
0775 }
0776 }
0777
0778 }
0779 }