CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

edm::ConfigurationDescriptions Class Reference

#include <ConfigurationDescriptions.h>

List of all members.

Classes

class  DescriptionCounter

Public Member Functions

void add (std::string const &label, ParameterSetDescription const &psetDescription)
void add (char const *label, ParameterSetDescription const &psetDescription)
void addDefault (ParameterSetDescription const &psetDescription)
std::string const & comment () const
 ConfigurationDescriptions (std::string const &baseType)
void print (std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentation, int iPlugin) const
void setComment (std::string const &value)
void setComment (char const *value)
void validate (ParameterSet &pset, std::string const &moduleLabel) const
void writeCfis (std::string const &baseType, std::string const &pluginName) const
 ~ConfigurationDescriptions ()

Private Member Functions

void printForLabel (std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentationn, DescriptionCounter &counter) const
void printForLabel (std::ostream &os, std::string const &label, ParameterSetDescription const &description, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentationn, DescriptionCounter &counter) const

Static Private Member Functions

static void writeCfiForLabel (std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::string const &baseType, std::string const &pluginName)

Private Attributes

std::string baseType_
std::string comment_
ParameterSetDescription defaultDesc_
bool defaultDescDefined_
std::vector< std::pair
< std::string,
ParameterSetDescription > > 
descriptions_

Detailed Description

Definition at line 27 of file ConfigurationDescriptions.h.


Constructor & Destructor Documentation

ConfigurationDescriptions::ConfigurationDescriptions ( std::string const &  baseType)

Definition at line 37 of file ConfigurationDescriptions.cc.

                                                                                :
    baseType_(baseType),
    defaultDescDefined_(false)
  { }
ConfigurationDescriptions::~ConfigurationDescriptions ( )

Definition at line 42 of file ConfigurationDescriptions.cc.

{} 

Member Function Documentation

void ConfigurationDescriptions::add ( std::string const &  label,
ParameterSetDescription const &  psetDescription 
)

Definition at line 60 of file ConfigurationDescriptions.cc.

References baseType_, defaultDescDefined_, descriptions_, Exception, label, edm::errors::LogicError, and mergeVDriftHistosByStation::name.

Referenced by add(), edm::service::UnixSignalService::fillDescriptions(), HLTHcalMETNoiseFilter::fillDescriptions(), HLTJetCollectionsFilter::fillDescriptions(), HLTJetCollectionsVBFFilter::fillDescriptions(), pat::PATElectronProducer::fillDescriptions(), pat::PATPhotonProducer::fillDescriptions(), edm::GetProductCheckerOutputModule::fillDescriptions(), edm::ProvenanceCheckerOutputModule::fillDescriptions(), edm::XMLOutputModule::fillDescriptions(), HLTJetCollectionsForLeptonPlusJets::fillDescriptions(), HLTMhtFilter::fillDescriptions(), HLTDiMuonGlbTrkFilter::fillDescriptions(), HLTMuonL1Filter::fillDescriptions(), edm::PoolOutputModule::fillDescriptions(), EventIDChecker::fillDescriptions(), RandomEngineStateProducer::fillDescriptions(), edm::StreamerFileReader::fillDescriptions(), pat::PATJetProducer::fillDescriptions(), edm::EmptySource::fillDescriptions(), edm::Prescaler::fillDescriptions(), edm::service::LoadAllDictionaries::fillDescriptions(), edm::service::SimpleProfiling::fillDescriptions(), HLTBool::fillDescriptions(), HLTExclDiJetFilter::fillDescriptions(), edm::EventAuxiliaryHistoryProducer::fillDescriptions(), HLTMhtProducer::fillDescriptions(), edm::StreamerOutputModule< Consumer >::fillDescriptions(), edm::PrintEventSetupContent::fillDescriptions(), edm::service::SimpleMemoryCheck::fillDescriptions(), edm::PrintEventSetupDataRetrieval::fillDescriptions(), UpdaterService::fillDescriptions(), HLTHtMhtProducer::fillDescriptions(), HLTMuonDimuonL3Filter::fillDescriptions(), TFileAdaptor::fillDescriptions(), edm::service::PrescaleService::fillDescriptions(), edm::rootfix::LockService::fillDescriptions(), HLTLevel1Activity::fillDescriptions(), HLTMuonTrackMassFilter::fillDescriptions(), edm::EventContentAnalyzer::fillDescriptions(), HLTForwardBackwardJetsFilter::fillDescriptions(), LogErrorFilter::fillDescriptions(), HLTHPDFilter::fillDescriptions(), HLTMuonTrimuonL3Filter::fillDescriptions(), edm::LogErrorHarvester::fillDescriptions(), HLTFatJetMassFilter::fillDescriptions(), HLTHtMhtFilter::fillDescriptions(), edm::AsciiOutputModule::fillDescriptions(), HLTJetCollForElePlusJets::fillDescriptions(), HLTRHemisphere::fillDescriptions(), edm::service::InitRootHandlers::fillDescriptions(), edm::service::Timing::fillDescriptions(), HLTDiJetAveFilter::fillDescriptions(), edm::service::RandomNumberGeneratorService::fillDescriptions(), pat::JetCorrFactorsProducer::fillDescriptions(), edm::service::EnableFloatingPointExceptions::fillDescriptions(), HLTHemiDPhiFilter::fillDescriptions(), edm::service::SiteLocalConfigService::fillDescriptions(), HLT1CaloJetEnergy::fillDescriptions(), JetCollectionForEleHT::fillDescriptions(), HLTRFilter::fillDescriptions(), MulticoreRunLumiEventChecker::fillDescriptions(), HLTMuonL2PreFilter::fillDescriptions(), HLTElectronPFMTFilter::fillDescriptions(), HLTJetCollectionsForElePlusJets::fillDescriptions(), HLTMhtHtFilter::fillDescriptions(), HLTMuonL3PreFilter::fillDescriptions(), edm::EventSetupRecordDataGetter::fillDescriptions(), edm::service::CPU::fillDescriptions(), PrintLoadingPlugins::fillDescriptions(), edm::service::Tracer::fillDescriptions(), and HLTLevel1Pattern::fillDescriptions().

                                                                                 {

    if (baseType_ == std::string("Source")) {
      if (label != std::string("source")) {
        throw edm::Exception(edm::errors::LogicError,
          "ConfigurationDescriptions::add, when adding a ParameterSetDescription for a source the label must be \"source\"\n");
      }
      if (descriptions_.size() != 0U ||
          defaultDescDefined_ == true) {
        throw edm::Exception(edm::errors::LogicError,
          "ConfigurationDescriptions::add, for a source only 1 ParameterSetDescription may be added\n");
      }
    }
    else if (baseType_ == std::string("Service")) {
      if (descriptions_.size() != 0U ||
          defaultDescDefined_ == true) {
        throw edm::Exception(edm::errors::LogicError,
          "ConfigurationDescriptions::add, for a service only 1 ParameterSetDescription may be added\n");
      }
    }

    // To minimize the number of copies involved create an empty description first
    // and push it into the vector.  Then perform the copy.
    std::pair<std::string, ParameterSetDescription> pairWithEmptyDescription;
    descriptions_.push_back(pairWithEmptyDescription);
    std::pair<std::string, ParameterSetDescription> & pair = descriptions_.back();

    pair.first = label;
    pair.second = psetDescription;

    if (baseType_ == std::string("ESSource") || baseType_ == std::string("ESProducer")) {
      std::string name("appendToDataLabel");
      if (pair.second.isLabelUnused(name)) {
        pair.second.add<std::string>(name, std::string(""));
      }
    }
  }
void ConfigurationDescriptions::add ( char const *  label,
ParameterSetDescription const &  psetDescription 
)

Definition at line 53 of file ConfigurationDescriptions.cc.

References add().

                                                                                 {
    std::string labelString(label);
    add(labelString, psetDescription);
  }
void ConfigurationDescriptions::addDefault ( ParameterSetDescription const &  psetDescription)

Definition at line 100 of file ConfigurationDescriptions.cc.

References edm::ParameterSetDescription::add(), baseType_, defaultDesc_, defaultDescDefined_, descriptions_, Exception, edm::ParameterSetDescription::isLabelUnused(), edm::errors::LogicError, and mergeVDriftHistosByStation::name.

Referenced by HLTOfflineReproducibility::fillDescriptions(), PythonService::fillDescriptions(), edm::OutputModule::fillDescriptions(), prodname::fillDescriptions(), MuPFIsoEmbedder::fillDescriptions(), edm::EDProducer::fillDescriptions(), EmDQMFeeder::fillDescriptions(), anlzrname::fillDescriptions(), DQMRootOutputModule::fillDescriptions(), edm::EDFilter::fillDescriptions(), edm::InputSource::fillDescriptions(), edm::EDAnalyzer::fillDescriptions(), DQMRootSource::fillDescriptions(), fltrname::fillDescriptions(), HLTOfflineReproducibilityDQM::fillDescriptions(), edm::service::JobReportService::fillDescriptions(), FastTimerServiceClient::fillDescriptions(), and edm::fillDetails::DoFillAsUnknown< T >::operator()().

                                                                                      {

    if (baseType_ == std::string("Source") || baseType_ == std::string("Service")) {
      if (descriptions_.size() != 0U ||
          defaultDescDefined_ == true) {
        throw edm::Exception(edm::errors::LogicError,
          "ConfigurationDescriptions::addDefault, for a source or service only 1 ParameterSetDescription may be added\n");
      }
    }

    defaultDescDefined_ = true;
    defaultDesc_ = psetDescription;

    if (baseType_ == std::string("ESSource") || baseType_ == std::string("ESProducer")) {
      std::string name("appendToDataLabel");
      if (defaultDesc_.isLabelUnused(name)) {
        defaultDesc_.add<std::string>(name, std::string(""));
      }
    }
  }
std::string const& edm::ConfigurationDescriptions::comment ( ) const [inline]

Definition at line 39 of file ConfigurationDescriptions.h.

References comment_.

Referenced by print().

{ return comment_; }
void ConfigurationDescriptions::print ( std::ostream &  os,
std::string const &  moduleLabel,
bool  brief,
bool  printOnlyLabels,
size_t  lineWidth,
int  indentation,
int  iPlugin 
) const

Definition at line 199 of file ConfigurationDescriptions.cc.

References comment(), defaultDesc_, defaultDescDefined_, descriptions_, relativeConstraints::empty, edm::for_all(), edm::ConfigurationDescriptions::DescriptionCounter::iModule, edm::ConfigurationDescriptions::DescriptionCounter::iPlugin, edm::ConfigurationDescriptions::DescriptionCounter::iSelectedModule, edm::ParameterSetDescription::isUnknown(), edm::DocFormatHelper::offsetModuleLabel(), printForLabel(), MultipleCompare::ref, and edm::DocFormatHelper::wrapAndPrintText().

                                                           {
    if (!brief) {
      if (!comment().empty()) {
        DocFormatHelper::wrapAndPrintText(os, comment(), indentation, lineWidth);
      }
      os << "\n";
    }

    char oldFill = os.fill();
    if (descriptions_.empty() && !defaultDescDefined_) {
      indentation += DocFormatHelper::offsetModuleLabel();
      os << std::setfill(' ') << std::setw(indentation) << "";
      os << "There are no PSet descriptions defined for this plugin.\n";
      os << std::setfill(' ') << std::setw(indentation) << "";
      os << "PSets will not be validated and no cfi files will be generated.\n";
      if (!brief) os << "\n";
      os.fill(oldFill);
      return;
    }

    if (descriptions_.empty() && defaultDescDefined_ && defaultDesc_.isUnknown()) {
      indentation += DocFormatHelper::offsetModuleLabel();
      os << std::setfill(' ') << std::setw(indentation) << "";
      os << "This plugin has not implemented the function which defines its\n";
      os << std::setfill(' ') << std::setw(indentation) << "";
      os << "configuration descriptions yet. No descriptions are available.\n";
      os << std::setfill(' ') << std::setw(indentation) << "";
      os << "Its PSets will not be validated, and no cfi files will be generated.\n";
      if (!brief) os << "\n";
      os.fill(oldFill);
      return;
    }

    if (!brief) {
      std::stringstream ss;
      if (defaultDescDefined_) {
        if (descriptions_.empty()) {
          ss << "This plugin has only one PSet description. "
             << "This description is always used to validate configurations. "
             << "Because this configuration has no label, no cfi files will be generated.";
        }
        else {
          ss << "This plugin has " << (descriptions_.size() + 1U) << " PSet descriptions. "
             << "The description used to validate a configuration is selected by "
             << "matching the module labels. If none match, then the last description, "
             << "which has no label, is selected. "
             << "A cfi file will be generated for each configuration with a module label.";
        }
      }
      else {
        if (descriptions_.size() == 1U) {
          ss << "This plugin has " << descriptions_.size() << " PSet description. "
             << "This description is always used to validate configurations. "
             << "The label below is used when generating the cfi file.";
        }
        else {
          ss << "This plugin has " << descriptions_.size() << " PSet descriptions. "
             << "The description used to validate a configuration is selected by "
             << "matching the module labels. If none match the first description below is used. "
             << "The module labels below are also used when generating the cfi files.";
        }
      }
      DocFormatHelper::wrapAndPrintText(os, ss.str(), indentation, lineWidth);
      os << "\n";
    }

    indentation += DocFormatHelper::offsetModuleLabel();

    DescriptionCounter counter;
    counter.iPlugin = iPlugin;
    counter.iSelectedModule = 0;
    counter.iModule = 0;

    for_all(descriptions_, boost::bind(&ConfigurationDescriptions::printForLabel,
                                       this,
                                       _1,
                                       boost::ref(os),
                                       boost::cref(moduleLabel),
                                       brief,
                                       printOnlyLabels,
                                       lineWidth,
                                       indentation,
                                       boost::ref(counter)));

    if (defaultDescDefined_) {
      printForLabel(os,
                    std::string("@default"),
                    defaultDesc_,
                    moduleLabel,
                    brief,
                    printOnlyLabels,
                    lineWidth,
                    indentation,
                    counter);
    }
  }
void ConfigurationDescriptions::printForLabel ( std::pair< std::string, ParameterSetDescription > const &  labelAndDesc,
std::ostream &  os,
std::string const &  moduleLabel,
bool  brief,
bool  printOnlyLabels,
size_t  lineWidth,
int  indentationn,
DescriptionCounter counter 
) const [private]

Definition at line 303 of file ConfigurationDescriptions.cc.

Referenced by print().

  {
    printForLabel(os,
                  labelAndDesc.first,
                  labelAndDesc.second,
                  moduleLabel,
                  brief,
                  printOnlyLabels,
                  lineWidth,
                  indentation,
                  counter);
  }
void ConfigurationDescriptions::printForLabel ( std::ostream &  os,
std::string const &  label,
ParameterSetDescription const &  description,
std::string const &  moduleLabel,
bool  brief,
bool  printOnlyLabels,
size_t  lineWidth,
int  indentationn,
DescriptionCounter counter 
) const [private]

Definition at line 324 of file ConfigurationDescriptions.cc.

References baseType_, edm::ParameterSetDescription::comment(), edm::ConfigurationDescriptions::DescriptionCounter::iModule, edm::ConfigurationDescriptions::DescriptionCounter::iPlugin, edm::ConfigurationDescriptions::DescriptionCounter::iSelectedModule, moduleLabel(), edm::DocFormatHelper::offsetTopLevelPSet(), edm::ParameterSetDescription::print(), edm::DocFormatHelper::setBrief(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setLineWidth(), edm::DocFormatHelper::setParent(), edm::DocFormatHelper::setSection(), edm::DocFormatHelper::TOP, and edm::DocFormatHelper::wrapAndPrintText().

  {
    ++counter.iModule;
    if (!moduleLabel.empty() && label != moduleLabel) return;
    ++counter.iSelectedModule;

    std::stringstream ss;
    ss << counter.iPlugin << "." << counter.iSelectedModule;
    std::string section = ss.str();

    char oldFill = os.fill();
    os << std::setfill(' ') << std::setw(indentation) << "";
    os.fill(oldFill);
    os << section << " ";
    if (label == std::string("@default")) {
      os << "description without a module label\n";
    }
    else {
      if (!brief) {
        if (baseType_ == std::string("Source") || baseType_ == std::string("Service")) {
          os << "label: ";
        }
        else {
          os << "module label: ";
        }
      }
      os << label << "\n";      
    }

    if (!brief) {
      if (!description.comment().empty()) {
        DocFormatHelper::wrapAndPrintText(os, description.comment(), indentation, lineWidth - indentation);        
      }
      os << "\n";
    }
    if (printOnlyLabels) return;

    DocFormatHelper dfh;
    dfh.setBrief(brief);
    dfh.setLineWidth(lineWidth);
    dfh.setIndentation(indentation + DocFormatHelper::offsetTopLevelPSet());
    dfh.setSection(section);
    dfh.setParent(DocFormatHelper::TOP);

    description.print(os, dfh);
  }
void ConfigurationDescriptions::setComment ( std::string const &  value)
void ConfigurationDescriptions::setComment ( char const *  value)

Definition at line 49 of file ConfigurationDescriptions.cc.

References comment_, and relativeConstraints::value.

  { comment_ = value; }
void ConfigurationDescriptions::validate ( ParameterSet pset,
std::string const &  moduleLabel 
) const

Definition at line 122 of file ConfigurationDescriptions.cc.

References defaultDesc_, defaultDescDefined_, descriptions_, edm::for_all(), MultipleCompare::ref, and edm::ParameterSetDescription::validate().

Referenced by edm::serviceregistry::ServicesManager::createServices(), edm::makeInput(), edm::Maker::makeWorker(), and edm::eventsetup::validateEventSetupParameters().

                                                                          {
    
    ParameterSetDescription const* psetDesc = 0;
    for_all(descriptions_, boost::bind(&matchLabel,
                                       _1,
                                       boost::cref(moduleLabel),
                                       boost::ref(psetDesc)));

    // If there is a matching label
    if (psetDesc != 0) {
      psetDesc->validate(pset);
    }
    // Is there an explicit description to be used for a non standard label
    else if (defaultDescDefined_) {
      defaultDesc_.validate(pset);
    }
    // Otherwise use the first one.
    else if (descriptions_.size() > 0U) {
      descriptions_[0].second.validate(pset);
    }
    // It is possible for no descriptions to be defined and no validation occurs
    // for this module ever.
  }
void ConfigurationDescriptions::writeCfiForLabel ( std::pair< std::string, ParameterSetDescription > const &  labelAndDesc,
std::string const &  baseType,
std::string const &  pluginName 
) [static, private]

Definition at line 159 of file ConfigurationDescriptions.cc.

References gather_cfg::cout, Exception, edm::errors::LogicError, and cmsMakeMELists::outFile.

Referenced by writeCfis().

  {
    if (baseType == std::string("Service") && labelAndDesc.first != pluginName) {
      throw edm::Exception(edm::errors::LogicError,
        "ConfigurationDescriptions::writeCfiForLabel\nFor a service the label and the plugin name must be the same.\n")
        << "This error probably is caused by an incorrect label being passed\nto the ConfigurationDescriptions::add function earlier.\n"
        << "plugin name = \"" << pluginName << "\"  label name = \"" << labelAndDesc.first << "\"\n";
    }

    std::string cfi_filename;
    if (baseType == std::string("Source")) {
      cfi_filename = pluginName + "_cfi.py";
    }
    else {
      cfi_filename = labelAndDesc.first + "_cfi.py";
    }
    std::ofstream outFile(cfi_filename.c_str());


    outFile << "import FWCore.ParameterSet.Config as cms\n\n";
    outFile << labelAndDesc.first << " = cms." << baseType << "('" << pluginName << "'";

    bool startWithComma = true;
    int indentation = 2;
    labelAndDesc.second.writeCfi(outFile, startWithComma, indentation);

    outFile << ")\n";
  
    outFile.close();

    if (baseType == std::string("Source")) {
      std::cout << pluginName << "\n";
    }
    else {
      std::cout << labelAndDesc.first << "\n";
    }
  }
void ConfigurationDescriptions::writeCfis ( std::string const &  baseType,
std::string const &  pluginName 
) const

Definition at line 148 of file ConfigurationDescriptions.cc.

References descriptions_, edm::for_all(), and writeCfiForLabel().

                                                                          {

    for_all(descriptions_, boost::bind(&ConfigurationDescriptions::writeCfiForLabel,
                                       _1,
                                       boost::cref(baseType),
                                       boost::cref(pluginName)));
  }

Member Data Documentation

Definition at line 99 of file ConfigurationDescriptions.h.

Referenced by add(), addDefault(), and printForLabel().

Definition at line 106 of file ConfigurationDescriptions.h.

Referenced by comment(), and setComment().

Definition at line 104 of file ConfigurationDescriptions.h.

Referenced by addDefault(), print(), and validate().

Definition at line 103 of file ConfigurationDescriptions.h.

Referenced by add(), addDefault(), print(), and validate().

std::vector<std::pair<std::string, ParameterSetDescription> > edm::ConfigurationDescriptions::descriptions_ [private]

Definition at line 101 of file ConfigurationDescriptions.h.

Referenced by add(), addDefault(), print(), validate(), and writeCfis().