CMS 3D CMS Logo

Classes | Public Types | 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 Types

typedef std::vector< std::pair
< std::string,
ParameterSetDescription >
>::iterator 
iterator

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)
iterator begin ()
std::string const & comment () const
 ConfigurationDescriptions (std::string const &baseType)
ParameterSetDescriptiondefaultDescription ()
 Returns 0 if no default has been assigned.
iterator end ()
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.


Member Typedef Documentation

typedef std::vector<std::pair<std::string, ParameterSetDescription> >::iterator edm::ConfigurationDescriptions::iterator

Definition at line 30 of file ConfigurationDescriptions.h.


Constructor & Destructor Documentation

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

Definition at line 42 of file ConfigurationDescriptions.cc.

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

Definition at line 47 of file ConfigurationDescriptions.cc.

{} 

Member Function Documentation

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

Definition at line 65 of file ConfigurationDescriptions.cc.

References baseType_, defaultDescDefined_, descriptions_, Exception, k_source, kService, kSource, label, and edm::errors::LogicError.

Referenced by add(), pat::PATPhotonProducer::fillDescriptions(), pat::PATElectronProducer::fillDescriptions(), HLTJetSortedVBFFilter< T >::fillDescriptions(), HLTJetL1MatchProducer< T >::fillDescriptions(), HLTHcalMETNoiseFilter::fillDescriptions(), edm::service::UnixSignalService::fillDescriptions(), HLTPFTauPairLeadTrackDzMatchFilter::fillDescriptions(), edm::PoolOutputModule::fillDescriptions(), HLTMuonL1Filter::fillDescriptions(), HLTDiMuonGlbTrkFilter::fillDescriptions(), HLTMhtFilter::fillDescriptions(), HLTJetCollectionsFilter< jetType >::fillDescriptions(), HLTHcalMETNoiseCleaner::fillDescriptions(), edm::XMLOutputModule::fillDescriptions(), edm::ProvenanceCheckerOutputModule::fillDescriptions(), edm::GetProductCheckerOutputModule::fillDescriptions(), pat::PATJetProducer::fillDescriptions(), edm::StreamerFileReader::fillDescriptions(), RandomEngineStateProducer::fillDescriptions(), HLTPFJetIDProducer::fillDescriptions(), HLTMonoJetFilter< T >::fillDescriptions(), EventIDChecker::fillDescriptions(), HLTBool::fillDescriptions(), HLTCollectionProducer< T >::fillDescriptions(), edm::service::SimpleProfiling::fillDescriptions(), edm::service::LoadAllDictionaries::fillDescriptions(), edm::Prescaler::fillDescriptions(), edm::EmptySource::fillDescriptions(), edm::StreamerOutputModule< Consumer >::fillDescriptions(), HLTMhtProducer::fillDescriptions(), HLTForwardBackwardJetsFilter< T >::fillDescriptions(), edm::EventAuxiliaryHistoryProducer::fillDescriptions(), TFileAdaptor::fillDescriptions(), HLTMuonDimuonL3Filter::fillDescriptions(), HLTJetCollectionsForLeptonPlusJets< jetType >::fillDescriptions(), HLTHtMhtProducer::fillDescriptions(), UpdaterService::fillDescriptions(), edm::PrintEventSetupDataRetrieval::fillDescriptions(), edm::service::SimpleMemoryCheck::fillDescriptions(), edm::PrintEventSetupContent::fillDescriptions(), HLTDeDxFilter::fillDescriptions(), HLTMuonTrackMassFilter::fillDescriptions(), HLTJetVBFFilter< T >::fillDescriptions(), HLTLevel1Activity::fillDescriptions(), HLTDoubletDZ< T1, T2 >::fillDescriptions(), edm::rootfix::LockService::fillDescriptions(), edm::service::PrescaleService::fillDescriptions(), HLTGlobalSums< T >::fillDescriptions(), HLTJetPairDzMatchFilter< T >::fillDescriptions(), edm::EventContentAnalyzer::fillDescriptions(), HLTMuonTrimuonL3Filter::fillDescriptions(), HLTHPDFilter::fillDescriptions(), HLTDoublet< T1, T2 >::fillDescriptions(), LogErrorFilter::fillDescriptions(), HLTHtMhtFilter::fillDescriptions(), edm::LogErrorHarvester::fillDescriptions(), HLTRHemisphere::fillDescriptions(), HLTJetCollectionsVBFFilter< T >::fillDescriptions(), HLTExclDiJetFilter< T >::fillDescriptions(), HLTDiJetAveFilter< T >::fillDescriptions(), edm::AsciiOutputModule::fillDescriptions(), pat::JetCorrFactorsProducer::fillDescriptions(), edm::service::RandomNumberGeneratorService::fillDescriptions(), HLTJetCollForElePlusJets< T >::fillDescriptions(), edm::service::Timing::fillDescriptions(), edm::service::InitRootHandlers::fillDescriptions(), HLTPFEnergyFractionsFilter::fillDescriptions(), HLTHemiDPhiFilter::fillDescriptions(), HLTFatJetMassFilter< jetType >::fillDescriptions(), HLTDisplacedEgammaFilter::fillDescriptions(), edm::service::EnableFloatingPointExceptions::fillDescriptions(), HLTRFilter::fillDescriptions(), JetCollectionForEleHT::fillDescriptions(), HLTSinglet< T >::fillDescriptions(), edm::service::SiteLocalConfigService::fillDescriptions(), HLTMuonL2PreFilter::fillDescriptions(), HLTAlphaTFilter< T >::fillDescriptions(), HLTJetTag< T >::fillDescriptions(), MulticoreRunLumiEventChecker::fillDescriptions(), HLTMuonL3PreFilter::fillDescriptions(), PFJetsMatchedToFilteredCaloJetsProducer::fillDescriptions(), HLTHcalTowerNoiseCleaner::fillDescriptions(), HLTElectronPFMTFilter::fillDescriptions(), HLTJetCollectionsForElePlusJets< T >::fillDescriptions(), HLTSmartSinglet< T >::fillDescriptions(), HLTLevel1Pattern::fillDescriptions(), edm::service::Tracer::fillDescriptions(), PrintLoadingPlugins::fillDescriptions(), edm::service::CPU::fillDescriptions(), and edm::EventSetupRecordDataGetter::fillDescriptions().

                                                                                 {

    if (0==strcmp(baseType_.c_str(),kSource)) {
      if (0!=strcmp(label.c_str(),k_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 (0==strcmp(baseType_.c_str(),kService)) {
      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;
    
  }
void ConfigurationDescriptions::add ( char const *  label,
ParameterSetDescription const &  psetDescription 
)

Definition at line 58 of file ConfigurationDescriptions.cc.

References add().

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

Definition at line 99 of file ConfigurationDescriptions.cc.

References baseType_, defaultDesc_, defaultDescDefined_, descriptions_, Exception, kService, kSource, and edm::errors::LogicError.

Referenced by HLTOfflineReproducibility::fillDescriptions(), PythonService::fillDescriptions(), FourLepFilter::fillDescriptions(), GBRWrapperMaker::fillDescriptions(), edm::ModelFilter::fillDescriptions(), edm::OutputModule::fillDescriptions(), prodname::fillDescriptions(), EGEnergyAnalyzer::fillDescriptions(), JetVertexChecker::fillDescriptions(), MuPFIsoEmbedder::fillDescriptions(), edm::EDProducer::fillDescriptions(), ExternalLHEProducer::fillDescriptions(), EmDQMFeeder::fillDescriptions(), anlzrname::fillDescriptions(), Mixing2DB::fillDescriptions(), DQMRootOutputModule::fillDescriptions(), edm::EDFilter::fillDescriptions(), edm::InputSource::fillDescriptions(), LHE2HepMCConverter::fillDescriptions(), VertexMonitor::fillDescriptions(), edm::EDAnalyzer::fillDescriptions(), DQMRootSource::fillDescriptions(), LogMessageMonitor::fillDescriptions(), fltrname::fillDescriptions(), HLTOfflineReproducibilityDQM::fillDescriptions(), BeamProfile2DB::fillDescriptions(), edm::service::JobReportService::fillDescriptions(), DJpsiFilter::fillDescriptions(), FastTimerServiceClient::fillDescriptions(), and edm::fillDetails::DoFillAsUnknown< T >::operator()().

                                                                                      {

    if (0==strcmp(baseType_.c_str(),kSource) || 0==strcmp(baseType_.c_str(),kService)) {
      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;
    
  }
ConfigurationDescriptions::iterator ConfigurationDescriptions::begin ( void  )

Definition at line 123 of file ConfigurationDescriptions.cc.

References descriptions_.

{ return descriptions_.begin();}
std::string const& edm::ConfigurationDescriptions::comment ( ) const [inline]

Definition at line 44 of file ConfigurationDescriptions.h.

References comment_.

Referenced by print().

{ return comment_; }
ParameterSetDescription * ConfigurationDescriptions::defaultDescription ( )

Returns 0 if no default has been assigned.

Definition at line 115 of file ConfigurationDescriptions.cc.

References defaultDesc_, and defaultDescDefined_.

Referenced by edm::edmodule_mightGet_config(), and edm::eventsetup::DataProxyProvider::prevalidate().

                                                {
    if (defaultDescDefined_) {
      return &defaultDesc_;
    }
    return 0;
  }
ConfigurationDescriptions::iterator ConfigurationDescriptions::end ( void  )

Definition at line 126 of file ConfigurationDescriptions.cc.

References descriptions_.

{return descriptions_.end();}
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 207 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(), and edm::DocFormatHelper::wrapAndPrintText().

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

    if (descriptions_.empty() && !defaultDescDefined_) {
      char oldFill = os.fill();
      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";
      os << std::setfill(oldFill);
      if (!brief) os << "\n";
      return;
    }

    if (descriptions_.empty() && defaultDescDefined_ && defaultDesc_.isUnknown()) {
      indentation += DocFormatHelper::offsetModuleLabel();
      char oldFill = os.fill();
      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";
      os << std::setfill(oldFill);
      if (!brief) os << "\n";
      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::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 333 of file ConfigurationDescriptions.cc.

References baseType_, edm::ParameterSetDescription::comment(), edm::ConfigurationDescriptions::DescriptionCounter::iModule, edm::ConfigurationDescriptions::DescriptionCounter::iPlugin, edm::ConfigurationDescriptions::DescriptionCounter::iSelectedModule, kService, kSource, 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) << "" << std::setfill(oldFill);
    os << section << " ";
    if (label == std::string("@default")) {
      os << "description without a module label\n";
    }
    else {
      if (!brief) {
        if (0 == strcmp(baseType_.c_str(),kSource) || 0 == strcmp(baseType_.c_str(),kService)) {
          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::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 312 of file ConfigurationDescriptions.cc.

Referenced by print().

  {
    printForLabel(os,
                  labelAndDesc.first,
                  labelAndDesc.second,
                  moduleLabel,
                  brief,
                  printOnlyLabels,
                  lineWidth,
                  indentation,
                  counter);
  }
void ConfigurationDescriptions::setComment ( std::string const &  value)
void ConfigurationDescriptions::setComment ( char const *  value)

Definition at line 54 of file ConfigurationDescriptions.cc.

References comment_, and relativeConstraints::value.

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

Definition at line 130 of file ConfigurationDescriptions.cc.

References defaultDesc_, defaultDescDefined_, descriptions_, edm::for_all(), 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 167 of file ConfigurationDescriptions.cc.

References gather_cfg::cout, Exception, kService, kSource, and edm::errors::LogicError.

Referenced by writeCfis().

  {
    if (0 == strcmp(baseType.c_str(),kService) && 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 (0 == strcmp(baseType.c_str(),kSource)) {
      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 (0 == strcmp(baseType.c_str(),kSource)) {
      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 156 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 109 of file ConfigurationDescriptions.h.

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

Definition at line 115 of file ConfigurationDescriptions.h.

Referenced by comment(), and setComment().

Definition at line 113 of file ConfigurationDescriptions.h.

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

Definition at line 116 of file ConfigurationDescriptions.h.

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

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

Definition at line 111 of file ConfigurationDescriptions.h.

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