Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
// -*- C++ -*-
//
// Package:     Services
// Class  :     MessageServicePSetValidation
//
// Implementation:
//     <Notes on implementation>
//
// Original Author:  M. Fischler
//         Created:  Wed May 20 2009
//
//

// system include files

#include <algorithm>

// user include files

#include "MessageServicePSetValidation.h"

using namespace edm;
using namespace edm::service;

namespace edm {
  namespace service {

    std::string edm::service::MessageServicePSetValidation::operator()(ParameterSet const& pset) {
      messageLoggerPSet(pset);
      return flaws_.str();
    }  // operator() to validate the PSet passed in

    void edm::service::MessageServicePSetValidation::messageLoggerPSet(ParameterSet const& pset) {
      // See if new config API is being used
      if (pset.exists("files") or
          (not(pset.exists("destinations") or pset.existsAs<std::vector<std::string>>("statistics", true) or
               pset.existsAs<std::vector<std::string>>("statistics", false) or pset.exists("categories")))) {
        return;
      }

      // Four types of material are allowed at the MessageLogger level:
      //   PSet lists (such as destinations or categories
      //   Suppression lists, such as SuppressInfo or debugModules
      //   General parameters, such as threshold or messageSummaryToJobReport
      //   Nested PSets, such as those for each destination

      // PSet lists

      psetLists(pset);

      // Suppression lists

      suppressionLists(pset);

      // No other vstrings

      vStringsCheck(pset, "MessageLogger");

      // General Parameters

      check<bool>(pset, "MessageLogger", "messageSummaryToJobReport");
      std::string dumps = check<std::string>(pset, "MessageLogger", "generate_preconfiguration_message");
      std::string thresh = check<std::string>(pset, "MessageLogger", "threshold");
      if (!thresh.empty())
        validateThreshold(thresh, "MessageLogger");
      check<unsigned int>(pset, "MessageLogger", "waiting_threshold");

      // Nested PSets

      destinationPSets(pset);
      defaultPSet(pset);
      statisticsPSets(pset);
      categoryPSets(pset, "MessageLogger");

      // No other PSets -- unless they contain optionalPSet or placeholder=True

      noOtherPsets(pset);

      // Nothing else -- look for int, unsigned int, bool, float, double, string

      noneExcept<int>(pset, "MessageLogger", "int");
      noneExcept<unsigned int>(pset, "MessageLogger", "unsigned int", "waiting_threshold");
      noneExcept<bool>(pset, "MessageLogger", "bool", "messageSummaryToJobReport");
      // Note - at this, the upper MessageLogger PSet level, the use of
      // optionalPSet makes no sense, so we are OK letting that be a flaw
      noneExcept<float>(pset, "MessageLogger", "float");
      noneExcept<double>(pset, "MessageLogger", "double");
      noneExcept<std::string>(pset, "MessageLogger", "string", "threshold", "generate_preconfiguration_message");

      // Append explanatory information if flaws were found

      if (!flaws_.str().empty()) {
        flaws_ << "\nThe above are from MessageLogger configuration validation.\n"
               << "In most cases, these involve lines that the logger configuration code\n"
               << "would not process, but which the cfg creator obviously meant to have "
               << "effect.\n";
      }

    }  // messageLoggerPSet

    void edm::service::MessageServicePSetValidation::psetLists(ParameterSet const& pset) {
      destinations_ = check<vString>(pset, "MessageLogger", "destinations");
      noDuplicates(destinations_, "MessageLogger", "destinations");
      noKeywords(destinations_, "MessageLogger", "destinations");
      noNonPSetUsage(pset, destinations_, "MessageLogger", "destinations");
      // REMOVED: noCoutCerrClash(destinations_,"MessageLogger", "destinations");

      statistics_ = check<vString>(pset, "MessageLogger", "statistics");
      noDuplicates(statistics_, "MessageLogger", "statistics");
      noKeywords(statistics_, "MessageLogger", "statistics");
      noNonPSetUsage(pset, statistics_, "MessageLogger", "statistics");

      categories_ = check<vString>(pset, "MessageLogger", "categories");
      noDuplicates(categories_, "MessageLogger", "categories");
      noKeywords(categories_, "MessageLogger", "categories");
      noNonPSetUsage(pset, categories_, "MessageLogger", "categories");
      noDuplicates(categories_, destinations_, "MessageLogger", "categories", "destinations");
      noDuplicates(categories_, statistics_, "MessageLogger", "categories", "statistics");

    }  // psetLists

    void edm::service::MessageServicePSetValidation::suppressionLists(ParameterSet const& pset) {
      debugModules_ = check<vString>(pset, "MessageLogger", "debugModules");
      bool dmStar = wildcard(debugModules_);
      if (dmStar && debugModules_.size() != 1) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << "debugModules contains wildcard character *"
               << " and also " << debugModules_.size() - 1 << " other entries - * must be alone\n";
      }
      suppressDebug_ = check<vString>(pset, "MessageLogger", "suppressDebug");
      if ((!suppressDebug_.empty()) && (!dmStar)) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << "suppressDebug contains modules, but debugModules is not *\n"
               << "Unless all the debugModules are enabled,\n"
               << "suppressing specific modules is meaningless\n";
      }
      if (wildcard(suppressDebug_)) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << "Use of wildcard (*) in suppressDebug is not supported\n"
               << "By default, LogDebug is suppressed for all modules\n";
      }
      suppressInfo_ = check<vString>(pset, "MessageLogger", "suppressInfo");
      if (wildcard(suppressInfo_)) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << "Use of wildcard (*) in suppressInfo is not supported\n";
      }
      suppressFwkInfo_ = check<vString>(pset, "MessageLogger", "suppressFwkInfo");
      if (wildcard(suppressFwkInfo_)) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << "Use of wildcard (*) in suppressFwkInfo is not supported\n";
      }
      suppressWarning_ = check<vString>(pset, "MessageLogger", "suppressWarning");
      if (wildcard(suppressWarning_)) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << "Use of wildcard (*) in suppressWarning is not supported\n";
      }
      suppressError_ = check<vString>(pset, "MessageLogger", "suppressError");
      if (wildcard(suppressError_)) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << "Use of wildcard (*) in suppressError is not supported\n";
      }

    }  // suppressionLists

    void edm::service::MessageServicePSetValidation::vStringsCheck(ParameterSet const& pset,
                                                                   std::string const& /*psetName*/) {
      vString vStrings = pset.getParameterNamesForType<vString>(false);
      vString::const_iterator end = vStrings.end();
      for (vString::const_iterator i = vStrings.begin(); i != end; ++i) {
        if (!allowedVstring(*i)) {
          flaws_ << "MessageLogger"
                 << " PSet: \n"
                 << (*i) << " is used as a vstring, "
                 << "but no such vstring is recognized\n";
        }
      }
      vStrings = pset.getParameterNamesForType<vString>(true);
      end = vStrings.end();
      for (vString::const_iterator i = vStrings.begin(); i != end; ++i) {
        flaws_ << "MessageLogger"
               << " PSet: \n"
               << (*i) << " is used as a tracked vstring: "
               << "tracked parameters not allowed here\n";
      }
    }  // vStringsCheck

    bool edm::service::MessageServicePSetValidation::allowedVstring(std::string const& s) {
      if (s == "destinations")
        return true;
      if (s == "statistics")
        return true;
      if (s == "destinations")
        return true;
      if (s == "categories")
        return true;
      if (s == "debugModules")
        return true;
      if (s == "suppressInfo")
        return true;
      if (s == "suppressFwkInfo")
        return true;
      if (s == "suppressDebug")
        return true;
      if (s == "suppressWarning")
        return true;
      if (s == "suppressError")
        return true;
      return false;
    }  // allowedVstring

    bool edm::service::MessageServicePSetValidation::validateThreshold(std::string const& thresh,
                                                                       std::string const& psetName) {
      if (checkThreshold(thresh))
        return true;
      flaws_ << psetName << " PSet: \n"
             << "threshold has value " << thresh << " which is not among {DEBUG, INFO, FWKINFO, WARNING, ERROR}\n";
      return false;
    }  // validateThreshold

    bool edm::service::MessageServicePSetValidation::checkThreshold(std::string const& thresh) {
      if (thresh == "WARNING")
        return true;
      if (thresh == "INFO")
        return true;
      if (thresh == "FWKINFO")
        return true;
      if (thresh == "ERROR")
        return true;
      if (thresh == "DEBUG")
        return true;
      return false;
    }

    void edm::service::MessageServicePSetValidation::noDuplicates(vString const& v,
                                                                  std::string const& psetName,
                                                                  std::string const& parameterLabel) {
      vString::const_iterator end = v.end();
      for (vString::const_iterator i = v.begin(); i != end; ++i) {
        for (vString::const_iterator j = i + 1; j != end; ++j) {
          if (*i == *j) {
            flaws_ << psetName << " PSet: \n"
                   << "in vString " << parameterLabel << " duplication of the string " << *i << "\n";
          }
        }
      }
    }  // noDuplicates(v)

    void edm::service::MessageServicePSetValidation::noDuplicates(vString const& v1,
                                                                  vString const& v2,
                                                                  std::string const& psetName,
                                                                  std::string const& p1,
                                                                  std::string const& p2) {
      vString::const_iterator end1 = v1.end();
      vString::const_iterator end2 = v2.end();
      for (vString::const_iterator i = v1.begin(); i != end1; ++i) {
        for (vString::const_iterator j = v2.begin(); j != end2; ++j) {
          if (*i == *j) {
            flaws_ << psetName << " PSet: \n"
                   << "in vStrings " << p1 << " and " << p2 << " duplication of the string " << *i << "\n";
          }
        }
      }
    }  // noDuplicates(v1,v2)

    void edm::service::MessageServicePSetValidation::noCoutCerrClash(vString const& v,
                                                                     std::string const& psetName,
                                                                     std::string const& parameterLabel) {
      vString::const_iterator end = v.end();
      bool coutPresent = false;
      bool cerrPresent = false;
      for (vString::const_iterator i = v.begin(); i != end; ++i) {
        if (*i == "cout")
          coutPresent = true;
        if (*i == "cerr")
          cerrPresent = true;
      }
      if (coutPresent && cerrPresent) {
        flaws_ << psetName << " PSet: \n"
               << "vString " << parameterLabel << " has both cout and cerr \n";
      }
    }  // noCoutCerrClash(v)

    void edm::service::MessageServicePSetValidation::noKeywords(vString const& v,
                                                                std::string const& psetName,
                                                                std::string const& parameterLabel) {
      vString::const_iterator end = v.end();
      for (vString::const_iterator i = v.begin(); i != end; ++i) {
        if (!keywordCheck(*i)) {
          flaws_ << psetName << " PSet: \n"
                 << "vString " << parameterLabel << " should not contain the keyword " << *i << "\n";
        }
      }
    }  // noKeywords(v)

    bool edm::service::MessageServicePSetValidation::keywordCheck(std::string const& word) {
      if (word == "default")
        return false;
      if (word == "categories")
        return false;
      if (word == "destinations")
        return false;
      if (word == "statistics")
        return false;
      if (word == "debugModules")
        return false;
      if (word == "suppressInfo")
        return false;
      if (word == "suppressFwkInfo")
        return false;
      if (word == "suppressDebug")
        return false;
      if (word == "suppressWarning")
        return false;
      if (word == "suppressError")
        return false;
      if (word == "threshold")
        return false;
      if (word == "ERROR")
        return false;
      if (word == "WARNING")
        return false;
      if (word == "FWKINFO")
        return false;
      if (word == "INFO")
        return false;
      if (word == "DEBUG")
        return false;
      if (word == "placeholder")
        return false;
      if (word == "limit")
        return false;
      if (word == "reportEvery")
        return false;
      if (word == "timespan")
        return false;
      if (word == "noLineBreaks")
        return false;
      if (word == "lineLength")
        return false;
      if (word == "noTimeStamps")
        return false;
      if (word == "output")
        return false;
      if (word == "filename")
        return false;
      if (word == "extension")
        return false;
      if (word == "reset")
        return false;
      if (word == "optionalPSet")
        return false;
      if (word == "enableStatistics")
        return false;
      if (word == "statisticsThreshold")
        return false;
      if (word == "resetStatistics")
        return false;
      return true;
    }  // keywordCheck

    void edm::service::MessageServicePSetValidation::noNonPSetUsage(ParameterSet const& pset,
                                                                    vString const& v,
                                                                    std::string const& psetName,
                                                                    std::string const& parameterLabel) {
      disallowedParam<int>(pset, v, psetName, parameterLabel, "int");
      disallowedParam<unsigned int>(pset, v, psetName, parameterLabel, "uint");
      disallowedParam<bool>(pset, v, psetName, parameterLabel, "bool");
      disallowedParam<float>(pset, v, psetName, parameterLabel, "float");
      disallowedParam<double>(pset, v, psetName, parameterLabel, "double");
      disallowedParam<std::string>(pset, v, psetName, parameterLabel, "string");
      disallowedParam<std::vector<std::string>>(pset, v, psetName, parameterLabel, "vstring");
    }  // noNonPSetUsage

    void edm::service::MessageServicePSetValidation::noBadParams(vString const& v,
                                                                 vString const& params,
                                                                 std::string const& psetName,
                                                                 std::string const& parameterLabel,
                                                                 std::string const& type) {
      vString::const_iterator end1 = v.end();
      vString::const_iterator end2 = params.end();
      for (vString::const_iterator i = v.begin(); i != end1; ++i) {
        for (vString::const_iterator j = params.begin(); j != end2; ++j) {
          if (*i == *j) {
            flaws_ << psetName << " PSet: \n"
                   << *i << " (listed in vstring " << parameterLabel << ")\n"
                   << "is used as a parameter of type " << type << " instead of as a PSet \n";
          }
        }
      }

    }  // noBadParams

    bool edm::service::MessageServicePSetValidation::wildcard(vString const& v) {
      vString::const_iterator end = v.end();
      for (vString::const_iterator i = v.begin(); i != end; ++i) {
        if ((*i) == "*")
          return true;
      }
      return false;
    }

    void edm::service::MessageServicePSetValidation::noOtherPsets(ParameterSet const& pset) {
      vString psnames;
      pset.getParameterSetNames(psnames, false);
      vString::const_iterator end = psnames.end();
      for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
        if (lookForMatch(destinations_, *i))
          continue;
        if (lookForMatch(statistics_, *i))
          continue;
        if (lookForMatch(categories_, *i))
          continue;
        if ((*i) == "default")
          continue;
        ParameterSet empty_PSet;
        bool ok_optionalPSet = false;
        try {
          ParameterSet const& culprit = pset.getUntrackedParameterSet((*i), empty_PSet);
          ok_optionalPSet = culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
          ok_optionalPSet = culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
        } catch (cms::Exception& e) {
        }
        if (ok_optionalPSet)
          continue;
        flaws_ << "MessageLogger "
               << " PSet: \n"
               << *i << " is an unrecognized name for a PSet\n";
      }
      psnames.clear();
      unsigned int n = pset.getParameterSetNames(psnames, true);
      if (n > 0) {
        end = psnames.end();
        for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
          flaws_ << "MessageLogger "
                 << " PSet: \n"
                 << "PSet " << *i << " is tracked - not allowed\n";
        }
      }
    }

    bool edm::service::MessageServicePSetValidation::lookForMatch(vString const& v, std::string const& s) {
      vString::const_iterator begin = v.begin();
      vString::const_iterator end = v.end();
      return (std::find(begin, end, s) != end);
    }

    void edm::service::MessageServicePSetValidation::destinationPSets(ParameterSet const& pset) {
      ParameterSet empty_PSet;
      std::vector<std::string>::const_iterator end = destinations_.end();
      for (std::vector<std::string>::const_iterator i = destinations_.begin(); i != end; ++i) {
        ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
        destinationPSet(d, *i);
      }
    }  // destinationPSets

    void edm::service::MessageServicePSetValidation::destinationPSet(ParameterSet const& pset,
                                                                     std::string const& psetName) {
      // Category PSets

      categoryPSets(pset, psetName);

      // No other PSets -- unless they contain optionalPSet or placeholder=True

      noNoncategoryPsets(pset, psetName);

      // General parameters

      check<bool>(pset, psetName, "placeholder");
      {
        std::string thresh = check<std::string>(pset, "psetName", "statisticsThreshold");
        if (!thresh.empty())
          validateThreshold(thresh, psetName);
      }
      std::string thresh = check<std::string>(pset, "psetName", "threshold");
      if (!thresh.empty())
        validateThreshold(thresh, psetName);
      check<bool>(pset, psetName, "noLineBreaks");
      check<int>(pset, psetName, "lineLength");
      check<bool>(pset, psetName, "noTimeStamps");
      check<bool>(pset, psetName, "enableStatistics");
      check<bool>(pset, psetName, "resetStatistics");
      std::string s = check<std::string>(pset, "psetName", "filename");
      if ((s == "cerr") || (s == "cout")) {
        flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of filename \n";
      }
      s = check<std::string>(pset, "psetName", "extension");
      if ((s == "cerr") || (s == "cout")) {
        flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of extension \n";
      }
      s = check<std::string>(pset, "psetName", "output");

      // No other parameters

      noneExcept<int>(pset, psetName, "int", "lineLength");

      vString okbool;
      okbool.push_back("placeholder");
      okbool.push_back("optionalPSet");
      okbool.push_back("noLineBreaks");
      okbool.push_back("noTimeStamps");
      okbool.push_back("enableStatistics");
      okbool.push_back("resetStatistics");
      noneExcept<bool>(pset, psetName, "bool", okbool);
      vString okstring;
      okstring.push_back("statisticsThreshold");
      okstring.push_back("threshold");
      okstring.push_back("output");
      okstring.push_back("filename");
      okstring.push_back("extension");
      noneExcept<std::string>(pset, psetName, "string", okstring);

    }  // destinationPSet

    void edm::service::MessageServicePSetValidation::defaultPSet(ParameterSet const& main_pset) {
      ParameterSet empty_PSet;
      ParameterSet const& pset = main_pset.getUntrackedParameterSet("default", empty_PSet);
      std::string psetName = "default (at MessageLogger main level)";

      // Category PSets

      categoryPSets(pset, psetName);

      // No other PSets -- unless they contain optionalPSet or placeholder=True

      noNoncategoryPsets(pset, psetName);

      // Parameters applying to the default category

      catInts(pset, psetName, "default");

      // General parameters

      check<bool>(pset, psetName, "placeholder");
      std::string thresh = check<std::string>(pset, "psetName", "threshold");
      if (!thresh.empty())
        validateThreshold(thresh, psetName);
      check<bool>(pset, psetName, "noLineBreaks");
      check<int>(pset, psetName, "limit");
      check<int>(pset, psetName, "reportEvery");
      check<int>(pset, psetName, "timespan");
      check<int>(pset, psetName, "lineLength");
      check<bool>(pset, psetName, "noTimeStamps");

      // No other parameters
      vString okint;
      okint.push_back("limit");
      okint.push_back("reportEvery");
      okint.push_back("timespan");
      okint.push_back("lineLength");
      noneExcept<int>(pset, psetName, "int", okint);
      vString okbool;
      okbool.push_back("placeholder");
      okbool.push_back("optionalPSet");
      okbool.push_back("noLineBreaks");
      okbool.push_back("noTimeStamps");
      noneExcept<bool>(pset, psetName, "bool", okbool);
      vString okstring;
      okstring.push_back("threshold");
      noneExcept<std::string>(pset, psetName, "string", okstring);

    }  // defaultPSet

    void edm::service::MessageServicePSetValidation::statisticsPSets(ParameterSet const& pset) {
      ParameterSet empty_PSet;
      std::vector<std::string>::const_iterator end = statistics_.end();
      for (std::vector<std::string>::const_iterator i = statistics_.begin(); i != end; ++i) {
        if (lookForMatch(destinations_, *i))
          continue;
        ParameterSet const& d = pset.getUntrackedParameterSet(*i, empty_PSet);
        statisticsPSet(d, *i);
      }
    }  // statisticsPSets

    void edm::service::MessageServicePSetValidation::statisticsPSet(ParameterSet const& pset,
                                                                    std::string const& psetName) {
      // Category PSets

      categoryPSets(pset, psetName);

      // No other PSets -- unless they contain optionalPSet or placeholder=True

      noNoncategoryPsets(pset, psetName);

      // General parameters

      std::string thresh = check<std::string>(pset, "psetName", "threshold");
      if (!thresh.empty())
        validateThreshold(thresh, psetName);
      check<bool>(pset, psetName, "placeholder");
      check<bool>(pset, psetName, "reset");
      std::string s = check<std::string>(pset, "psetName", "filename");
      if ((s == "cerr") || (s == "cout")) {
        flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of filename \n";
      }
      s = check<std::string>(pset, "psetName", "extension");
      if ((s == "cerr") || (s == "cout")) {
        flaws_ << psetName << " PSet: \n" << s << " is not allowed as a value of extension \n";
      }
      s = check<std::string>(pset, "psetName", "output");

      // No other parameters

      noneExcept<int>(pset, psetName, "int");

      vString okbool;
      okbool.push_back("placeholder");
      okbool.push_back("optionalPSet");
      okbool.push_back("reset");
      noneExcept<bool>(pset, psetName, "bool", okbool);
      vString okstring;
      okstring.push_back("output");
      okstring.push_back("filename");
      okstring.push_back("extension");
      okstring.push_back("threshold");
      noneExcept<std::string>(pset, psetName, "string", okstring);

    }  // statisticsPSet

    void edm::service::MessageServicePSetValidation::noNoncategoryPsets(ParameterSet const& pset,
                                                                        std::string const& psetName) {
      vString psnames;
      pset.getParameterSetNames(psnames, false);
      vString::const_iterator end = psnames.end();
      for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
        if (lookForMatch(categories_, *i))
          continue;
        if ((*i) == "default")
          continue;
        if ((*i) == "ERROR")
          continue;
        if ((*i) == "WARNING")
          continue;
        if ((*i) == "FWKINFO")
          continue;
        if ((*i) == "INFO")
          continue;
        if ((*i) == "DEBUG")
          continue;
        ParameterSet empty_PSet;
        bool ok_optionalPSet = false;
        try {
          ParameterSet const& culprit = pset.getUntrackedParameterSet((*i), empty_PSet);
          ok_optionalPSet = culprit.getUntrackedParameter<bool>("placeholder", ok_optionalPSet);
          ok_optionalPSet = culprit.getUntrackedParameter<bool>("optionalPSet", ok_optionalPSet);
        } catch (cms::Exception& e) {
        }
        if (ok_optionalPSet)
          continue;
        flaws_ << psetName << " PSet: \n" << *i << " is an unrecognized name for a PSet in this context \n";
      }
      psnames.clear();
      unsigned int n = pset.getParameterSetNames(psnames, true);
      if (n > 0) {
        end = psnames.end();
        for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
          flaws_ << psetName << " PSet: \n"
                 << "PSet " << *i << " is tracked - not allowed\n";
        }
      }
    }  // noNoncategoryPsets

    void edm::service::MessageServicePSetValidation::categoryPSets(ParameterSet const& pset,
                                                                   std::string const& psetName) {
      categoryPSet(pset, psetName, "ERROR");
      categoryPSet(pset, psetName, "WARNING");
      categoryPSet(pset, psetName, "FWKINFO");
      categoryPSet(pset, psetName, "INFO");
      categoryPSet(pset, psetName, "DEBUG");
      if (psetName != "MessageLogger")
        categoryPSet(pset, psetName, "default");
      // The above conditional is because default in the main level is treated
      // as a set of defaults differnt from those of a simple category.
      std::vector<std::string>::const_iterator end = categories_.end();
      for (std::vector<std::string>::const_iterator i = categories_.begin(); i != end; ++i) {
        categoryPSet(pset, psetName, *i);
      }
    }  // categoryPSets

    void edm::service::MessageServicePSetValidation::categoryPSet(ParameterSet const& pset,
                                                                  std::string const& OuterPsetName,
                                                                  std::string const& categoryName) {
      if (pset.existsAs<ParameterSet>(categoryName, true)) {
        flaws_ << OuterPsetName << " PSet: \n"
               << "Category PSet " << categoryName << " is tracked - not allowed\n";
        return;
      }
      ParameterSet empty_PSet;
      ParameterSet const& c = pset.getUntrackedParameterSet(categoryName, empty_PSet);
      std::string const& psetName(OuterPsetName);
      catInts(c, psetName, categoryName);
      catNone<unsigned int>(c, psetName, categoryName, "unsigned int");
      catBoolRestriction(c, psetName, categoryName, "bool");
      catNone<float>(c, psetName, categoryName, "float");
      catNone<double>(c, psetName, categoryName, "double");
      catNone<std::string>(c, psetName, categoryName, "string");
      catNone<vString>(c, psetName, categoryName, "vSting");
      catNoPSets(c, psetName, categoryName);
    }  // categoryPSet

    void edm::service::MessageServicePSetValidation::catInts(ParameterSet const& pset,
                                                             std::string const& psetName,
                                                             std::string const& categoryName) {
      vString x = pset.getParameterNamesForType<int>(false);
      vString::const_iterator end = x.end();
      for (vString::const_iterator i = x.begin(); i != end; ++i) {
        if (*i == "limit")
          continue;
        if (*i == "reportEvery")
          continue;
        if (*i == "timespan")
          continue;
        flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
               << (*i) << " is not an allowed parameter within a category PSet \n";
      }
      x = pset.getParameterNamesForType<int>(true);
      end = x.end();
      for (vString::const_iterator i = x.begin(); i != end; ++i) {
        flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
               << (*i) << " is used as a tracked int \n"
               << "Tracked parameters not allowed here \n";
      }
    }  // catInts()

    void edm::service::MessageServicePSetValidation::catNoPSets(ParameterSet const& pset,
                                                                std::string const& psetName,
                                                                std::string const& categoryName) {
      vString psnames;
      pset.getParameterSetNames(psnames, false);
      vString::const_iterator end = psnames.end();
      for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
        flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
               << *i << " is used as a  PSet\n"
               << "PSets not allowed within a category PSet\n";
      }
      psnames.clear();
      unsigned int n = pset.getParameterSetNames(psnames, true);
      if (n > 0) {
        end = psnames.end();
        for (vString::const_iterator i = psnames.begin(); i != end; ++i) {
          flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
                 << *i << " is used as a tracked PSet\n"
                 << "tracked parameters not permitted, and "
                 << "PSets not allowed within a category PSet\n";
        }
      }
    }  // catNoPSets

    void edm::service::MessageServicePSetValidation::catBoolRestriction(ParameterSet const& pset,
                                                                        std::string const& psetName,
                                                                        std::string const& categoryName,
                                                                        std::string const& type) {
      vString x = pset.getParameterNamesForType<bool>(false);
      vString::const_iterator end = x.end();
      for (vString::const_iterator i = x.begin(); i != end; ++i) {
        if (((*i) == "placeholder") || ((*i) == "optionalPSet"))
          continue;
        flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
               << (*i) << " is used as a " << type << "\n"
               << "Usage of " << type << " is not recognized here\n";
      }
      x = pset.getParameterNamesForType<bool>(true);
      end = x.end();
      for (vString::const_iterator i = x.begin(); i != end; ++i) {
        flaws_ << categoryName << " category PSet nested in " << psetName << " PSet: \n"
               << (*i) << " is used as a tracked " << type << "\n"
               << "Tracked parameters not allowed here, "
               << " and even untracked it would not be recognized\n";
      }
    }  // catBoolRestriction()

  }  // end of namespace service
}  // end of namespace edm